Removes local streams from the connection object.
This commit is contained in:
parent
faaf24d3c4
commit
e6fbb0934e
61
app.js
61
app.js
|
@ -58,11 +58,6 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect(jid, password) {
|
function connect(jid, password) {
|
||||||
var localAudio, localVideo;
|
|
||||||
if (connection && connection.jingle) {
|
|
||||||
localAudio = connection.jingle.localAudio;
|
|
||||||
localVideo = connection.jingle.localVideo;
|
|
||||||
}
|
|
||||||
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
||||||
|
|
||||||
var settings = UI.getSettings();
|
var settings = UI.getSettings();
|
||||||
|
@ -86,8 +81,6 @@ function connect(jid, password) {
|
||||||
if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
|
if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
|
||||||
connection.jingle.pc_constraints.optional.push({googIPv6: true});
|
connection.jingle.pc_constraints.optional.push({googIPv6: true});
|
||||||
}
|
}
|
||||||
if (localAudio) connection.jingle.localAudio = localAudio;
|
|
||||||
if (localVideo) connection.jingle.localVideo = localVideo;
|
|
||||||
|
|
||||||
if(!password)
|
if(!password)
|
||||||
password = document.getElementById('password').value;
|
password = document.getElementById('password').value;
|
||||||
|
@ -127,7 +120,7 @@ function connect(jid, password) {
|
||||||
|
|
||||||
function maybeDoJoin() {
|
function maybeDoJoin() {
|
||||||
if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
||||||
&& (connection.jingle.localAudio || connection.jingle.localVideo)) {
|
&& (RTC.localAudio || RTC.localVideo)) {
|
||||||
doJoin();
|
doJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,7 +293,7 @@ function waitForPresence(data, sid) {
|
||||||
if (isVideo &&
|
if (isVideo &&
|
||||||
data.peerjid && sess.peerjid === data.peerjid &&
|
data.peerjid && sess.peerjid === data.peerjid &&
|
||||||
data.stream.getVideoTracks().length === 0 &&
|
data.stream.getVideoTracks().length === 0 &&
|
||||||
connection.jingle.localVideo.getVideoTracks().length > 0) {
|
RTC.localVideo.getTracks().length > 0) {
|
||||||
//
|
//
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
sendKeyframe(sess.peerconnection);
|
sendKeyframe(sess.peerconnection);
|
||||||
|
@ -621,11 +614,9 @@ function isVideoSrcDesktop(jid) {
|
||||||
* contrast to an automatic decision taken by the application logic)
|
* contrast to an automatic decision taken by the application logic)
|
||||||
*/
|
*/
|
||||||
function setVideoMute(mute, options) {
|
function setVideoMute(mute, options) {
|
||||||
if (connection && connection.jingle.localVideo) {
|
if (connection && RTC.localVideo) {
|
||||||
var session = activecall;
|
if (activecall) {
|
||||||
|
activecall.setVideoMute(
|
||||||
if (session) {
|
|
||||||
session.setVideoMute(
|
|
||||||
mute,
|
mute,
|
||||||
function (mute) {
|
function (mute) {
|
||||||
var video = $('#video');
|
var video = $('#video');
|
||||||
|
@ -659,12 +650,8 @@ $(document).on('inlastnchanged', function (event, oldValue, newValue) {
|
||||||
function toggleVideo() {
|
function toggleVideo() {
|
||||||
buttonClick("#video", "icon-camera icon-camera-disabled");
|
buttonClick("#video", "icon-camera icon-camera-disabled");
|
||||||
|
|
||||||
if (connection && connection.jingle.localVideo) {
|
if (connection && activecall && RTC.localVideo ) {
|
||||||
var session = activecall;
|
setVideoMute(!RTC.localVideo.isMuted());
|
||||||
|
|
||||||
if (session) {
|
|
||||||
setVideoMute(!session.isVideoMute());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,14 +659,14 @@ function toggleVideo() {
|
||||||
* Mutes / unmutes audio for the local participant.
|
* Mutes / unmutes audio for the local participant.
|
||||||
*/
|
*/
|
||||||
function toggleAudio() {
|
function toggleAudio() {
|
||||||
setAudioMuted(!isAudioMuted());
|
setAudioMuted(!RTC.localAudio.isMuted());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets muted audio state for the local participant.
|
* Sets muted audio state for the local participant.
|
||||||
*/
|
*/
|
||||||
function setAudioMuted(mute) {
|
function setAudioMuted(mute) {
|
||||||
if (!(connection && connection.jingle.localAudio)) {
|
if (!(connection && RTC.localAudio)) {
|
||||||
preMuted = mute;
|
preMuted = mute;
|
||||||
// We still click the button.
|
// We still click the button.
|
||||||
buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
||||||
|
@ -693,7 +680,7 @@ function setAudioMuted(mute) {
|
||||||
forceMuted = false;
|
forceMuted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mute == isAudioMuted()) {
|
if (mute == RTC.localAudio.isMuted()) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -701,12 +688,7 @@ function setAudioMuted(mute) {
|
||||||
// It is not clear what is the right way to handle multiple tracks.
|
// It is not clear what is the right way to handle multiple tracks.
|
||||||
// So at least make sure that they are all muted or all unmuted and
|
// So at least make sure that they are all muted or all unmuted and
|
||||||
// that we send presence just once.
|
// that we send presence just once.
|
||||||
var localAudioTracks = connection.jingle.localAudio.getAudioTracks();
|
RTC.localAudio.mute();
|
||||||
if (localAudioTracks.length > 0) {
|
|
||||||
for (var idx = 0; idx < localAudioTracks.length; idx++) {
|
|
||||||
localAudioTracks[idx].enabled = !mute;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// isMuted is the opposite of audioEnabled
|
// isMuted is the opposite of audioEnabled
|
||||||
connection.emuc.addAudioInfoToPresence(mute);
|
connection.emuc.addAudioInfoToPresence(mute);
|
||||||
connection.emuc.sendPresence();
|
connection.emuc.sendPresence();
|
||||||
|
@ -715,19 +697,6 @@ function setAudioMuted(mute) {
|
||||||
buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the audio is muted or not.
|
|
||||||
* @returns {boolean} true if audio is muted and false if not.
|
|
||||||
*/
|
|
||||||
function isAudioMuted()
|
|
||||||
{
|
|
||||||
var localAudio = connection.jingle.localAudio;
|
|
||||||
for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
|
|
||||||
if(localAudio.getAudioTracks()[idx].enabled === true)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
@ -780,11 +749,11 @@ function disposeConference(onUnload) {
|
||||||
if (handler && handler.peerconnection) {
|
if (handler && handler.peerconnection) {
|
||||||
// FIXME: probably removing streams is not required and close() should
|
// FIXME: probably removing streams is not required and close() should
|
||||||
// be enough
|
// be enough
|
||||||
if (connection.jingle.localAudio) {
|
if (RTC.localAudio) {
|
||||||
handler.peerconnection.removeStream(connection.jingle.localAudio, onUnload);
|
handler.peerconnection.removeStream(RTC.localAudio.getOriginalStream(), onUnload);
|
||||||
}
|
}
|
||||||
if (connection.jingle.localVideo) {
|
if (RTC.localVideo) {
|
||||||
handler.peerconnection.removeStream(connection.jingle.localVideo, onUnload);
|
handler.peerconnection.removeStream(RTC.localVideo.getOriginalStream(), onUnload);
|
||||||
}
|
}
|
||||||
handler.peerconnection.close();
|
handler.peerconnection.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,9 +254,9 @@ function streamSwitchDone() {
|
||||||
|
|
||||||
function newStreamCreated(stream) {
|
function newStreamCreated(stream) {
|
||||||
|
|
||||||
var oldStream = connection.jingle.localVideo;
|
var oldStream = RTC.localVideo.getOriginalStream();
|
||||||
|
|
||||||
connection.jingle.localVideo = stream;
|
RTC.localVideo.stream = stream;
|
||||||
|
|
||||||
UI.changeLocalVideo(stream, !isUsingScreenStream);
|
UI.changeLocalVideo(stream, !isUsingScreenStream);
|
||||||
|
|
||||||
|
|
16
index.html
16
index.html
|
@ -15,9 +15,9 @@
|
||||||
<script src="libs/strophe/strophe.min.js?v=1"></script>
|
<script src="libs/strophe/strophe.min.js?v=1"></script>
|
||||||
<script src="libs/strophe/strophe.disco.min.js?v=1"></script>
|
<script src="libs/strophe/strophe.disco.min.js?v=1"></script>
|
||||||
<script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
|
<script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.js?v=2"></script>
|
<script src="libs/strophe/strophe.jingle.js?v=3"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.sdp.js?v=4"></script>
|
<script src="libs/strophe/strophe.jingle.sdp.js?v=5"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.session.js?v=4"></script>
|
<script src="libs/strophe/strophe.jingle.session.js?v=5"></script>
|
||||||
<script src="libs/strophe/strophe.util.js"></script>
|
<script src="libs/strophe/strophe.util.js"></script>
|
||||||
<script src="libs/jquery-ui.js"></script>
|
<script src="libs/jquery-ui.js"></script>
|
||||||
<script src="libs/rayo.js?v=1"></script>
|
<script src="libs/rayo.js?v=1"></script>
|
||||||
|
@ -29,22 +29,22 @@
|
||||||
<script src="service/RTC/RTCBrowserType.js?v=1"></script>
|
<script src="service/RTC/RTCBrowserType.js?v=1"></script>
|
||||||
<script src="service/RTC/StreamEventTypes.js?v=1"></script>
|
<script src="service/RTC/StreamEventTypes.js?v=1"></script>
|
||||||
<script src="service/RTC/MediaStreamTypes.js?v=1"></script>
|
<script src="service/RTC/MediaStreamTypes.js?v=1"></script>
|
||||||
<script src="libs/modules/simulcast.bundle.js?v=1"></script>
|
<script src="libs/modules/simulcast.bundle.js?v=2"></script>
|
||||||
<script src="libs/modules/connectionquality.bundle.js?v=1"></script>
|
<script src="libs/modules/connectionquality.bundle.js?v=1"></script>
|
||||||
<script src="libs/modules/UI.bundle.js?v=2"></script>
|
<script src="libs/modules/UI.bundle.js?v=3"></script>
|
||||||
<script src="libs/modules/statistics.bundle.js?v=1"></script>
|
<script src="libs/modules/statistics.bundle.js?v=1"></script>
|
||||||
<script src="libs/modules/RTC.bundle.js?v=1"></script>
|
<script src="libs/modules/RTC.bundle.js?v=2"></script>
|
||||||
<script src="muc.js?v=17"></script><!-- simple MUC library -->
|
<script src="muc.js?v=17"></script><!-- simple MUC library -->
|
||||||
<script src="estos_log.js?v=2"></script><!-- simple stanza logger -->
|
<script src="estos_log.js?v=2"></script><!-- simple stanza logger -->
|
||||||
<script src="desktopsharing.js?v=3"></script><!-- desktop sharing -->
|
<script src="desktopsharing.js?v=3"></script><!-- desktop sharing -->
|
||||||
<script src="app.js?v=24"></script><!-- application logic -->
|
<script src="app.js?v=25"></script><!-- application logic -->
|
||||||
<script src="libs/modules/API.bundle.js?v=1"></script>
|
<script src="libs/modules/API.bundle.js?v=1"></script>
|
||||||
<script src="util.js?v=7"></script><!-- utility functions -->
|
<script src="util.js?v=7"></script><!-- utility functions -->
|
||||||
<script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
|
<script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
|
||||||
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
<script src="analytics.js?v=1"></script><!-- google analytics plugin -->
|
||||||
<script src="moderator.js?v=2"></script><!-- media stream -->
|
<script src="moderator.js?v=2"></script><!-- media stream -->
|
||||||
<script src="tracking.js?v=1"></script><!-- tracking -->
|
<script src="tracking.js?v=1"></script><!-- tracking -->
|
||||||
<script src="keyboard_shortcut.js?v=3"></script>
|
<script src="keyboard_shortcut.js?v=4"></script>
|
||||||
<link rel="stylesheet" href="css/font.css?v=6"/>
|
<link rel="stylesheet" href="css/font.css?v=6"/>
|
||||||
<link rel="stylesheet" href="css/toastr.css?v=1">
|
<link rel="stylesheet" href="css/toastr.css?v=1">
|
||||||
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>
|
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>
|
||||||
|
|
|
@ -19,7 +19,7 @@ var KeyboardShortcut = (function(my) {
|
||||||
84: {
|
84: {
|
||||||
character: "T",
|
character: "T",
|
||||||
function: function() {
|
function: function() {
|
||||||
if(!isAudioMuted()) {
|
if(!RTC.localAudio.isMuted()) {
|
||||||
toggleAudio();
|
toggleAudio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ var KeyboardShortcut = (function(my) {
|
||||||
window.onkeydown = function(e) {
|
window.onkeydown = function(e) {
|
||||||
if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
|
if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
|
||||||
if(e.which === "T".charCodeAt(0)) {
|
if(e.which === "T".charCodeAt(0)) {
|
||||||
if(isAudioMuted()) {
|
if(RTC.localAudio.isMuted()) {
|
||||||
toggleAudio();
|
toggleAudio();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,8 +243,20 @@ function LocalStream(stream, type, eventEmitter)
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.eventEmitter = eventEmitter;
|
this.eventEmitter = eventEmitter;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
if(type == "audio")
|
||||||
|
{
|
||||||
|
this.getTracks = function () {
|
||||||
|
return self.stream.getAudioTracks();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.getTracks = function () {
|
||||||
|
return self.stream.getVideoTracks();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
this.stream.onended = function()
|
this.stream.onended = function()
|
||||||
{
|
{
|
||||||
self.streamEnded();
|
self.streamEnded();
|
||||||
|
@ -262,31 +274,32 @@ LocalStream.prototype.getOriginalStream = function()
|
||||||
|
|
||||||
LocalStream.prototype.isAudioStream = function () {
|
LocalStream.prototype.isAudioStream = function () {
|
||||||
return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
|
return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
LocalStream.prototype.mute = function()
|
LocalStream.prototype.mute = function()
|
||||||
{
|
{
|
||||||
var ismuted = false;
|
var ismuted = false;
|
||||||
var tracks = [];
|
var tracks = this.getTracks();
|
||||||
if(this.type = "audio")
|
|
||||||
{
|
|
||||||
tracks = this.stream.getAudioTracks();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tracks = this.stream.getVideoTracks();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var idx = 0; idx < tracks.length; idx++) {
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
ismuted = !tracks[idx].enabled;
|
ismuted = !tracks[idx].enabled;
|
||||||
tracks[idx].enabled = !tracks[idx].enabled;
|
tracks[idx].enabled = ismuted;
|
||||||
}
|
}
|
||||||
return ismuted;
|
return ismuted;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
LocalStream.prototype.setMute = function(mute)
|
||||||
|
{
|
||||||
|
var tracks = this.getTracks();
|
||||||
|
|
||||||
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
|
tracks[idx].enabled = mute;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LocalStream.prototype.isMuted = function () {
|
LocalStream.prototype.isMuted = function () {
|
||||||
var tracks = [];
|
var tracks = [];
|
||||||
if(this.type = "audio")
|
if(this.type == "audio")
|
||||||
{
|
{
|
||||||
tracks = this.stream.getAudioTracks();
|
tracks = this.stream.getAudioTracks();
|
||||||
}
|
}
|
||||||
|
@ -301,6 +314,12 @@ LocalStream.prototype.isMuted = function () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocalStream.prototype.getId = function () {
|
||||||
|
return this.stream.getTracks()[0].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = LocalStream;
|
module.exports = LocalStream;
|
||||||
|
|
||||||
},{}],3:[function(require,module,exports){
|
},{}],3:[function(require,module,exports){
|
||||||
|
@ -394,7 +413,10 @@ var RTC = {
|
||||||
createLocalStream: function (stream, type) {
|
createLocalStream: function (stream, type) {
|
||||||
|
|
||||||
var localStream = new LocalStream(stream, type, eventEmitter);
|
var localStream = new LocalStream(stream, type, eventEmitter);
|
||||||
this.localStreams.push(localStream);
|
//in firefox we have only one stream object
|
||||||
|
if(this.localStreams.length == 0 ||
|
||||||
|
this.localStreams[0].getOriginalStream() != stream)
|
||||||
|
this.localStreams.push(localStream);
|
||||||
if(type == "audio")
|
if(type == "audio")
|
||||||
{
|
{
|
||||||
this.localAudio = localStream;
|
this.localAudio = localStream;
|
||||||
|
@ -484,6 +506,16 @@ var RTC = {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
switchVideoStreams: function (new_stream) {
|
||||||
|
this.localVideo.stream = new_stream;
|
||||||
|
|
||||||
|
this.localStreams = [];
|
||||||
|
|
||||||
|
//in firefox we have only one stream object
|
||||||
|
if(this.localAudio.getOriginalStream() != new_stream)
|
||||||
|
this.localStreams.push(this.localAudio);
|
||||||
|
this.localStreams.push(this.localVideo);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -84,7 +84,7 @@ function registerListeners() {
|
||||||
if(jid === statistics.LOCAL_JID)
|
if(jid === statistics.LOCAL_JID)
|
||||||
{
|
{
|
||||||
resourceJid = AudioLevels.LOCAL_LEVEL;
|
resourceJid = AudioLevels.LOCAL_LEVEL;
|
||||||
if(isAudioMuted())
|
if(RTC.localAudio.isMuted())
|
||||||
{
|
{
|
||||||
audioLevel = 0;
|
audioLevel = 0;
|
||||||
}
|
}
|
||||||
|
@ -4591,12 +4591,10 @@ var VideoLayout = (function (my) {
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalStream = function (stream) {
|
my.changeLocalStream = function (stream) {
|
||||||
connection.jingle.localAudio = stream;
|
|
||||||
VideoLayout.changeLocalVideo(stream, true);
|
VideoLayout.changeLocalVideo(stream, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalAudio = function(stream) {
|
my.changeLocalAudio = function(stream) {
|
||||||
connection.jingle.localAudio = stream;
|
|
||||||
RTC.attachMediaStream($('#localAudio'), stream);
|
RTC.attachMediaStream($('#localAudio'), stream);
|
||||||
document.getElementById('localAudio').autoplay = true;
|
document.getElementById('localAudio').autoplay = true;
|
||||||
document.getElementById('localAudio').volume = 0;
|
document.getElementById('localAudio').volume = 0;
|
||||||
|
@ -4607,8 +4605,6 @@ var VideoLayout = (function (my) {
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalVideo = function(stream, flipX) {
|
my.changeLocalVideo = function(stream, flipX) {
|
||||||
connection.jingle.localVideo = stream;
|
|
||||||
|
|
||||||
var localVideo = document.createElement('video');
|
var localVideo = document.createElement('video');
|
||||||
localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
|
localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
|
||||||
localVideo.autoplay = true;
|
localVideo.autoplay = true;
|
||||||
|
|
|
@ -369,7 +369,7 @@ SimulcastSender.prototype.getLocalVideoStream = function () {
|
||||||
return (this.displayedLocalVideoStream != null)
|
return (this.displayedLocalVideoStream != null)
|
||||||
? this.displayedLocalVideoStream
|
? this.displayedLocalVideoStream
|
||||||
// in case we have no simulcast at all, i.e. we didn't perform the GUM
|
// in case we have no simulcast at all, i.e. we didn't perform the GUM
|
||||||
: connection.jingle.localVideo;
|
: RTC.localVideo.getOriginalStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
function NativeSimulcastSender() {
|
function NativeSimulcastSender() {
|
||||||
|
|
|
@ -31,9 +31,6 @@ Strophe.addConnectionPlugin('jingle', {
|
||||||
}
|
}
|
||||||
// MozDontOfferDataChannel: true when this is firefox
|
// MozDontOfferDataChannel: true when this is firefox
|
||||||
},
|
},
|
||||||
localAudio: null,
|
|
||||||
localVideo: null,
|
|
||||||
|
|
||||||
init: function (conn) {
|
init: function (conn) {
|
||||||
this.connection = conn;
|
this.connection = conn;
|
||||||
if (this.connection.disco) {
|
if (this.connection.disco) {
|
||||||
|
@ -108,13 +105,6 @@ Strophe.addConnectionPlugin('jingle', {
|
||||||
sess = new JingleSession($(iq).attr('to'), $(iq).find('jingle').attr('sid'), this.connection);
|
sess = new JingleSession($(iq).attr('to'), $(iq).find('jingle').attr('sid'), this.connection);
|
||||||
// configure session
|
// configure session
|
||||||
|
|
||||||
//in firefox we have only one stream object
|
|
||||||
if (this.localAudio != this.localVideo) {
|
|
||||||
sess.localStreams.push(this.localAudio);
|
|
||||||
}
|
|
||||||
if (this.localVideo) {
|
|
||||||
sess.localStreams.push(this.localVideo);
|
|
||||||
}
|
|
||||||
sess.media_constraints = this.media_constraints;
|
sess.media_constraints = this.media_constraints;
|
||||||
sess.pc_constraints = this.pc_constraints;
|
sess.pc_constraints = this.pc_constraints;
|
||||||
sess.ice_config = this.ice_config;
|
sess.ice_config = this.ice_config;
|
||||||
|
@ -195,13 +185,6 @@ Strophe.addConnectionPlugin('jingle', {
|
||||||
this.connection);
|
this.connection);
|
||||||
// configure session
|
// configure session
|
||||||
|
|
||||||
//in firefox we have only one stream
|
|
||||||
if (this.localAudio != this.localVideo) {
|
|
||||||
sess.localStreams.push(this.localAudio);
|
|
||||||
}
|
|
||||||
if (this.localVideo) {
|
|
||||||
sess.localStreams.push(this.localVideo);
|
|
||||||
}
|
|
||||||
sess.media_constraints = this.media_constraints;
|
sess.media_constraints = this.media_constraints;
|
||||||
sess.pc_constraints = this.pc_constraints;
|
sess.pc_constraints = this.pc_constraints;
|
||||||
sess.ice_config = this.ice_config;
|
sess.ice_config = this.ice_config;
|
||||||
|
|
|
@ -396,11 +396,11 @@ SDP.prototype.toJingle = function (elem, thecreator, ssrcs) {
|
||||||
var msid = null;
|
var msid = null;
|
||||||
if(mline.media == "audio")
|
if(mline.media == "audio")
|
||||||
{
|
{
|
||||||
msid = connection.jingle.localAudio.getAudioTracks()[0].id;
|
msid = RTC.localAudio.getId();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msid = connection.jingle.localVideo.getVideoTracks()[0].id;
|
msid = RTC.localVideo.getId();
|
||||||
}
|
}
|
||||||
if(msid != null)
|
if(msid != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,6 @@ function JingleSession(me, sid, connection) {
|
||||||
this.state = null;
|
this.state = null;
|
||||||
this.localSDP = null;
|
this.localSDP = null;
|
||||||
this.remoteSDP = null;
|
this.remoteSDP = null;
|
||||||
this.localStreams = [];
|
|
||||||
this.relayedStreams = [];
|
this.relayedStreams = [];
|
||||||
this.remoteStreams = [];
|
this.remoteStreams = [];
|
||||||
this.startTime = null;
|
this.startTime = null;
|
||||||
|
@ -103,8 +102,8 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
|
||||||
$(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
|
$(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
|
||||||
};
|
};
|
||||||
// add any local and relayed stream
|
// add any local and relayed stream
|
||||||
this.localStreams.forEach(function(stream) {
|
RTC.localStreams.forEach(function(stream) {
|
||||||
self.peerconnection.addStream(stream);
|
self.peerconnection.addStream(stream.getOriginalStream());
|
||||||
});
|
});
|
||||||
this.relayedStreams.forEach(function(stream) {
|
this.relayedStreams.forEach(function(stream) {
|
||||||
self.peerconnection.addStream(stream);
|
self.peerconnection.addStream(stream);
|
||||||
|
@ -934,14 +933,7 @@ JingleSession.prototype.switchStreams = function (new_stream, oldStream, success
|
||||||
self.peerconnection.addStream(new_stream);
|
self.peerconnection.addStream(new_stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.connection.jingle.localVideo = new_stream;
|
RTC.switchVideoStreams(new_stream, oldStream);
|
||||||
|
|
||||||
self.connection.jingle.localStreams = [];
|
|
||||||
|
|
||||||
//in firefox we have only one stream object
|
|
||||||
if(self.connection.jingle.localAudio != self.connection.jingle.localVideo)
|
|
||||||
self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
|
|
||||||
self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
|
|
||||||
|
|
||||||
// Conference is not active
|
// Conference is not active
|
||||||
if(!oldSdp || !self.peerconnection) {
|
if(!oldSdp || !self.peerconnection) {
|
||||||
|
@ -1031,7 +1023,7 @@ JingleSession.prototype.notifyMySSRCUpdate = function (old_sdp, new_sdp) {
|
||||||
* disabled; otherwise, <tt>false</tt>
|
* disabled; otherwise, <tt>false</tt>
|
||||||
*/
|
*/
|
||||||
JingleSession.prototype.isVideoMute = function () {
|
JingleSession.prototype.isVideoMute = function () {
|
||||||
var tracks = connection.jingle.localVideo.getVideoTracks();
|
var tracks = RTC.localVideo.getVideoTracks();
|
||||||
var mute = true;
|
var mute = true;
|
||||||
|
|
||||||
for (var i = 0; i < tracks.length; ++i) {
|
for (var i = 0; i < tracks.length; ++i) {
|
||||||
|
@ -1075,7 +1067,7 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
||||||
} else if (this.videoMuteByUser) {
|
} else if (this.videoMuteByUser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mute == this.isVideoMute())
|
if (mute == RTC.localVideo.isMuted())
|
||||||
{
|
{
|
||||||
// Even if no change occurs, the specified callback is to be executed.
|
// Even if no change occurs, the specified callback is to be executed.
|
||||||
// The specified callback may, optionally, return a successCallback
|
// The specified callback may, optionally, return a successCallback
|
||||||
|
@ -1086,11 +1078,7 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
||||||
successCallback();
|
successCallback();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var tracks = connection.jingle.localVideo.getVideoTracks();
|
RTC.localVideo.setMute(!mute);
|
||||||
|
|
||||||
for (var i = 0; i < tracks.length; ++i) {
|
|
||||||
tracks[i].enabled = !mute;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hardMuteVideo(mute);
|
this.hardMuteVideo(mute);
|
||||||
|
|
||||||
|
@ -1101,7 +1089,7 @@ JingleSession.prototype.setVideoMute = function (mute, callback, options) {
|
||||||
// SDP-based mute by going recvonly/sendrecv
|
// SDP-based mute by going recvonly/sendrecv
|
||||||
// FIXME: should probably black out the screen as well
|
// FIXME: should probably black out the screen as well
|
||||||
JingleSession.prototype.toggleVideoMute = function (callback) {
|
JingleSession.prototype.toggleVideoMute = function (callback) {
|
||||||
setVideoMute(isVideoMute(), callback);
|
setVideoMute(RTC.localVideo.isMuted(), callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
JingleSession.prototype.hardMuteVideo = function (muted) {
|
JingleSession.prototype.hardMuteVideo = function (muted) {
|
||||||
|
|
|
@ -5,8 +5,20 @@ function LocalStream(stream, type, eventEmitter)
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.eventEmitter = eventEmitter;
|
this.eventEmitter = eventEmitter;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
if(type == "audio")
|
||||||
|
{
|
||||||
|
this.getTracks = function () {
|
||||||
|
return self.stream.getAudioTracks();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.getTracks = function () {
|
||||||
|
return self.stream.getVideoTracks();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
this.stream.onended = function()
|
this.stream.onended = function()
|
||||||
{
|
{
|
||||||
self.streamEnded();
|
self.streamEnded();
|
||||||
|
@ -24,31 +36,32 @@ LocalStream.prototype.getOriginalStream = function()
|
||||||
|
|
||||||
LocalStream.prototype.isAudioStream = function () {
|
LocalStream.prototype.isAudioStream = function () {
|
||||||
return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
|
return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
|
||||||
}
|
};
|
||||||
|
|
||||||
LocalStream.prototype.mute = function()
|
LocalStream.prototype.mute = function()
|
||||||
{
|
{
|
||||||
var ismuted = false;
|
var ismuted = false;
|
||||||
var tracks = [];
|
var tracks = this.getTracks();
|
||||||
if(this.type = "audio")
|
|
||||||
{
|
|
||||||
tracks = this.stream.getAudioTracks();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tracks = this.stream.getVideoTracks();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var idx = 0; idx < tracks.length; idx++) {
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
ismuted = !tracks[idx].enabled;
|
ismuted = !tracks[idx].enabled;
|
||||||
tracks[idx].enabled = !tracks[idx].enabled;
|
tracks[idx].enabled = ismuted;
|
||||||
}
|
}
|
||||||
return ismuted;
|
return ismuted;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
LocalStream.prototype.setMute = function(mute)
|
||||||
|
{
|
||||||
|
var tracks = this.getTracks();
|
||||||
|
|
||||||
|
for (var idx = 0; idx < tracks.length; idx++) {
|
||||||
|
tracks[idx].enabled = mute;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LocalStream.prototype.isMuted = function () {
|
LocalStream.prototype.isMuted = function () {
|
||||||
var tracks = [];
|
var tracks = [];
|
||||||
if(this.type = "audio")
|
if(this.type == "audio")
|
||||||
{
|
{
|
||||||
tracks = this.stream.getAudioTracks();
|
tracks = this.stream.getAudioTracks();
|
||||||
}
|
}
|
||||||
|
@ -63,4 +76,10 @@ LocalStream.prototype.isMuted = function () {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LocalStream.prototype.getId = function () {
|
||||||
|
return this.stream.getTracks()[0].id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = LocalStream;
|
module.exports = LocalStream;
|
||||||
|
|
|
@ -27,7 +27,10 @@ var RTC = {
|
||||||
createLocalStream: function (stream, type) {
|
createLocalStream: function (stream, type) {
|
||||||
|
|
||||||
var localStream = new LocalStream(stream, type, eventEmitter);
|
var localStream = new LocalStream(stream, type, eventEmitter);
|
||||||
this.localStreams.push(localStream);
|
//in firefox we have only one stream object
|
||||||
|
if(this.localStreams.length == 0 ||
|
||||||
|
this.localStreams[0].getOriginalStream() != stream)
|
||||||
|
this.localStreams.push(localStream);
|
||||||
if(type == "audio")
|
if(type == "audio")
|
||||||
{
|
{
|
||||||
this.localAudio = localStream;
|
this.localAudio = localStream;
|
||||||
|
@ -117,6 +120,16 @@ var RTC = {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
switchVideoStreams: function (new_stream) {
|
||||||
|
this.localVideo.stream = new_stream;
|
||||||
|
|
||||||
|
this.localStreams = [];
|
||||||
|
|
||||||
|
//in firefox we have only one stream object
|
||||||
|
if(this.localAudio.getOriginalStream() != new_stream)
|
||||||
|
this.localStreams.push(this.localAudio);
|
||||||
|
this.localStreams.push(this.localVideo);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,7 +83,7 @@ function registerListeners() {
|
||||||
if(jid === statistics.LOCAL_JID)
|
if(jid === statistics.LOCAL_JID)
|
||||||
{
|
{
|
||||||
resourceJid = AudioLevels.LOCAL_LEVEL;
|
resourceJid = AudioLevels.LOCAL_LEVEL;
|
||||||
if(isAudioMuted())
|
if(RTC.localAudio.isMuted())
|
||||||
{
|
{
|
||||||
audioLevel = 0;
|
audioLevel = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -414,12 +414,10 @@ var VideoLayout = (function (my) {
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalStream = function (stream) {
|
my.changeLocalStream = function (stream) {
|
||||||
connection.jingle.localAudio = stream;
|
|
||||||
VideoLayout.changeLocalVideo(stream, true);
|
VideoLayout.changeLocalVideo(stream, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalAudio = function(stream) {
|
my.changeLocalAudio = function(stream) {
|
||||||
connection.jingle.localAudio = stream;
|
|
||||||
RTC.attachMediaStream($('#localAudio'), stream);
|
RTC.attachMediaStream($('#localAudio'), stream);
|
||||||
document.getElementById('localAudio').autoplay = true;
|
document.getElementById('localAudio').autoplay = true;
|
||||||
document.getElementById('localAudio').volume = 0;
|
document.getElementById('localAudio').volume = 0;
|
||||||
|
@ -430,8 +428,6 @@ var VideoLayout = (function (my) {
|
||||||
};
|
};
|
||||||
|
|
||||||
my.changeLocalVideo = function(stream, flipX) {
|
my.changeLocalVideo = function(stream, flipX) {
|
||||||
connection.jingle.localVideo = stream;
|
|
||||||
|
|
||||||
var localVideo = document.createElement('video');
|
var localVideo = document.createElement('video');
|
||||||
localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
|
localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
|
||||||
localVideo.autoplay = true;
|
localVideo.autoplay = true;
|
||||||
|
|
|
@ -32,7 +32,7 @@ SimulcastSender.prototype.getLocalVideoStream = function () {
|
||||||
return (this.displayedLocalVideoStream != null)
|
return (this.displayedLocalVideoStream != null)
|
||||||
? this.displayedLocalVideoStream
|
? this.displayedLocalVideoStream
|
||||||
// in case we have no simulcast at all, i.e. we didn't perform the GUM
|
// in case we have no simulcast at all, i.e. we didn't perform the GUM
|
||||||
: connection.jingle.localVideo;
|
: RTC.localVideo.getOriginalStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
function NativeSimulcastSender() {
|
function NativeSimulcastSender() {
|
||||||
|
|
Loading…
Reference in New Issue