mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-15 03:53:43 +00:00
removed libuuid dep and using get_now_id()
This commit is contained in:
2
Makefile
2
Makefile
@@ -25,7 +25,7 @@ _LDFLAGS = $(LDFLAGS)
|
|||||||
|
|
||||||
_COMMON_LIBS = -lm -ljpeg -pthread -lrt
|
_COMMON_LIBS = -lm -ljpeg -pthread -lrt
|
||||||
|
|
||||||
_USTR_LIBS = $(_COMMON_LIBS) -levent -levent_pthreads -luuid
|
_USTR_LIBS = $(_COMMON_LIBS) -levent -levent_pthreads
|
||||||
_USTR_SRCS = $(shell ls \
|
_USTR_SRCS = $(shell ls \
|
||||||
src/libs/*.c \
|
src/libs/*.c \
|
||||||
src/ustreamer/*.c \
|
src/ustreamer/*.c \
|
||||||
|
|||||||
@@ -34,12 +34,12 @@ 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```, ```libuuid``` and ```libbsd``` (only for Linux).
|
You'll need ```make```, ```gcc```, ```libevent``` with ```pthreads``` support, ```libjpeg8```/```libjpeg-turbo``` and ```libbsd``` (only for Linux).
|
||||||
|
|
||||||
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
||||||
* Raspbian: `sudo apt install libevent-dev libjpeg8-dev uuid-dev libbsd-dev`. Add `libraspberrypi-dev` for `WITH_OMX=1` and `libgpiod` for `WITH_GPIO=1`.
|
* Raspbian: `sudo apt install libevent-dev libjpeg8-dev libbsd-dev`. Add `libraspberrypi-dev` for `WITH_OMX=1` and `libgpiod` for `WITH_GPIO=1`.
|
||||||
* Debian: `sudo apt install build-essential libevent-dev libjpeg62-turbo-dev uuid-dev libbsd-dev`.
|
* Debian: `sudo apt install build-essential libevent-dev libjpeg62-turbo-dev libbsd-dev`.
|
||||||
* Ubuntu 20.04 x86_64: `sudo apt install build-essential libevent-dev libjpeg-dev libjpeg62-dev uuid-dev libbsd-dev make gcc libjpeg8 libjpeg-turbo8 libuuid1 libbsd0`.
|
* Ubuntu 20.04 x86_64: `sudo apt install build-essential libevent-dev libjpeg-dev libjpeg62-dev libbsd-dev make gcc libjpeg8 libjpeg-turbo8 libbsd0`.
|
||||||
|
|
||||||
On Raspberry Pi you can build the program with OpenMAX IL. To do this pass option ```WITH_OMX=1``` to ```make```. To enable GPIO support install [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about) and pass option ```WITH_GPIO=1```. If the compiler reports about a missing function ```pthread_get_name_np()``` (or similar), add option ```WITH_PTHREAD_NP=0``` (it's enabled by default). For the similar error with ```setproctitle()``` add option ```WITH_SETPROCTITLE=0```.
|
On Raspberry Pi you can build the program with OpenMAX IL. To do this pass option ```WITH_OMX=1``` to ```make```. To enable GPIO support install [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about) and pass option ```WITH_GPIO=1```. If the compiler reports about a missing function ```pthread_get_name_np()``` (or similar), add option ```WITH_PTHREAD_NP=0``` (it's enabled by default). For the similar error with ```setproctitle()``` add option ```WITH_SETPROCTITLE=0```.
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,12 @@
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
# Сборка
|
# Сборка
|
||||||
Для сборки вам понадобятся ```make```, ```gcc```, ```libevent``` с поддержкой ```pthreads```, ```libjpeg8```/```libjpeg-turbo```, ```libuuid``` и ```libbsd``` (только для Linux).
|
Для сборки вам понадобятся ```make```, ```gcc```, ```libevent``` с поддержкой ```pthreads```, ```libjpeg8```/```libjpeg-turbo``` и ```libbsd``` (только для Linux).
|
||||||
|
|
||||||
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
||||||
* Raspbian: `sudo apt install libevent-dev libjpeg8-dev uuid-dev libbsd-dev`. Добавьте `libraspberrypi-dev` для сборки с `WITH_OMX=1` и `libgpiod` для `WITH_GPIO=1`.
|
* Raspbian: `sudo apt install libevent-dev libjpeg8-dev libbsd-dev`. Добавьте `libraspberrypi-dev` для сборки с `WITH_OMX=1` и `libgpiod` для `WITH_GPIO=1`.
|
||||||
* Debian: `sudo apt install build-essential libevent-dev libjpeg62-turbo-dev uuid-dev libbsd-dev`.
|
* Debian: `sudo apt install build-essential libevent-dev libjpeg62-turbo-dev libbsd-dev`.
|
||||||
* Ubuntu 20.04 x86_64: `sudo apt install build-essential libevent-dev libjpeg-dev libjpeg62-dev uuid-dev libbsd-dev make gcc libjpeg8 libjpeg-turbo8 libuuid1 libbsd0`.
|
* Ubuntu 20.04 x86_64: `sudo apt install build-essential libevent-dev libjpeg-dev libjpeg62-dev libbsd-dev make gcc libjpeg8 libjpeg-turbo8 libbsd0`.
|
||||||
|
|
||||||
На Raspberry Pi программу можно собрать с поддержкой OpenMAX IL. Для этого передайте ```make``` параметр ```WITH_OMX=1```. Для включения сборки с поддержкой GPIO установите [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about) и добавьте параметр ```WITH_GPIO=1```. Если при сборке компилятор ругается на отсутствие функции ```pthread_get_name_np()``` или другой подобной, добавьте параметр ```WITH_PTHREAD_NP=0``` (по умолчанию он включен). При аналогичной ошибке с функцией ```setproctitle()``` добавьте параметр ```WITH_SETPROCTITLE=0```.
|
На Raspberry Pi программу можно собрать с поддержкой OpenMAX IL. Для этого передайте ```make``` параметр ```WITH_OMX=1```. Для включения сборки с поддержкой GPIO установите [libgpiod](https://git.kernel.org/pub/scm/libs/libgpiod/libgpiod.git/about) и добавьте параметр ```WITH_GPIO=1```. Если при сборке компилятор ругается на отсутствие функции ```pthread_get_name_np()``` или другой подобной, добавьте параметр ```WITH_PTHREAD_NP=0``` (по умолчанию он включен). При аналогичной ошибке с функцией ```setproctitle()``` добавьте параметр ```WITH_SETPROCTITLE=0```.
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ 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 aarch64)
|
arch=(i686 x86_64 armv6h armv7h aarch64)
|
||||||
depends=(libjpeg libevent libutil-linux libbsd libgpiod)
|
depends=(libjpeg libevent libbsd libgpiod)
|
||||||
makedepends=(gcc make)
|
makedepends=(gcc make)
|
||||||
source=(${pkgname}::"git+https://github.com/pikvm/ustreamer#commit=v${pkgver}")
|
source=(${pkgname}::"git+https://github.com/pikvm/ustreamer#commit=v${pkgver}")
|
||||||
md5sums=(SKIP)
|
md5sums=(SKIP)
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ RUN apt-get update \
|
|||||||
libevent-2.1 \
|
libevent-2.1 \
|
||||||
libevent-pthreads-2.1-6 \
|
libevent-pthreads-2.1-6 \
|
||||||
libjpeg8 \
|
libjpeg8 \
|
||||||
uuid \
|
|
||||||
libbsd0 \
|
libbsd0 \
|
||||||
libgpiod2 \
|
libgpiod2 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ RUN apt-get update \
|
|||||||
libevent-2.1 \
|
libevent-2.1 \
|
||||||
libevent-pthreads-2.1-6 \
|
libevent-pthreads-2.1-6 \
|
||||||
libjpeg8 \
|
libjpeg8 \
|
||||||
uuid \
|
|
||||||
libbsd0 \
|
libbsd0 \
|
||||||
libgpiod2 \
|
libgpiod2 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ RUN apt-get update \
|
|||||||
git \
|
git \
|
||||||
libevent-dev \
|
libevent-dev \
|
||||||
libjpeg62-turbo-dev \
|
libjpeg62-turbo-dev \
|
||||||
uuid-dev \
|
|
||||||
libbsd-dev \
|
libbsd-dev \
|
||||||
libgpiod-dev \
|
libgpiod-dev \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
@@ -25,7 +24,6 @@ RUN apt-get update \
|
|||||||
libevent-2.1 \
|
libevent-2.1 \
|
||||||
libevent-pthreads-2.1-6 \
|
libevent-pthreads-2.1-6 \
|
||||||
libjpeg62-turbo \
|
libjpeg62-turbo \
|
||||||
uuid \
|
|
||||||
libbsd0 \
|
libbsd0 \
|
||||||
libgpiod2 \
|
libgpiod2 \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ IUSE=""
|
|||||||
DEPEND="
|
DEPEND="
|
||||||
>=dev-libs/libevent-2.1.8
|
>=dev-libs/libevent-2.1.8
|
||||||
>=media-libs/libjpeg-turbo-1.5.3
|
>=media-libs/libjpeg-turbo-1.5.3
|
||||||
>=sys-apps/util-linux-2.33
|
|
||||||
>=dev-libs/libbsd-0.9.1
|
>=dev-libs/libbsd-0.9.1
|
||||||
"
|
"
|
||||||
RDEPEND="${DEPEND}"
|
RDEPEND="${DEPEND}"
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ define Package/ustreamer
|
|||||||
SECTION:=multimedia
|
SECTION:=multimedia
|
||||||
CATEGORY:=Multimedia
|
CATEGORY:=Multimedia
|
||||||
TITLE:=uStreamer
|
TITLE:=uStreamer
|
||||||
DEPENDS:=+libpthread +libjpeg +libv4l +libuuid +libbsd +libevent2 +libevent2-core +libevent2-extra +libevent2-pthreads
|
DEPENDS:=+libpthread +libjpeg +libv4l +libbsd +libevent2 +libevent2-core +libevent2-extra +libevent2-pthreads
|
||||||
URL:=https://github.com/pikvm/ustreamer
|
URL:=https://github.com/pikvm/ustreamer
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|||||||
@@ -368,7 +368,7 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
|
|||||||
|
|
||||||
for (stream_client_s * client = RUN(stream_clients); client != NULL; client = client->next) {
|
for (stream_client_s * client = RUN(stream_clients); client != NULL; client = client->next) {
|
||||||
assert(evbuffer_add_printf(buf,
|
assert(evbuffer_add_printf(buf,
|
||||||
"\"%s\": {\"fps\": %u, \"extra_headers\": %s, \"advance_headers\": %s,"
|
"\"%" PRIx64 "\": {\"fps\": %u, \"extra_headers\": %s, \"advance_headers\": %s,"
|
||||||
" \"dual_final_frames\": %s, \"zero_data\": %s}%s",
|
" \"dual_final_frames\": %s, \"zero_data\": %s}%s",
|
||||||
client->id,
|
client->id,
|
||||||
client->fps,
|
client->fps,
|
||||||
@@ -473,9 +473,7 @@ static void _http_callback_stream(struct evhttp_request *request, void *v_server
|
|||||||
# undef PARSE_PARAM
|
# undef PARSE_PARAM
|
||||||
evhttp_clear_headers(¶ms);
|
evhttp_clear_headers(¶ms);
|
||||||
|
|
||||||
uuid_t uuid;
|
client->id = get_now_id();
|
||||||
uuid_generate(uuid);
|
|
||||||
uuid_unparse_lower(uuid, client->id);
|
|
||||||
|
|
||||||
if (RUN(stream_clients) == NULL) {
|
if (RUN(stream_clients) == NULL) {
|
||||||
RUN(stream_clients) = client;
|
RUN(stream_clients) = client;
|
||||||
@@ -499,7 +497,7 @@ static void _http_callback_stream(struct evhttp_request *request, void *v_server
|
|||||||
unsigned short client_port;
|
unsigned short client_port;
|
||||||
evhttp_connection_get_peer(conn, &client_addr, &client_port);
|
evhttp_connection_get_peer(conn, &client_addr, &client_port);
|
||||||
|
|
||||||
LOG_INFO("HTTP: Registered client: [%s]:%u, id=%s; clients now: %u",
|
LOG_INFO("HTTP: Registered client: [%s]:%u, id=%" PRIx64 "; clients now: %u",
|
||||||
client_addr, client_port, client->id, RUN(stream_clients_count));
|
client_addr, client_port, client->id, RUN(stream_clients_count));
|
||||||
|
|
||||||
|
|
||||||
@@ -575,7 +573,7 @@ static void _http_callback_stream_write(struct bufferevent *buf_event, void *v_c
|
|||||||
"Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, pre-check=0, post-check=0, max-age=0" RN
|
"Cache-Control: no-store, no-cache, must-revalidate, proxy-revalidate, pre-check=0, post-check=0, max-age=0" RN
|
||||||
"Pragma: no-cache" RN
|
"Pragma: no-cache" RN
|
||||||
"Expires: Mon, 3 Jan 2000 12:34:56 GMT" RN
|
"Expires: Mon, 3 Jan 2000 12:34:56 GMT" RN
|
||||||
"Set-Cookie: stream_client=%s/%s; path=/; max-age=30" RN
|
"Set-Cookie: stream_client=%s/%" PRIx64 "; path=/; max-age=30" RN
|
||||||
"Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY RN
|
"Content-Type: multipart/x-mixed-replace;boundary=" BOUNDARY RN
|
||||||
RN
|
RN
|
||||||
"--" BOUNDARY RN,
|
"--" BOUNDARY RN,
|
||||||
@@ -678,7 +676,7 @@ static void _http_callback_stream_error(UNUSED struct bufferevent *buf_event, UN
|
|||||||
evhttp_connection_get_peer(conn, &client_addr, &client_port);
|
evhttp_connection_get_peer(conn, &client_addr, &client_port);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("HTTP: Disconnected client: [%s]:%u, id=%s, %s; clients now: %u",
|
LOG_INFO("HTTP: Disconnected client: [%s]:%u, id=%" PRIx64 ", %s; clients now: %u",
|
||||||
client_addr, client_port, client->id, reason, RUN(stream_clients_count));
|
client_addr, client_port, client->id, reason, RUN(stream_clients_count));
|
||||||
|
|
||||||
if (conn) {
|
if (conn) {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -47,8 +48,6 @@
|
|||||||
#include <event2/bufferevent.h>
|
#include <event2/bufferevent.h>
|
||||||
#include <event2/keyvalq_struct.h>
|
#include <event2/keyvalq_struct.h>
|
||||||
|
|
||||||
#include <uuid/uuid.h>
|
|
||||||
|
|
||||||
#ifndef EVTHREAD_USE_PTHREADS_IMPLEMENTED
|
#ifndef EVTHREAD_USE_PTHREADS_IMPLEMENTED
|
||||||
# error Required libevent-pthreads support
|
# error Required libevent-pthreads support
|
||||||
#endif
|
#endif
|
||||||
@@ -83,7 +82,7 @@ typedef struct stream_client_sx {
|
|||||||
bool dual_final_frames;
|
bool dual_final_frames;
|
||||||
bool zero_data;
|
bool zero_data;
|
||||||
|
|
||||||
char id[37]; // ex. "1b4e28ba-2fa1-11d2-883f-0016d3cca427" + "\0"
|
uint64_t id;
|
||||||
bool need_initial;
|
bool need_initial;
|
||||||
bool need_first_frame;
|
bool need_first_frame;
|
||||||
bool updated_prev;
|
bool updated_prev;
|
||||||
|
|||||||
Reference in New Issue
Block a user