|
@@ -1,14 +1,14 @@
|
1
|
|
-
|
2
|
1
|
var SDPUtil = require("./SDPUtil");
|
3
|
2
|
|
4
|
|
-function SDPDiffer(mySDP, otherSDP) {
|
|
3
|
+function SDPDiffer(mySDP, otherSDP)
|
|
4
|
+{
|
5
|
5
|
this.mySDP = mySDP;
|
6
|
6
|
this.otherSDP = otherSDP;
|
7
|
7
|
}
|
8
|
8
|
|
9
|
9
|
/**
|
10
|
|
- * Returns map of MediaChannel that contains only media not contained in <tt>otherSdp</tt>. Mapped by channel idx.
|
11
|
|
- * @param otherSdp the other SDP to check ssrc with.
|
|
10
|
+ * Returns map of MediaChannel that contains media contained in
|
|
11
|
+ * 'mySDP', but not contained in 'otherSdp'. Mapped by channel idx.
|
12
|
12
|
*/
|
13
|
13
|
SDPDiffer.prototype.getNewMedia = function() {
|
14
|
14
|
|
|
@@ -30,7 +30,8 @@ SDPDiffer.prototype.getNewMedia = function() {
|
30
|
30
|
return false;
|
31
|
31
|
}
|
32
|
32
|
else if (this[i] != array[i]) {
|
33
|
|
- // Warning - two different object instances will never be equal: {x:20} != {x:20}
|
|
33
|
+ // Warning - two different object instances will never be
|
|
34
|
+ // equal: {x:20} != {x:20}
|
34
|
35
|
return false;
|
35
|
36
|
}
|
36
|
37
|
}
|
|
@@ -48,10 +49,11 @@ SDPDiffer.prototype.getNewMedia = function() {
|
48
|
49
|
newMedia[othersMediaIdx] = othersMedia;
|
49
|
50
|
return;
|
50
|
51
|
}
|
51
|
|
- // Look for new ssrcs accross the channel
|
|
52
|
+ // Look for new ssrcs across the channel
|
52
|
53
|
Object.keys(othersMedia.ssrcs).forEach(function(ssrc) {
|
53
|
54
|
if(Object.keys(myMedia.ssrcs).indexOf(ssrc) === -1) {
|
54
|
|
- // Allocate channel if we've found ssrc that doesn't exist in our channel
|
|
55
|
+ // Allocate channel if we've found ssrc that doesn't exist in
|
|
56
|
+ // our channel
|
55
|
57
|
if(!newMedia[othersMediaIdx]){
|
56
|
58
|
newMedia[othersMediaIdx] = {
|
57
|
59
|
mediaindex: othersMedia.mediaindex,
|
|
@@ -71,8 +73,9 @@ SDPDiffer.prototype.getNewMedia = function() {
|
71
|
73
|
var matched = false;
|
72
|
74
|
for (var i = 0; i < myMedia.ssrcGroups.length; i++) {
|
73
|
75
|
var mySsrcGroup = myMedia.ssrcGroups[i];
|
74
|
|
- if (otherSsrcGroup.semantics == mySsrcGroup.semantics
|
75
|
|
- && arrayEquals.apply(otherSsrcGroup.ssrcs, [mySsrcGroup.ssrcs])) {
|
|
76
|
+ if (otherSsrcGroup.semantics == mySsrcGroup.semantics &&
|
|
77
|
+ arrayEquals.apply(otherSsrcGroup.ssrcs,
|
|
78
|
+ [mySsrcGroup.ssrcs])) {
|
76
|
79
|
|
77
|
80
|
matched = true;
|
78
|
81
|
break;
|
|
@@ -99,27 +102,21 @@ SDPDiffer.prototype.getNewMedia = function() {
|
99
|
102
|
};
|
100
|
103
|
|
101
|
104
|
/**
|
102
|
|
- * Sends SSRC update IQ.
|
103
|
|
- * @param sdpMediaSsrcs SSRCs map obtained from SDP.getNewMedia. Cntains SSRCs to add/remove.
|
104
|
|
- * @param sid session identifier that will be put into the IQ.
|
105
|
|
- * @param initiator initiator identifier.
|
106
|
|
- * @param toJid destination Jid
|
107
|
|
- * @param isAdd indicates if this is remove or add operation.
|
|
105
|
+ * TODO: document!
|
108
|
106
|
*/
|
109
|
107
|
SDPDiffer.prototype.toJingle = function(modify) {
|
110
|
108
|
var sdpMediaSsrcs = this.getNewMedia();
|
111
|
|
- var self = this;
|
112
|
109
|
|
113
|
|
- // FIXME: only announce video ssrcs since we mix audio and dont need
|
114
|
|
- // the audio ssrcs therefore
|
115
|
110
|
var modified = false;
|
116
|
111
|
Object.keys(sdpMediaSsrcs).forEach(function(mediaindex){
|
117
|
112
|
modified = true;
|
118
|
113
|
var media = sdpMediaSsrcs[mediaindex];
|
119
|
114
|
modify.c('content', {name: media.mid});
|
120
|
115
|
|
121
|
|
- modify.c('description', {xmlns:'urn:xmpp:jingle:apps:rtp:1', media: media.mid});
|
122
|
|
- // FIXME: not completly sure this operates on blocks and / or handles different ssrcs correctly
|
|
116
|
+ modify.c('description',
|
|
117
|
+ {xmlns:'urn:xmpp:jingle:apps:rtp:1', media: media.mid});
|
|
118
|
+ // FIXME: not completely sure this operates on blocks and / or handles
|
|
119
|
+ // different ssrcs correctly
|
123
|
120
|
// generate sources from lines
|
124
|
121
|
Object.keys(media.ssrcs).forEach(function(ssrcNum) {
|
125
|
122
|
var mediaSsrc = media.ssrcs[ssrcNum];
|