mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-05-26 15:26:12 +00:00
refactoring
This commit is contained in:
@@ -95,7 +95,6 @@ void us_m2m_encoder_destroy(us_m2m_encoder_s *enc) {
|
|||||||
int us_m2m_encoder_compress(us_m2m_encoder_s *enc, const us_frame_s *src, us_frame_s *dest, bool force_key) {
|
int us_m2m_encoder_compress(us_m2m_encoder_s *enc, const us_frame_s *src, us_frame_s *dest, bool force_key) {
|
||||||
us_m2m_encoder_runtime_s *const run = enc->run;
|
us_m2m_encoder_runtime_s *const run = enc->run;
|
||||||
|
|
||||||
const ldf now_ts = us_get_now_monotonic();
|
|
||||||
uint dest_format = enc->output_format;
|
uint dest_format = enc->output_format;
|
||||||
switch (enc->output_format) {
|
switch (enc->output_format) {
|
||||||
case V4L2_PIX_FMT_JPEG:
|
case V4L2_PIX_FMT_JPEG:
|
||||||
@@ -108,7 +107,7 @@ int us_m2m_encoder_compress(us_m2m_encoder_s *enc, const us_frame_s *src, us_fra
|
|||||||
force_key = (
|
force_key = (
|
||||||
force_key
|
force_key
|
||||||
|| run->last_online != src->online
|
|| run->last_online != src->online
|
||||||
|| run->last_encode_ts + 0.5 < now_ts
|
|| run->last_encode_ts + 0.5 < us_get_now_monotonic()
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -134,7 +133,7 @@ int us_m2m_encoder_compress(us_m2m_encoder_s *enc, const us_frame_s *src, us_fra
|
|||||||
dest->used, dest->encode_end_ts - dest->encode_begin_ts, force_key);
|
dest->used, dest->encode_end_ts - dest->encode_begin_ts, force_key);
|
||||||
|
|
||||||
run->last_online = src->online;
|
run->last_online = src->online;
|
||||||
run->last_encode_ts = now_ts;
|
run->last_encode_ts = dest->encode_end_ts;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -610,7 +610,6 @@ static void _stream_drm_ensure_no_signal(us_stream_s *stream) {
|
|||||||
if (us_drm_ensure_no_signal(stream->drm) < 0) {
|
if (us_drm_ensure_no_signal(stream->drm) < 0) {
|
||||||
goto close;
|
goto close;
|
||||||
}
|
}
|
||||||
|
|
||||||
us_fpsi_update(stream->run->http->drm_fpsi, true, &meta);
|
us_fpsi_update(stream->run->http->drm_fpsi, true, &meta);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -643,13 +642,12 @@ static void _stream_expose_raw(us_stream_s *stream, const us_frame_s *frame) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _stream_encode_expose_h264(us_stream_s *stream, const us_frame_s *frame, bool force_key) {
|
static void _stream_encode_expose_h264(us_stream_s *stream, const us_frame_s *frame, bool force_key) {
|
||||||
us_stream_runtime_s *run = stream->run;
|
|
||||||
if (stream->h264_sink == NULL) {
|
if (stream->h264_sink == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
us_stream_runtime_s *run = stream->run;
|
||||||
|
|
||||||
us_fpsi_meta_s meta = {.online = false};
|
us_fpsi_meta_s meta = {.online = false};
|
||||||
|
|
||||||
if (us_is_jpeg(frame->format)) {
|
if (us_is_jpeg(frame->format)) {
|
||||||
if (us_unjpeg(frame, run->h264_tmp_src, true) < 0) {
|
if (us_unjpeg(frame, run->h264_tmp_src, true) < 0) {
|
||||||
goto done;
|
goto done;
|
||||||
|
|||||||
Reference in New Issue
Block a user