mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-02-28 12:46:32 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a06a484ce | ||
|
|
0307d3bdb6 | ||
|
|
f2dd9c3c5a | ||
|
|
4e3f873f0d | ||
|
|
029440cf82 | ||
|
|
df74f5cf18 | ||
|
|
97494c3531 | ||
|
|
71544880d1 | ||
|
|
83127e58ff | ||
|
|
604a8f7cb4 | ||
|
|
602c1747d5 | ||
|
|
a2b8b35070 | ||
|
|
dd7701be38 | ||
|
|
1c9bd91b31 | ||
|
|
e19a3ca7ff | ||
|
|
b2d1a5612d | ||
|
|
f3e0613de3 | ||
|
|
5baf921660 | ||
|
|
6cabcd39f1 | ||
|
|
3df3658e4f | ||
|
|
f21fc5f6d3 |
@@ -1,7 +1,7 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
current_version = 6.29
|
current_version = 6.34
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)
|
parse = (?P<major>\d+)\.(?P<minor>\d+)
|
||||||
serialize =
|
serialize =
|
||||||
{major}.{minor}
|
{major}.{minor}
|
||||||
|
|||||||
36
Makefile
36
Makefile
@@ -1,5 +1,7 @@
|
|||||||
-include config.mk
|
-include config.mk
|
||||||
|
|
||||||
|
|
||||||
|
# =====
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
MANPREFIX ?= $(PREFIX)/share/man
|
MANPREFIX ?= $(PREFIX)/share/man
|
||||||
@@ -12,6 +14,27 @@ LDFLAGS ?=
|
|||||||
|
|
||||||
R_DESTDIR = $(if $(DESTDIR),$(shell realpath "$(DESTDIR)"),)
|
R_DESTDIR = $(if $(DESTDIR),$(shell realpath "$(DESTDIR)"),)
|
||||||
|
|
||||||
|
WITH_PYTHON ?= 0
|
||||||
|
WITH_JANUS ?= 0
|
||||||
|
WITH_V4P ?= 0
|
||||||
|
WITH_GPIO ?= 0
|
||||||
|
WITH_SYSTEMD ?= 0
|
||||||
|
WITH_PTHREAD_NP ?= 1
|
||||||
|
WITH_SETPROCTITLE ?= 1
|
||||||
|
WITH_PDEATHSIG ?= 1
|
||||||
|
|
||||||
|
define optbool
|
||||||
|
$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
|
||||||
|
endef
|
||||||
|
MK_WITH_PYTHON = $(call optbool,$(WITH_PYTHON))
|
||||||
|
MK_WITH_JANUS = $(call optbool,$(WITH_JANUS))
|
||||||
|
MK_WITH_V4P = $(call optbool,$(WITH_V4P))
|
||||||
|
MK_WITH_GPIO = $(call optbool,$(WITH_GPIO))
|
||||||
|
MK_WITH_SYSTEMD = $(call optbool,$(WITH_SYSTEMD))
|
||||||
|
MK_WITH_PTHREAD_NP = $(call optbool,$(WITH_PTHREAD_NP))
|
||||||
|
MK_WITH_SETPROCTITLE = $(call optbool,$(WITH_SETPROCTITLE))
|
||||||
|
MK_WITH_PDEATHSIG = $(call optbool,$(WITH_PDEATHSIG))
|
||||||
|
|
||||||
export
|
export
|
||||||
|
|
||||||
_LINTERS_IMAGE ?= ustreamer-linters
|
_LINTERS_IMAGE ?= ustreamer-linters
|
||||||
@@ -24,21 +47,18 @@ endif
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
define optbool
|
|
||||||
$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
|
|
||||||
endef
|
|
||||||
|
|
||||||
ifeq ($(V),)
|
ifeq ($(V),)
|
||||||
ECHO = @
|
ECHO = @
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
all:
|
all:
|
||||||
+ $(MAKE) apps
|
+ $(MAKE) apps
|
||||||
ifneq ($(call optbool,$(WITH_PYTHON)),)
|
ifneq ($(MK_WITH_PYTHON),)
|
||||||
+ $(MAKE) python
|
+ $(MAKE) python
|
||||||
endif
|
endif
|
||||||
ifneq ($(call optbool,$(WITH_JANUS)),)
|
ifneq ($(MK_WITH_JANUS),)
|
||||||
+ $(MAKE) janus
|
+ $(MAKE) janus
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -62,10 +82,10 @@ janus:
|
|||||||
|
|
||||||
install: all
|
install: all
|
||||||
$(MAKE) -C src install
|
$(MAKE) -C src install
|
||||||
ifneq ($(call optbool,$(WITH_PYTHON)),)
|
ifneq ($(MK_WITH_PYTHON),)
|
||||||
$(MAKE) -C python install
|
$(MAKE) -C python install
|
||||||
endif
|
endif
|
||||||
ifneq ($(call optbool,$(WITH_JANUS)),)
|
ifneq ($(MK_WITH_JANUS),)
|
||||||
$(MAKE) -C janus install
|
$(MAKE) -C janus install
|
||||||
endif
|
endif
|
||||||
mkdir -p $(R_DESTDIR)$(MANPREFIX)/man1
|
mkdir -p $(R_DESTDIR)$(MANPREFIX)/man1
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ You need to download the µStreamer onto your system and build it from the sourc
|
|||||||
* FreeBSD port: https://www.freshports.org/multimedia/ustreamer.
|
* FreeBSD port: https://www.freshports.org/multimedia/ustreamer.
|
||||||
|
|
||||||
### Preconditions
|
### Preconditions
|
||||||
You'll need ```make```, ```gcc```, ```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).
|
||||||
|
|
||||||
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
* Arch: `sudo pacman -S libevent libjpeg-turbo libutil-linux libbsd`.
|
||||||
* Raspberry OS Bullseye: `sudo apt install libevent-dev libjpeg62-turbo libbsd-dev`. Add `libgpiod-dev` for `WITH_GPIO=1` and `libsystemd-dev` for `WITH_SYSTEMD=1` and `libasound2-dev libspeex-dev libspeexdsp-dev libopus-dev` for `WITH_JANUS=1`.
|
* Raspberry OS Bullseye: `sudo apt install libevent-dev libjpeg62-turbo libbsd-dev`. Add `libgpiod-dev` for `WITH_GPIO=1` and `libsystemd-dev` for `WITH_SYSTEMD=1` and `libasound2-dev libspeex-dev libspeexdsp-dev libopus-dev` for `WITH_JANUS=1`.
|
||||||
|
|||||||
@@ -18,13 +18,12 @@ _SRCS = $(shell ls src/uslibs/*.c src/*.c)
|
|||||||
_BUILD = build
|
_BUILD = build
|
||||||
|
|
||||||
|
|
||||||
define optbool
|
# =====
|
||||||
$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
|
ifneq ($(shell sh -c 'uname 2>/dev/null || echo Unknown'),FreeBSD)
|
||||||
endef
|
override _LDFLAGS += -latomic
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_PTHREAD_NP),)
|
||||||
WITH_PTHREAD_NP ?= 1
|
|
||||||
ifneq ($(call optbool,$(WITH_PTHREAD_NP)),)
|
|
||||||
override _CFLAGS += -DWITH_PTHREAD_NP
|
override _CFLAGS += -DWITH_PTHREAD_NP
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,9 @@
|
|||||||
#include "memsinkfd.h"
|
#include "memsinkfd.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
|
static const char *const default_ice_url = "stun:stun.l.google.com:19302";
|
||||||
|
|
||||||
static us_config_s *_g_config = NULL;
|
static us_config_s *_g_config = NULL;
|
||||||
static const useconds_t _g_watchers_polling = 100000;
|
static const useconds_t _g_watchers_polling = 100000;
|
||||||
|
|
||||||
@@ -669,10 +672,12 @@ static struct janus_plugin_result *_plugin_handle_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else if (!strcmp(request_str, "features")) {
|
} else if (!strcmp(request_str, "features")) {
|
||||||
|
const char *const ice_url = getenv("JANUS_USTREAMER_WEB_ICE_URL");
|
||||||
json_t *const features = json_pack(
|
json_t *const features = json_pack(
|
||||||
"{sbsb}",
|
"{s:b, s:b, s:{s:s?}}",
|
||||||
"audio", (_g_rtpa != NULL),
|
"audio", (_g_rtpa != NULL),
|
||||||
"mic", (_g_rtpa != NULL && _g_config->aplay_dev_name != NULL)
|
"mic", (_g_rtpa != NULL && _g_config->aplay_dev_name != NULL),
|
||||||
|
"ice", "url", (ice_url != NULL ? ice_url : default_ice_url)
|
||||||
);
|
);
|
||||||
PUSH_STATUS("features", features, NULL);
|
PUSH_STATUS("features", features, NULL);
|
||||||
json_decref(features);
|
json_decref(features);
|
||||||
|
|||||||
@@ -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.29" "January 2021"
|
.TH USTREAMER-DUMP 1 "version 6.34" "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.29" "November 2020"
|
.TH USTREAMER 1 "version 6.34" "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
|
||||||
@@ -274,7 +274,7 @@ Timeout for lock. Default: 1.
|
|||||||
.SS "Process options"
|
.SS "Process options"
|
||||||
.TP
|
.TP
|
||||||
.BR \-\-exit\-on\-parent\-death
|
.BR \-\-exit\-on\-parent\-death
|
||||||
Exit the program if the parent process is dead. Required \fBHAS_PDEATHSIG\fR feature. Default: disabled.
|
Exit the program if the parent process is dead. Required \fBWITH_PDEATHSIG\fR feature. Default: disabled.
|
||||||
.TP
|
.TP
|
||||||
.BR \-\-exit\-on\-no\-clients \fIsec
|
.BR \-\-exit\-on\-no\-clients \fIsec
|
||||||
Exit the program if there have been no stream or sink clients or any HTTP requests in the last N seconds. Default: 0 (disabled).
|
Exit the program if there have been no stream or sink clients or any HTTP requests in the last N seconds. Default: 0 (disabled).
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
pkgname=ustreamer
|
pkgname=ustreamer
|
||||||
pkgver=6.29
|
pkgver=6.34
|
||||||
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"
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=ustreamer
|
PKG_NAME:=ustreamer
|
||||||
PKG_VERSION:=6.29
|
PKG_VERSION:=6.34
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
-include ../config.mk
|
|
||||||
|
|
||||||
R_DESTDIR ?=
|
R_DESTDIR ?=
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
@@ -8,7 +6,7 @@ PY ?= python3
|
|||||||
|
|
||||||
# =====
|
# =====
|
||||||
all: root
|
all: root
|
||||||
root: $(shell find src -type f,l)
|
root: $(shell find src -type f,l) setup.py
|
||||||
$(info == PY_BUILD ustreamer-*.so)
|
$(info == PY_BUILD ustreamer-*.so)
|
||||||
rm -rf root
|
rm -rf root
|
||||||
$(ECHO) $(PY) -m build --skip-dependency-check --no-isolation
|
$(ECHO) $(PY) -m build --skip-dependency-check --no-isolation
|
||||||
|
|||||||
@@ -5,19 +5,36 @@ from setuptools import setup
|
|||||||
|
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
def _find_sources(suffix: str) -> list[str]:
|
def _find_sources() -> list[str]:
|
||||||
sources: list[str] = []
|
sources: list[str] = []
|
||||||
for (root_path, _, names) in os.walk("src"):
|
for (root_path, _, names) in os.walk("src"):
|
||||||
for name in names:
|
for name in names:
|
||||||
if name.endswith(suffix):
|
if name.endswith(".c"):
|
||||||
sources.append(os.path.join(root_path, name))
|
sources.append(os.path.join(root_path, name))
|
||||||
return sources
|
return sources
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def _find_flags() -> dict[str, bool]:
|
||||||
|
return {
|
||||||
|
key[3:]: (value.strip().lower() in ["true", "on", "1"])
|
||||||
|
for (key, value) in sorted(os.environ.items())
|
||||||
|
if key.startswith("MK_WITH_")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _make_d_features(flags: dict[str, bool]) -> str:
|
||||||
|
features = " ".join([
|
||||||
|
f"{key}={int(value)}"
|
||||||
|
for (key, value) in flags.items()
|
||||||
|
])
|
||||||
|
return f"-DUS_FEATURES=\"{features}\""
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
flags = _find_flags()
|
||||||
setup(
|
setup(
|
||||||
name="ustreamer",
|
name="ustreamer",
|
||||||
version="6.29",
|
version="6.34",
|
||||||
description="uStreamer tools",
|
description="uStreamer tools",
|
||||||
author="Maxim Devaev",
|
author="Maxim Devaev",
|
||||||
author_email="mdevaev@gmail.com",
|
author_email="mdevaev@gmail.com",
|
||||||
@@ -26,9 +43,16 @@ if __name__ == "__main__":
|
|||||||
Extension(
|
Extension(
|
||||||
"ustreamer",
|
"ustreamer",
|
||||||
libraries=["rt", "m", "pthread"],
|
libraries=["rt", "m", "pthread"],
|
||||||
extra_compile_args=["-std=c17", "-D_GNU_SOURCE"],
|
extra_compile_args=[
|
||||||
|
"-std=c17", "-D_GNU_SOURCE",
|
||||||
|
_make_d_features(flags),
|
||||||
|
],
|
||||||
undef_macros=["NDEBUG"],
|
undef_macros=["NDEBUG"],
|
||||||
sources=_find_sources(".c"),
|
sources=_find_sources(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|||||||
1
python/src/uslibs/const.h
Symbolic link
1
python/src/uslibs/const.h
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../../../src/libs/const.h
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
|
#include "uslibs/const.h"
|
||||||
#include "uslibs/types.h"
|
#include "uslibs/types.h"
|
||||||
#include "uslibs/errors.h"
|
#include "uslibs/errors.h"
|
||||||
#include "uslibs/tools.h"
|
#include "uslibs/tools.h"
|
||||||
@@ -48,6 +49,8 @@ static void _MemsinkObject_destroy_internals(_MemsinkObject *self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int _MemsinkObject_init(_MemsinkObject *self, PyObject *args, PyObject *kwargs) {
|
static int _MemsinkObject_init(_MemsinkObject *self, PyObject *args, PyObject *kwargs) {
|
||||||
|
self->fd = -1;
|
||||||
|
|
||||||
self->lock_timeout = 1;
|
self->lock_timeout = 1;
|
||||||
self->wait_timeout = 1;
|
self->wait_timeout = 1;
|
||||||
|
|
||||||
@@ -228,7 +231,8 @@ static PyObject *_MemsinkObject_wait_frame(_MemsinkObject *self, PyObject *args,
|
|||||||
} \
|
} \
|
||||||
Py_DECREF(m_tmp); \
|
Py_DECREF(m_tmp); \
|
||||||
}
|
}
|
||||||
# define SET_NUMBER(x_key, x_from, x_to) SET_VALUE(#x_key, Py##x_to##_From##x_from(self->frame->x_key))
|
# define SET_NUMBER(x_key, x_from, x_to) \
|
||||||
|
SET_VALUE(#x_key, Py##x_to##_From##x_from(self->frame->x_key))
|
||||||
|
|
||||||
SET_NUMBER(width, Long, Long);
|
SET_NUMBER(width, Long, Long);
|
||||||
SET_NUMBER(height, Long, Long);
|
SET_NUMBER(height, Long, Long);
|
||||||
@@ -275,7 +279,8 @@ static PyMethodDef _MemsinkObject_methods[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyGetSetDef _MemsinkObject_getsets[] = {
|
static PyGetSetDef _MemsinkObject_getsets[] = {
|
||||||
# define ADD_GETTER(x_field) {.name = #x_field, .get = (getter)_MemsinkObject_getter_##x_field}
|
# define ADD_GETTER(x_field) \
|
||||||
|
{.name = #x_field, .get = (getter)_MemsinkObject_getter_##x_field}
|
||||||
ADD_GETTER(obj),
|
ADD_GETTER(obj),
|
||||||
ADD_GETTER(lock_timeout),
|
ADD_GETTER(lock_timeout),
|
||||||
ADD_GETTER(wait_timeout),
|
ADD_GETTER(wait_timeout),
|
||||||
@@ -304,20 +309,30 @@ static PyModuleDef _Module = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
PyMODINIT_FUNC PyInit_ustreamer(void) {
|
PyMODINIT_FUNC PyInit_ustreamer(void) {
|
||||||
PyObject *module = PyModule_Create(&_Module);
|
PyObject *module = NULL;
|
||||||
if (module == NULL) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PyType_Ready(&_MemsinkType) < 0) {
|
if (PyType_Ready(&_MemsinkType) < 0) {
|
||||||
return NULL;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(&_MemsinkType);
|
if ((module = PyModule_Create(&_Module)) == NULL) {
|
||||||
|
goto error;
|
||||||
if (PyModule_AddObject(module, "Memsink", (PyObject*)&_MemsinkType) < 0) {
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# define ADD(x_what, x_key, x_value) \
|
||||||
|
{ if (PyModule_Add##x_what(module, x_key, x_value) < 0) { goto error; } }
|
||||||
|
ADD(StringConstant, "__version__", US_VERSION);
|
||||||
|
ADD(StringConstant, "VERSION", US_VERSION);
|
||||||
|
ADD(IntConstant, "VERSION_MAJOR", US_VERSION_MAJOR);
|
||||||
|
ADD(IntConstant, "VERSION_MINOR", US_VERSION_MINOR);
|
||||||
|
ADD(StringConstant, "FEATURES", US_FEATURES); // Defined in setup.py
|
||||||
|
ADD(ObjectRef, "Memsink", (PyObject*)&_MemsinkType);
|
||||||
|
# undef ADD
|
||||||
return module;
|
return module;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (module != NULL) {
|
||||||
|
Py_DECREF(module);
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
52
src/Makefile
52
src/Makefile
@@ -14,9 +14,9 @@ _V4P = ustreamer-v4p.bin
|
|||||||
|
|
||||||
_CFLAGS = -MD -c -std=c17 -Wall -Wextra -D_GNU_SOURCE $(CFLAGS)
|
_CFLAGS = -MD -c -std=c17 -Wall -Wextra -D_GNU_SOURCE $(CFLAGS)
|
||||||
|
|
||||||
_USTR_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt -latomic -levent -levent_pthreads
|
_USTR_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt -levent -levent_pthreads
|
||||||
_DUMP_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt -latomic
|
_DUMP_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt
|
||||||
_V4P_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt -latomic
|
_V4P_LDFLAGS = $(LDFLAGS) -lm -ljpeg -pthread -lrt
|
||||||
|
|
||||||
_USTR_SRCS = $(shell ls \
|
_USTR_SRCS = $(shell ls \
|
||||||
libs/*.c \
|
libs/*.c \
|
||||||
@@ -41,50 +41,56 @@ _V4P_SRCS = $(shell ls \
|
|||||||
|
|
||||||
_BUILD = build
|
_BUILD = build
|
||||||
|
|
||||||
|
|
||||||
_TARGETS = $(_USTR) $(_DUMP)
|
_TARGETS = $(_USTR) $(_DUMP)
|
||||||
_OBJS = $(_USTR_SRCS:%.c=$(_BUILD)/%.o) $(_DUMP_SRCS:%.c=$(_BUILD)/%.o)
|
_OBJS = $(_USTR_SRCS:%.c=$(_BUILD)/%.o) $(_DUMP_SRCS:%.c=$(_BUILD)/%.o)
|
||||||
|
|
||||||
|
|
||||||
define optbool
|
# =====
|
||||||
$(filter $(shell echo $(1) | tr A-Z a-z), yes on 1)
|
ifneq ($(shell sh -c 'uname 2>/dev/null || echo Unknown'),FreeBSD)
|
||||||
endef
|
override _USTR_LDFLAGS += -latomic
|
||||||
|
override _DUMP_LDFLAGS += -latomic
|
||||||
|
override _V4P_LDFLAGS += -latomic
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_PYTHON),)
|
||||||
|
override _CFLAGS += -DMK_WITH_PYTHON
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ($(call optbool,$(WITH_GPIO)),)
|
ifneq ($(MK_WITH_JANUS),)
|
||||||
override _CFLAGS += -DWITH_GPIO $(shell $(PKG_CONFIG) --atleast-version=2 libgpiod 2> /dev/null && echo -DHAVE_GPIOD2)
|
override _CFLAGS += -DMK_WITH_JANUS
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_GPIO),)
|
||||||
|
override _CFLAGS += -DMK_WITH_GPIO -DWITH_GPIO $(shell $(PKG_CONFIG) --atleast-version=2 libgpiod 2> /dev/null && echo -DHAVE_GPIOD2)
|
||||||
override _USTR_LDFLAGS += -lgpiod
|
override _USTR_LDFLAGS += -lgpiod
|
||||||
override _USTR_SRCS += $(shell ls ustreamer/gpio/*.c)
|
override _USTR_SRCS += $(shell ls ustreamer/gpio/*.c)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_SYSTEMD),)
|
||||||
ifneq ($(call optbool,$(WITH_SYSTEMD)),)
|
override _CFLAGS += -DMK_WITH_SYSTEMD -DWITH_SYSTEMD
|
||||||
override _CFLAGS += -DWITH_SYSTEMD
|
|
||||||
override _USTR_LDFLAGS += -lsystemd
|
override _USTR_LDFLAGS += -lsystemd
|
||||||
override _USTR_SRCS += $(shell ls ustreamer/http/systemd/*.c)
|
override _USTR_SRCS += $(shell ls ustreamer/http/systemd/*.c)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_PTHREAD_NP),)
|
||||||
WITH_PTHREAD_NP ?= 1
|
override _CFLAGS += -DMK_WITH_PTHREAD_NP -DWITH_PTHREAD_NP
|
||||||
ifneq ($(call optbool,$(WITH_PTHREAD_NP)),)
|
|
||||||
override _CFLAGS += -DWITH_PTHREAD_NP
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_SETPROCTITLE),)
|
||||||
WITH_SETPROCTITLE ?= 1
|
override _CFLAGS += -DMK_WITH_SETPROCTITLE -DWITH_SETPROCTITLE
|
||||||
ifneq ($(call optbool,$(WITH_SETPROCTITLE)),)
|
|
||||||
override _CFLAGS += -DWITH_SETPROCTITLE
|
|
||||||
ifeq ($(shell uname -s | tr A-Z a-z),linux)
|
ifeq ($(shell uname -s | tr A-Z a-z),linux)
|
||||||
override _USTR_LDFLAGS += -lbsd
|
override _USTR_LDFLAGS += -lbsd
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq ($(MK_WITH_PDEATHSIG),)
|
||||||
|
override _CFLAGS += -DMK_WITH_PDEATHSIG -DWITH_PDEATHSIG
|
||||||
|
endif
|
||||||
|
|
||||||
WITH_V4P ?= 0
|
ifneq ($(MK_WITH_V4P),)
|
||||||
ifneq ($(call optbool,$(WITH_V4P)),)
|
|
||||||
override _TARGETS += $(_V4P)
|
override _TARGETS += $(_V4P)
|
||||||
override _OBJS += $(_V4P_SRCS:%.c=$(_BUILD)/%.o)
|
override _OBJS += $(_V4P_SRCS:%.c=$(_BUILD)/%.o)
|
||||||
override _CFLAGS += -DWITH_V4P $(shell $(PKG_CONFIG) --cflags libdrm)
|
override _CFLAGS += -DMK_WITH_V4P -DWITH_V4P $(shell $(PKG_CONFIG) --cflags libdrm)
|
||||||
override _V4P_LDFLAGS += $(shell $(PKG_CONFIG) --libs libdrm)
|
override _V4P_LDFLAGS += $(shell $(PKG_CONFIG) --libs libdrm)
|
||||||
override _USTR_SRCS += $(shell ls libs/drm/*.c)
|
override _USTR_SRCS += $(shell ls libs/drm/*.c)
|
||||||
override _USTR_LDFLAGS += $(shell $(PKG_CONFIG) --libs libdrm)
|
override _USTR_LDFLAGS += $(shell $(PKG_CONFIG) --libs libdrm)
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define US_VERSION_MAJOR 6
|
#define US_VERSION_MAJOR 6
|
||||||
#define US_VERSION_MINOR 29
|
#define US_VERSION_MINOR 34
|
||||||
|
|
||||||
#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)
|
||||||
|
|||||||
@@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/sysmacros.h>
|
#ifdef __linux__
|
||||||
|
# include <sys/sysmacros.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
|
|
||||||
|
|||||||
@@ -25,14 +25,8 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if defined(__FreeBSD__)
|
||||||
#if defined(__linux__)
|
|
||||||
# define HAS_PDEATHSIG
|
|
||||||
#elif defined(__FreeBSD__)
|
|
||||||
# include <sys/param.h>
|
# include <sys/param.h>
|
||||||
# if __FreeBSD_version >= 1102000
|
|
||||||
# define HAS_PDEATHSIG
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -49,20 +43,22 @@
|
|||||||
# error setproctitle() not implemented, you can disable it using WITH_SETPROCTITLE=0
|
# error setproctitle() not implemented, you can disable it using WITH_SETPROCTITLE=0
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_PDEATHSIG
|
|
||||||
|
#ifdef WITH_PDEATHSIG
|
||||||
# if defined(__linux__)
|
# if defined(__linux__)
|
||||||
# include <sys/prctl.h>
|
# include <sys/prctl.h>
|
||||||
# elif defined(__FreeBSD__)
|
# elif defined(__FreeBSD__) && (__FreeBSD_version >= 1102000)
|
||||||
# include <sys/procctl.h>
|
# include <sys/procctl.h>
|
||||||
|
# else
|
||||||
|
# error WITH_PDEATHSIG is not supported on your system
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#ifdef WITH_SETPROCTITLE
|
#ifdef WITH_SETPROCTITLE
|
||||||
# include "tools.h"
|
# include "tools.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAS_PDEATHSIG
|
#include "logging.h"
|
||||||
# include "logging.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef WITH_SETPROCTITLE
|
#ifdef WITH_SETPROCTITLE
|
||||||
@@ -70,7 +66,7 @@ extern char **environ;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_PDEATHSIG
|
#ifdef WITH_PDEATHSIG
|
||||||
INLINE int us_process_track_parent_death(void) {
|
INLINE int us_process_track_parent_death(void) {
|
||||||
const pid_t parent = getppid();
|
const pid_t parent = getppid();
|
||||||
int signum = SIGTERM;
|
int signum = SIGTERM;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ enum _US_OPT_VALUES {
|
|||||||
_O_GPIO_HAS_HTTP_CLIENTS,
|
_O_GPIO_HAS_HTTP_CLIENTS,
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef HAS_PDEATHSIG
|
# ifdef WITH_PDEATHSIG
|
||||||
_O_EXIT_ON_PARENT_DEATH,
|
_O_EXIT_ON_PARENT_DEATH,
|
||||||
# endif
|
# endif
|
||||||
_O_EXIT_ON_NO_CLIENTS,
|
_O_EXIT_ON_NO_CLIENTS,
|
||||||
@@ -224,7 +224,7 @@ static const struct option _LONG_OPTS[] = {
|
|||||||
{"gpio-has-http-clients", required_argument, NULL, _O_GPIO_HAS_HTTP_CLIENTS},
|
{"gpio-has-http-clients", required_argument, NULL, _O_GPIO_HAS_HTTP_CLIENTS},
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef HAS_PDEATHSIG
|
# ifdef WITH_PDEATHSIG
|
||||||
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
|
{"exit-on-parent-death", no_argument, NULL, _O_EXIT_ON_PARENT_DEATH},
|
||||||
# endif
|
# endif
|
||||||
{"exit-on-no-clients", required_argument, NULL, _O_EXIT_ON_NO_CLIENTS},
|
{"exit-on-no-clients", required_argument, NULL, _O_EXIT_ON_NO_CLIENTS},
|
||||||
@@ -483,7 +483,7 @@ int options_parse(us_options_s *options, us_capture_s *cap, us_encoder_s *enc, u
|
|||||||
case _O_GPIO_HAS_HTTP_CLIENTS: OPT_NUMBER("--gpio-has-http-clients", us_g_gpio.has_http_clients.pin, 0, 256, 0);
|
case _O_GPIO_HAS_HTTP_CLIENTS: OPT_NUMBER("--gpio-has-http-clients", us_g_gpio.has_http_clients.pin, 0, 256, 0);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef HAS_PDEATHSIG
|
# ifdef WITH_PDEATHSIG
|
||||||
case _O_EXIT_ON_PARENT_DEATH:
|
case _O_EXIT_ON_PARENT_DEATH:
|
||||||
if (us_process_track_parent_death() < 0) {
|
if (us_process_track_parent_death() < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -581,34 +581,52 @@ static int _check_instance_id(const char *str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _features(void) {
|
static void _features(void) {
|
||||||
# ifdef WITH_GPIO
|
# ifdef MK_WITH_PYTHON
|
||||||
|
puts("+ WITH_PYTHON");
|
||||||
|
# else
|
||||||
|
puts("- WITH_PYTHON");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef MK_WITH_JANUS
|
||||||
|
puts("+ WITH_JANUS");
|
||||||
|
# else
|
||||||
|
puts("- WITH_JANUS");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef MK_WITH_V4P
|
||||||
|
puts("+ WITH_V4P");
|
||||||
|
# else
|
||||||
|
puts("- WITH_V4P");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef MK_WITH_GPIO
|
||||||
puts("+ WITH_GPIO");
|
puts("+ WITH_GPIO");
|
||||||
# else
|
# else
|
||||||
puts("- WITH_GPIO");
|
puts("- WITH_GPIO");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef WITH_SYSTEMD
|
# ifdef MK_WITH_SYSTEMD
|
||||||
puts("+ WITH_SYSTEMD");
|
puts("+ WITH_SYSTEMD");
|
||||||
# else
|
# else
|
||||||
puts("- WITH_SYSTEMD");
|
puts("- WITH_SYSTEMD");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef WITH_PTHREAD_NP
|
# ifdef MK_WITH_PTHREAD_NP
|
||||||
puts("+ WITH_PTHREAD_NP");
|
puts("+ WITH_PTHREAD_NP");
|
||||||
# else
|
# else
|
||||||
puts("- WITH_PTHREAD_NP");
|
puts("- WITH_PTHREAD_NP");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef WITH_SETPROCTITLE
|
# ifdef MK_WITH_SETPROCTITLE
|
||||||
puts("+ WITH_SETPROCTITLE");
|
puts("+ WITH_SETPROCTITLE");
|
||||||
# else
|
# else
|
||||||
puts("- WITH_SETPROCTITLE");
|
puts("- WITH_SETPROCTITLE");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef HAS_PDEATHSIG
|
# ifdef MK_WITH_PDEATHSIG
|
||||||
puts("+ HAS_PDEATHSIG");
|
puts("+ WITH_PDEATHSIG");
|
||||||
# else
|
# else
|
||||||
puts("- HAS_PDEATHSIG");
|
puts("- WITH_PDEATHSIG");
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,11 +758,11 @@ static void _help(FILE *fp, const us_capture_s *cap, const us_encoder_s *enc, co
|
|||||||
SAY(" --gpio-stream-online <pin> ──── Set 1 while streaming. Default: disabled.\n");
|
SAY(" --gpio-stream-online <pin> ──── Set 1 while streaming. Default: disabled.\n");
|
||||||
SAY(" --gpio-has-http-clients <pin> ─ Set 1 while stream has at least one client. Default: disabled.\n");
|
SAY(" --gpio-has-http-clients <pin> ─ Set 1 while stream has at least one client. Default: disabled.\n");
|
||||||
# endif
|
# endif
|
||||||
# if (defined(HAS_PDEATHSIG) || defined(WITH_SETPROCTITLE))
|
# if (defined(WITH_PDEATHSIG) || defined(WITH_SETPROCTITLE))
|
||||||
SAY("Process options:");
|
SAY("Process options:");
|
||||||
SAY("════════════════");
|
SAY("════════════════");
|
||||||
# endif
|
# endif
|
||||||
# ifdef HAS_PDEATHSIG
|
# ifdef WITH_PDEATHSIG
|
||||||
SAY(" --exit-on-parent-death ─────── Exit the program if the parent process is dead. Default: disabled.\n");
|
SAY(" --exit-on-parent-death ─────── Exit the program if the parent process is dead. Default: disabled.\n");
|
||||||
# endif
|
# endif
|
||||||
SAY(" --exit-on-no-clients <sec> ──── Exit the program if there have been no stream or sink clients");
|
SAY(" --exit-on-no-clients <sec> ──── Exit the program if there have been no stream or sink clients");
|
||||||
|
|||||||
Reference in New Issue
Block a user