From ba92140f2b68b1a7215819f2ef65c166ffc8b372 Mon Sep 17 00:00:00 2001 From: pkv Date: Thu, 22 Jun 2023 13:46:44 +0200 Subject: [PATCH] rtmp-services: Enforce encoder settings per protocol For mpegts output, used in rtmp-custom service, encoder settings require: - ADTS with fdk-aac. For all non-rtmp protocols, one also requires: - video encoder header repetition; This future proofs the code against protocol addition. Additionally, I've added a check against NULL audio settings, which was in my fork but that I forgot to add in the PR [1]. [1] https://github.com/obsproject/obs-studio/pull/6163 Signed-off-by: pkv --- plugins/rtmp-services/rtmp-custom.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/rtmp-services/rtmp-custom.c b/plugins/rtmp-services/rtmp-custom.c index 482f1ce08..c44d881a2 100644 --- a/plugins/rtmp-services/rtmp-custom.c +++ b/plugins/rtmp-services/rtmp-custom.c @@ -134,18 +134,21 @@ static const char *rtmp_custom_get_protocol(void *data) return "RTMP"; } -#define RTMP_PROTOCOL "rtmp" - static void rtmp_custom_apply_settings(void *data, obs_data_t *video_settings, obs_data_t *audio_settings) { struct rtmp_custom *service = data; - if (service->server != NULL && video_settings != NULL && - strncmp(service->server, RTMP_PROTOCOL, strlen(RTMP_PROTOCOL)) != - 0) { + const char *protocol = rtmp_custom_get_protocol(service); + bool has_mpegts = false; + bool is_rtmp = false; + if (strcmp(protocol, "SRT") == 0 || strcmp(protocol, "RIST") == 0) + has_mpegts = true; + if (strcmp(protocol, "RTMP") == 0 || strcmp(protocol, "RTMPS") == 0) + is_rtmp = true; + if (!is_rtmp && video_settings != NULL) obs_data_set_bool(video_settings, "repeat_headers", true); + if (has_mpegts && audio_settings != NULL) obs_data_set_bool(audio_settings, "set_to_ADTS", true); - } } static const char *rtmp_custom_get_connect_info(void *data, uint32_t type)