Skip to content

Commit

Permalink
Updated multistream demo to use deviceId instead id field, added id f…
Browse files Browse the repository at this point in the history
…ield to deviceList for backwards compatibility
  • Loading branch information
EricDavies committed Oct 17, 2016
1 parent 01cd09b commit 0746889
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 27 deletions.
69 changes: 47 additions & 22 deletions api/easyrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,7 @@ var Easyrtc = function() {
for (var i = 0; i < values.length; i++) {
var source = values[i];
if (source.kind === sourceType) {
source.id = source.deviceId; //backwards compatibility
results.push(source);
}
}
Expand Down Expand Up @@ -3440,7 +3441,7 @@ var Easyrtc = function() {
};
}
if (self._desiredVideoProperties.videoSrcId) {
constraints.video.sourceId = self._desiredVideoProperties.videoSrcId;
constraints.video.deviceId = self._desiredVideoProperties.videoSrcId;
}
// hack for opera
if (Object.keys(constraints.video).length === 0 ) {
Expand All @@ -3463,7 +3464,7 @@ var Easyrtc = function() {
constraints.audio = {mandatory: {}, optional: []};
if (self._desiredAudioProperties.audioSrcId) {
constraints.audio.optional = constraints.audio.optional || [];
constraints.audio.optional.push({sourceId: self._desiredAudioProperties.audioSrcId});
constraints.audio.optional.push({deviceId: self._desiredAudioProperties.audioSrcId});
}
}
}
Expand Down Expand Up @@ -3578,8 +3579,8 @@ var Easyrtc = function() {
};

