Skip to content

Commit

Permalink
H264 profile fix (#2212)
Browse files Browse the repository at this point in the history
* handle case where fmtp is before rtpmap in sdp
  • Loading branch information
groupboard committed Jun 9, 2020
1 parent 5d56572 commit dcf6a91
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions sdp-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,16 +705,21 @@ 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 */
Expand All @@ -725,7 +730,11 @@ 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);
Expand All @@ -734,7 +743,11 @@ 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")) {
Expand All @@ -743,7 +756,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 {
Expand Down

0 comments on commit dcf6a91

Please sign in to comment.