mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-27 12:16:31 +00:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ac9f77619 | ||
|
|
c1bc1d9506 | ||
|
|
deb37986b6 | ||
|
|
ee6c555ce0 | ||
|
|
4395b8487f | ||
|
|
f622d03d1b | ||
|
|
36e6fa7b09 | ||
|
|
8cf6c66f21 | ||
|
|
ac9761beb2 | ||
|
|
90b7a5600f | ||
|
|
4c70baecb1 | ||
|
|
15c14bfebf | ||
|
|
eab8043496 |
@@ -1,7 +1,7 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
current_version = 1.22
|
current_version = 1.24
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?)?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)(\.(?P<patch>\d+)(\-(?P<release>[a-z]+))?)?
|
||||||
serialize =
|
serialize =
|
||||||
{major}.{minor}
|
{major}.{minor}
|
||||||
|
|||||||
6
.dockerignore
Normal file
6
.dockerignore
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Ignore everything
|
||||||
|
*
|
||||||
|
|
||||||
|
# Allow source code
|
||||||
|
!Makefile
|
||||||
|
!src/**
|
||||||
@@ -69,6 +69,8 @@ $ ./ustreamer \
|
|||||||
--drop-same-frames=30 # Save the traffic
|
--drop-same-frames=30 # Save the traffic
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Please note that to use `--drop-same-frames` for different browsers you need to use some specific URL `/stream` parameters (see URL `/` for details).
|
||||||
|
|
||||||
You can always view the full list of options with ```ustreamer --help```.
|
You can always view the full list of options with ```ustreamer --help```.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ $ ./ustreamer \
|
|||||||
--drop-same-frames=30 # Экономим трафик
|
--drop-same-frames=30 # Экономим трафик
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Обратите внимание что для использования `--drop-same-frames` для разных браузеров нужно использовать ряд специальных параметров в `/stream` (за деталями обратитесь к урлу `/`).
|
||||||
|
|
||||||
За полным списком опций обращайтесь ко встроенной справке: ```ustreamer --help```.
|
За полным списком опций обращайтесь ко встроенной справке: ```ustreamer --help```.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
|
|
||||||
pkgname=ustreamer
|
pkgname=ustreamer
|
||||||
pkgver=1.22
|
pkgver=1.24
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Lightweight and fast MJPG-HTTP streamer"
|
pkgdesc="Lightweight and fast MJPG-HTTP streamer"
|
||||||
url="https://github.com/pikvm/ustreamer"
|
url="https://github.com/pikvm/ustreamer"
|
||||||
license=(GPL)
|
license=(GPL)
|
||||||
arch=(i686 x86_64 armv6h armv7h)
|
arch=(i686 x86_64 armv6h armv7h aarch64)
|
||||||
depends=(libjpeg libevent libutil-linux libbsd)
|
depends=(libjpeg libevent libutil-linux libbsd)
|
||||||
# optional: raspberrypi-firmware for OMX encoder
|
# optional: raspberrypi-firmware for OMX encoder
|
||||||
# optional: wiringpi for GPIO support
|
# optional: wiringpi for GPIO support
|
||||||
|
|||||||
41
pkg/docker/Dockerfile.arm.cross
Normal file
41
pkg/docker/Dockerfile.arm.cross
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
FROM balenalib/raspberrypi3-debian:build as build
|
||||||
|
|
||||||
|
RUN ["cross-build-start"]
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
libjpeg8-dev \
|
||||||
|
libbsd-dev \
|
||||||
|
libraspberrypi-dev \
|
||||||
|
wiringpi \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build/ustreamer/
|
||||||
|
COPY . .
|
||||||
|
RUN make -j5 WITH_OMX=1 WITH_GPIO=1
|
||||||
|
RUN ["cross-build-end"]
|
||||||
|
|
||||||
|
FROM balenalib/raspberrypi3-debian:run as RUN
|
||||||
|
|
||||||
|
RUN ["cross-build-start"]
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
libevent-2.1 \
|
||||||
|
libevent-pthreads-2.1-6 \
|
||||||
|
libjpeg8 \
|
||||||
|
uuid \
|
||||||
|
libbsd0 \
|
||||||
|
wiringpi \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN ["cross-build-end"]
|
||||||
|
|
||||||
|
WORKDIR /ustreamer
|
||||||
|
COPY --from=build /build/ustreamer/ustreamer .
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["./ustreamer", "--host=::"]
|
||||||
|
|
||||||
|
# vim: syntax=dockerfile
|
||||||
34
pkg/docker/Dockerfile.arm.native
Normal file
34
pkg/docker/Dockerfile.arm.native
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
FROM balenalib/raspberrypi3-debian:build as build
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
gcc \
|
||||||
|
libjpeg8-dev \
|
||||||
|
libbsd-dev \
|
||||||
|
libraspberrypi-dev \
|
||||||
|
wiringpi \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build/ustreamer/
|
||||||
|
COPY . .
|
||||||
|
RUN make -j5 WITH_OMX=1 WITH_GPIO=1
|
||||||
|
|
||||||
|
FROM balenalib/raspberrypi3-debian:run as RUN
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
libevent-2.1 \
|
||||||
|
libevent-pthreads-2.1-6 \
|
||||||
|
libjpeg8 \
|
||||||
|
uuid \
|
||||||
|
libbsd0 \
|
||||||
|
wiringpi \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /ustreamer
|
||||||
|
COPY --from=build /build/ustreamer/ustreamer .
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["./ustreamer", "--host=::"]
|
||||||
|
|
||||||
|
# vim: syntax=dockerfile
|
||||||
38
pkg/docker/Dockerfile.x64.native
Normal file
38
pkg/docker/Dockerfile.x64.native
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
FROM debian:buster-slim as build
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y \
|
||||||
|
ca-certificates \
|
||||||
|
make \
|
||||||
|
gcc \
|
||||||
|
git \
|
||||||
|
libevent-dev \
|
||||||
|
libjpeg62-turbo-dev \
|
||||||
|
uuid-dev \
|
||||||
|
libbsd-dev \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /build/ustreamer/
|
||||||
|
COPY . .
|
||||||
|
RUN make -j5
|
||||||
|
|
||||||
|
FROM debian:buster-slim as run
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y \
|
||||||
|
ca-certificates \
|
||||||
|
libevent-2.1 \
|
||||||
|
libevent-pthreads-2.1-6 \
|
||||||
|
libjpeg62-turbo \
|
||||||
|
uuid \
|
||||||
|
libbsd0 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
WORKDIR /ustreamer
|
||||||
|
COPY --from=build /build/ustreamer/ustreamer .
|
||||||
|
|
||||||
|
#ENV LD_LIBRARY_PATH=/opt/vc/lib
|
||||||
|
EXPOSE 8080
|
||||||
|
ENTRYPOINT ["./ustreamer", "--host=0.0.0.0"]
|
||||||
|
|
||||||
|
# vim: syntax=dockerfile
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=ustreamer
|
PKG_NAME:=ustreamer
|
||||||
PKG_VERSION:=1.22
|
PKG_VERSION:=1.24
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
||||||
|
|
||||||
|
|||||||
@@ -23,5 +23,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef VERSION
|
#ifndef VERSION
|
||||||
# define VERSION "1.22"
|
# define VERSION "1.24"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
19
src/device.c
19
src/device.c
@@ -501,6 +501,8 @@ static int _device_open_format(struct device_t *dev) {
|
|||||||
static void _device_open_hw_fps(struct device_t *dev) {
|
static void _device_open_hw_fps(struct device_t *dev) {
|
||||||
struct v4l2_streamparm setfps;
|
struct v4l2_streamparm setfps;
|
||||||
|
|
||||||
|
dev->run->hw_fps = 0;
|
||||||
|
|
||||||
MEMSET_ZERO(setfps);
|
MEMSET_ZERO(setfps);
|
||||||
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
setfps.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
|
|
||||||
@@ -531,10 +533,21 @@ static void _device_open_hw_fps(struct device_t *dev) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev->desired_fps != SETFPS_TPF(denominator)) {
|
if (SETFPS_TPF(numerator) != 1) {
|
||||||
LOG_INFO("Using HW FPS: %u -> %u (coerced)", dev->desired_fps, SETFPS_TPF(denominator));
|
LOG_ERROR("Invalid HW FPS numerator: %u != 1", SETFPS_TPF(numerator));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SETFPS_TPF(denominator) == 0) { // Не знаю, бывает ли так, но пускай на всякий случай
|
||||||
|
LOG_ERROR("Invalid HW FPS denominator: 0");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev->run->hw_fps = SETFPS_TPF(denominator);
|
||||||
|
if (dev->desired_fps != dev->run->hw_fps) {
|
||||||
|
LOG_INFO("Using HW FPS: %u -> %u (coerced)", dev->desired_fps, dev->run->hw_fps);
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Using HW FPS: %u", dev->desired_fps);
|
LOG_INFO("Using HW FPS: %u", dev->run->hw_fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
# undef SETFPS_TPF
|
# undef SETFPS_TPF
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ struct device_runtime_t {
|
|||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned format;
|
unsigned format;
|
||||||
|
unsigned hw_fps;
|
||||||
size_t raw_size;
|
size_t raw_size;
|
||||||
unsigned n_buffers;
|
unsigned n_buffers;
|
||||||
unsigned n_workers;
|
unsigned n_workers;
|
||||||
|
|||||||
@@ -680,5 +680,5 @@ static void _help(struct device_t *dev, struct encoder_t *encoder, struct http_s
|
|||||||
printf("═════════════\n");
|
printf("═════════════\n");
|
||||||
printf(" -h|--help ─────── Print this text and exit.\n\n");
|
printf(" -h|--help ─────── Print this text and exit.\n\n");
|
||||||
printf(" -v|--version ──── Print version and exit.\n\n");
|
printf(" -v|--version ──── Print version and exit.\n\n");
|
||||||
printf(" --features ────── Print list of supporeted features.\n\n");
|
printf(" --features ────── Print list of supported features.\n\n");
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/stream.c
15
src/stream.c
@@ -350,11 +350,14 @@ static void _stream_expose_picture(struct stream_t *stream, unsigned buf_index,
|
|||||||
static struct _workers_pool_t *_workers_pool_init(struct stream_t *stream) {
|
static struct _workers_pool_t *_workers_pool_init(struct stream_t *stream) {
|
||||||
struct _workers_pool_t *pool;
|
struct _workers_pool_t *pool;
|
||||||
|
|
||||||
LOG_INFO("Creating pool with %u workers ...", stream->dev->run->n_workers);
|
# define DEV(_next) stream->dev->_next
|
||||||
|
# define RUN(_next) stream->dev->run->_next
|
||||||
|
|
||||||
|
LOG_INFO("Creating pool with %u workers ...", RUN(n_workers));
|
||||||
|
|
||||||
A_CALLOC(pool, 1);
|
A_CALLOC(pool, 1);
|
||||||
|
|
||||||
pool->n_workers = stream->dev->run->n_workers;
|
pool->n_workers = RUN(n_workers);
|
||||||
A_CALLOC(pool->workers, pool->n_workers);
|
A_CALLOC(pool->workers, pool->n_workers);
|
||||||
|
|
||||||
A_MUTEX_INIT(&pool->free_workers_mutex);
|
A_MUTEX_INIT(&pool->free_workers_mutex);
|
||||||
@@ -362,10 +365,13 @@ static struct _workers_pool_t *_workers_pool_init(struct stream_t *stream) {
|
|||||||
|
|
||||||
atomic_init(&pool->workers_stop, false);
|
atomic_init(&pool->workers_stop, false);
|
||||||
|
|
||||||
if (stream->dev->desired_fps > 0) {
|
if (DEV(desired_fps) > 0 && (DEV(desired_fps) < RUN(hw_fps) || RUN(hw_fps) == 0)) {
|
||||||
pool->desired_frames_interval = (long double)1 / stream->dev->desired_fps;
|
pool->desired_frames_interval = (long double)1 / DEV(desired_fps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# undef RUN
|
||||||
|
# undef DEV
|
||||||
|
|
||||||
for (unsigned number = 0; number < pool->n_workers; ++number) {
|
for (unsigned number = 0; number < pool->n_workers; ++number) {
|
||||||
# define WORKER(_next) pool->workers[number]._next
|
# define WORKER(_next) pool->workers[number]._next
|
||||||
|
|
||||||
@@ -557,6 +563,7 @@ static long double _workers_pool_get_fluency_delay(struct _workers_pool_t *pool,
|
|||||||
|
|
||||||
if (pool->desired_frames_interval > 0 && min_delay > 0 && pool->desired_frames_interval > min_delay) {
|
if (pool->desired_frames_interval > 0 && min_delay > 0 && pool->desired_frames_interval > min_delay) {
|
||||||
// Искусственное время задержки на основе желаемого FPS, если включен --desired-fps
|
// Искусственное время задержки на основе желаемого FPS, если включен --desired-fps
|
||||||
|
// и аппаратный fps не попадает точно в желаемое значение
|
||||||
return pool->desired_frames_interval;
|
return pool->desired_frames_interval;
|
||||||
}
|
}
|
||||||
return min_delay;
|
return min_delay;
|
||||||
|
|||||||
@@ -102,7 +102,23 @@ INLINE void thread_get_name(char *name) { // Always required for logging
|
|||||||
# endif
|
# endif
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
#endif
|
#endif
|
||||||
assert(snprintf(name, MAX_THREAD_NAME, "tid=%d", (pid_t)syscall(SYS_gettid)) > 0);
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
pid_t tid = syscall(SYS_gettid);
|
||||||
|
#elif defined(__FreeBSD__)
|
||||||
|
pid_t tid = syscall(SYS_thr_self);
|
||||||
|
#elif defined(__OpenBSD__)
|
||||||
|
pid_t tid = syscall(SYS_getthrid);
|
||||||
|
#elif defined(__NetBSD__)
|
||||||
|
pid_t tid = syscall(SYS__lwp_self);
|
||||||
|
#elif defined(__DragonFly__)
|
||||||
|
pid_t tid = syscall(SYS_lwp_gettid);
|
||||||
|
#else
|
||||||
|
pid_t tid = 0; // Makes cppcheck happy
|
||||||
|
# warning gettid() not implemented
|
||||||
|
#endif
|
||||||
|
assert(snprintf(name, MAX_THREAD_NAME, "tid=%d", tid) > 0);
|
||||||
|
|
||||||
#ifdef WITH_PTHREAD_NP
|
#ifdef WITH_PTHREAD_NP
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user