|
|
@@ -46,7 +46,7 @@ function JitsiConference(options) {
|
|
46
|
46
|
this.authIdentity;
|
|
47
|
47
|
this.startAudioMuted = false;
|
|
48
|
48
|
this.startVideoMuted = false;
|
|
49
|
|
- this.tracks = [];
|
|
|
49
|
+ this.startMutedPolicy = {audio: false, video: false};
|
|
50
|
50
|
}
|
|
51
|
51
|
|
|
52
|
52
|
/**
|
|
|
@@ -253,16 +253,9 @@ JitsiConference.prototype.setDisplayName = function(name) {
|
|
253
|
253
|
JitsiConference.prototype.addTrack = function (track) {
|
|
254
|
254
|
this.room.addStream(track.getOriginalStream(), function () {
|
|
255
|
255
|
this.rtc.addLocalStream(track);
|
|
256
|
|
- if (this.startAudioMuted && track.isAudioTrack()) {
|
|
257
|
|
- track.mute();
|
|
258
|
|
- }
|
|
259
|
|
- if (this.startVideoMuted && track.isVideoTrack()) {
|
|
260
|
|
- track.mute();
|
|
261
|
|
- }
|
|
262
|
256
|
if (track.startMuted) {
|
|
263
|
257
|
track.mute();
|
|
264
|
258
|
}
|
|
265
|
|
- this.tracks.push(track);
|
|
266
|
259
|
var muteHandler = this._fireMuteChangeEvent.bind(this, track);
|
|
267
|
260
|
var stopHandler = this.removeTrack.bind(this, track);
|
|
268
|
261
|
var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
|
|
|
@@ -304,10 +297,6 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
|
|
304
|
297
|
* @param track the JitsiLocalTrack object.
|
|
305
|
298
|
*/
|
|
306
|
299
|
JitsiConference.prototype.removeTrack = function (track) {
|
|
307
|
|
- var pos = this.tracks.indexOf(track);
|
|
308
|
|
- if (pos > -1) {
|
|
309
|
|
- this.tracks.splice(pos, 1);
|
|
310
|
|
- }
|
|
311
|
300
|
if(!this.room){
|
|
312
|
301
|
if(this.rtc)
|
|
313
|
302
|
this.rtc.removeLocalStream(track);
|
|
|
@@ -670,25 +659,34 @@ JitsiConference.prototype.getConnectionState = function () {
|
|
670
|
659
|
|
|
671
|
660
|
/**
|
|
672
|
661
|
* Make all new participants mute their audio/video on join.
|
|
673
|
|
- * @param {boolean} audioMuted if audio should be muted.
|
|
674
|
|
- * @param {boolean} videoMuted if video should be muted.
|
|
|
662
|
+ * @param policy {Object} object with 2 boolean properties for video and audio:
|
|
|
663
|
+ * @param {boolean} audio if audio should be muted.
|
|
|
664
|
+ * @param {boolean} video if video should be muted.
|
|
675
|
665
|
*/
|
|
676
|
|
-JitsiConference.prototype.setStartMuted = function (audioMuted, videoMuted) {
|
|
|
666
|
+JitsiConference.prototype.setStartMutedPolicy = function (policy) {
|
|
677
|
667
|
if (!this.isModerator()) {
|
|
678
|
668
|
return;
|
|
679
|
669
|
}
|
|
680
|
|
-
|
|
|
670
|
+ this.startMutedPolicy = policy;
|
|
681
|
671
|
this.room.removeFromPresence("startmuted");
|
|
682
|
672
|
this.room.addToPresence("startmuted", {
|
|
683
|
673
|
attributes: {
|
|
684
|
|
- audio: audioMuted,
|
|
685
|
|
- video: videoMuted,
|
|
|
674
|
+ audio: policy.audio,
|
|
|
675
|
+ video: policy.video,
|
|
686
|
676
|
xmlns: 'http://jitsi.org/jitmeet/start-muted'
|
|
687
|
677
|
}
|
|
688
|
678
|
});
|
|
689
|
679
|
this.room.sendPresence();
|
|
690
|
680
|
};
|
|
691
|
681
|
|
|
|
682
|
+/**
|
|
|
683
|
+ * Returns current start muted policy
|
|
|
684
|
+ * @returns {Object} with 2 proprties - audio and video.
|
|
|
685
|
+ */
|
|
|
686
|
+JitsiConference.prototype.getStartMutedPolicy = function () {
|
|
|
687
|
+ return this.startMutedPolicy;
|
|
|
688
|
+};
|
|
|
689
|
+
|
|
692
|
690
|
/**
|
|
693
|
691
|
* Check if audio is muted on join.
|
|
694
|
692
|
*/
|
|
|
@@ -818,30 +816,23 @@ function setupListeners(conference) {
|
|
818
|
816
|
conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
|
|
819
|
817
|
});
|
|
820
|
818
|
|
|
821
|
|
- conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS, function (audioMuted, videoMuted) {
|
|
822
|
|
- conference.startAudioMuted = audioMuted;
|
|
823
|
|
- conference.startVideoMuted = videoMuted;
|
|
824
|
|
-
|
|
825
|
|
- // mute existing local tracks because this is initial mute from Jicofo
|
|
826
|
|
- conference.tracks.forEach(function (track) {
|
|
827
|
|
- if (conference.startAudioMuted && track.isAudioTrack()) {
|
|
828
|
|
- track.mute();
|
|
829
|
|
- }
|
|
830
|
|
- if (conference.startVideoMuted && track.isVideoTrack()) {
|
|
831
|
|
- track.mute();
|
|
832
|
|
- }
|
|
|
819
|
+ conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
|
|
|
820
|
+ function (audioMuted, videoMuted) {
|
|
|
821
|
+ conference.startAudioMuted = audioMuted;
|
|
|
822
|
+ conference.startVideoMuted = videoMuted;
|
|
|
823
|
+
|
|
|
824
|
+ // mute existing local tracks because this is initial mute from
|
|
|
825
|
+ // Jicofo
|
|
|
826
|
+ conference.getLocalTracks().forEach(function (track) {
|
|
|
827
|
+ if (conference.startAudioMuted && track.isAudioTrack()) {
|
|
|
828
|
+ track.mute();
|
|
|
829
|
+ }
|
|
|
830
|
+ if (conference.startVideoMuted && track.isVideoTrack()) {
|
|
|
831
|
+ track.mute();
|
|
|
832
|
+ }
|
|
|
833
|
+ });
|
|
833
|
834
|
});
|
|
834
|
835
|
|
|
835
|
|
- var initiallyMuted = audioMuted || videoMuted;
|
|
836
|
|
-
|
|
837
|
|
- conference.eventEmitter.emit(
|
|
838
|
|
- JitsiConferenceEvents.START_MUTED,
|
|
839
|
|
- conference.startAudioMuted,
|
|
840
|
|
- conference.startVideoMuted,
|
|
841
|
|
- initiallyMuted
|
|
842
|
|
- );
|
|
843
|
|
- });
|
|
844
|
|
-
|
|
845
|
836
|
conference.room.addPresenceListener("startmuted", function (data, from) {
|
|
846
|
837
|
var isModerator = false;
|
|
847
|
838
|
if (conference.myUserId() === from && conference.isModerator()) {
|
|
|
@@ -862,22 +853,20 @@ function setupListeners(conference) {
|
|
862
|
853
|
|
|
863
|
854
|
var updated = false;
|
|
864
|
855
|
|
|
865
|
|
- if (startAudioMuted !== conference.startAudioMuted) {
|
|
866
|
|
- conference.startAudioMuted = startAudioMuted;
|
|
|
856
|
+ if (startAudioMuted !== conference.startMutedPolicy.audio) {
|
|
|
857
|
+ conference.startMutedPolicy.audio = startAudioMuted;
|
|
867
|
858
|
updated = true;
|
|
868
|
859
|
}
|
|
869
|
860
|
|
|
870
|
|
- if (startVideoMuted !== conference.startVideoMuted) {
|
|
871
|
|
- conference.startVideoMuted = startVideoMuted;
|
|
|
861
|
+ if (startVideoMuted !== conference.startMutedPolicy.video) {
|
|
|
862
|
+ conference.startMutedPolicy.video = startVideoMuted;
|
|
872
|
863
|
updated = true;
|
|
873
|
864
|
}
|
|
874
|
865
|
|
|
875
|
866
|
if (updated) {
|
|
876
|
867
|
conference.eventEmitter.emit(
|
|
877
|
|
- JitsiConferenceEvents.START_MUTED,
|
|
878
|
|
- conference.startAudioMuted,
|
|
879
|
|
- conference.startVideoMuted,
|
|
880
|
|
- false
|
|
|
868
|
+ JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
|
|
|
869
|
+ conference.startMutedPolicy
|
|
881
|
870
|
);
|
|
882
|
871
|
}
|
|
883
|
872
|
});
|