mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-19 08:16:31 +00:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88460b72e1 | ||
|
|
8c69c77481 | ||
|
|
5331ae14aa | ||
|
|
0127dcf018 | ||
|
|
aa58b1b002 | ||
|
|
a05eab71a8 | ||
|
|
e013356cf0 | ||
|
|
c730981827 | ||
|
|
3bb1ed3ef3 | ||
|
|
1cda22bfd2 |
@@ -1,7 +1,7 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
current_version = 6.52
|
current_version = 6.55
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)
|
parse = (?P<major>\d+)\.(?P<minor>\d+)
|
||||||
serialize =
|
serialize =
|
||||||
{major}.{minor}
|
{major}.{minor}
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -35,13 +35,14 @@ If you're going to live-stream from your backyard webcam and need to control it,
|
|||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
You need to download the µStreamer onto your system and build it from the sources.
|
You need to download the µStreamer onto your system and build it from the sources, or use a package:
|
||||||
|
|
||||||
* AUR has a package for Arch Linux: https://aur.archlinux.org/packages/ustreamer.
|
* Arch Linux: https://aur.archlinux.org/packages/ustreamer
|
||||||
* Fedora: https://src.fedoraproject.org/rpms/ustreamer.
|
* Fedora: https://src.fedoraproject.org/rpms/ustreamer
|
||||||
* Ubuntu: https://packages.ubuntu.com/jammy/ustreamer.
|
* Ubuntu: https://packages.ubuntu.com/jammy/ustreamer
|
||||||
* Debian: https://packages.debian.org/sid/ustreamer
|
* Debian: https://packages.debian.org/sid/ustreamer
|
||||||
* FreeBSD port: https://www.freshports.org/multimedia/ustreamer.
|
* OpenWRT: https://github.com/openwrt/packages/tree/master/multimedia/ustreamer
|
||||||
|
* FreeBSD port: https://www.freshports.org/multimedia/ustreamer
|
||||||
|
|
||||||
### Preconditions
|
### Preconditions
|
||||||
You'll need ```make```, ```gcc```, ```pkg-config```, ```libevent``` with ```pthreads``` support, ```libjpeg9```/```libjpeg-turbo``` and ```libbsd``` (only for Linux).
|
You'll need ```make```, ```gcc```, ```pkg-config```, ```libevent``` with ```pthreads``` support, ```libjpeg9```/```libjpeg-turbo``` and ```libbsd``` (only for Linux).
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ static void *_acap_thread(void *arg) {
|
|||||||
if (_get_acap_hz(&hz) < 0 || acap->pcm_hz != hz) {
|
if (_get_acap_hz(&hz) < 0 || acap->pcm_hz != hz) {
|
||||||
goto close_acap;
|
goto close_acap;
|
||||||
}
|
}
|
||||||
uz size = US_RTP_DATAGRAM_SIZE - US_RTP_HEADER_SIZE;
|
uz size = US_RTP_TOTAL_SIZE - US_RTP_HEADER_SIZE;
|
||||||
u8 data[size];
|
u8 data[size];
|
||||||
u64 pts;
|
u64 pts;
|
||||||
const int result = us_acap_get_encoded(acap, data, &size, &pts);
|
const int result = us_acap_get_encoded(acap, data, &size, &pts);
|
||||||
|
|||||||
@@ -25,10 +25,17 @@
|
|||||||
#include "uslibs/types.h"
|
#include "uslibs/types.h"
|
||||||
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/47635545/why-webrtc-chose-rtp-max-packet-size-to-1200-bytes
|
// Max RTP size for WebRTC is 1200 bytes:
|
||||||
#define US_RTP_DATAGRAM_SIZE 1200
|
// - https://stackoverflow.com/questions/47635545/why-webrtc-chose-rtp-max-packet-size-to-1200-bytes
|
||||||
|
// But(!) Tailscale has 1200 MTU. So to fit it required to substract:
|
||||||
|
// 1. possible RTP extensions (see sdp.c)
|
||||||
|
// 2. additional SRTP fields (>= 10 bytes)
|
||||||
|
// 3. UDP header (8 bytes)
|
||||||
|
// 4. IPv6 header (40 bytes)
|
||||||
|
// Finally it looks like 100 bytes for all above should be enough
|
||||||
|
#define US_RTP_TOTAL_SIZE (1200 - 100)
|
||||||
#define US_RTP_HEADER_SIZE 12
|
#define US_RTP_HEADER_SIZE 12
|
||||||
#define US_RTP_PAYLOAD_SIZE (US_RTP_DATAGRAM_SIZE - US_RTP_HEADER_SIZE)
|
#define US_RTP_PAYLOAD_SIZE (US_RTP_TOTAL_SIZE - US_RTP_HEADER_SIZE)
|
||||||
|
|
||||||
#define US_RTP_H264_PAYLOAD 96
|
#define US_RTP_H264_PAYLOAD 96
|
||||||
#define US_RTP_OPUS_PAYLOAD 111
|
#define US_RTP_OPUS_PAYLOAD 111
|
||||||
@@ -43,7 +50,7 @@ typedef struct {
|
|||||||
u32 ssrc;
|
u32 ssrc;
|
||||||
|
|
||||||
u16 seq;
|
u16 seq;
|
||||||
u8 datagram[US_RTP_DATAGRAM_SIZE];
|
u8 datagram[US_RTP_TOTAL_SIZE];
|
||||||
uz used;
|
uz used;
|
||||||
|
|
||||||
bool first_of_frame;
|
bool first_of_frame;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void us_rtpa_destroy(us_rtpa_s *rtpa) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void us_rtpa_wrap(us_rtpa_s *rtpa, const u8 *data, uz size, u32 pts) {
|
void us_rtpa_wrap(us_rtpa_s *rtpa, const u8 *data, uz size, u32 pts) {
|
||||||
if (size + US_RTP_HEADER_SIZE <= US_RTP_DATAGRAM_SIZE) {
|
if (size + US_RTP_HEADER_SIZE <= US_RTP_TOTAL_SIZE) {
|
||||||
us_rtp_write_header(rtpa->rtp, pts, false);
|
us_rtp_write_header(rtpa->rtp, pts, false);
|
||||||
memcpy(rtpa->rtp->datagram + US_RTP_HEADER_SIZE, data, size);
|
memcpy(rtpa->rtp->datagram + US_RTP_HEADER_SIZE, data, size);
|
||||||
rtpa->rtp->used = size + US_RTP_HEADER_SIZE;
|
rtpa->rtp->used = size + US_RTP_HEADER_SIZE;
|
||||||
|
|||||||
@@ -105,13 +105,30 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const u8 *data, uz size, u32 pts, bool
|
|||||||
const uint type = data[0] & 0x1F;
|
const uint type = data[0] & 0x1F;
|
||||||
u8 *dg = rtpv->rtp->datagram;
|
u8 *dg = rtpv->rtp->datagram;
|
||||||
|
|
||||||
if (size + US_RTP_HEADER_SIZE <= US_RTP_DATAGRAM_SIZE) {
|
// Set *_of_frame flags only for non-SPS/PPS packages
|
||||||
|
/*
|
||||||
|
# define CALL_FOR_SERVICE { \
|
||||||
|
const bool m_fof = rtpv->rtp->first_of_frame; \
|
||||||
|
const bool m_lof = rtpv->rtp->last_of_frame; \
|
||||||
|
rtpv->rtp->first_of_frame = false; \
|
||||||
|
rtpv->rtp->last_of_frame = false; \
|
||||||
|
rtpv->callback(rtpv->rtp); \
|
||||||
|
rtpv->rtp->first_of_frame = m_fof; \
|
||||||
|
rtpv->rtp->last_of_frame = m_lof; \
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (size + US_RTP_HEADER_SIZE <= US_RTP_TOTAL_SIZE) {
|
||||||
us_rtp_write_header(rtpv->rtp, pts, marked);
|
us_rtp_write_header(rtpv->rtp, pts, marked);
|
||||||
memcpy(dg + US_RTP_HEADER_SIZE, data, size);
|
memcpy(dg + US_RTP_HEADER_SIZE, data, size);
|
||||||
rtpv->rtp->used = size + US_RTP_HEADER_SIZE;
|
rtpv->rtp->used = size + US_RTP_HEADER_SIZE;
|
||||||
|
// if (type == 7 || type == 8) {
|
||||||
|
// CALL_FOR_SERVICE;
|
||||||
|
// } else {*/
|
||||||
rtpv->rtp->last_of_frame = true;
|
rtpv->rtp->last_of_frame = true;
|
||||||
rtpv->callback(rtpv->rtp);
|
rtpv->callback(rtpv->rtp);
|
||||||
rtpv->rtp->first_of_frame = false;
|
rtpv->rtp->first_of_frame = false;
|
||||||
|
// }
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,7 +139,7 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const u8 *data, uz size, u32 pts, bool
|
|||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
while (remaining > 0) {
|
while (remaining > 0) {
|
||||||
sz frag_size = US_RTP_DATAGRAM_SIZE - fu_overhead;
|
sz frag_size = US_RTP_TOTAL_SIZE - fu_overhead;
|
||||||
const bool last = (remaining <= frag_size);
|
const bool last = (remaining <= frag_size);
|
||||||
if (last) {
|
if (last) {
|
||||||
frag_size = remaining;
|
frag_size = remaining;
|
||||||
@@ -143,14 +160,20 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const u8 *data, uz size, u32 pts, bool
|
|||||||
|
|
||||||
memcpy(dg + fu_overhead, src, frag_size);
|
memcpy(dg + fu_overhead, src, frag_size);
|
||||||
rtpv->rtp->used = fu_overhead + frag_size;
|
rtpv->rtp->used = fu_overhead + frag_size;
|
||||||
|
// if (type == 7 || type == 8) {
|
||||||
|
// CALL_FOR_SERVICE;
|
||||||
|
// } else {
|
||||||
rtpv->rtp->last_of_frame = last;
|
rtpv->rtp->last_of_frame = last;
|
||||||
rtpv->callback(rtpv->rtp);
|
rtpv->callback(rtpv->rtp);
|
||||||
rtpv->rtp->first_of_frame = false;
|
rtpv->rtp->first_of_frame = false;
|
||||||
|
// }
|
||||||
|
|
||||||
src += frag_size;
|
src += frag_size;
|
||||||
remaining -= frag_size;
|
remaining -= frag_size;
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# undef CALL_FOR_SERVICE
|
||||||
}
|
}
|
||||||
|
|
||||||
static sz _find_annexb(const u8 *data, uz size) {
|
static sz _find_annexb(const u8 *data, uz size) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.\" Manpage for ustreamer-dump.
|
.\" Manpage for ustreamer-dump.
|
||||||
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
|
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
|
||||||
.TH USTREAMER-DUMP 1 "version 6.52" "January 2021"
|
.TH USTREAMER-DUMP 1 "version 6.55" "January 2021"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ustreamer-dump \- Dump uStreamer's memory sink to file
|
ustreamer-dump \- Dump uStreamer's memory sink to file
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
.\" Manpage for ustreamer.
|
.\" Manpage for ustreamer.
|
||||||
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
|
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
|
||||||
.TH USTREAMER 1 "version 6.52" "November 2020"
|
.TH USTREAMER 1 "version 6.55" "November 2020"
|
||||||
|
|
||||||
.SH NAME
|
.SH NAME
|
||||||
ustreamer \- stream MJPEG video from any V4L2 device to the network
|
ustreamer \- stream MJPEG video from any V4L2 device to the network
|
||||||
@@ -23,7 +23,7 @@ For example, the recommended way of running µStreamer with TC358743-based captu
|
|||||||
.RS
|
.RS
|
||||||
\fB\-\-format=uyvy \e\fR # Device input format
|
\fB\-\-format=uyvy \e\fR # Device input format
|
||||||
.nf
|
.nf
|
||||||
\fB\-\-encoder=m2m-image \e\fR # Hardware encoding with V4L2 M2M intraface
|
\fB\-\-encoder=m2m-image \e\fR # Hardware encoding with V4L2 M2M interface
|
||||||
.nf
|
.nf
|
||||||
\fB\-\-workers=3 \e\fR # Maximum workers for V4L2 encoder
|
\fB\-\-workers=3 \e\fR # Maximum workers for V4L2 encoder
|
||||||
.nf
|
.nf
|
||||||
@@ -66,7 +66,7 @@ Available: MMAP, USERPTR; default: MMAP.
|
|||||||
Desired FPS. Default: maximum possible.
|
Desired FPS. Default: maximum possible.
|
||||||
.TP
|
.TP
|
||||||
.BR \-z\ \fIN ", " \-\-min\-frame\-size\ \fIN
|
.BR \-z\ \fIN ", " \-\-min\-frame\-size\ \fIN
|
||||||
Drop frames smaller then this limit. Useful if the device produces small\-sized garbage frames. Default: 128 bytes.
|
Drop frames smaller than this limit. Useful if the device produces small\-sized garbage frames. Default: 128 bytes.
|
||||||
.TP
|
.TP
|
||||||
.BR \-T ", " \-\-allow\-truncated\-frames
|
.BR \-T ", " \-\-allow\-truncated\-frames
|
||||||
Allows to handle truncated frames. Useful if the device produces incorrect but still acceptable frames. Default: disabled.
|
Allows to handle truncated frames. Useful if the device produces incorrect but still acceptable frames. Default: disabled.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
pkgname=ustreamer
|
pkgname=ustreamer
|
||||||
pkgver=6.52
|
pkgver=6.55
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Lightweight and fast MJPEG-HTTP streamer"
|
pkgdesc="Lightweight and fast MJPEG-HTTP streamer"
|
||||||
url="https://github.com/pikvm/ustreamer"
|
url="https://github.com/pikvm/ustreamer"
|
||||||
|
|||||||
@@ -2,11 +2,14 @@
|
|||||||
# This is free software, licensed under the GNU General Public License v2.
|
# This is free software, licensed under the GNU General Public License v2.
|
||||||
# See /LICENSE for more information.
|
# See /LICENSE for more information.
|
||||||
#
|
#
|
||||||
|
# This package is just an example. For OpenWRT it is recommended to use upstream package:
|
||||||
|
# - https://github.com/openwrt/packages/tree/master/multimedia/ustreamer
|
||||||
|
#
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=ustreamer
|
PKG_NAME:=ustreamer
|
||||||
PKG_VERSION:=6.52
|
PKG_VERSION:=6.55
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ def main() -> None:
|
|||||||
flags = _find_flags()
|
flags = _find_flags()
|
||||||
setup(
|
setup(
|
||||||
name="ustreamer",
|
name="ustreamer",
|
||||||
version="6.52",
|
version="6.55",
|
||||||
description="uStreamer tools",
|
description="uStreamer tools",
|
||||||
author="Maxim Devaev",
|
author="Maxim Devaev",
|
||||||
author_email="mdevaev@gmail.com",
|
author_email="mdevaev@gmail.com",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define US_VERSION_MAJOR 6
|
#define US_VERSION_MAJOR 6
|
||||||
#define US_VERSION_MINOR 52
|
#define US_VERSION_MINOR 55
|
||||||
|
|
||||||
#define US_MAKE_VERSION2(_major, _minor) #_major "." #_minor
|
#define US_MAKE_VERSION2(_major, _minor) #_major "." #_minor
|
||||||
#define US_MAKE_VERSION1(_major, _minor) US_MAKE_VERSION2(_major, _minor)
|
#define US_MAKE_VERSION1(_major, _minor) US_MAKE_VERSION2(_major, _minor)
|
||||||
|
|||||||
@@ -705,7 +705,7 @@ static void _help(
|
|||||||
SAY(" Changing of this parameter may increase the performance. Or not.");
|
SAY(" Changing of this parameter may increase the performance. Or not.");
|
||||||
SAY(" Available: %s; default: MMAP.\n", US_IO_METHODS_STR);
|
SAY(" Available: %s; default: MMAP.\n", US_IO_METHODS_STR);
|
||||||
SAY(" -f|--desired-fps <N> ──────────────── Desired FPS. Default: maximum possible.\n");
|
SAY(" -f|--desired-fps <N> ──────────────── Desired FPS. Default: maximum possible.\n");
|
||||||
SAY(" -z|--min-frame-size <N> ───────────── Drop frames smaller then this limit. Useful if the device");
|
SAY(" -z|--min-frame-size <N> ───────────── Drop frames smaller than this limit. Useful if the device");
|
||||||
SAY(" produces small-sized garbage frames. Default: %zu bytes.\n", cap->min_frame_size);
|
SAY(" produces small-sized garbage frames. Default: %zu bytes.\n", cap->min_frame_size);
|
||||||
SAY(" -T|--allow-truncated-frames ───────── Allows to handle truncated frames. Useful if the device");
|
SAY(" -T|--allow-truncated-frames ───────── Allows to handle truncated frames. Useful if the device");
|
||||||
SAY(" produces incorrect but still acceptable frames. Default: disabled.\n");
|
SAY(" produces incorrect but still acceptable frames. Default: disabled.\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user