Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H264 profile fix #2212

Merged
merged 4 commits into from
Jun 9, 2020
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions sdp-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style nit: please put the else on the same line as the closing bracket.

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 +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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

got_profile = TRUE;
}
}
/* Not found, try converting the profile to upper case */
char *profile_upper = g_ascii_strup(profile, -1);
Expand All @@ -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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

got_profile = TRUE;
}
}
}
} else if(a->name != NULL && a->value != NULL && !strcasecmp(a->name, "rtpmap")) {
Expand All @@ -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 {
Expand Down