mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-28 12:46:32 +00:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07ecc5b0a0 | ||
|
|
8d19711f2c | ||
|
|
c94117ae1e | ||
|
|
06a80df708 | ||
|
|
13dff256c8 | ||
|
|
07e9dbc0f7 | ||
|
|
c83dddbf0b | ||
|
|
5672d1aa75 | ||
|
|
078097efec | ||
|
|
3cd8338886 | ||
|
|
d2b57cc7d5 | ||
|
|
2c4f59c87a | ||
|
|
36eb7eeb76 | ||
|
|
3b6544db8a | ||
|
|
8033ab23ed | ||
|
|
ddb3db8b20 | ||
|
|
b3c8071edb | ||
|
|
bc70faae09 | ||
|
|
ae7c4c91e0 | ||
|
|
613baa4e1e |
@@ -1,7 +1,7 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
current_version = 0.71
|
current_version = 0.77
|
||||||
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}
|
||||||
|
|||||||
43
Makefile
43
Makefile
@@ -1,24 +1,27 @@
|
|||||||
|
PROG ?= ustreamer
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
|
CC ?= gcc
|
||||||
CFLAGS ?= -O3
|
CFLAGS ?= -O3
|
||||||
LDFLAGS ?=
|
LDFLAGS ?=
|
||||||
CC ?= gcc
|
|
||||||
|
RPI_VC_HEADERS ?= /opt/vc/include
|
||||||
|
RPI_VC_LIBS ?= /opt/vc/lib
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
LIBS = -lm -ljpeg -pthread -levent -levent_pthreads -luuid
|
LIBS = -lm -ljpeg -pthread -levent -levent_pthreads -luuid
|
||||||
override CFLAGS += -c -std=c11 -Wall -Wextra -D_GNU_SOURCE
|
override CFLAGS += -c -std=c11 -Wall -Wextra -D_GNU_SOURCE
|
||||||
SOURCES = $(shell ls src/*.c src/http/*.c src/encoders/cpu/*.c src/encoders/hw/*.c)
|
SOURCES = $(shell ls src/*.c src/http/*.c src/encoders/cpu/*.c src/encoders/hw/*.c)
|
||||||
PROG = ustreamer
|
|
||||||
|
|
||||||
ifeq ($(shell ls -d /opt/vc/include 2>/dev/null), /opt/vc/include)
|
ifeq ($(WITH_OMX_ENCODER),)
|
||||||
SOURCES += $(shell ls src/encoders/omx/*.c)
|
else
|
||||||
LIBS += -lbcm_host -lvcos -lopenmaxil -L/opt/vc/lib
|
LIBS += -lbcm_host -lvcos -lopenmaxil -L$(RPI_VC_LIBS)
|
||||||
override CFLAGS += -DWITH_OMX_ENCODER -DOMX_SKIP64BIT -I/opt/vc/include
|
override CFLAGS += -DWITH_OMX_ENCODER -DOMX_SKIP64BIT -I$(RPI_VC_HEADERS)
|
||||||
|
SOURCES += $(shell ls src/encoders/omx/*.c)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJECTS = $(SOURCES:.c=.o)
|
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
all: $(SOURCES) $(PROG)
|
all: $(SOURCES) $(PROG)
|
||||||
@@ -28,17 +31,32 @@ install: $(PROG)
|
|||||||
install -Dm755 $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
install -Dm755 $(PROG) $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
||||||
|
|
||||||
|
|
||||||
|
install-strip: install
|
||||||
|
strip $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
||||||
|
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm $(DESTDIR)$(PREFIX)/bin/$(PROG)
|
||||||
|
|
||||||
|
|
||||||
regen:
|
regen:
|
||||||
tools/make-jpeg-h.py src/http/data/blank.jpeg src/http/data/blank_jpeg.h BLANK
|
tools/make-jpeg-h.py src/http/data/blank.jpeg src/http/data/blank_jpeg.h BLANK
|
||||||
tools/make-html-h.py src/http/data/index.html src/http/data/index_html.h INDEX
|
tools/make-html-h.py src/http/data/index.html src/http/data/index_html.h INDEX
|
||||||
|
|
||||||
|
|
||||||
$(PROG): $(OBJECTS)
|
$(PROG): $(SOURCES:.c=.o)
|
||||||
$(CC) $(LIBS) $(LDFLAGS) $(OBJECTS) -o $@
|
$(info -- LINKING $@)
|
||||||
|
@ $(CC) $(SOURCES:.c=.o) -o $@ $(LDFLAGS) $(LIBS)
|
||||||
|
$(info ===== Build complete =====)
|
||||||
|
$(info == CC = $(CC))
|
||||||
|
$(info == LIBS = $(LIBS))
|
||||||
|
$(info == CFLAGS = $(CFLAGS))
|
||||||
|
$(info == LDFLAGS = $(LDFLAGS))
|
||||||
|
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(LIBS) $(CFLAGS) $< -o $@
|
$(info -- CC $<)
|
||||||
|
@ $(CC) $< -o $@ $(CFLAGS) $(LIBS)
|
||||||
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
@@ -50,13 +68,14 @@ release:
|
|||||||
|
|
||||||
|
|
||||||
bump:
|
bump:
|
||||||
bumpversion $(if $(V), $(V), minor)
|
bumpversion $(if $(V),$(V),minor)
|
||||||
|
|
||||||
|
|
||||||
push:
|
push:
|
||||||
git push
|
git push
|
||||||
git push --tags
|
git push --tags
|
||||||
|
|
||||||
|
|
||||||
clean-all: clean
|
clean-all: clean
|
||||||
clean:
|
clean:
|
||||||
find src -name '*.o' -exec rm '{}' \;
|
find src -name '*.o' -exec rm '{}' \;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
| Multithreaded JPEG encoding |  Yes |  No |
|
| Multithreaded JPEG encoding |  Yes |  No |
|
||||||
| [OpenMAX IL](https://www.khronos.org/openmaxil) hardware acceleration<br>on Raspberry Pi |  Yes |  No |
|
| [OpenMAX IL](https://www.khronos.org/openmaxil) hardware acceleration<br>on Raspberry Pi |  Yes |  No |
|
||||||
| Behavior when the device<br>is disconnected while streaming |  Shows a black screen<br>with ```NO SIGNAL``` on it<br>until reconnected |  Stops the broadcast <sup>1</sup> |
|
| Behavior when the device<br>is disconnected while streaming |  Shows a black screen<br>with ```NO SIGNAL``` on it<br>until reconnected |  Stops the broadcast <sup>1</sup> |
|
||||||
| [DV-timings](https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/dv-timings.html) support -<br>the ability to change resolution<br>on the fly by source signal |  Yes |  Partially yes <sup>2</sup> |
|
| [DV-timings](https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/dv-timings.html) support -<br>the ability to change resolution<br>on the fly by source signal |  Yes |  Partially yes <sup>1</sup> |
|
||||||
| Option to skip frames when streaming<br>static images by HTTP to save traffic |  Yes <sup>2</sup> |  No |
|
| Option to skip frames when streaming<br>static images by HTTP to save traffic |  Yes <sup>2</sup> |  No |
|
||||||
| Streaming via UNIX domain socket |  Yes |  No |
|
| Streaming via UNIX domain socket |  Yes |  No |
|
||||||
| Debug logs without recompiling,<br>performance statistics log,<br>access to HTTP broadcast parameters |  Yes |  No |
|
| Debug logs without recompiling,<br>performance statistics log,<br>access to HTTP broadcast parameters |  Yes |  No |
|
||||||
@@ -31,7 +31,7 @@ If you're going to live-stream from your backyard webcam and need to control it,
|
|||||||
# Building
|
# Building
|
||||||
You'll need ```make```, ```gcc```, ```libevent``` with ```pthreads``` support, ```libjpeg8```/```libjpeg-turbo``` and ```libuuid```.
|
You'll need ```make```, ```gcc```, ```libevent``` with ```pthreads``` support, ```libjpeg8```/```libjpeg-turbo``` and ```libuuid```.
|
||||||
|
|
||||||
It should compile automatically with OpenMAX IL on Raspberry Pi, if the corresponding headers are present in ```/opt/vc/include```.
|
On Raspberry Pi you can build the program with OpenMAX IL. To do this pass option ```WITH_OMX_ENCODER=1``` to ```make```.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone --depth=1 https://github.com/pi-kvm/ustreamer
|
$ git clone --depth=1 https://github.com/pi-kvm/ustreamer
|
||||||
@@ -40,7 +40,8 @@ $ make
|
|||||||
$ ./ustreamer --help
|
$ ./ustreamer --help
|
||||||
```
|
```
|
||||||
|
|
||||||
AUR has a package for Arch Linux: https://aur.archlinux.org/packages/ustreamer
|
AUR has a package for Arch Linux: https://aur.archlinux.org/packages/ustreamer. It should compile automatically with OpenMAX IL on Raspberry Pi, if the corresponding headers are present in ```/opt/vc/include```.
|
||||||
|
FreeBSD port: https://www.freshports.org/multimedia/ustreamer.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
# Usage
|
# Usage
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
| Многопоточное кодирование JPEG |  Есть |  Нет |
|
| Многопоточное кодирование JPEG |  Есть |  Нет |
|
||||||
| Аппаратное кодирование с помощью [OpenMAX IL](https://www.khronos.org/openmaxil) на Raspberry Pi |  Есть |  Нет |
|
| Аппаратное кодирование с помощью [OpenMAX IL](https://www.khronos.org/openmaxil) на Raspberry Pi |  Есть |  Нет |
|
||||||
| Поведение при физическом отключении<br>устройства от сервера во время работы |  Транслирует черный экран<br>с надписью ```NO SIGNAL```,<br>пока устройство не будет подключено снова |  Прерывает трансляцию <sup>1</sup> |
|
| Поведение при физическом отключении<br>устройства от сервера во время работы |  Транслирует черный экран<br>с надписью ```NO SIGNAL```,<br>пока устройство не будет подключено снова |  Прерывает трансляцию <sup>1</sup> |
|
||||||
| Поддержка [DV-таймингов](https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/dv-timings.html) - возможности<br>изменения параметров разрешения<br>трансляции на лету по сигналу<br>источника (устройства видеозахвата) |  Есть |  Условно есть <sup>2</sup> |
|
| Поддержка [DV-таймингов](https://linuxtv.org/downloads/v4l-dvb-apis/uapi/v4l/dv-timings.html) - возможности<br>изменения параметров разрешения<br>трансляции на лету по сигналу<br>источника (устройства видеозахвата) |  Есть |  Условно есть <sup>1</sup> |
|
||||||
| Возможность пропуска фреймов при передаче<br>статического изображения по HTTP<br>для экономии трафика |  Есть <sup>2</sup> |  Нет |
|
| Возможность пропуска фреймов при передаче<br>статического изображения по HTTP<br>для экономии трафика |  Есть <sup>2</sup> |  Нет |
|
||||||
| Стрим через UNIX domain socket |  Есть |  Нет |
|
| Стрим через UNIX domain socket |  Есть |  Нет |
|
||||||
| Дебаг-логи без перекомпиляции,<br>логгирование статистики производительности,<br>возможность получения параметров<br>трансляции по HTTP |  Есть |  Нет |
|
| Дебаг-логи без перекомпиляции,<br>логгирование статистики производительности,<br>возможность получения параметров<br>трансляции по HTTP |  Есть |  Нет |
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
# Сборка
|
# Сборка
|
||||||
Для сборки вам понадобятся ```make```, ```gcc```, ```libevent``` с поддержкой ```pthreads```, ```libjpeg8```/```libjpeg-turbo``` и ```libuuid```.
|
Для сборки вам понадобятся ```make```, ```gcc```, ```libevent``` с поддержкой ```pthreads```, ```libjpeg8```/```libjpeg-turbo``` и ```libuuid```.
|
||||||
|
|
||||||
На Raspberry Pi програма автоматически собирается с поддержкой OpenMAX IL, если обнаружит нужные хедеры в ```/opt/vc/include```.
|
На Raspberry Pi программу можно собрать с поддержкой OpenMAX IL. Для этого передайте ```make``` параметр ```WITH_OMX_ENCODER=1```.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone --depth=1 https://github.com/pi-kvm/ustreamer
|
$ git clone --depth=1 https://github.com/pi-kvm/ustreamer
|
||||||
@@ -40,7 +40,8 @@ $ make
|
|||||||
$ ./ustreamer --help
|
$ ./ustreamer --help
|
||||||
```
|
```
|
||||||
|
|
||||||
Для Arch Linux в AUR есть готовый пакет: https://aur.archlinux.org/packages/ustreamer
|
Для Arch Linux в AUR есть готовый пакет: https://aur.archlinux.org/packages/ustreamer. На Raspberry Pi програма автоматически собирается с поддержкой OpenMAX IL, если обнаружит нужные хедеры в ```/opt/vc/include```.
|
||||||
|
Порт для FreeBSD: https://www.freshports.org/multimedia/ustreamer.
|
||||||
|
|
||||||
-----
|
-----
|
||||||
# Использование
|
# Использование
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
pkgname=ustreamer
|
pkgname=ustreamer
|
||||||
pkgver=0.71
|
pkgver=0.77
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Lightweight and fast MJPG-HTTP streamer"
|
pkgdesc="Lightweight and fast MJPG-HTTP streamer"
|
||||||
url="https://github.com/pi-kvm/ustreamer"
|
url="https://github.com/pi-kvm/ustreamer"
|
||||||
@@ -12,19 +12,23 @@ arch=(i686 x86_64 armv6h armv7h)
|
|||||||
depends=(libjpeg libevent libutil-linux)
|
depends=(libjpeg libevent libutil-linux)
|
||||||
# optional: raspberrypi-firmware for OMX JPEG encoder
|
# optional: raspberrypi-firmware for OMX JPEG encoder
|
||||||
makedepends=(gcc make)
|
makedepends=(gcc make)
|
||||||
source=("$url/archive/v$pkgver.tar.gz")
|
source=(${pkgname}::"git+https://github.com/pi-kvm/ustreamer#commit=v${pkgver}")
|
||||||
md5sums=(SKIP)
|
md5sums=(SKIP)
|
||||||
|
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
cd $srcdir
|
cd "$srcdir"
|
||||||
rm -rf $pkgname-build
|
rm -rf $pkgname-build
|
||||||
cp -r $pkgname-$pkgver $pkgname-build
|
cp -r $pkgname $pkgname-build
|
||||||
cd $pkgname-build
|
cd $pkgname-build
|
||||||
make CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" $MAKEFLAGS
|
|
||||||
|
local _options=""
|
||||||
|
[ -d /opt/vc/include ] && _options="$_options WITH_OMX_ENCODER=1"
|
||||||
|
|
||||||
|
make $_options CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" $MAKEFLAGS
|
||||||
}
|
}
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd $srcdir/$pkgname-build
|
cd "$srcdir/$pkgname-build"
|
||||||
make DESTDIR="$pkgdir" PREFIX=/usr install
|
make DESTDIR="$pkgdir" PREFIX=/usr install
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=ustreamer
|
PKG_NAME:=ustreamer
|
||||||
PKG_VERSION:=0.71
|
PKG_VERSION:=0.77
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
||||||
|
|
||||||
|
|||||||
@@ -22,4 +22,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION "0.71"
|
#ifndef VERSION
|
||||||
|
# define VERSION "0.77"
|
||||||
|
#endif
|
||||||
|
|||||||
12
src/device.c
12
src/device.c
@@ -85,6 +85,12 @@ struct device_t *device_init() {
|
|||||||
struct controls_t *ctl;
|
struct controls_t *ctl;
|
||||||
struct device_runtime_t *run;
|
struct device_runtime_t *run;
|
||||||
struct device_t *dev;
|
struct device_t *dev;
|
||||||
|
long cores_sysconf;
|
||||||
|
unsigned cores_available;
|
||||||
|
|
||||||
|
cores_sysconf = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
cores_sysconf = (cores_sysconf < 0 ? 0 : cores_sysconf);
|
||||||
|
cores_available = max_u(min_u(cores_sysconf, 4), 1);
|
||||||
|
|
||||||
A_CALLOC(ctl, 1);
|
A_CALLOC(ctl, 1);
|
||||||
|
|
||||||
@@ -97,8 +103,8 @@ struct device_t *device_init() {
|
|||||||
dev->height = 480;
|
dev->height = 480;
|
||||||
dev->format = V4L2_PIX_FMT_YUYV;
|
dev->format = V4L2_PIX_FMT_YUYV;
|
||||||
dev->standard = V4L2_STD_UNKNOWN;
|
dev->standard = V4L2_STD_UNKNOWN;
|
||||||
dev->n_buffers = max_u(min_u(sysconf(_SC_NPROCESSORS_ONLN), 4), 1) + 1;
|
dev->n_buffers = cores_available + 1;
|
||||||
dev->n_workers = dev->n_buffers;
|
dev->n_workers = min_u(cores_available, dev->n_buffers);
|
||||||
dev->timeout = 1;
|
dev->timeout = 1;
|
||||||
dev->error_delay = 1;
|
dev->error_delay = 1;
|
||||||
dev->ctl = ctl;
|
dev->ctl = ctl;
|
||||||
@@ -322,7 +328,7 @@ static int _device_open_check_cap(struct device_t *dev) {
|
|||||||
static int _device_open_dv_timings(struct device_t *dev) {
|
static int _device_open_dv_timings(struct device_t *dev) {
|
||||||
_device_apply_resolution(dev, dev->width, dev->height);
|
_device_apply_resolution(dev, dev->width, dev->height);
|
||||||
if (dev->dv_timings) {
|
if (dev->dv_timings) {
|
||||||
LOG_DEBUG("Using DV-timings");
|
LOG_DEBUG("Using DV timings");
|
||||||
|
|
||||||
if (_device_apply_dv_timings(dev) < 0) {
|
if (_device_apply_dv_timings(dev) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -105,8 +105,6 @@ void cpu_encoder_compress_buffer(struct device_t *dev, unsigned index, unsigned
|
|||||||
|
|
||||||
# undef WRITE_SCANLINES
|
# undef WRITE_SCANLINES
|
||||||
|
|
||||||
// TODO: process jpeg errors:
|
|
||||||
// https://stackoverflow.com/questions/19857766/error-handling-in-libjpeg
|
|
||||||
jpeg_finish_compress(&jpeg);
|
jpeg_finish_compress(&jpeg);
|
||||||
jpeg_destroy_compress(&jpeg);
|
jpeg_destroy_compress(&jpeg);
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ static int _jpeg_read_geometry(FILE *fp, unsigned *width, unsigned *height) {
|
|||||||
|
|
||||||
jpeg_create_decompress(&jpeg);
|
jpeg_create_decompress(&jpeg);
|
||||||
|
|
||||||
|
// https://stackoverflow.com/questions/19857766/error-handling-in-libjpeg
|
||||||
jpeg.err = jpeg_std_error((struct jpeg_error_mgr *)&jpeg_error);
|
jpeg.err = jpeg_std_error((struct jpeg_error_mgr *)&jpeg_error);
|
||||||
jpeg_error.mgr.error_exit = _jpeg_error_handler;
|
jpeg_error.mgr.error_exit = _jpeg_error_handler;
|
||||||
if (setjmp(jpeg_error.jmp) < 0) {
|
if (setjmp(jpeg_error.jmp) < 0) {
|
||||||
|
|||||||
@@ -121,7 +121,10 @@ void http_server_destroy(struct http_server_t *server) {
|
|||||||
close(server->run->unix_fd);
|
close(server->run->unix_fd);
|
||||||
}
|
}
|
||||||
event_base_free(server->run->base);
|
event_base_free(server->run->base);
|
||||||
|
|
||||||
|
# if LIBEVENT_VERSION_NUMBER >= 0x02010100
|
||||||
libevent_global_shutdown();
|
libevent_global_shutdown();
|
||||||
|
# endif
|
||||||
|
|
||||||
for (struct stream_client_t *client = server->run->stream_clients; client != NULL;) {
|
for (struct stream_client_t *client = server->run->stream_clients; client != NULL;) {
|
||||||
struct stream_client_t *next = client->next;
|
struct stream_client_t *next = client->next;
|
||||||
@@ -199,19 +202,25 @@ int http_server_listen(struct http_server_t *server) {
|
|||||||
|
|
||||||
if (server->unix_path[0] != '\0') {
|
if (server->unix_path[0] != '\0') {
|
||||||
struct sockaddr_un unix_addr;
|
struct sockaddr_un unix_addr;
|
||||||
int unix_fd_flags;
|
|
||||||
|
|
||||||
LOG_DEBUG("Binding HTTP to UNIX socket '%s' ...", server->unix_path);
|
LOG_DEBUG("Binding HTTP to UNIX socket '%s' ...", server->unix_path);
|
||||||
|
|
||||||
assert((server->run->unix_fd = socket(AF_UNIX, SOCK_STREAM, 0)));
|
# define MAX_SUN_PATH (sizeof(unix_addr.sun_path) - 1)
|
||||||
assert((unix_fd_flags = fcntl(server->run->unix_fd, F_GETFL)) >= 0);
|
|
||||||
unix_fd_flags |= O_NONBLOCK;
|
|
||||||
assert(fcntl(server->run->unix_fd, F_SETFL, unix_fd_flags) >= 0);
|
|
||||||
|
|
||||||
strncpy(unix_addr.sun_path, server->unix_path, 107);
|
if (strlen(server->unix_path) > MAX_SUN_PATH) {
|
||||||
unix_addr.sun_path[107] = '\0';
|
LOG_ERROR("UNIX socket path is too long, max=%zu", MAX_SUN_PATH);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
MEMSET_ZERO(unix_addr);
|
||||||
|
strncpy(unix_addr.sun_path, server->unix_path, MAX_SUN_PATH);
|
||||||
unix_addr.sun_family = AF_UNIX;
|
unix_addr.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
# undef MAX_SUN_PATH
|
||||||
|
|
||||||
|
assert((server->run->unix_fd = socket(AF_UNIX, SOCK_STREAM, 0)) >= 0);
|
||||||
|
assert(!evutil_make_socket_nonblocking(server->run->unix_fd));
|
||||||
|
|
||||||
if (server->unix_rm && unlink(server->unix_path) < 0) {
|
if (server->unix_rm && unlink(server->unix_path) < 0) {
|
||||||
if (errno != ENOENT) {
|
if (errno != ENOENT) {
|
||||||
LOG_PERROR("Can't remove old UNIX socket '%s'", server->unix_path);
|
LOG_PERROR("Can't remove old UNIX socket '%s'", server->unix_path);
|
||||||
|
|||||||
@@ -123,10 +123,10 @@ pthread_mutex_t log_mutex;
|
|||||||
|
|
||||||
|
|
||||||
INLINE char *errno_to_string(char *buf, size_t size) {
|
INLINE char *errno_to_string(char *buf, size_t size) {
|
||||||
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
|
# if defined(__GLIBC__) && defined(_GNU_SOURCE)
|
||||||
return strerror_r(errno, buf, size);
|
return strerror_r(errno, buf, size);
|
||||||
#else
|
# else
|
||||||
strerror_r(errno, buf, size);
|
strerror_r(errno, buf, size);
|
||||||
return buf;
|
return buf;
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/main.c
12
src/main.c
@@ -129,19 +129,19 @@ static void _help(struct device_t *dev, struct encoder_t *encoder, struct http_s
|
|||||||
printf(" -z|--min-frame-size <N> ──────── Drop frames smaller then this limit. Useful if the device\n");
|
printf(" -z|--min-frame-size <N> ──────── Drop frames smaller then this limit. Useful if the device\n");
|
||||||
printf(" produces small-sized garbage frames. Default: disabled.\n\n");
|
printf(" produces small-sized garbage frames. Default: disabled.\n\n");
|
||||||
printf(" -n|--persistent ──────────────── Don't re-initialize device on timeout. Default: disabled.\n\n");
|
printf(" -n|--persistent ──────────────── Don't re-initialize device on timeout. Default: disabled.\n\n");
|
||||||
printf(" -t|--dv-timings ──────────────── Enable DV timings queriyng and events processing.\n");
|
printf(" -t|--dv-timings ──────────────── Enable DV timings queriyng and events processing\n");
|
||||||
printf(" Supports automatic resolution changing. Default: disabled.\n\n");
|
printf(" to automatic resolution change. Default: disabled.\n\n");
|
||||||
printf(" -b|--buffers <N> ─────────────── The number of buffers to receive data from the device.\n");
|
printf(" -b|--buffers <N> ─────────────── The number of buffers to receive data from the device.\n");
|
||||||
printf(" Each buffer may processed using an intermediate thread.\n");
|
printf(" Each buffer may processed using an intermediate thread.\n");
|
||||||
printf(" Default: %u (the number of CPU cores (but not more 4) + 1).\n\n", dev->n_buffers);
|
printf(" Default: %u (the number of CPU cores (but not more than 4) + 1).\n\n", dev->n_buffers);
|
||||||
printf(" -w|--workers <N> ─────────────── The number of worker threads but not more than buffers.\n");
|
printf(" -w|--workers <N> ─────────────── The number of worker threads but not more than buffers.\n");
|
||||||
printf(" Default: %u (== --buffers).\n\n", dev->n_workers);
|
printf(" Default: %u (the number of CPU cores (but not more than 4)).\n\n", dev->n_workers);
|
||||||
printf(" -q|--quality <N> ─────────────── Set quality of JPEG encoding from 1 to 100 (best). Default: %u.\n\n", encoder->quality);
|
printf(" -q|--quality <N> ─────────────── Set quality of JPEG encoding from 1 to 100 (best). Default: %u.\n\n", encoder->quality);
|
||||||
printf(" -c|--encoder <type> ──────────── Use specified encoder. It may affects to workers number.\n");
|
printf(" -c|--encoder <type> ──────────── Use specified encoder. It may affects to workers number.\n");
|
||||||
printf(" Available: %s; default: CPU.\n\n", ENCODER_TYPES_STR);
|
printf(" Available: %s; default: CPU.\n\n", ENCODER_TYPES_STR);
|
||||||
printf(" --device-timeout <seconds> ───── Timeout for device querying. Default: %u\n\n", dev->timeout);
|
printf(" --device-timeout <seconds> ───── Timeout for device querying. Default: %u.\n\n", dev->timeout);
|
||||||
printf(" --device-error-delay <seconds> ─ Delay before trying to connect to the device again\n");
|
printf(" --device-error-delay <seconds> ─ Delay before trying to connect to the device again\n");
|
||||||
printf(" after an error (timeout for example). Default: %u\n\n", dev->error_delay);
|
printf(" after an error (timeout for example). Default: %u.\n\n", dev->error_delay);
|
||||||
printf("Image control options:\n");
|
printf("Image control options:\n");
|
||||||
printf("══════════════════════\n");
|
printf("══════════════════════\n");
|
||||||
printf(" --brightness <N> ───────────── Set brightness. Default: no change.\n\n");
|
printf(" --brightness <N> ───────────── Set brightness. Default: no change.\n\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user