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

Commit

Permalink
Merge pull request #302 from stefanholmer/master
Browse files Browse the repository at this point in the history
Add support for GET parameter to disable video FEC.
  • Loading branch information
KaptenJansson committed May 18, 2016
2 parents eb13ae3 + 71e57dc commit de6024f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/web_app/html/params.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ <h1>AppRTC parameters</h1>
<tr><td><a href="https://appr.tc?asbr=16000">asbr=[bitrate]</a></td><td>Set audio send bitrate</td></tr>
<tr><td><a href="https://appr.tc?vsbr=1000">vsbr=[bitrate]</a></td><td>Set video receive bitrate</td></tr>
<tr><td><a href="https://appr.tc?vrbr=8000">vrbr=[bitrate]</a></td><td>Set video send bitrate</td></tr>
<tr><td><a href="https://appr.tc?videofec=false">videofec=false</a></td><td>Turn off video FEC</td></tr>
<tr><td><a href="https://appr.tc?opusfec=false">opusfec=false</a></td><td>Turn off Opus FEC</td></tr>
<tr><td><a href="https://appr.tc?opusdtx=true">opusdtx=true</a></td><td>Turn on Opus DTX</td></tr>
<tr><td><a href="https://appr.tc?opusmaxpbr=8000">opusmaxpbr=8000</a></td><td>Set the maximum sample rate that the receiver can operate, for optimal Opus encoding performance</td></tr>
Expand Down
1 change: 1 addition & 0 deletions src/web_app/js/appcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ AppController.prototype.loadUrlParams_ = function() {
this.loadingParams_.videoSendCodec = urlParams['vsc'];
this.loadingParams_.videoRecvBitrate = urlParams['vrbr'];
this.loadingParams_.videoRecvCodec = urlParams['vrc'] || DEFAULT_VIDEO_CODEC;
this.loadingParams_.videoFec = urlParams['videofec'];
/* jshint ignore:end */
/* jscs: enable */
};
Expand Down
3 changes: 2 additions & 1 deletion src/web_app/js/peerconnectionclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
maybeSetAudioSendBitRate, maybeSetVideoSendBitRate,
maybeSetAudioReceiveBitRate, maybeSetVideoSendInitialBitRate,
maybeSetVideoReceiveBitRate, maybeSetVideoSendInitialBitRate,
maybeSetOpusOptions */
maybeRemoveVideoFec, maybeSetOpusOptions */

/* exported PeerConnectionClient */

Expand Down Expand Up @@ -213,6 +213,7 @@ PeerConnectionClient.prototype.setRemoteSdp_ = function(message) {
message.sdp = maybeSetAudioSendBitRate(message.sdp, this.params_);
message.sdp = maybeSetVideoSendBitRate(message.sdp, this.params_);
message.sdp = maybeSetVideoSendInitialBitRate(message.sdp, this.params_);
message.sdp = maybeRemoveVideoFec(message.sdp);
this.pc_.setRemoteDescription(new RTCSessionDescription(message))
.then(this.onSetRemoteDescriptionSuccess_.bind(this))
.catch(this.onError_.bind(this, 'setRemoteDescription'));
Expand Down
75 changes: 74 additions & 1 deletion src/web_app/js/sdputils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
maybeSetAudioSendBitRate, maybePreferVideoReceiveCodec,
maybePreferVideoSendCodec, maybeSetVideoReceiveBitRate,
maybeSetVideoSendBitRate, maybeSetVideoSendInitialBitRate,
mergeConstraints, removeCodecParam*/
maybeRemoveVideoFec, mergeConstraints, removeCodecParam*/

'use strict';

Expand Down Expand Up @@ -202,6 +202,79 @@ function maybeSetVideoSendInitialBitRate(sdp, params) {
return sdp;
}

function removePayloadTypeFromMline(mLine, payloadType) {
mLine = mLine.split(' ');
for (var i = 0; i < mLine.length; ++i) {
if (mLine[i] === payloadType.toString()) {
mLine.splice(i, 1);
}
}
return mLine.join(' ');
}

function removeCodecByName(sdpLines, codec) {
var index = findLine(sdpLines, 'a=rtpmap', codec);
if (index === null) {
return sdpLines;
}
var payloadType = getCodecPayloadTypeFromLine(sdpLines[index]);
sdpLines.splice(index, 1);

// Search for the video m= line and remove the codec.
var mLineIndex = findLine(sdpLines, 'm=', 'video');
if (mLineIndex === null) {
return sdpLines;
}
sdpLines[mLineIndex] = removePayloadTypeFromMline(sdpLines[mLineIndex],
payloadType);
return sdpLines;
}

function removeCodecByPayloadType(sdpLines, payloadType) {
var index = findLine(sdpLines, 'a=rtpmap', payloadType.toString());
if (index === null) {
return sdpLines;
}
sdpLines.splice(index, 1);

// Search for the video m= line and remove the codec.
var mLineIndex = findLine(sdpLines, 'm=', 'video');
if (mLineIndex === null) {
return sdpLines;
}
sdpLines[mLineIndex] = removePayloadTypeFromMline(sdpLines[mLineIndex],
payloadType);
return sdpLines;
}

function maybeRemoveVideoFec(sdp) {
var sdpLines = sdp.split('\r\n');

var index = findLine(sdpLines, 'a=rtpmap', 'red');
if (index === null) {
return sdp;
}
var redPayloadType = getCodecPayloadTypeFromLine(sdpLines[index]);
sdpLines = removeCodecByPayloadType(sdpLines, redPayloadType);

sdpLines = removeCodecByName(sdpLines, 'ulpfec');

// Remove fmtp lines associated with red codec.
index = findLine(sdpLines, 'a=fmtp', redPayloadType.toString());
if (index === null) {
return sdp;
}
var fmtpLine = parseFmtpLine(sdpLines[index]);
var rtxPayloadType = fmtpLine.pt;
if (rtxPayloadType === null) {
return sdp;
}
sdpLines.splice(index, 1);

sdpLines = removeCodecByPayloadType(sdpLines, rtxPayloadType);
return sdpLines.join('\r\n');
}

// Promotes |audioSendCodec| to be the first in the m=audio line, if set.
function maybePreferAudioSendCodec(sdp, params) {
return maybePreferCodec(sdp, 'audio', 'send', params.audioSendCodec);
Expand Down

0 comments on commit de6024f

Please sign in to comment.