mirror of
https://github.com/pikvm/ustreamer.git
synced 2025-12-23 18:50:00 +00:00
pass encoders if there is no clients
This commit is contained in:
parent
33b9bff0b9
commit
36dd5d1533
@ -129,7 +129,13 @@ bool us_memsink_server_check(us_memsink_s *sink, const us_frame_s *frame) {
|
||||
US_LOG_PERROR("%s-sink: Can't unlock memory", sink->name);
|
||||
return false;
|
||||
}
|
||||
return (has_clients || !US_FRAME_COMPARE_GEOMETRY(sink->mem, frame));;
|
||||
if (has_clients) {
|
||||
return true;
|
||||
}
|
||||
if (frame != NULL && !US_FRAME_COMPARE_GEOMETRY(sink->mem, frame)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int us_memsink_server_put(us_memsink_s *sink, const us_frame_s *frame, bool *key_requested) {
|
||||
|
||||
@ -53,9 +53,9 @@ void us_h264_stream_destroy(us_h264_stream_s *h264) {
|
||||
}
|
||||
|
||||
void us_h264_stream_process(us_h264_stream_s *h264, const us_frame_s *frame, bool force_key) {
|
||||
if (!us_memsink_server_check(h264->sink, frame)) {
|
||||
/*if (!us_memsink_server_check(h264->sink, frame)) {
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (us_is_jpeg(frame->format)) {
|
||||
const ldf now_ts = us_get_now_monotonic();
|
||||
|
||||
@ -304,6 +304,16 @@ static void *_jpeg_thread(void *v_ctx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( // Если никто не смотрит MJPEG - пропускаем кадр
|
||||
!atomic_load(&stream->run->http_has_clients)
|
||||
&& (atomic_load(&stream->run->http_snapshot_requested) == 0)
|
||||
&& (stream->jpeg_sink == NULL || !us_memsink_server_check(stream->jpeg_sink, NULL))
|
||||
) {
|
||||
US_LOG_VERBOSE("Passed JPEG encoding because nobody is watching");
|
||||
us_device_buffer_decref(hw);
|
||||
continue;
|
||||
}
|
||||
|
||||
const ldf now_ts = us_get_now_monotonic();
|
||||
if (now_ts < grab_after) {
|
||||
fluency_passed += 1;
|
||||
@ -335,7 +345,13 @@ static void *_h264_thread(void *v_ctx) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Форсим кейфрейм, если от захвата давно не было фреймов (при слоудауне)
|
||||
if (!us_memsink_server_check(ctx->h264->sink, NULL)) {
|
||||
us_device_buffer_decref(hw);
|
||||
US_LOG_VERBOSE("Passed JPEG encoding because nobody is watching");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Форсим кейфрейм, если от захвата давно не было фреймов
|
||||
const ldf now_ts = us_get_now_monotonic();
|
||||
const bool force_key = (last_encode_ts + 0.5 < now_ts);
|
||||
last_encode_ts = now_ts;
|
||||
@ -485,7 +501,7 @@ static void _stream_expose_frame(us_stream_s *stream, us_frame_s *frame) {
|
||||
!atomic_load(&run->stop)
|
||||
&& ((ri = us_ring_producer_acquire(run->http_jpeg_ring, 0)) < 0)
|
||||
) {
|
||||
US_LOG_ERROR("Can't push JPEG to HTTP ring (no free slots)");
|
||||
// US_LOG_ERROR("Can't push JPEG to HTTP ring (no free slots)");
|
||||
}
|
||||
if (ri < 0) {
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user