Merge audio and video on the receiver's side.

pull/404/head
paweldomas 9 years ago
parent cd1e761699
commit 7abe02d756
  1. 53
      modules/xmpp/JingleSessionPC.js
  2. 6
      modules/xmpp/strophe.jingle.js

@ -556,6 +556,50 @@ JingleSessionPC.prototype.getSsrcOwner = function (ssrc) {
return this.ssrcOwners[ssrc];
};
function copyParamAttr(dstElem, srcElem, name) {
var srcSelector = $(srcElem).find('parameter[name="' + name + '"]');
var dstSelector = $(dstElem).find('parameter[name="' + name + '"]');
if (srcSelector.length && dstSelector.length) {
dstSelector[0].setAttribute('value', srcSelector[0].getAttribute('value'));
} else {
console.error("did not copy " + name + " from|to ", srcElem, dstElem);
}
}
JingleSessionPC.prototype.mungeRemoteMsid = function (jingle) {
var videoContent = $(jingle).find(">content[name='video']");
console.info("Video contents", videoContent);
var audioContent = $(jingle).find(">content[name='audio']");
console.info("Audio contents", audioContent);
var videoSSRCInfos = videoContent.find('description>source>ssrc-info');
console.info("Video SSRC infos: ", videoSSRCInfos);
var videoSSRCs = {};
videoSSRCInfos.each(function (idx, ssrcInfo) {
var owner = ssrcInfo.getAttribute('owner');
if (owner !== 'jvb') {
console.info("Got video SSRC owner: " + owner + " of: ", ssrcInfo.parentNode);
videoSSRCs[owner] = ssrcInfo.parentNode;
}
});
Object.keys(videoSSRCs).forEach(function (owner) {
console.info("Looking for audio SSRC owned by: " + owner);
var audioSSRCInfo = audioContent.find('description>source>ssrc-info[owner="' + owner + '"]');
if (audioSSRCInfo.length) {
var audioSSRC = audioSSRCInfo[0].parentNode;
console.info("Found corresponding audio SSRC: ", audioSSRC);
var videoSSRC = videoSSRCs[owner];
console.info("Will copy fields from: ", videoSSRC);
copyParamAttr(audioSSRC, videoSSRC, 'msid');
copyParamAttr(audioSSRC, videoSSRC, 'mslabel');
copyParamAttr(audioSSRC, videoSSRC, 'label');
}
});
return jingle;
};
JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
this.remoteSDP = new SDP('');
if (config.webrtcIceTcpDisable) {
@ -564,7 +608,8 @@ JingleSessionPC.prototype.setRemoteDescription = function (elem, desctype) {
if (config.webrtcIceUdpDisable) {
this.remoteSDP.removeUdpCandidates = true;
}
elem = this.mungeRemoteMsid(elem);
console.info("Jingle after munge: ", elem[0]);
this.remoteSDP.fromJingle(elem);
this.readSsrcInfo($(elem).find(">content"));
if (this.peerconnection.remoteDescription !== null) {
@ -881,6 +926,12 @@ JingleSessionPC.prototype.addSource = function (elem) {
console.log('addssrc', new Date().getTime());
console.log('ice', this.peerconnection.iceConnectionState);
elem = this.mungeRemoteMsid(elem);
console.info("SSRC-ADD Jingle after munge: ", elem[0]);
elem = $(elem).find('>content');
console.info("ELEM: ", elem);
this.readSsrcInfo(elem);
var sdp = new SDP(this.peerconnection.remoteDescription.sdp);

@ -96,7 +96,7 @@ module.exports = function(XMPP, eventEmitter) {
switch (action) {
case 'session-initiate':
console.log("(TIME) received session-initiate:\t",
window.performance.now());
window.performance.now(), iq);
var startMuted = $(iq).find('jingle>startmuted');
if (startMuted && startMuted.length > 0) {
var audioMuted = startMuted.attr("audio");
@ -176,10 +176,12 @@ module.exports = function(XMPP, eventEmitter) {
break;
case 'addsource': // FIXME: proprietary, un-jingleish
case 'source-add': // FIXME: proprietary
sess.addSource($(iq).find('>jingle>content'));
console.info("source-add", iq);
sess.addSource($(iq).find('>jingle'));
break;
case 'removesource': // FIXME: proprietary, un-jingleish
case 'source-remove': // FIXME: proprietary
console.info("source-remove", iq);
sess.removeSource($(iq).find('>jingle>content'));
break;
default:

Loading…
Cancel
Save