Merge branch 'isymchych-lib-jitsi-meet' into lib-jitsi-meet

This commit is contained in:
hristoterezov 2016-01-12 13:39:47 -06:00
commit e10bbf4b41
10 changed files with 1110 additions and 527 deletions

5
.gitattributes vendored
View File

@ -1,2 +1,3 @@
*.bundle.js -text -diff
.editorconfig
lib-jitsi-meet.min.js -text -diff
lib-jitsi-meet.js -text -diff
lib-jitsi-meet.js.map -text -diff

View File

@ -44,6 +44,9 @@ function JitsiConference(options) {
this.somebodySupportsDTMF = false;
this.authEnabled = false;
this.authIdentity;
this.startAudioMuted = false;
this.startVideoMuted = false;
this.tracks = [];
}
/**
@ -250,6 +253,16 @@ 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);
@ -291,6 +304,10 @@ 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);
@ -411,12 +428,13 @@ JitsiConference.prototype.muteParticipant = function (id) {
this.room.muteParticipant(participant.getJid(), true);
};
JitsiConference.prototype.onMemberJoined = function (jid, nick) {
JitsiConference.prototype.onMemberJoined = function (jid, nick, role) {
var id = Strophe.getResourceFromJid(jid);
if (id === 'focus' || this.myUserId() === id) {
return;
}
var participant = new JitsiParticipant(jid, this, nick);
participant._role = role;
this.participants[id] = participant;
this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
this.xmpp.connection.disco.info(
@ -650,6 +668,41 @@ JitsiConference.prototype.getConnectionState = function () {
return null;
}
/**
* 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.
*/
JitsiConference.prototype.setStartMuted = function (audioMuted, videoMuted) {
if (!this.isModerator()) {
return;
}
this.room.removeFromPresence("startmuted");
this.room.addToPresence("startmuted", {
attributes: {
audio: audioMuted,
video: videoMuted,
xmlns: 'http://jitsi.org/jitmeet/start-muted'
}
});
this.room.sendPresence();
};
/**
* Check if audio is muted on join.
*/
JitsiConference.prototype.isStartAudioMuted = function () {
return this.startAudioMuted;
};
/**
* Check if video is muted on join.
*/
JitsiConference.prototype.isStartVideoMuted = function () {
return this.startVideoMuted;
};
/**
* Setups the listeners needed for the conference.
* @param conference the conference
@ -691,6 +744,9 @@ function setupListeners(conference) {
conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
});
conference.room.addListener(XMPPEvents.BRIDGE_DOWN, function () {
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
});
// FIXME
// conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
// conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
@ -762,6 +818,70 @@ 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;
// 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();
}
});
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()) {
isModerator = true;
} else {
var participant = conference.getParticipantById(from);
if (participant && participant.isModerator()) {
isModerator = true;
}
}
if (!isModerator) {
return;
}
var startAudioMuted = data.attributes.audio === 'true';
var startVideoMuted = data.attributes.video === 'true';
var updated = false;
if (startAudioMuted !== conference.startAudioMuted) {
conference.startAudioMuted = startAudioMuted;
updated = true;
}
if (startVideoMuted !== conference.startVideoMuted) {
conference.startVideoMuted = startVideoMuted;
updated = true;
}
if (updated) {
conference.eventEmitter.emit(
JitsiConferenceEvents.START_MUTED,
conference.startAudioMuted,
conference.startVideoMuted,
false
);
}
});
if(conference.statistics) {
//FIXME: Maybe remove event should not be associated with the conference.
conference.statistics.addAudioLevelListener(function (ssrc, level) {

View File

@ -84,6 +84,10 @@ var JitsiConferenceEvents = {
* You are kicked from the conference.
*/
KICKED: "conferenece.kicked",
/**
* Indicates that start muted settings changed.
*/
START_MUTED: "conference.start_muted",
/**
* Indicates that DTMF support changed.
*/

View File

@ -90,6 +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))
2. connection
- CONNECTION_FAILED - indicates that the server connection failed.
@ -253,6 +254,16 @@ 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
Note: available only for moderator
26. isStartAudioMuted() - check if audio is muted on join
27. isStartVideoMuted() - check if video is muted on join
JitsiTrack
======
The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant).

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

@ -33,6 +33,9 @@ JitsiLocalTrack.prototype.constructor = JitsiLocalTrack;
* @param mute {boolean} if true the track will be muted. Otherwise the track will be unmuted.
*/
JitsiLocalTrack.prototype._setMute = function (mute) {
if (this.isMuted() === mute) {
return;
}
if(!this.rtc) {
this.startMuted = mute;
return;

View File

@ -262,7 +262,7 @@ ChatRoom.prototype.onPresence = function (pres) {
}
else {
this.eventEmitter.emit(
XMPPEvents.MUC_MEMBER_JOINED, from, member.nick);
XMPPEvents.MUC_MEMBER_JOINED, from, member.nick, member.role);
}
} else {
// Presence update for existing participant

View File

@ -1,9 +1,4 @@
var DesktopSharingEventTypes = {
INIT: "ds.init",
SWITCHING_DONE: "ds.switching_done",
NEW_STREAM_CREATED: "ds.new_stream_created",
/**
* An event which indicates that the jidesha extension for Firefox is
* needed to proceed with screen sharing, and that it is not installed.

View File

@ -59,9 +59,6 @@ var XMPPEvents = {
// Designates an event indicating that the focus has asked us to mute our
// audio.
AUDIO_MUTED_BY_FOCUS: "xmpp.audio_muted_by_focus",
// Designates an event indicating that a moderator in the room changed the
// "start muted" settings for the conference.
START_MUTED_SETTING_CHANGED: "xmpp.start_muted_setting_changed",
// Designates an event indicating that we should join the conference with
// audio and/or video muted.
START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",