Added Stereo url paramter to apprtc demo.
R=dutton@google.com Review URL: https://webrtc-codereview.appspot.com/1418004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4013 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
52b3905ec8
commit
1993a559e8
@ -327,6 +327,10 @@ class MainPage(webapp2.RequestHandler):
|
|||||||
if debug == 'loopback':
|
if debug == 'loopback':
|
||||||
# set compat to false as DTLS does not work for loopback.
|
# set compat to false as DTLS does not work for loopback.
|
||||||
compat = 'false'
|
compat = 'false'
|
||||||
|
# set stereo to false by default
|
||||||
|
stereo = 'false'
|
||||||
|
if self.request.get('stereo'):
|
||||||
|
stereo = self.request.get('stereo')
|
||||||
|
|
||||||
|
|
||||||
# token_timeout for channel creation, default 30min, max 2 days, min 3min.
|
# token_timeout for channel creation, default 30min, max 2 days, min 3min.
|
||||||
@ -390,7 +394,8 @@ class MainPage(webapp2.RequestHandler):
|
|||||||
'pc_constraints': json.dumps(pc_constraints),
|
'pc_constraints': json.dumps(pc_constraints),
|
||||||
'offer_constraints': json.dumps(offer_constraints),
|
'offer_constraints': json.dumps(offer_constraints),
|
||||||
'media_constraints': json.dumps(media_constraints),
|
'media_constraints': json.dumps(media_constraints),
|
||||||
'turn_url': turn_url
|
'turn_url': turn_url,
|
||||||
|
'stereo': stereo
|
||||||
}
|
}
|
||||||
if unittest:
|
if unittest:
|
||||||
target_page = 'test/test_' + unittest + '.html'
|
target_page = 'test/test_' + unittest + '.html'
|
||||||
|
@ -125,6 +125,7 @@
|
|||||||
'OfferToReceiveVideo':true }};
|
'OfferToReceiveVideo':true }};
|
||||||
var isVideoMuted = false;
|
var isVideoMuted = false;
|
||||||
var isAudioMuted = false;
|
var isAudioMuted = false;
|
||||||
|
var stereo = false;
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
console.log("Initializing; room={{ room_key }}.");
|
console.log("Initializing; room={{ room_key }}.");
|
||||||
@ -137,6 +138,7 @@
|
|||||||
// changing here.
|
// changing here.
|
||||||
openChannel('{{ token }}');
|
openChannel('{{ token }}');
|
||||||
requestTurn('{{ turn_url }}');
|
requestTurn('{{ turn_url }}');
|
||||||
|
stereo = {{ stereo }};
|
||||||
doGetUserMedia();
|
doGetUserMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,15 +294,19 @@
|
|||||||
|
|
||||||
function processSignalingMessage(message) {
|
function processSignalingMessage(message) {
|
||||||
var msg = JSON.parse(message);
|
var msg = JSON.parse(message);
|
||||||
|
|
||||||
if (msg.type === 'offer') {
|
if (msg.type === 'offer') {
|
||||||
// Callee creates PeerConnection
|
// Callee creates PeerConnection
|
||||||
if (!initiator && !started)
|
if (!initiator && !started)
|
||||||
maybeStart();
|
maybeStart();
|
||||||
|
// Set Opus in Stereo, if stereo enabled.
|
||||||
|
if (stereo)
|
||||||
|
msg.sdp = addStereo(msg.sdp);
|
||||||
pc.setRemoteDescription(new RTCSessionDescription(msg));
|
pc.setRemoteDescription(new RTCSessionDescription(msg));
|
||||||
doAnswer();
|
doAnswer();
|
||||||
} else if (msg.type === 'answer' && started) {
|
} else if (msg.type === 'answer' && started) {
|
||||||
|
// Set Opus in Stereo, if stereo enabled.
|
||||||
|
if (stereo)
|
||||||
|
msg.sdp = addStereo(msg.sdp);
|
||||||
pc.setRemoteDescription(new RTCSessionDescription(msg));
|
pc.setRemoteDescription(new RTCSessionDescription(msg));
|
||||||
} else if (msg.type === 'candidate' && started) {
|
} else if (msg.type === 'candidate' && started) {
|
||||||
var candidate = new RTCIceCandidate({sdpMLineIndex:msg.label,
|
var candidate = new RTCIceCandidate({sdpMLineIndex:msg.label,
|
||||||
@ -535,6 +541,39 @@
|
|||||||
return sdp;
|
return sdp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set Opus in stereo if stereo is enabled.
|
||||||
|
function addStereo(sdp) {
|
||||||
|
var sdpLines = sdp.split('\r\n');
|
||||||
|
|
||||||
|
// Find opus payload.
|
||||||
|
for (var i = 0; i < sdpLines.length; i++) {
|
||||||
|
if (sdpLines[i].search('opus/48000') !== -1) {
|
||||||
|
var opusPayload = extractSdp(sdpLines[i], /:(\d+) opus\/48000/i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the payload in fmtp line.
|
||||||
|
for (var i = 0; i < sdpLines.length; i++) {
|
||||||
|
if (sdpLines[i].search('a=fmtp') !== -1) {
|
||||||
|
var payload = extractSdp(sdpLines[i], /a=fmtp:(\d+)/ );
|
||||||
|
if (payload === opusPayload) {
|
||||||
|
var fmtpLineIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No fmtp line found.
|
||||||
|
if (fmtpLineIndex === null)
|
||||||
|
return sdp;
|
||||||
|
|
||||||
|
// append stereo=1 to fmtp line.
|
||||||
|
sdpLines[fmtpLineIndex] = sdpLines[fmtpLineIndex].concat(' stereo=1');
|
||||||
|
|
||||||
|
sdp = sdpLines.join('\r\n');
|
||||||
|
return sdp;
|
||||||
|
}
|
||||||
|
|
||||||
function extractSdp(sdpLine, pattern) {
|
function extractSdp(sdpLine, pattern) {
|
||||||
var result = sdpLine.match(pattern);
|
var result = sdpLine.match(pattern);
|
||||||
return (result && result.length == 2)? result[1]: null;
|
return (result && result.length == 2)? result[1]: null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user