Browse Source

propagate AVAILABLE_DEVICES_CHANGED event

dev1
isymchych 9 years ago
parent
commit
4efc997a62
8 changed files with 13983 additions and 13903 deletions
  1. 48
    4
      JitsiConference.js
  2. 5
    1
      JitsiConferenceEvents.js
  3. 4
    0
      JitsiParticipant.js
  4. 1
    0
      doc/API.md
  5. 13909
    13874
      lib-jitsi-meet.js
  6. 16
    16
      lib-jitsi-meet.min.js
  7. 0
    3
      modules/xmpp/xmpp.js
  8. 0
    5
      service/xmpp/XMPPEvents.js

+ 48
- 4
JitsiConference.js View File

58
     this.startAudioMuted = false;
58
     this.startAudioMuted = false;
59
     this.startVideoMuted = false;
59
     this.startVideoMuted = false;
60
     this.startMutedPolicy = {audio: false, video: false};
60
     this.startMutedPolicy = {audio: false, video: false};
61
+    this.availableDevices = {
62
+        audio: undefined,
63
+        video: undefined
64
+    };
61
 }
65
 }
62
 
66
 
63
 /**
67
 /**
962
         }
966
         }
963
     });
967
     });
964
 
968
 
969
+    conference.rtc.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
970
+        conference.room.updateDeviceAvailability(devices);
971
+    });
972
+    conference.room.addPresenceListener("devices", function (data, from) {
973
+        var isAudioAvailable = false;
974
+        var isVideoAvailable = false;
975
+        data.children.forEach(function (config) {
976
+            if (config.tagName === 'audio') {
977
+                isAudioAvailable = config.value === 'true';
978
+            }
979
+            if (config.tagName === 'video') {
980
+                isVideoAvailable = config.value === 'true';
981
+            }
982
+        });
983
+
984
+        var availableDevices;
985
+        if (conference.myUserId() === from) {
986
+            availableDevices = conference.availableDevices;
987
+        } else {
988
+            var participant = conference.getParticipantById(from);
989
+            if (!participant) {
990
+                return;
991
+            }
992
+
993
+            availableDevices = participant._availableDevices;
994
+        }
995
+
996
+        var updated = false;
997
+
998
+        if (availableDevices.audio !== isAudioAvailable) {
999
+            updated = true;
1000
+            availableDevices.audio = isAudioAvailable;
1001
+        }
1002
+
1003
+        if (availableDevices.video !== isVideoAvailable) {
1004
+            updated = true;
1005
+            availableDevices.video = isVideoAvailable;
1006
+        }
1007
+
1008
+        if (updated) {
1009
+            conference.eventEmitter.emit(JitsiConferenceEvents.AVAILABLE_DEVICES_CHANGED, from, availableDevices);
1010
+        }
1011
+    });
1012
+
965
     if(conference.statistics) {
1013
     if(conference.statistics) {
966
         //FIXME: Maybe remove event should not be associated with the conference.
1014
         //FIXME: Maybe remove event should not be associated with the conference.
967
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
1015
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
976
             function () {
1024
             function () {
977
                 conference.statistics.dispose();
1025
                 conference.statistics.dispose();
978
             });
1026
             });
979
-        // FIXME: Maybe we should move this.
980
-        // RTC.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
981
-        //     conference.room.updateDeviceAvailability(devices);
982
-        // });
983
 
1027
 
984
         conference.room.addListener(XMPPEvents.PEERCONNECTION_READY,
1028
         conference.room.addListener(XMPPEvents.PEERCONNECTION_READY,
985
             function (session) {
1029
             function (session) {

+ 5
- 1
JitsiConferenceEvents.js View File

112
      * Indicates that to proceed with screen sharing
112
      * Indicates that to proceed with screen sharing
113
      * browser extension must be installed first.
113
      * browser extension must be installed first.
114
      */
114
      */
115
-    FIREFOX_EXTENSION_NEEDED: "conference.firefoxExtensionRequired"
115
+    FIREFOX_EXTENSION_NEEDED: "conference.firefoxExtensionRequired",
116
+    /**
117
+     * Indicates that available devices changed.
118
+     */
119
+    AVAILABLE_DEVICES_CHANGED: "conference.availableDevicesChanged"
116
 };
120
 };
117
 
121
 
118
 module.exports = JitsiConferenceEvents;
122
 module.exports = JitsiConferenceEvents;

+ 4
- 0
JitsiParticipant.js View File

12
     this._tracks = [];
12
     this._tracks = [];
13
     this._role = 'none';
13
     this._role = 'none';
14
     this._status = null;
14
     this._status = null;
15
+    this._availableDevices = {
16
+        audio: undefined,
17
+        video: undefined
18
+    };
15
 }
19
 }
16
 
20
 
17
 /**
21
 /**

+ 1
- 0
doc/API.md View File

95
         - 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))
95
         - 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))
96
         - STARTED_MUTED - notifies that the local user has started muted
96
         - STARTED_MUTED - notifies that the local user has started muted
97
         - FIREFOX_EXTENSION_NEEDED - notifies that browser extension must be installed to proceed with screen sharing (parameters - extension url(string))
97
         - FIREFOX_EXTENSION_NEEDED - notifies that browser extension must be installed to proceed with screen sharing (parameters - extension url(string))
98
+        - AVAILABLE_DEVICES_CHANGED - notifies that available participant devices changed (camera or microphone was added or removed) (parameters - id(string), devices(JS object with 2 properties - audio(boolean), video(boolean)))
98
 
99
 
99
     2. connection
100
     2. connection
100
         - CONNECTION_FAILED - indicates that the server connection failed.
101
         - CONNECTION_FAILED - indicates that the server connection failed.

+ 13909
- 13874
lib-jitsi-meet.js
File diff suppressed because it is too large
View File


+ 16
- 16
lib-jitsi-meet.min.js
File diff suppressed because it is too large
View File


+ 0
- 3
modules/xmpp/xmpp.js View File

53
 //        broadcastLocalVideoType,
53
 //        broadcastLocalVideoType,
54
 //        StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED
54
 //        StreamEventTypes.EVENT_TYPE_LOCAL_CHANGED
55
 //    );
55
 //    );
56
-//    RTC.addListener(RTCEvents.AVAILABLE_DEVICES_CHANGED, function (devices) {
57
-//        XMPP.addToPresence("devices", devices);
58
-//    });
59
 //}
56
 //}
60
 
57
 
61
 function XMPP(options) {
58
 function XMPP(options) {

+ 0
- 5
service/xmpp/XMPPEvents.js View File

57
     // Designates an event indicating that we should join the conference with
57
     // Designates an event indicating that we should join the conference with
58
     // audio and/or video muted.
58
     // audio and/or video muted.
59
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",
59
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",
60
-    // Designates an event indicating that a remote participant's available
61
-    // devices (whether he supports a audio and/or video) changed.
62
-    // Note: currently this event fires every time we receive presence from
63
-    // someone (regardless of whether or not the devices changed).
64
-    DEVICE_AVAILABLE: "xmpp.device_available",
65
 
60
 
66
 
61
 
67
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",
62
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",

Loading…
Cancel
Save