Browse Source

feat(external_api): Add command for setting send/recv video quality

master
Jaya Allamsetty 4 years ago
parent
commit
a48aa2b999

+ 4
- 0
doc/api.md View File

@@ -275,6 +275,10 @@ api.executeCommand('avatarUrl', 'https://avatars0.githubusercontent.com/u/367164
275 275
 ```javascript
276 276
 api.executeCommand('receiverParticipantId', 'text');
277 277
 ```
278
+* **setVideoQuality** - Sets the send and receive video resolution. This command requires one argument - the resolution height to be set.
279
+```javascript
280
+api.executeCommand('setVideoQuality', 720);
281
+```
278 282
 
279 283
 You can also execute multiple commands using the `executeCommands` method:
280 284
 ```javascript

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

@@ -14,6 +14,7 @@ import { parseJWTFromURLParams } from '../../react/features/base/jwt';
14 14
 import { setE2EEKey } from '../../react/features/e2ee';
15 15
 import { invite } from '../../react/features/invite';
16 16
 import { toggleTileView } from '../../react/features/video-layout';
17
+import { setVideoQuality } from '../../react/features/video-quality';
17 18
 import { getJitsiMeetTransport } from '../transport';
18 19
 
19 20
 import { API_ID, ENDPOINT_TEXT_MESSAGE_NAME } from './constants';
@@ -171,6 +172,11 @@ function initCommands() {
171 172
         'e2ee-key': key => {
172 173
             logger.debug('Set E2EE key command received');
173 174
             APP.store.dispatch(setE2EEKey(key));
175
+        },
176
+        'set-video-quality': frameHeight => {
177
+            logger.debug('Set video quality command received');
178
+            sendAnalytics(createApiEvent('set.video.quality'));
179
+            APP.store.dispatch(setVideoQuality(frameHeight));
174 180
         }
175 181
     };
176 182
     transport.on('event', ({ data, name }) => {

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

@@ -35,6 +35,7 @@ const commands = {
35 35
     password: 'password',
36 36
     sendEndpointTextMessage: 'send-endpoint-text-message',
37 37
     sendTones: 'send-tones',
38
+    setVideoQuality: 'set-video-quality',
38 39
     subject: 'subject',
39 40
     submitFeedback: 'submit-feedback',
40 41
     toggleAudio: 'toggle-audio',

+ 31
- 0
react/features/video-quality/actions.js View File

@@ -0,0 +1,31 @@
1
+// @flow
2
+
3
+import { VIDEO_QUALITY_LEVELS } from '../base/conference';
4
+import logger from './logger';
5
+
6
+import type { Dispatch } from 'redux';
7
+
8
+/**
9
+ * Sets the maximum video size the local participant should send and receive from
10
+ * remote participants.
11
+ *
12
+ * @param {number} frameHeight - The user preferred max frame height for send and
13
+ * receive video.
14
+ * @returns {void}
15
+ */
16
+export function setVideoQuality(frameHeight: number) {
17
+    return (dispatch: Dispatch<any>, getState: Function) => {
18
+        const { conference, maxReceiverVideoQuality } = getState()['features/base/conference'];
19
+
20
+        if (frameHeight < VIDEO_QUALITY_LEVELS.LOW) {
21
+            logger.error(`Invalid frame height for video quality - ${frameHeight}`);
22
+
23
+            return;
24
+        }
25
+        conference.setReceiverVideoConstraint(Math.min(frameHeight, maxReceiverVideoQuality));
26
+        conference.setSenderVideoConstraint(Math.min(frameHeight, VIDEO_QUALITY_LEVELS.HIGH))
27
+            .catch(err => {
28
+                logger.error(`Set video quality command failed - ${err}`);
29
+            });
30
+    };
31
+}

+ 1
- 0
react/features/video-quality/index.js View File

@@ -1 +1,2 @@
1 1
 export * from './components';
2
+export * from './actions';

Loading…
Cancel
Save