Fixes start muted implementation.

This commit is contained in:
hristoterezov 2016-01-12 15:25:27 -06:00
parent e10bbf4b41
commit dfeab252b0
6 changed files with 601 additions and 952 deletions

View File

@ -46,7 +46,7 @@ function JitsiConference(options) {
this.authIdentity;
this.startAudioMuted = false;
this.startVideoMuted = false;
this.tracks = [];
this.startMutedPolicy = {audio: false, video: false};
}
/**
@ -253,16 +253,9 @@ JitsiConference.prototype.setDisplayName = function(name) {
JitsiConference.prototype.addTrack = function (track) {
this.room.addStream(track.getOriginalStream(), function () {
this.rtc.addLocalStream(track);
if (this.startAudioMuted && track.isAudioTrack()) {
track.mute();
}
if (this.startVideoMuted && track.isVideoTrack()) {
track.mute();
}
if (track.startMuted) {
track.mute();
}
this.tracks.push(track);
var muteHandler = this._fireMuteChangeEvent.bind(this, track);
var stopHandler = this.removeTrack.bind(this, track);
var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
@ -304,10 +297,6 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
* @param track the JitsiLocalTrack object.
*/
JitsiConference.prototype.removeTrack = function (track) {
var pos = this.tracks.indexOf(track);
if (pos > -1) {
this.tracks.splice(pos, 1);
}
if(!this.room){
if(this.rtc)
this.rtc.removeLocalStream(track);
@ -670,25 +659,34 @@ JitsiConference.prototype.getConnectionState = function () {
/**
* Make all new participants mute their audio/video on join.
* @param {boolean} audioMuted if audio should be muted.
* @param {boolean} videoMuted if video should be muted.
* @param policy {Object} object with 2 boolean properties for video and audio:
* @param {boolean} audio if audio should be muted.
* @param {boolean} video if video should be muted.
*/
JitsiConference.prototype.setStartMuted = function (audioMuted, videoMuted) {
JitsiConference.prototype.setStartMutedPolicy = function (policy) {
if (!this.isModerator()) {
return;
}
this.startMutedPolicy = policy;
this.room.removeFromPresence("startmuted");
this.room.addToPresence("startmuted", {
attributes: {
audio: audioMuted,
video: videoMuted,
audio: policy.audio,
video: policy.video,
xmlns: 'http://jitsi.org/jitmeet/start-muted'
}
});
this.room.sendPresence();
};
/**
* Returns current start muted policy
* @returns {Object} with 2 proprties - audio and video.
*/
JitsiConference.prototype.getStartMutedPolicy = function () {
return this.startMutedPolicy;
};
/**
* Check if audio is muted on join.
*/
@ -818,30 +816,23 @@ function setupListeners(conference) {
conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
});
conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS, function (audioMuted, videoMuted) {
conference.startAudioMuted = audioMuted;
conference.startVideoMuted = videoMuted;
conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
function (audioMuted, videoMuted) {
conference.startAudioMuted = audioMuted;
conference.startVideoMuted = videoMuted;
// mute existing local tracks because this is initial mute from Jicofo
conference.tracks.forEach(function (track) {
if (conference.startAudioMuted && track.isAudioTrack()) {
track.mute();
}
if (conference.startVideoMuted && track.isVideoTrack()) {
track.mute();
}
// mute existing local tracks because this is initial mute from
// Jicofo
conference.getLocalTracks().forEach(function (track) {
if (conference.startAudioMuted && track.isAudioTrack()) {
track.mute();
}
if (conference.startVideoMuted && track.isVideoTrack()) {
track.mute();
}
});
});
var initiallyMuted = audioMuted || videoMuted;
conference.eventEmitter.emit(
JitsiConferenceEvents.START_MUTED,
conference.startAudioMuted,
conference.startVideoMuted,
initiallyMuted
);
});
conference.room.addPresenceListener("startmuted", function (data, from) {
var isModerator = false;
if (conference.myUserId() === from && conference.isModerator()) {
@ -862,22 +853,20 @@ function setupListeners(conference) {
var updated = false;
if (startAudioMuted !== conference.startAudioMuted) {
conference.startAudioMuted = startAudioMuted;
if (startAudioMuted !== conference.startMutedPolicy.audio) {
conference.startMutedPolicy.audio = startAudioMuted;
updated = true;
}
if (startVideoMuted !== conference.startVideoMuted) {
conference.startVideoMuted = startVideoMuted;
if (startVideoMuted !== conference.startMutedPolicy.video) {
conference.startMutedPolicy.video = startVideoMuted;
updated = true;
}
if (updated) {
conference.eventEmitter.emit(
JitsiConferenceEvents.START_MUTED,
conference.startAudioMuted,
conference.startVideoMuted,
false
JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
conference.startMutedPolicy
);
}
});

View File

@ -90,7 +90,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
- USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
- CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
- KICKED - notifies that user has been kicked from the conference.
- START_MUTED - notifies that all new participants will join with muted audio/video stream (parameters - audioMuted(boolean), videoMuted(boolean))
- START_MUTED_POLICY_CHANGED - notifies that all new participants will join with muted audio/video stream (parameters - JS object with 2 properties - audio(boolean), video(boolean))
2. connection
- CONNECTION_FAILED - indicates that the server connection failed.
@ -254,15 +254,21 @@ The object represents a conference. We have the following methods to control the
24. kick(id) - Kick participant from the conference
- id - string participant id
25. setStartMuted(audioMuted, videoMuted) - make all new participants join with muted audio/video
- audioMuted - boolean if audio stream should be muted
- videoMuted - boolean if video stream should be muted
25. setStartMutedPolicy(policy) - make all new participants join with muted audio/video
- policy - JS object with following properties
- audio - boolean if audio stream should be muted
- video - boolean if video stream should be muted
Note: available only for moderator
26. isStartAudioMuted() - check if audio is muted on join
26. getStartMutedPolicy() - returns the current policy with JS object:
- policy - JS object with following properties
- audio - boolean if audio stream should be muted
- video - boolean if video stream should be muted
27. isStartVideoMuted() - check if video is muted on join
27. isStartAudioMuted() - check if audio is muted on join
28. isStartVideoMuted() - check if video is muted on join
JitsiTrack
======

File diff suppressed because it is too large Load Diff

25
lib-jitsi-meet.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -136,12 +136,10 @@ RTC.prototype.setAudioMute = function (value) {
}
}
RTC.prototype.removeLocalStream = function (stream) {
for(var i = 0; i < this.localStreams.length; i++) {
if(this.localStreams[i].getOriginalStream() === stream) {
delete this.localStreams[i];
return;
}
RTC.prototype.removeLocalStream = function (track) {
var pos = this.localStreams.indexOf(track);
if (pos > -1) {
this.localStreams.splice(pos, 1);
}
};

View File

@ -225,7 +225,8 @@ var getters = {
// if we're running on FF, transform to Plan B first.
if (RTCBrowserType.usesUnifiedPlan()) {
desc = this.interop.toPlanB(desc);
this.trace('getLocalDescription::postTransform (Plan B)', dumpSDP(desc));
this.trace('getLocalDescription::postTransform (Plan B)',
dumpSDP(desc));
}
return desc;
},