use JitsiParticipant; add some method implementations
This commit is contained in:
parent
60d6277f56
commit
3b633c014a
|
@ -1,4 +1,4 @@
|
|||
/* global Strophe */
|
||||
/* global Strophe, $ */
|
||||
/* jshint -W101 */
|
||||
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
||||
var RTC = require("./modules/RTC/RTC");
|
||||
|
@ -238,19 +238,44 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
|
|||
var id = Strophe.getResourceFromJid(jid);
|
||||
var participant = new JitsiParticipant(id, this, nick);
|
||||
this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id);
|
||||
this.participants[jid] = participant;
|
||||
this.xmpp.getConnection().disco.info(
|
||||
this.participants[id] = participant;
|
||||
this.connection.xmpp.connection.disco.info(
|
||||
jid, "" /* node */, function(iq) {
|
||||
participant._supportsDTMF = $(iq).find('>query>feature[var="urn:xmpp:jingle:dtmf:0"]').length > 0;
|
||||
this.updateDTMFSupport();
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
||||
|
||||
JitsiConference.prototype.onMemberLeft = function (jid) {
|
||||
var id = Strophe.getResourceFromJid(jid);
|
||||
delete this.participants[id];
|
||||
this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id);
|
||||
};
|
||||
|
||||
|
||||
JitsiConference.prototype.onTrackAdded = function (track) {
|
||||
var id = track.getParticipantId();
|
||||
var participant = this.getParticipantById(id);
|
||||
participant._tracks.push(track);
|
||||
this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, track);
|
||||
};
|
||||
|
||||
JitsiConference.prototype.onTrackRemoved = function (track) {
|
||||
var id = track.getParticipantId();
|
||||
var participant = this.getParticipantById(id);
|
||||
var pos = participant._tracks.indexOf(track);
|
||||
if (pos > -1) {
|
||||
participant._tracks.splice(pos, 1);
|
||||
}
|
||||
this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
|
||||
};
|
||||
|
||||
JitsiConference.prototype.updateDTMFSupport = function () {
|
||||
var somebodySupportsDTMF = false;
|
||||
var participants = this.getParticipants();
|
||||
|
||||
// check if at least 1 participant supports DTMF
|
||||
for (var i = 0; i < participants.length; i += 1) {
|
||||
if (participants[i].supportsDTMF()) {
|
||||
somebodySupportsDTMF = true;
|
||||
|
@ -273,7 +298,7 @@ JitsiConference.prototype.myUserId = function () {
|
|||
|
||||
JitsiConference.prototype.sendTones = function (tones, duration, pause) {
|
||||
if (!this.dtmfManager) {
|
||||
var connection = this.xmpp.getConnection().jingle.activecall.peerconnection;
|
||||
var connection = this.connection.xmpp.connection.jingle.activecall.peerconnection;
|
||||
if (!connection) {
|
||||
logger.warn("cannot sendTones: no conneciton");
|
||||
return;
|
||||
|
@ -304,7 +329,21 @@ function setupListeners(conference) {
|
|||
});
|
||||
conference.room.addListener(XMPPEvents.REMOTE_STREAM_RECEIVED,
|
||||
conference.rtc.createRemoteStream.bind(conference.rtc));
|
||||
|
||||
//FIXME: Maybe remove event should not be associated with the conference.
|
||||
conference.rtc.addListener(
|
||||
StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, conference.onTrackAdded.bind(conference)
|
||||
);
|
||||
//FIXME: Maybe remove event should not be associated with the conference.
|
||||
conference.rtc.addListener(
|
||||
StreamEventTypes.EVENT_TYPE_REMOTE_ENDED, conference.onTrackRemoved.bind(conference)
|
||||
);
|
||||
conference.rtc.addListener(StreamEventTypes.EVENT_TYPE_LOCAL_ENDED, function (stream) {
|
||||
conference.removeTrack(stream);
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, stream);
|
||||
});
|
||||
conference.rtc.addListener(StreamEventTypes.TRACK_MUTE_CHANGED, function (track) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
|
||||
});
|
||||
|
@ -312,53 +351,6 @@ function setupListeners(conference) {
|
|||
// conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
|
||||
// conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
|
||||
// });
|
||||
|
||||
conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED,
|
||||
conference.onMemberJoined.bind(conference));
|
||||
conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT,function (jid) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT,
|
||||
Strophe.getResourceFromJid(jid));
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
|
||||
function (from, displayName) {
|
||||
conference.eventEmitter.emit(
|
||||
JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
|
||||
Strophe.getResourceFromJid(from), displayName);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED,
|
||||
function () {
|
||||
conference.eventEmitter.emit(
|
||||
JitsiConferenceEvents.CONNECTION_INTERRUPTED);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function() {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
|
||||
});
|
||||
|
||||
conference.rtc.addListener(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED,
|
||||
function (stream) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, stream);
|
||||
});
|
||||
|
||||
//FIXME: Maybe remove event should not be associated with the conference.
|
||||
conference.rtc.addListener(StreamEventTypes.EVENT_TYPE_REMOTE_ENDED, function (stream) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, stream);
|
||||
});
|
||||
//FIXME: Maybe remove event should not be associated with the conference.
|
||||
conference.rtc.addListener(StreamEventTypes.EVENT_TYPE_LOCAL_ENDED, function (stream) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, stream);
|
||||
conference.removeTrack(stream);
|
||||
});
|
||||
|
||||
conference.rtc.addListener(StreamEventTypes.TRACK_MUTE_CHANGED, function (track) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.TRACK_MUTE_CHANGED, track);
|
||||
});
|
||||
|
||||
conference.rtc.addListener(RTCEvents.DOMINANTSPEAKER_CHANGED, function (id) {
|
||||
if(conference.lastActiveSpeaker !== id && conference.room) {
|
||||
conference.lastActiveSpeaker = id;
|
||||
|
@ -376,6 +368,25 @@ function setupListeners(conference) {
|
|||
lastNEndpoints, endpointsEnteringLastN);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
|
||||
conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
|
||||
|
||||
conference.room.addListener(XMPPEvents.DISPLAY_NAME_CHANGED, function (from, displayName) {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
|
||||
Strophe.getResourceFromJid(from), displayName);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.CONNECTION_INTERRUPTED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_INTERRUPTED);
|
||||
});
|
||||
|
||||
conference.room.addListener(XMPPEvents.CONNECTION_RESTORED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.CONNECTION_RESTORED);
|
||||
});
|
||||
conference.room.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
|
||||
conference.eventEmitter.emit(JitsiConferenceEvents.SETUP_FAILED);
|
||||
});
|
||||
|
||||
if(conference.statistics) {
|
||||
//FIXME: Maybe remove event should not be associated with the conference.
|
||||
conference.statistics.addAudioLevelListener(function (ssrc, level) {
|
||||
|
|
|
@ -6,6 +6,8 @@ function JitsiParticipant(id, conference, displayName){
|
|||
this._conference = conference;
|
||||
this._displayName = displayName;
|
||||
this._supportsDTMF = false;
|
||||
this._tracks = [];
|
||||
this._isModerator = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +21,7 @@ JitsiParticipant.prototype.getConference = function() {
|
|||
* @returns {Array.<JitsiTrack>} The list of media tracks for this participant.
|
||||
*/
|
||||
JitsiParticipant.prototype.getTracks = function() {
|
||||
|
||||
return this._tracks;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -40,6 +42,7 @@ JitsiParticipant.prototype.getDisplayName = function() {
|
|||
* @returns {Boolean} Whether this participant is a moderator or not.
|
||||
*/
|
||||
JitsiParticipant.prototype.isModerator = function() {
|
||||
return this._isModerator;
|
||||
};
|
||||
|
||||
// Gets a link to an etherpad instance advertised by the participant?
|
||||
|
@ -52,14 +55,18 @@ JitsiParticipant.prototype.isModerator = function() {
|
|||
* @returns {Boolean} Whether this participant has muted their audio.
|
||||
*/
|
||||
JitsiParticipant.prototype.isAudioMuted = function() {
|
||||
|
||||
return this.getTracks().reduce(function (track, isAudioMuted) {
|
||||
return isAudioMuted && (track.isVideoTrack() || track.isMuted());
|
||||
}, true);
|
||||
};
|
||||
|
||||
/*
|
||||
* @returns {Boolean} Whether this participant has muted their video.
|
||||
*/
|
||||
JitsiParticipant.prototype.isVideoMuted = function() {
|
||||
|
||||
return this.getTracks().reduce(function (track, isVideoMuted) {
|
||||
return isVideoMuted && (track.isAudioTrack() || track.isMuted());
|
||||
}, true);
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -98,13 +105,6 @@ JitsiParticipant.prototype.isSipGateway = function() {
|
|||
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {String} The ID for this participant's avatar.
|
||||
*/
|
||||
JitsiParticipant.prototype.getAvatarId = function() {
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns {Boolean} Whether this participant is currently sharing their screen.
|
||||
*/
|
||||
|
|
|
@ -38,7 +38,7 @@ function onLocalTracks(tracks)
|
|||
* @param track JitsiTrack object
|
||||
*/
|
||||
function onRemoteTrack(track) {
|
||||
var participant = track.getParitcipantId();
|
||||
var participant = track.getParticipantId();
|
||||
if(!remoteTracks[participant])
|
||||
remoteTracks[participant] = [];
|
||||
var idx = remoteTracks[participant].push(track);
|
||||
|
|
2331
lib-jitsi-meet.js
2331
lib-jitsi-meet.js
File diff suppressed because it is too large
Load Diff
|
@ -55,7 +55,7 @@ JitsiRemoteTrack.prototype.isMuted = function () {
|
|||
* Returns the participant id which owns the track.
|
||||
* @returns {string} the id of the participants.
|
||||
*/
|
||||
JitsiRemoteTrack.prototype.getParitcipantId = function() {
|
||||
JitsiRemoteTrack.prototype.getParticipantId = function() {
|
||||
return Strophe.getResourceFromJid(this.peerjid);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var logger = require("jitsi-meet-logger").getLogger(__filename);
|
||||
var RTCBrowserType = require("../RTC/RTCBrowserType");
|
||||
|
||||
|
@ -361,4 +360,5 @@ SDPUtil = {
|
|||
return line + '\r\n';
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = SDPUtil;
|
||||
|
|
Loading…
Reference in New Issue