Compare commits

...

3 Commits
v3.25 ... v3.26

Author SHA1 Message Date
Devaev Maxim
a97f08eac8 Bump version: 3.25 → 3.26 2021-04-20 19:35:49 +03:00
Devaev Maxim
92ff097d7e show memsink has_client in the /state 2021-04-08 08:42:53 +03:00
Devaev Maxim
0eb0370bd3 moved python sources 2021-04-08 05:19:19 +03:00
20 changed files with 49 additions and 20 deletions

View File

@@ -1,7 +1,7 @@
[bumpversion]
commit = True
tag = True
current_version = 3.25
current_version = 3.26
parse = (?P<major>\d+)\.(?P<minor>\d+)
serialize =
{major}.{minor}

View File

@@ -1,6 +1,6 @@
.\" Manpage for ustreamer-dump.
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
.TH USTREAMER-DUMP 1 "version 3.25" "January 2021"
.TH USTREAMER-DUMP 1 "version 3.26" "January 2021"
.SH NAME
ustreamer-dump \- Dump uStreamer's memory sink to file

View File

@@ -1,6 +1,6 @@
.\" Manpage for ustreamer.
.\" Open an issue or pull request to https://github.com/pikvm/ustreamer to correct errors or typos
.TH USTREAMER 1 "version 3.25" "November 2020"
.TH USTREAMER 1 "version 3.26" "November 2020"
.SH NAME
ustreamer \- stream MJPG video from any V4L2 device to the network

View File

@@ -3,7 +3,7 @@
pkgname=ustreamer
pkgver=3.25
pkgver=3.26
pkgrel=1
pkgdesc="Lightweight and fast MJPG-HTTP streamer"
url="https://github.com/pikvm/ustreamer"

View File

@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ustreamer
PKG_VERSION:=3.25
PKG_VERSION:=3.26
PKG_RELEASE:=1
PKG_MAINTAINER:=Maxim Devaev <mdevaev@gmail.com>

View File

@@ -1 +0,0 @@
../src/libs/frame.c

View File

@@ -1 +0,0 @@
../src/libs/frame.h

View File

@@ -1 +0,0 @@
../src/libs/memsinksh.h

View File

@@ -8,7 +8,7 @@ from distutils.core import setup
if __name__ == "__main__":
setup(
name="ustreamer",
version="3.25",
version="3.26",
description="uStreamer tools",
author="Maxim Devaev",
author_email="mdevaev@gmail.com",
@@ -18,8 +18,8 @@ if __name__ == "__main__":
"ustreamer",
libraries=["rt", "m", "pthread"],
undef_macros=["NDEBUG"],
sources=[name for name in os.listdir(".") if name.endswith(".c")],
depends=[name for name in os.listdir(".") if name.endswith(".h")],
sources=["src/" + name for name in os.listdir("src") if name.endswith(".c")],
depends=["src/" + name for name in os.listdir("src") if name.endswith(".h")],
),
],
)

1
python/src/frame.c Symbolic link
View File

@@ -0,0 +1 @@
../../src/libs/frame.c

1
python/src/frame.h Symbolic link
View File

@@ -0,0 +1 @@
../../src/libs/frame.h

1
python/src/memsinksh.h Symbolic link
View File

@@ -0,0 +1 @@
../../src/libs/memsinksh.h

1
python/src/tools.h Symbolic link
View File

@@ -0,0 +1 @@
../../src/libs/tools.h

View File

@@ -1 +0,0 @@
../src/libs/tools.h

View File

@@ -23,7 +23,7 @@
#pragma once
#define VERSION_MAJOR 3
#define VERSION_MINOR 25
#define VERSION_MINOR 26
#define MAKE_VERSION2(_major, _minor) #_major "." #_minor
#define MAKE_VERSION1(_major, _minor) MAKE_VERSION2(_major, _minor)

View File

