Chromium Code Reviews| Index: chrome/test/data/webrtc/munge_sdp.js |
| diff --git a/chrome/test/data/webrtc/munge_sdp.js b/chrome/test/data/webrtc/munge_sdp.js |
| index 9a8a37e6d78a754b5c195dc119360c131b5711e1..91d109ddd2340f11f394486734653bec04762ce3 100644 |
| --- a/chrome/test/data/webrtc/munge_sdp.js |
| +++ b/chrome/test/data/webrtc/munge_sdp.js |
| @@ -19,6 +19,41 @@ function setSdpDefaultVideoCodec(sdp, codec) { |
| } |
| /** |
| + * Returns a modified version of |sdp| where the opus DTX flag has been |
| + * enabled. |
| + */ |
| +function setOpusDtxEnabled(sdp) { |
| + var sdpLines = splitSdpLines(sdp); |
| + |
| + // Get default audio codec |
| + var defaultCodec = getSdpDefaultAudioCodec(sdp); |
| + if (defaultCodec !== 'opus') { |
| + failure('setOpusDtxEnabled', |
| + 'Default audio codec is not set to \'opus\'.'); |
| + } |
| + |
| + // Find codec ID for Opus, e.g. 111 if 'a=rtpmap:111 opus/48000/2'. |
| + var codecId = findRtpmapId(sdpLines, 'opus'); |
| + if (codecId === null) { |
| + failure('setOpusDtxEnabled', 'Unknown ID for |codec| = \'opus\'.'); |
| + } |
| + |
| + // Find 'a=fmtp:111' line, where 111 is the codecId |
| + var fmtLineNo = findFmtpLine(sdpLines, codecId); |
| + if (fmtLineNo === null) { |
| + // Add the line to the SDP. |
| + newLine = 'a=fmtp:' + codecId + ' usedtx=1' |
| + rtpMapLine = findRtpmapLine(sdpLines, codecId); |
| + sdpLines.splice(rtpMapLine+1, 0, newLine); |
|
minyue
2016/07/28 14:17:37
add spaces around +
Ivo-OOO until feb 6
2016/07/28 14:42:38
Done.
|
| + } |
| + else { |
|
minyue
2016/07/28 14:17:37
move up
Ivo-OOO until feb 6
2016/07/28 14:42:38
Done.
|
| + // Modify the line to enable Opus Dtx. |
| + sdpLines[fmtLineNo] += ';usedtx=1' |
| + } |
| + return mergeSdpLines(sdpLines); |
| +} |
| + |
| +/** |
| * Returns a modified version of |sdp| where the |codec| has been promoted to be |
| * the default codec, i.e. the codec whose ID is first in the list of codecs on |
| * the 'm=|type|' line, where |type| is 'audio' or 'video'. |
| @@ -150,6 +185,15 @@ function findRtpmapLine(sdpLines, contains) { |
| } |
| /** |
| + * Finds the fmtp line in |sdpLines| for the given |codecId|. The line |
| + * starts with 'a=fmtp:<codecId>'. |
| + */ |
|
minyue
2016/07/28 14:17:37
Say return line number, and add @private
Ivo-OOO until feb 6
2016/07/28 14:42:38
Done.
|
| +function findFmtpLine(sdpLines, codecId) { |
| + return findLine(sdpLines, 'a=fmtp:' + codecId); |
| + |
| +} |
| + |
| +/** |
| * Returns a modified version of |mLine| that has |codecId| first in the list of |
| * codec IDs. For example, setMLineDefaultCodec( |
| * 'm=video 9 UDP/TLS/RTP/SAVPF 100 101 107 116 117 96', 107) |