Browse Source

Move stream id creation to PeerCall.

That way the streams can be registered internally and properly cleaned up on hangup.
pull/283/head
Joachim Bauch 9 years ago
parent
commit
2e7b51a15a
  1. 12
      static/js/directives/audiovideo.js
  2. 12
      static/js/mediastream/peercall.js

12
static/js/directives/audiovideo.js

@ -31,12 +31,6 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -31,12 +31,6 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
var streams = {};
var calls = {};
var getStreamId = function(stream, currentcall) {
var id = currentcall.id + "-" + stream.id;
//console.log("Created stream ID", id);
return id;
};
$scope.container = $element[0];
$scope.layoutparent = $element.parent();
@ -58,7 +52,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -58,7 +52,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
$scope.addRemoteStream = function(stream, currentcall) {
var id = getStreamId(stream, currentcall);
var id = currentcall.getStreamId(stream);
console.log("New stream", id);
if (streams.hasOwnProperty(id)) {
@ -76,7 +70,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -76,7 +70,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
callscope = calls[currentcall.id];
if (callscope.dummy) {
// Current call is marked as dummy. Use it directly.
var dummyId = getStreamId(callscope.dummy, currentcall);
var dummyId = currentcall.getStreamId(callscope.dummy);
subscope = streams[dummyId];
if (subscope) {
subscope.dummy = null;
@ -198,7 +192,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -198,7 +192,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
$scope.removeRemoteStream = function(stream, currentcall) {
var id = getStreamId(stream, currentcall);
var id = currentcall.getStreamId(stream);
console.log("Stream removed", id);
var subscope = streams[id];

12
static/js/mediastream/peercall.js

@ -52,6 +52,18 @@ define(['jquery', 'underscore', 'mediastream/utils', 'mediastream/peerconnection @@ -52,6 +52,18 @@ define(['jquery', 'underscore', 'mediastream/utils', 'mediastream/peerconnection
//console.log("Set initiate", this.initiate, this);
};
PeerCall.prototype.getStreamId = function(stream) {
var streamid = stream.id;
var id = this.id + "-" + streamid;
if (!this.stream.hasOwnProperty(streamid) || this.streams[streamid] === stream) {
this.streams[streamid] = stream;
} else {
console.warn("A different stream is already registered, not replacing", stream, this.streams[stream.id])
}
//console.log("Created stream ID", id);
return id;
};
PeerCall.prototype.createPeerConnection = function(success_cb, error_cb) {
var peerconnection = this.peerconnection = new PeerConnection(this.webrtc, this);

Loading…
Cancel
Save