Comparing version 1.2.3 to 1.3.0
@@ -134,14 +134,18 @@ var _ = require('underscore'); | ||
}, | ||
addStream2: function (stream) { | ||
addStream2: function (stream, cb) { | ||
// note that this method is highly experimental and may | ||
// go away without notice | ||
// it is basically a renegotiation-capable version of addStream | ||
cb = cb || function () {}; | ||
var self = this; | ||
this.pc.addStream(stream); | ||
this.pc.handleOffer({type: 'offer', jingle: this.pc.remoteDescription}, function (err) { | ||
console.log('handleOffer', err); | ||
if (err) { | ||
return cb(err); | ||
} | ||
self.pc.answer(function (err, answer) { | ||
console.log('answer', answer); | ||
if (err) { | ||
return cb(err); | ||
} | ||
answer.jingle.contents.forEach(function (content) { | ||
//console.log('answer', content.name, 'msid', content.description.sources[0].parameters[1].value.split(' ')[0]); | ||
delete content.transport; | ||
@@ -156,2 +160,3 @@ delete content.description.payloads; | ||
self.send('source-add', answer.jingle); | ||
cb(); | ||
}); | ||
@@ -163,9 +168,9 @@ }); | ||
}, | ||
removeStream2: function (stream) { | ||
removeStream2: function (stream, cb) { | ||
// note that this method is highly experimental and may | ||
// go away without notice | ||
// it is basically a renegotiation-capable version of removeStream | ||
cb = cb || function () {}; | ||
var self = this; | ||
var desc = this.pc.localDescription; | ||
console.log('remove stream id', stream.id); | ||
desc.contents.forEach(function (content) { | ||
@@ -184,5 +189,10 @@ delete content.transport; | ||
this.pc.handleOffer({type: 'offer', jingle: this.pc.remoteDescription}, function (err) { | ||
console.log('handleOffer', err); | ||
self.pc.answer(function (err, answer) { | ||
console.log('answer', answer); | ||
if (err) { | ||
return cb(err); | ||
} | ||
self.pc.answer(function (err/*, answer*/) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
cb(); | ||
}); | ||
@@ -413,3 +423,4 @@ }); | ||
}, | ||
switchStream: function (oldStream, newStream) { | ||
switchStream: function (oldStream, newStream, cb) { | ||
cb = cb || function () {}; | ||
var self = this; | ||
@@ -424,3 +435,2 @@ // pluck the <source/> to be removed | ||
}); | ||
console.log(JSON.parse(JSON.stringify(desc))); | ||
this.pc.removeStream(oldStream); | ||
@@ -436,8 +446,11 @@ // FIXME: send a source-remove | ||
//console.log(newStream); | ||
this.pc.addStream(newStream); | ||
this.pc.handleOffer({type: 'offer', jingle: this.pc.remoteDescription}, function (err) { | ||
console.log('handleOffer', err); | ||
if (err) { | ||
return cb(err); | ||
} | ||
self.pc.answer(function (err, answer) { | ||
console.log('answer', answer); | ||
if (err) { | ||
return cb(err); | ||
} | ||
answer.jingle.contents.forEach(function (content) { | ||
@@ -447,4 +460,4 @@ delete content.transport; | ||
}); | ||
console.log(JSON.parse(JSON.stringify(answer.jingle))); | ||
self.send('source-add', answer.jingle); | ||
cb(); | ||
}); | ||
@@ -451,0 +464,0 @@ }); |
{ | ||
"name": "jingle", | ||
"description": "Generic Jingle via WebRTC session manager.", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"author": "Lance Stout <lance@andyet.net>", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/otalk/jingle.js/issues", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45377
1103