From a51c321d1db7246a5dcb4ecf27c539482aa6e091 Mon Sep 17 00:00:00 2001 From: David Jameson Date: Mon, 8 Jun 2020 12:54:14 -0700 Subject: [PATCH 1/2] handle case where fmtp is before rtpmap in sdp --- sdp-utils.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/sdp-utils.c b/sdp-utils.c index d7cf9e2e8a..2beeedef07 100644 --- a/sdp-utils.c +++ b/sdp-utils.c @@ -705,16 +705,22 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p GList *ma = m->attributes; int pt = -1; gboolean check_profile = FALSE; + gboolean got_profile = FALSE; while(ma) { janus_sdp_attribute *a = (janus_sdp_attribute *)ma->data; - if(check_profile && a->name != NULL && a->value != NULL && !strcasecmp(a->name, "fmtp")) { + if(profile != NULL && a->name != NULL && a->value != NULL && !strcasecmp(a->name, "fmtp")) { if(vp9) { char profile_id[20]; g_snprintf(profile_id, sizeof(profile_id), "profile-id=%s", profile); if(strstr(a->value, profile_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "VP9 profile %s found --> %d\n", profile, pt); - return pt; + if(check_profile) { + return pt; + } + else { + got_profile = TRUE; + } } } else if(h264 && strstr(a->value, "packetization-mode=0") == NULL) { /* We only support packetization-mode=1, no matter the profile */ @@ -725,7 +731,12 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p if(strstr(a->value, profile_level_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); - return pt; + if(check_profile) { + return pt; + } + else { + got_profile = TRUE; + } } /* Not found, try converting the profile to upper case */ char *profile_upper = g_ascii_strup(profile, -1); @@ -734,7 +745,12 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p if(strstr(a->value, profile_level_id) != NULL) { /* Found */ JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); - return pt; + if(check_profile) { + return pt; + } + else { + got_profile = TRUE; + } } } } else if(a->name != NULL && a->value != NULL && !strcasecmp(a->name, "rtpmap")) { @@ -743,7 +759,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p if(pt < 0) { JANUS_LOG(LOG_ERR, "Invalid payload type (%s)\n", a->value); } else if(strstr(a->value, format) || strstr(a->value, format2)) { - if(profile != NULL && (vp9 || h264)) { + if(profile != NULL && !got_profile && (vp9 || h264)) { /* Let's check the profile first */ check_profile = TRUE; } else { From facc16bb0e9ff3c533390f0dc291307af48636e8 Mon Sep 17 00:00:00 2001 From: David Jameson Date: Tue, 9 Jun 2020 09:15:08 -0700 Subject: [PATCH 2/2] styling --- sdp-utils.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sdp-utils.c b/sdp-utils.c index 2beeedef07..983ffde699 100644 --- a/sdp-utils.c +++ b/sdp-utils.c @@ -717,8 +717,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p JANUS_LOG(LOG_VERB, "VP9 profile %s found --> %d\n", profile, pt); if(check_profile) { return pt; - } - else { + } else { got_profile = TRUE; } } @@ -733,8 +732,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); if(check_profile) { return pt; - } - else { + } else { got_profile = TRUE; } } @@ -747,8 +745,7 @@ int janus_sdp_get_codec_pt_full(janus_sdp *sdp, const char *codec, const char *p JANUS_LOG(LOG_VERB, "H.264 profile %s found --> %d\n", profile, pt); if(check_profile) { return pt; - } - else { + } else { got_profile = TRUE; } }