Removes the sid property from MediaStream (how did we end up having a

Jingle session ID in MediaStream and passing it around in the UI?)
This commit is contained in:
Boris Grozev 2015-10-01 15:10:55 -05:00
parent 4934779187
commit ebdd91df4e
6 changed files with 16 additions and 20 deletions

View File

@ -6,13 +6,12 @@ var MediaStreamType = require("../../service/RTC/MediaStreamTypes");
* *
* @param data the data object from which we obtain the stream, * @param data the data object from which we obtain the stream,
* the peerjid, etc. * the peerjid, etc.
* @param sid the session id
* @param ssrc the ssrc corresponding to this MediaStream * @param ssrc the ssrc corresponding to this MediaStream
* @param mute the whether this MediaStream is muted * @param mute the whether this MediaStream is muted
* *
* @constructor * @constructor
*/ */
function MediaStream(data, sid, ssrc, browser, eventEmitter, mute) { function MediaStream(data, ssrc, browser, eventEmitter, muted) {
// XXX(gp) to minimize headaches in the future, we should build our // XXX(gp) to minimize headaches in the future, we should build our
// abstractions around tracks and not streams. ORTC is track based API. // abstractions around tracks and not streams. ORTC is track based API.
@ -24,14 +23,13 @@ function MediaStream(data, sid, ssrc, browser, eventEmitter, mute) {
// Also, we should be able to associate multiple SSRCs with a MediaTrack as // Also, we should be able to associate multiple SSRCs with a MediaTrack as
// a track might have an associated RTX and FEC sources. // a track might have an associated RTX and FEC sources.
this.sid = sid;
this.stream = data.stream; this.stream = data.stream;
this.peerjid = data.peerjid; this.peerjid = data.peerjid;
this.videoType = data.videoType; this.videoType = data.videoType;
this.ssrc = ssrc; this.ssrc = ssrc;
this.type = (this.stream.getVideoTracks().length > 0)? this.type = (this.stream.getVideoTracks().length > 0)?
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE; MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
this.muted = mute; this.muted = muted;
this.eventEmitter = eventEmitter; this.eventEmitter = eventEmitter;
} }

View File

@ -101,7 +101,7 @@ var RTC = {
} }
} }
}, },
createRemoteStream: function (data, sid, ssrc) { createRemoteStream: function (data, ssrc) {
var jid = data.peerjid || APP.xmpp.myJid(); var jid = data.peerjid || APP.xmpp.myJid();
// check the video muted state from last stored presence if any // check the video muted state from last stored presence if any
@ -111,7 +111,7 @@ var RTC = {
muted = pres.videoMuted; muted = pres.videoMuted;
} }
var remoteStream = new MediaStream(data, sid, ssrc, var remoteStream = new MediaStream(data, ssrc,
RTCBrowserType.getBrowserType(), eventEmitter, muted); RTCBrowserType.getBrowserType(), eventEmitter, muted);
if(!this.remoteStreams[jid]) { if(!this.remoteStreams[jid]) {

View File

@ -204,13 +204,13 @@ RemoteVideo.prototype.waitForPlayback = function (sel, stream) {
sel[0].onplaying = onPlayingHandler; sel[0].onplaying = onPlayingHandler;
}; };
RemoteVideo.prototype.addRemoteStreamElement = function (sid, stream) { RemoteVideo.prototype.addRemoteStreamElement = function (stream) {
if (!this.container) if (!this.container)
return; return;
var self = this; var self = this;
var isVideo = stream.getVideoTracks().length > 0; var isVideo = stream.getVideoTracks().length > 0;
var streamElement = SmallVideo.createStreamElement(sid, stream); var streamElement = SmallVideo.createStreamElement(stream);
var newElementId = streamElement.id; var newElementId = streamElement.id;
// Put new stream element always in front // Put new stream element always in front

View File

@ -102,20 +102,21 @@ SmallVideo.prototype.setPresenceStatus = function (statusMsg) {
}; };
/** /**
* Creates an audio or video stream element. * Creates an audio or video element for a particular MediaStream.
*/ */
SmallVideo.createStreamElement = function (sid, stream) { SmallVideo.createStreamElement = function (stream) {
var isVideo = stream.getVideoTracks().length > 0; var isVideo = stream.getVideoTracks().length > 0;
var element = isVideo ? document.createElement('video') var element = isVideo ? document.createElement('video')
: document.createElement('audio'); : document.createElement('audio');
var id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') + sid + '_' +
APP.RTC.getStreamID(stream);
element.id = id;
if (!RTCBrowserType.isIExplorer()) { if (!RTCBrowserType.isIExplorer()) {
element.autoplay = true; element.autoplay = true;
} }
element.id = (isVideo ? 'remoteVideo_' : 'remoteAudio_') +
APP.RTC.getStreamID(stream);
element.oncontextmenu = function () { return false; }; element.oncontextmenu = function () { return false; };
return element; return element;

View File

@ -175,9 +175,7 @@ var VideoLayout = (function (my) {
var resourceJid = Strophe.getResourceFromJid(stream.peerjid); var resourceJid = Strophe.getResourceFromJid(stream.peerjid);
remoteVideos[resourceJid].addRemoteStreamElement( remoteVideos[resourceJid].addRemoteStreamElement(
stream.sid, stream.getOriginalStream());
stream.getOriginalStream(),
stream.ssrc);
} }
}; };

View File

@ -122,9 +122,8 @@ JingleSessionPC.prototype.doInitialize = function () {
self.remoteStreamAdded(event); self.remoteStreamAdded(event);
}; };
this.peerconnection.onremovestream = function (event) { this.peerconnection.onremovestream = function (event) {
// Remove the stream from remoteStreams // Remove the stream from remoteStreams?
// FIXME: remotestreamremoved.jingle not defined anywhere(unused) console.log("We are ignoring a removestream event: " + event);
$(document).trigger('remotestreamremoved.jingle', [event, self.sid]);
}; };
this.peerconnection.onsignalingstatechange = function (event) { this.peerconnection.onsignalingstatechange = function (event) {
if (!(self && self.peerconnection)) return; if (!(self && self.peerconnection)) return;
@ -1487,7 +1486,7 @@ JingleSessionPC.prototype.remoteStreamAdded = function (event) {
} }
} }
APP.RTC.createRemoteStream(event, this.sid, ssrc); APP.RTC.createRemoteStream(event, ssrc);
}; };
module.exports = JingleSessionPC; module.exports = JingleSessionPC;