mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-01 13:16:32 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5515654497 | ||
|
|
5955310bf3 | ||
|
|
a9df6da912 |
@@ -1,7 +1,7 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
current_version = 0.18
|
current_version = 0.19
|
||||||
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}
|
||||||
|
|||||||
2
PKGBUILD
2
PKGBUILD
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
pkgname=ustreamer
|
pkgname=ustreamer
|
||||||
pkgver=0.18
|
pkgver=0.19
|
||||||
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"
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ $ ./ustreamer \
|
|||||||
--format=uyvy \ # Настройка входного формата устройства
|
--format=uyvy \ # Настройка входного формата устройства
|
||||||
--encoder=omx \ # Использование аппаратного кодирования с помощью OpenMAX
|
--encoder=omx \ # Использование аппаратного кодирования с помощью OpenMAX
|
||||||
--dv-timings # Включение DV-таймингов
|
--dv-timings # Включение DV-таймингов
|
||||||
|
--quality=20 # У OpenMAX нелинейная шкала качества
|
||||||
|
--drop-same-frames=30 # Экономим трафик
|
||||||
```
|
```
|
||||||
|
|
||||||
За полным списком опций обращайтесь ко встроенной справке: ```ustreamer --help```.
|
За полным списком опций обращайтесь ко встроенной справке: ```ustreamer --help```.
|
||||||
|
|||||||
@@ -21,4 +21,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION "0.18"
|
#define VERSION "0.19"
|
||||||
|
|||||||
34
src/http.c
34
src/http.c
@@ -174,12 +174,12 @@ static void _http_callback_ping(struct evhttp_request *request, void *v_server)
|
|||||||
assert(evbuffer_add_printf(buf,
|
assert(evbuffer_add_printf(buf,
|
||||||
"{\"stream\": {\"resolution\":"
|
"{\"stream\": {\"resolution\":"
|
||||||
" {\"width\": %u, \"height\": %u},"
|
" {\"width\": %u, \"height\": %u},"
|
||||||
" \"cps\": %u, \"eps\": %u,"
|
" \"captured_fps\": %u, \"queued_fps\": %u,"
|
||||||
" \"online\": %s, \"clients\": %u}}",
|
" \"online\": %s, \"clients\": %u}}",
|
||||||
(server->fake_width ? server->fake_width : server->run->exposed->width),
|
(server->fake_width ? server->fake_width : server->run->exposed->width),
|
||||||
(server->fake_height ? server->fake_height : server->run->exposed->height),
|
(server->fake_height ? server->fake_height : server->run->exposed->height),
|
||||||
server->run->exposed->cps, // Captured per second
|
server->run->exposed->captured_fps,
|
||||||
server->run->exposed->eps, // Exposed per second (server)
|
server->run->exposed->queued_fps,
|
||||||
(server->run->exposed->online ? "true" : "false"),
|
(server->run->exposed->online ? "true" : "false"),
|
||||||
server->run->stream_clients_count
|
server->run->stream_clients_count
|
||||||
));
|
));
|
||||||
@@ -390,6 +390,10 @@ static void _http_queue_send_stream(struct http_server_t *server, const bool upd
|
|||||||
struct stream_client_t *client;
|
struct stream_client_t *client;
|
||||||
struct evhttp_connection *conn;
|
struct evhttp_connection *conn;
|
||||||
struct bufferevent *buf_event;
|
struct bufferevent *buf_event;
|
||||||
|
long long now;
|
||||||
|
bool queued = false;
|
||||||
|
static unsigned queued_fps = 0;
|
||||||
|
static long long queued_fps_second = 0;
|
||||||
|
|
||||||
for (client = server->run->stream_clients; client != NULL; client = client->next) {
|
for (client = server->run->stream_clients; client != NULL; client = client->next) {
|
||||||
conn = evhttp_request_get_connection(client->request);
|
conn = evhttp_request_get_connection(client->request);
|
||||||
@@ -398,17 +402,24 @@ static void _http_queue_send_stream(struct http_server_t *server, const bool upd
|
|||||||
bufferevent_setcb(buf_event, NULL, _http_callback_stream_write, _http_callback_stream_error, (void *)client);
|
bufferevent_setcb(buf_event, NULL, _http_callback_stream_write, _http_callback_stream_error, (void *)client);
|
||||||
bufferevent_enable(buf_event, EV_READ|EV_WRITE);
|
bufferevent_enable(buf_event, EV_READ|EV_WRITE);
|
||||||
client->need_first_frame = false;
|
client->need_first_frame = false;
|
||||||
|
queued = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (queued) {
|
||||||
|
if ((now = floor_ms(get_now_monotonic())) != queued_fps_second) {
|
||||||
|
server->run->exposed->queued_fps = queued_fps;
|
||||||
|
queued_fps = 0;
|
||||||
|
queued_fps_second = now;
|
||||||
|
}
|
||||||
|
queued_fps += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _http_exposed_refresh(UNUSED int fd, UNUSED short what, void *v_server) {
|
static void _http_exposed_refresh(UNUSED int fd, UNUSED short what, void *v_server) {
|
||||||
struct http_server_t *server = (struct http_server_t *)v_server;
|
struct http_server_t *server = (struct http_server_t *)v_server;
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
bool queue_send = false;
|
bool queue_send = false;
|
||||||
long long now;
|
|
||||||
static unsigned eps = 0;
|
|
||||||
static long long eps_second = 0;
|
|
||||||
|
|
||||||
#define LOCK_STREAM \
|
#define LOCK_STREAM \
|
||||||
A_PTHREAD_M_LOCK(&server->run->stream->mutex);
|
A_PTHREAD_M_LOCK(&server->run->stream->mutex);
|
||||||
@@ -434,13 +445,6 @@ static void _http_exposed_refresh(UNUSED int fd, UNUSED short what, void *v_serv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (queue_send) {
|
if (queue_send) {
|
||||||
if ((now = floor_ms(get_now_monotonic())) != eps_second) {
|
|
||||||
server->run->exposed->eps = eps;
|
|
||||||
eps = 0;
|
|
||||||
eps_second = now;
|
|
||||||
}
|
|
||||||
eps += 1;
|
|
||||||
|
|
||||||
if (server->drop_same_frames) {
|
if (server->drop_same_frames) {
|
||||||
// Хром всегда показывает не новый пришедший фрейм, а предыдущий.
|
// Хром всегда показывает не новый пришедший фрейм, а предыдущий.
|
||||||
// При updated == false нужно еще один раз послать предыдущий фрейм
|
// При updated == false нужно еще один раз послать предыдущий фрейм
|
||||||
@@ -467,7 +471,7 @@ static bool _expose_new_picture(struct http_server_t *server) {
|
|||||||
# define EXPOSED(_next) server->run->exposed->_next
|
# define EXPOSED(_next) server->run->exposed->_next
|
||||||
|
|
||||||
assert(STREAM(picture.size) > 0);
|
assert(STREAM(picture.size) > 0);
|
||||||
EXPOSED(cps) = STREAM(cps);
|
EXPOSED(captured_fps) = STREAM(captured_fps);
|
||||||
EXPOSED(expose_begin_time) = get_now_monotonic();
|
EXPOSED(expose_begin_time) = get_now_monotonic();
|
||||||
|
|
||||||
# define MEM_STREAM_TO_EXPOSED \
|
# define MEM_STREAM_TO_EXPOSED \
|
||||||
@@ -550,7 +554,7 @@ static bool _expose_blank_picture(struct http_server_t *server) {
|
|||||||
|
|
||||||
EXPOSED(width) = BLANK_JPG_WIDTH;
|
EXPOSED(width) = BLANK_JPG_WIDTH;
|
||||||
EXPOSED(height) = BLANK_JPG_HEIGHT;
|
EXPOSED(height) = BLANK_JPG_HEIGHT;
|
||||||
EXPOSED(cps) = 0;
|
EXPOSED(captured_fps) = 0;
|
||||||
EXPOSED(online) = false;
|
EXPOSED(online) = false;
|
||||||
goto updated;
|
goto updated;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ struct exposed_t {
|
|||||||
struct picture_t picture;
|
struct picture_t picture;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned cps; // Captured per second
|
unsigned captured_fps;
|
||||||
unsigned eps; // Exposed per second
|
unsigned queued_fps;
|
||||||
bool online;
|
bool online;
|
||||||
unsigned dropped;
|
unsigned dropped;
|
||||||
long double expose_begin_time;
|
long double expose_begin_time;
|
||||||
|
|||||||
16
src/stream.c
16
src/stream.c
@@ -85,8 +85,8 @@ void stream_loop(struct stream_t *stream) {
|
|||||||
unsigned frames_count = 0;
|
unsigned frames_count = 0;
|
||||||
long double grab_after = 0;
|
long double grab_after = 0;
|
||||||
unsigned fluency_passed = 0;
|
unsigned fluency_passed = 0;
|
||||||
unsigned cps = 0; // Captured per second
|
unsigned captured_fps = 0;
|
||||||
long long cps_second = 0;
|
long long captured_fps_second = 0;
|
||||||
|
|
||||||
LOG_DEBUG("Allocation memory for stream picture ...");
|
LOG_DEBUG("Allocation memory for stream picture ...");
|
||||||
A_CALLOC(stream->picture.data, stream->dev->run->max_picture_size);
|
A_CALLOC(stream->picture.data, stream->dev->run->max_picture_size);
|
||||||
@@ -197,13 +197,13 @@ void stream_loop(struct stream_t *stream) {
|
|||||||
}
|
}
|
||||||
fluency_passed = 0;
|
fluency_passed = 0;
|
||||||
|
|
||||||
if (now_second != cps_second) {
|
if (now_second != captured_fps_second) {
|
||||||
LOG_PERF("Oldest worker complete, CPS = %u", cps);
|
LOG_PERF("Oldest worker complete, Captured-FPS = %u", captured_fps);
|
||||||
stream->cps = cps;
|
stream->captured_fps = captured_fps;
|
||||||
cps = 0;
|
captured_fps = 0;
|
||||||
cps_second = now_second;
|
captured_fps_second = now_second;
|
||||||
}
|
}
|
||||||
cps += 1;
|
captured_fps += 1;
|
||||||
|
|
||||||
long double fluency_delay = _stream_get_fluency_delay(stream->dev, &pool);
|
long double fluency_delay = _stream_get_fluency_delay(stream->dev, &pool);
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ struct stream_t {
|
|||||||
struct picture_t picture;
|
struct picture_t picture;
|
||||||
unsigned width;
|
unsigned width;
|
||||||
unsigned height;
|
unsigned height;
|
||||||
unsigned cps; // Captured per second
|
unsigned captured_fps;
|
||||||
bool updated;
|
bool updated;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
struct device_t *dev;
|
struct device_t *dev;
|
||||||
|
|||||||
Reference in New Issue
Block a user