浏览代码

propagate AVAILABLE_DEVICES_CHANGED event

dev1
isymchych 9 年前
父节点
当前提交
4efc997a62
共有 8 个文件被更改,包括 13983 次插入13903 次删除
  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 查看文件

@@ -58,6 +58,10 @@ function JitsiConference(options) {
58 58
     this.startAudioMuted = false;
59 59
     this.startVideoMuted = false;
60 60
     this.startMutedPolicy = {audio: false, video: false};
61
+    this.availableDevices = {
62
+        audio: undefined,
63
+        video: undefined
64
+    };
61 65
 }
62 66
 
63 67
 /**
@@ -962,6 +966,50 @@ function setupListeners(conference) {
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 1013
     if(conference.statistics) {
966 1014
         //FIXME: Maybe remove event should not be associated with the conference.
967 1015
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
@@ -976,10 +1024,6 @@ function setupListeners(conference) {
976 1024
             function () {
977 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 1028
         conference.room.addListener(XMPPEvents.PEERCONNECTION_READY,
985 1029
             function (session) {

+ 5
- 1
JitsiConferenceEvents.js 查看文件

@@ -112,7 +112,11 @@ var JitsiConferenceEvents = {
112 112
      * Indicates that to proceed with screen sharing
113 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 122
 module.exports = JitsiConferenceEvents;

+ 4
- 0
JitsiParticipant.js 查看文件

@@ -12,6 +12,10 @@ function JitsiParticipant(jid, conference, displayName){
12 12
     this._tracks = [];
13 13
     this._role = 'none';
14 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 查看文件

@@ -95,6 +95,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
95 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 96
         - STARTED_MUTED - notifies that the local user has started muted
97 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 100
     2. connection
100 101
         - CONNECTION_FAILED - indicates that the server connection failed.

+ 13909
- 13874
lib-jitsi-meet.js
文件差异内容过多而无法显示
查看文件


+ 16
- 16
lib-jitsi-meet.min.js
文件差异内容过多而无法显示
查看文件


+ 0
- 3
modules/xmpp/xmpp.js 查看文件

@@ -53,9 +53,6 @@ function initStrophePlugins(XMPP)
53 53
 //        broadcastLocalVideoType,
54 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 58
 function XMPP(options) {

+ 0
- 5
service/xmpp/XMPPEvents.js 查看文件

@@ -57,11 +57,6 @@ var XMPPEvents = {
57 57
     // Designates an event indicating that we should join the conference with
58 58
     // audio and/or video muted.
59 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 62
     PEERCONNECTION_READY: "xmpp.peerconnection_ready",

正在加载...
取消
保存