Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Find all matching SDP codecs for defaults #530

Merged
merged 3 commits into from
Feb 26, 2018

Conversation

tylergibson
Copy link

Small fix for setting H264 and other multi-profile codecs as default for SDP offers.

Copy link
Contributor

@KaptenJansson KaptenJansson left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! I would normally ask you to write a test for this but since Chrome is broken in Karma, I will write one later after I fix it.

Just one nit, otherwise LGTM.

var payload = null;
for (var i = 0; i < sdpLines.length; i++) {
var index = findLineInRange(sdpLines, i, -1, 'a=rtpmap', codec);
if(index !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Space between if and (.

@tylergibson
Copy link
Author

@KaptenJansson Thanks, fixed the spacing nit and amended the commit.

Also I believe this resolves #492, as it prioritizes all h264 profiles and will cycle offer candidates until one is accepted.

payload = getCodecPayloadTypeFromLine(sdpLines[index]);
if (payload) {
sdpLines[mLineIndex] = setDefaultCodec(sdpLines[mLineIndex], payload);
}

Choose a reason for hiding this comment

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

SDP lines from i to index was scanned in findLineInRange. Perhaps we can skip them by adding i = index; here.

Copy link
Author

Choose a reason for hiding this comment

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

@jianjunz I originally had exactly that, but removed it thinking it was redundant. You're right though it would skip the next index - i iterations. I'll update

@tylergibson
Copy link
Author

Thanks to @jianjunz, added the index to i assignment to reduce loop iterations. Also added null break to exit the search once no match is found.

Finally, updated findLineInRange to search ascending or descending. By doing a descending search we end up with all matched codecs in the same preference order as the original SDP, preserving client preference.

@tylergibson tylergibson force-pushed the fix-multi-sdp-h264 branch 8 times, most recently from 94c5051 to 616cdac Compare January 31, 2018 08:16
@tylergibson
Copy link
Author

@KaptenJansson Pingback, anything blocking accepting this PR?

Copy link
Contributor

@KaptenJansson KaptenJansson left a comment

Choose a reason for hiding this comment

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

Sorry for the late response. LGTM.

@KaptenJansson KaptenJansson merged commit cfb35d9 into webrtc:master Feb 26, 2018
@KaptenJansson
Copy link
Contributor

Will publish a new AppRTC release later this week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants