diff --git a/janus/src/client.c b/janus/src/client.c index 6ce9147..28be3b1 100644 --- a/janus/src/client.c +++ b/janus/src/client.c @@ -108,12 +108,13 @@ static void *_common_thread(void *v_client, bool video) { packet.mindex = (rtp->video ? 0 : 1); # endif janus_plugin_rtp_extensions_reset(&packet.extensions); - // FIXME: Это очень эффективный способ уменьшить задержку, но WebRTC стек в хроме и фоксе - // слишком корявый, чтобы обработать это, из-за чего на кейфреймах начинаются заикания. - // - https://github.com/Glimesh/janus-ftl-plugin/issues/101 if (rtp->zero_playout_delay) { + // https://github.com/pikvm/pikvm/issues/784 packet.extensions.min_delay = 0; packet.extensions.max_delay = 0; + } else { + packet.extensions.min_delay = 0; + packet.extensions.max_delay = 1000; } client->gw->relay_rtp(client->session, &packet); } diff --git a/janus/src/config.c b/janus/src/config.c index 9806818..2c7e9d1 100644 --- a/janus/src/config.c +++ b/janus/src/config.c @@ -24,7 +24,7 @@ static char *_get_value(janus_config *jcfg, const char *section, const char *option); -static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def); +// static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def); us_config_s *us_config_init(const char *config_dir_path) { @@ -51,9 +51,6 @@ us_config_s *us_config_init(const char *config_dir_path) { US_JLOG_ERROR("config", "Missing config value: video.sink (ex. memsink.object)"); goto error; } - if ((config->video_zero_playout_delay = _get_bool(jcfg, "video", "zero_playout_delay", false)) == true) { - US_JLOG_INFO("config", "Enabled the experimental Playout-Delay=0 RTP extension for VIDEO"); - } if ((config->audio_dev_name = _get_value(jcfg, "audio", "device")) != NULL) { US_JLOG_INFO("config", "Enabled the experimental AUDIO feature"); if ((config->tc358743_dev_path = _get_value(jcfg, "audio", "tc358743")) == NULL) { @@ -88,7 +85,7 @@ static char *_get_value(janus_config *jcfg, const char *section, const char *opt return us_strdup(option_obj->value); } -static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def) { +/*static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def) { char *const tmp = _get_value(jcfg, section, option); bool value = def; if (tmp != NULL) { @@ -96,4 +93,4 @@ static bool _get_bool(janus_config *jcfg, const char *section, const char *optio free(tmp); } return value; -} +}*/ diff --git a/janus/src/config.h b/janus/src/config.h index 52de3d1..4bdb852 100644 --- a/janus/src/config.h +++ b/janus/src/config.h @@ -36,7 +36,6 @@ typedef struct { char *video_sink_name; - bool video_zero_playout_delay; char *audio_dev_name; char *tc358743_dev_path; diff --git a/janus/src/plugin.c b/janus/src/plugin.c index 8537f8e..ee34c94 100644 --- a/janus/src/plugin.c +++ b/janus/src/plugin.c @@ -262,7 +262,7 @@ static int _plugin_init(janus_callbacks *gw, const char *config_dir_path) { _g_gw = gw; _g_video_queue = us_queue_init(1024); - _g_rtpv = us_rtpv_init(_relay_rtp_clients, _g_config->video_zero_playout_delay); + _g_rtpv = us_rtpv_init(_relay_rtp_clients); if (_g_config->audio_dev_name != NULL) { _g_rtpa = us_rtpa_init(_relay_rtp_clients); US_THREAD_CREATE(_g_audio_tid, _audio_thread, NULL); diff --git a/janus/src/rtp.c b/janus/src/rtp.c index b7f0ea9..1c31b84 100644 --- a/janus/src/rtp.c +++ b/janus/src/rtp.c @@ -26,12 +26,11 @@ #include "rtp.h" -us_rtp_s *us_rtp_init(unsigned payload, bool video, bool zero_playout_delay) { +us_rtp_s *us_rtp_init(unsigned payload, bool video) { us_rtp_s *rtp; US_CALLOC(rtp, 1); rtp->payload = payload; rtp->video = video; - rtp->zero_playout_delay = zero_playout_delay; // See client.c rtp->ssrc = us_triple_u32(us_get_now_monotonic_u64()); return rtp; } diff --git a/janus/src/rtp.h b/janus/src/rtp.h index 372bbbe..06cc1d7 100644 --- a/janus/src/rtp.h +++ b/janus/src/rtp.h @@ -39,18 +39,18 @@ typedef struct { unsigned payload; bool video; - bool zero_playout_delay; uint32_t ssrc; uint16_t seq; uint8_t datagram[US_RTP_DATAGRAM_SIZE]; size_t used; + bool zero_playout_delay; } us_rtp_s; typedef void (*us_rtp_callback_f)(const us_rtp_s *rtp); -us_rtp_s *us_rtp_init(unsigned payload, bool video, bool zero_playout_delay); +us_rtp_s *us_rtp_init(unsigned payload, bool video); us_rtp_s *us_rtp_dup(const us_rtp_s *rtp); void us_rtp_destroy(us_rtp_s *rtp); diff --git a/janus/src/rtpa.c b/janus/src/rtpa.c index 8c2305d..c3be0b0 100644 --- a/janus/src/rtpa.c +++ b/janus/src/rtpa.c @@ -26,7 +26,7 @@ us_rtpa_s *us_rtpa_init(us_rtp_callback_f callback) { us_rtpa_s *rtpa; US_CALLOC(rtpa, 1); - rtpa->rtp = us_rtp_init(111, false, false); + rtpa->rtp = us_rtp_init(111, false); rtpa->callback = callback; return rtpa; } diff --git a/janus/src/rtpv.c b/janus/src/rtpv.c index e81b93f..f21c9b3 100644 --- a/janus/src/rtpv.c +++ b/janus/src/rtpv.c @@ -31,10 +31,10 @@ void _rtpv_process_nalu(us_rtpv_s *rtpv, const uint8_t *data, size_t size, uint3 static ssize_t _find_annexb(const uint8_t *data, size_t size); -us_rtpv_s *us_rtpv_init(us_rtp_callback_f callback, bool zero_playout_delay) { +us_rtpv_s *us_rtpv_init(us_rtp_callback_f callback) { us_rtpv_s *rtpv; US_CALLOC(rtpv, 1); - rtpv->rtp = us_rtp_init(96, true, zero_playout_delay); + rtpv->rtp = us_rtp_init(96, true); rtpv->callback = callback; return rtpv; } @@ -59,12 +59,11 @@ char *us_rtpv_make_sdp(us_rtpv_s *rtpv) { "a=rtcp-fb:%u nack pli" RN "a=rtcp-fb:%u goog-remb" RN "a=ssrc:%" PRIu32 " cname:ustreamer" RN - "%s" // playout-delay + "a=extmap:1 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay" RN "a=sendonly" RN, PAYLOAD, PAYLOAD, PAYLOAD, PAYLOAD, PAYLOAD, PAYLOAD, PAYLOAD, - rtpv->rtp->ssrc, - (rtpv->rtp->zero_playout_delay ? "a=extmap:1 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay" RN : "") + rtpv->rtp->ssrc ); return sdp; # undef PAYLOAD @@ -78,6 +77,8 @@ void us_rtpv_wrap(us_rtpv_s *rtpv, const us_frame_s *frame) { assert(frame->format == V4L2_PIX_FMT_H264); + rtpv->rtp->zero_playout_delay = (frame->gop == 0); + const uint32_t pts = us_get_now_monotonic_u64() * 9 / 100; // PTS units are in 90 kHz ssize_t last_offset = -_PRE; diff --git a/janus/src/rtpv.h b/janus/src/rtpv.h index e24736d..01c2010 100644 --- a/janus/src/rtpv.h +++ b/janus/src/rtpv.h @@ -43,7 +43,7 @@ typedef struct { } us_rtpv_s; -us_rtpv_s *us_rtpv_init(us_rtp_callback_f callback, bool zero_playout_delay); +us_rtpv_s *us_rtpv_init(us_rtp_callback_f callback); void us_rtpv_destroy(us_rtpv_s *rtpv); char *us_rtpv_make_sdp(us_rtpv_s *rtpv);