/** @private
* @param pc_config ice configuration array
* @param optionalStuff peer constraints.
* @param {Array} pc_config ice configuration array
* @param {Object} optionalStuff peer constraints.
*/
this.createRTCPeerConnection = function(pc_config, optionalStuff) {
if (self.supportsPeerConnections()) {
Expand Down Expand Up @@ -3657,28 +3658,28 @@ var Easyrtc = function() {
var acceptancePending = {};

/** @private
* @param caller
* @param helper
* @param {string} caller
* @param {Function} helper
*/
this.acceptCheck = function(caller, helper) {
helper(true);
};

/** @private
* @param easyrtcid
* @param stream
* @param {string} easyrtcid
* @param {HTMLMediaStream} stream
*/
this.streamAcceptor = function(easyrtcid, stream) {
};

/** @private
* @param easyrtcid
* @param {string} easyrtcid
*/
this.onStreamClosed = function(easyrtcid) {
};

/** @private
* @param easyrtcid
* @param {string} easyrtcid
*/
this.callCancelled = function(easyrtcid) {
};
Expand Down Expand Up @@ -5378,9 +5379,9 @@ var Easyrtc = function() {

/**
* @private
* @param easyrtcid
* @param checkAudio
* @param streamName
* @param {string} easyrtcid
* @param {boolean} checkAudio
* @param {string} streamName
*/
function _haveTracks(easyrtcid, checkAudio, streamName) {
var stream, peerConnObj;
Expand Down Expand Up @@ -7247,7 +7248,7 @@ var Easyrtc = function() {
/**
* Checks to see if a particular peer is present in any room.
* If it isn't, we assume it's logged out.
* @param easyrtcid the easyrtcId of the peer.
* @param {string} easyrtcid the easyrtcId of the peer.
*/
this.isPeerInAnyRoom = function(easyrtcid) {
return isPeerInAnyRoom(easyrtcid);
Expand Down Expand Up @@ -7878,7 +7879,7 @@ var Easyrtc = function() {
* Returns true if the ipAddress parameter was the address of a stun server. This is done by checking against information
* collected during peer to peer calls. Don't expect it to work before the first call, or to identify turn servers that aren't
* in the ice config.
* @param ipAddress
* @param {string} ipAddress
* @returns {boolean} true if ip address is known to be that of a stun server, false otherwise.
*/
this.isStunServer = function(ipAddress) {
Expand Down Expand Up @@ -8327,7 +8328,7 @@ var Easyrtc = function() {

return new Easyrtc();

}));
}));

/* global define, module, require, console */
/*!
Expand Down Expand Up @@ -8381,17 +8382,18 @@ return new Easyrtc();
"use strict";

/**
* @mixin Easyrtc_App
* @augments Easyrtc
* This file adds additional methods to Easyrtc for simplifying the
* management of video-mediastream assignment.
* @class Easyrtc_App
*/

/** @private */
var autoAddCloseButtons = true;

/** By default, the easyApp routine sticks a "close" button on top of each caller
* video object that it manages. Call this function(before calling easyApp) to disable that particular feature.
* @alias easyrtc.dontAddCloseButtons
* @memberOf module:EasyRTC/Easyrtc_App
* @function
* @memberOf Easyrtc_App
* @example
* easyrtc.dontAddCloseButtons();
*/
Expand Down Expand Up @@ -8505,6 +8507,8 @@ return new Easyrtc();
/** Sets an event handler that gets called when an incoming MediaStream is assigned
* to a video object. The name is poorly chosen and reflects a simpler era when you could
* only have one media stream per peer connection.
* @function
* @memberOf Easyrtc_App
* @param {Function} cb has the signature function(easyrtcid, slot){}
* @example
* easyrtc.setOnCall( function(easyrtcid, slot){
Expand All @@ -8521,6 +8525,8 @@ return new Easyrtc();
* The slot is parameter is the index into the array of video ids.
* Note: if you call easyrtc.getConnectionCount() from inside your callback
* it's count will reflect the number of connections before the hangup started.
* @function
* @memberOf Easyrtc_App
* @param {Function} cb has the signature function(easyrtcid, slot){}
* @example
* easyrtc.setOnHangup( function(easyrtcid, slot){
Expand All @@ -8531,6 +8537,13 @@ return new Easyrtc();
onHangup = cb;
};

/**
* Get the easyrtcid of the ith caller, starting at 0.
* @function
* @memberOf Easyrtc_App
* @param {number} i
* @returns {String}
*/
easyrtc.getIthCaller = function(i) {
if (i < 0 || i >= videoIdsP.length) {
return null;
Expand All @@ -8539,6 +8552,14 @@ return new Easyrtc();
return getCallerOfVideo(vid);
};

/**
* This is the complement of getIthCaller. Given an easyrtcid,
* it determines which slot the easyrtc is in.
* @function
* @memberOf Easyrtc_App
* @param {string} easyrtcid
* @returns {number} or -1 if the easyrtcid is not a caller.
*/
easyrtc.getSlotOfCaller = function(easyrtcid) {
var i;
for (i = 0; i < numPEOPLE; i++) {
Expand Down Expand Up @@ -8666,6 +8687,8 @@ return new Easyrtc();
* side effects is to add hangup buttons to the remote video objects, buttons
* that only appear when you hover over them with the mouse cursor. This method will also add the
* easyrtcMirror class to the monitor video object so that it behaves like a mirror.
* @function
* @memberOf Easyrtc_App
* @param {String} applicationName - name of the application.
* @param {String} monitorVideoId - the id of the video object used for monitoring the local stream.
* @param {Array} videoIds - an array of video object ids (strings)
Expand Down Expand Up @@ -8704,6 +8727,8 @@ return new Easyrtc();

/** Sets an event handler that gets called when a connection to the signaling
* server has or has not been made. Can only be called after calling easyrtc.easyApp.
* @function
* @memberOf Easyrtc_App
* @param {Function} gotConnectionCB has the signature (gotConnection, errorText)
* @example
* easyrtc.setGotConnection( function(gotConnection, errorText){
Expand Down Expand Up @@ -8773,5 +8798,5 @@ return new Easyrtc();

return easyrtc;

}));

})); // end of module wrapper
;
5 changes: 3 additions & 2 deletions api/easyrtc_int.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ var Easyrtc = function() {
for (var i = 0; i < values.length; i++) {
var source = values[i];
if (source.kind === sourceType) {
source.id = source.deviceId; //backwards compatibility
results.push(source);
}
}
Expand Down Expand Up @@ -757,7 +758,7 @@ var Easyrtc = function() {
};
}
if (self._desiredVideoProperties.videoSrcId) {
constraints.video.sourceId = self._desiredVideoProperties.videoSrcId;
constraints.video.deviceId = self._desiredVideoProperties.videoSrcId;
}
// hack for opera
if (Object.keys(constraints.video).length === 0 ) {
Expand All @@ -780,7 +781,7 @@ var Easyrtc = function() {
constraints.audio = {mandatory: {}, optional: []};
if (self._desiredAudioProperties.audioSrcId) {
constraints.audio.optional = constraints.audio.optional || [];
constraints.audio.optional.push({sourceId: self._desiredAudioProperties.audioSrcId});
constraints.audio.optional.push({deviceId: self._desiredAudioProperties.audioSrcId});
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion demos/js/demo_multistream.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function connect() {
var videoEle = videoSrcList[i];
var videoLabel = (videoSrcList[i].label &&videoSrcList[i].label.length > 0)?
(videoSrcList[i].label):("src_" + i);
addSrcButton(videoLabel, videoSrcList[i].id);
addSrcButton(videoLabel, videoSrcList[i].deviceId);
}
//
// add an extra button for screen sharing
Expand Down
2 changes: 1 addition & 1 deletion demos/js/demo_multistream_iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function connect() {
var videoEle = videoSrcList[i];
var videoLabel = (videoSrcList[i].label && videoSrcList[i].label.length > 0) ?
(videoSrcList[i].label) : ("src_" + i);
addSrcButton(videoLabel, videoSrcList[i].id);
addSrcButton(videoLabel, videoSrcList[i].deviceId);
}
});
//
Expand Down
2 changes: 1 addition & 1 deletion demos/js/demo_multistream_no_iframe.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function connect() {
var videoEle = videoSrcList[i];
var videoLabel = (videoSrcList[i].label && videoSrcList[i].label.length > 0) ?
(videoSrcList[i].label) : ("src_" + i);
addSrcButton(videoLabel, videoSrcList[i].id);
addSrcButton(videoLabel, videoSrcList[i].deviceId);
}
});
//
Expand Down

0 comments on commit 0746889

Please sign in to comment.