@@ -37,6 +37,7 @@ memsink_s *memsink_init(
sink->timeout = timeout;
sink->fd = -1;
sink->mem = MAP_FAILED;
atomic_init(&sink->has_clients, false);
LOG_INFO("Using %s-sink: %s", name, obj);
@@ -92,16 +93,16 @@ bool memsink_server_check(memsink_s *sink, const frame_s *frame) {
if (flock(sink->fd, LOCK_EX | LOCK_NB) < 0) {
if (errno == EWOULDBLOCK) {
sink->has_clients = true;
atomic_store(&sink->has_clients, true);
return true;
}
LOG_PERROR("%s-sink: Can't lock memory", sink->name);
return false;
}
sink->has_clients = (sink->mem->last_client_ts + sink->client_ttl > get_now_monotonic());
atomic_store(&sink->has_clients, (sink->mem->last_client_ts + sink->client_ttl > get_now_monotonic()));
bool retval = (sink->has_clients || !FRAME_COMPARE_META_USED_NOTS(sink->mem, frame));
bool retval = (atomic_load(&sink->has_clients) || !FRAME_COMPARE_META_USED_NOTS(sink->mem, frame));
if (flock(sink->fd, LOCK_UN) < 0) {
LOG_PERROR("%s-sink: Can't unlock memory", sink->name);
@@ -133,7 +134,7 @@ int memsink_server_put(memsink_s *sink, const frame_s *frame) {
sink->mem->magic = MEMSINK_MAGIC;
sink->mem->version = MEMSINK_VERSION;
sink->has_clients = (sink->mem->last_client_ts + sink->client_ttl > get_now_monotonic());
atomic_store(&sink->has_clients, (sink->mem->last_client_ts + sink->client_ttl > get_now_monotonic()));
if (flock(sink->fd, LOCK_UN) < 0) {
LOG_PERROR("%s-sink: Can't unlock memory", sink->name);

View File

@@ -24,6 +24,7 @@
#include <stdint.h>
#include <stdbool.h>
#include <stdatomic.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
@@ -51,7 +52,7 @@ typedef struct {
int fd;
memsink_shared_s *mem;
uint64_t last_id;
bool has_clients; // Only for server
atomic_bool has_clients; // Only for server
} memsink_s;

View File

@@ -342,6 +342,7 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
encoder_type_to_string(enc_type),
enc_quality
));
# ifdef WITH_OMX
if (STREAM(run->h264)) {
assert(evbuffer_add_printf(buf,
@@ -352,6 +353,32 @@ static void _http_callback_state(struct evhttp_request *request, void *v_server)
));
}
# endif
if (
STREAM(sink)
# ifdef WITH_OMX
|| STREAM(h264_sink)
# endif
) {
assert(evbuffer_add_printf(buf, " \"sinks\": {"));
if (STREAM(sink)) {
assert(evbuffer_add_printf(buf,
"\"jpeg\": {\"has_clients\": %s}",
bool_to_string(atomic_load(&STREAM(sink->has_clients)))
));
}
# ifdef WITH_OMX
if (STREAM(h264_sink)) {
assert(evbuffer_add_printf(buf,
"%s\"h264\": {\"has_clients\": %s}",
(STREAM(sink) ? ", " : ""),
bool_to_string(atomic_load(&STREAM(h264_sink->has_clients)))
));
}
# endif
assert(evbuffer_add_printf(buf, "},"));
}
assert(evbuffer_add_printf(buf,
" \"source\": {\"resolution\": {\"width\": %u, \"height\": %u},"
" \"online\": %s, \"desired_fps\": %u, \"captured_fps\": %u},"

View File

@@ -136,9 +136,9 @@ void stream_loop(stream_s *stream) {
&& !atomic_load(&RUN(stop))
&& !atomic_load(&RUN(video->has_clients))
// has_clients синков НЕ обновляются в реальном времени
&& (stream->sink == NULL || !stream->sink->has_clients)
&& (stream->sink == NULL || !atomic_load(&stream->sink->has_clients))
# ifdef WITH_OMX
&& (RUN(h264) == NULL || /*RUN(h264->sink) == NULL ||*/ !RUN(h264->sink->has_clients))
&& (RUN(h264) == NULL || /*RUN(h264->sink) == NULL ||*/ !atomic_load(&RUN(h264->sink->has_clients)))
# endif
) {
usleep(100000);