From cf1dbfbe6621d49ec4a7ca2e310c8e63317691b0 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Wed, 26 Feb 2014 14:43:55 +0100 Subject: [PATCH] signal direction in issue #41 --- app.js | 8 ++++++-- muc.js | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 71b797fc9..fe938d13c 100644 --- a/app.js +++ b/app.js @@ -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(); diff --git a/muc.js b/muc.js index 792f12fd1..c049661e6 100644 --- a/muc.js +++ b/muc.js @@ -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';