signal direction in issue #41

This commit is contained in:
Philipp Hancke 2014-02-26 14:43:55 +01:00
parent 69dc3b4ea1
commit cf1dbfbe66
2 changed files with 12 additions and 5 deletions

8
app.js
View File

@ -360,13 +360,17 @@ $(document).bind('setLocalDescription.jingle', function (event, sid) {
// put our ssrcs into presence so other clients can identify our stream
var sess = connection.jingle.sessions[sid];
var newssrcs = {};
var directions = {};
var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
localSDP.media.forEach(function (media) {
var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
if (SDPUtil.find_line(media, 'a=ssrc:')) {
var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
// assumes a single local ssrc
var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
newssrcs[type] = ssrc;
directions[type] = (SDPUtil.find_line(media, 'a=sendrecv') || SDPUtil.find_line(media, 'a=recvonly') || SDPUtil.find_line('a=sendonly') || SDPUtil.find_line('a=inactive') || 'a=sendrecv').substr(2);
}
});
console.log('new ssrcs', newssrcs);
@ -374,7 +378,7 @@ $(document).bind('setLocalDescription.jingle', function (event, sid) {
var i = 0;
Object.keys(newssrcs).forEach(function (mtype) {
i++;
connection.emuc.addMediaToPresence(i, mtype, newssrcs[mtype]);
connection.emuc.addMediaToPresence(i, mtype, newssrcs[mtype], directions[mtype]);
});
if (i > 0) {
connection.emuc.sendPresence();

9
muc.js
View File

@ -210,10 +210,12 @@ Strophe.addConnectionPlugin('emuc', {
}
});
if (sourceNumber > 0)
for (var i = 1; i <= sourceNumber/2; i ++) {
for (var i = 1; i <= sourceNumber/3; i ++) {
pres.c('source',
{type: this.presMap['source' + i + '_type'],
ssrc: this.presMap['source' + i + '_ssrc']}).up();
ssrc: this.presMap['source' + i + '_ssrc'],
direction: this.presMap['source'+ i + '_direction'] || 'sendrecv' }
).up();
}
}
pres.up();
@ -222,12 +224,13 @@ Strophe.addConnectionPlugin('emuc', {
addDisplayNameToPresence: function (displayName) {
this.presMap['displayName'] = displayName;
},
addMediaToPresence: function (sourceNumber, mtype, ssrcs) {
addMediaToPresence: function (sourceNumber, mtype, ssrcs, direction) {
if (!this.presMap['medians'])
this.presMap['medians'] = 'http://estos.de/ns/mjs';
this.presMap['source' + sourceNumber + '_type'] = mtype;
this.presMap['source' + sourceNumber + '_ssrc'] = ssrcs;
this.presMap['source' + sourceNumber + '_direction'] = direction;
},
addPreziToPresence: function (url, currentSlide) {
this.presMap['prezins'] = 'http://jitsi.org/jitmeet/prezi';