Browse Source

feat(external_api) add command and event listener for CS

j8
hmuresan 4 years ago
parent
commit
4dda508708

+ 22
- 0
modules/API/API.js View File

413
         case 'is-sharing-screen':
413
         case 'is-sharing-screen':
414
             callback(Boolean(APP.conference.isSharingScreen));
414
             callback(Boolean(APP.conference.isSharingScreen));
415
             break;
415
             break;
416
+        case 'get-content-sharing-participants': {
417
+            const tracks = getState()['features/base/tracks'];
418
+            const sharingParticipantIds = tracks.filter(tr => tr.videoType === 'desktop').map(t => t.participantId);
419
+
420
+            callback({
421
+                sharingParticipantIds
422
+            });
423
+            break;
424
+        }
416
         default:
425
         default:
417
             return false;
426
             return false;
418
         }
427
         }
656
         });
665
         });
657
     }
666
     }
658
 
667
 
668
+    /**
669
+     * Notify external application (if API is enabled) that the list of sharing participants changed.
670
+     *
671
+     * @param {Object} data - The event data.
672
+     * @returns {void}
673
+     */
674
+    notifySharingParticipantsChanged(data: Object) {
675
+        this._sendEvent({
676
+            name: 'content-sharing-participants-changed',
677
+            data
678
+        });
679
+    }
680
+
659
     /**
681
     /**
660
      * Notify external application (if API is enabled) that the device list has
682
      * Notify external application (if API is enabled) that the device list has
661
      * changed.
683
      * changed.

+ 12
- 0
modules/API/external/external_api.js View File

62
     'audio-availability-changed': 'audioAvailabilityChanged',
62
     'audio-availability-changed': 'audioAvailabilityChanged',
63
     'audio-mute-status-changed': 'audioMuteStatusChanged',
63
     'audio-mute-status-changed': 'audioMuteStatusChanged',
64
     'camera-error': 'cameraError',
64
     'camera-error': 'cameraError',
65
+    'content-sharing-participants-changed': 'contentSharingParticipantsChanged',
65
     'device-list-changed': 'deviceListChanged',
66
     'device-list-changed': 'deviceListChanged',
66
     'display-name-change': 'displayNameChange',
67
     'display-name-change': 'displayNameChange',
67
     'email-change': 'emailChange',
68
     'email-change': 'emailChange',
723
         return getAvailableDevices(this._transport);
724
         return getAvailableDevices(this._transport);
724
     }
725
     }
725
 
726
 
727
+    /**
728
+     * Gets a list of the currently sharing participant id's.
729
+     *
730
+     * @returns {Promise} - Resolves with the list of participant id's currently sharing.
731
+     */
732
+    getContentSharingParticipants() {
733
+        return this._transport.sendRequest({
734
+            name: 'get-content-sharing-participants'
735
+        });
736
+    }
737
+
726
     /**
738
     /**
727
      * Returns Promise that resolves with current selected devices.
739
      * Returns Promise that resolves with current selected devices.
728
      *
740
      *

+ 2
- 0
react/features/base/tracks/middleware.js View File

35
     setTrackMuted
35
     setTrackMuted
36
 } from './functions';
36
 } from './functions';
37
 
37
 
38
+import './subscriber';
39
+
38
 declare var APP: Object;
40
 declare var APP: Object;
39
 
41
 
40
 /**
42
 /**

+ 24
- 0
react/features/base/tracks/subscriber.js View File

1
+// @flow
2
+
3
+import _ from 'lodash';
4
+
5
+import { StateListenerRegistry } from '../../base/redux';
6
+
7
+declare var APP: Object;
8
+
9
+/**
10
+ * Notifies when the list of currently sharing participants changes.
11
+ */
12
+StateListenerRegistry.register(
13
+    /* selector */ state =>
14
+        state['features/base/tracks'].filter(tr => tr.videoType === 'desktop').map(t => t.participantId),
15
+    /* listener */ (participantIDs, store, previousParticipantIDs) => {
16
+        if (typeof APP !== 'object') {
17
+            return;
18
+        }
19
+
20
+        if (!_.isEqual(_.sortBy(participantIDs), _.sortBy(previousParticipantIDs))) {
21
+            APP.API.notifySharingParticipantsChanged(participantIDs);
22
+        }
23
+    }
24
+);

Loading…
Cancel
Save