Selaa lähdekoodia

fix(quality-control) Configure encodings for all sources on media session creation.

When multi-stream-support is enabled, configure the encodings on all the local video sources.
release-8443
Jaya Allamsetty 3 vuotta sitten
vanhempi
commit
61265e3b42

+ 28
- 5
modules/qualitycontrol/SendVideoController.js Näytä tiedosto

@@ -6,6 +6,7 @@ import FeatureFlags from '../flags/FeatureFlags';
6 6
 import MediaSessionEvents from '../xmpp/MediaSessionEvents';
7 7
 
8 8
 const logger = getLogger(__filename);
9
+const MAX_LOCAL_RESOLUTION = 2160;
9 10
 
10 11
 /**
11 12
  * The class manages send video constraints across media sessions({@link JingleSessionPC}) which belong to
@@ -24,6 +25,7 @@ export default class SendVideoController {
24 25
      */
25 26
     constructor(conference, rtc) {
26 27
         this._conference = conference;
28
+        this._preferredSendMaxFrameHeight = MAX_LOCAL_RESOLUTION;
27 29
         this._rtc = rtc;
28 30
 
29 31
         /**
@@ -37,12 +39,30 @@ export default class SendVideoController {
37 39
             session => this._onMediaSessionStarted(session));
38 40
         this._conference.on(
39 41
             JitsiConferenceEvents._MEDIA_SESSION_ACTIVE_CHANGED,
40
-            () => this._propagateSendMaxFrameHeight());
42
+            () => this._configureConstraintsForLocalSources());
41 43
         this._rtc.on(
42 44
             RTCEvents.SENDER_VIDEO_CONSTRAINTS_CHANGED,
43 45
             videoConstraints => this._onSenderConstraintsReceived(videoConstraints));
44 46
     }
45 47
 
48
+    /**
49
+     * Configures the video encodings on the local sources when a media connection is established or becomes active.
50
+     *
51
+     * @returns {Promise<void[]>}
52
+     * @private
53
+     */
54
+    _configureConstraintsForLocalSources() {
55
+        if (FeatureFlags.isSourceNameSignalingEnabled()) {
56
+            for (const track of this._rtc.getLocalVideoTracks()) {
57
+                const sourceName = track.getSourceName();
58
+
59
+                sourceName && this._propagateSendMaxFrameHeight(sourceName);
60
+            }
61
+        } else {
62
+            this._propagateSendMaxFrameHeight();
63
+        }
64
+    }
65
+
46 66
     /**
47 67
      * Handles the {@link JitsiConferenceEvents.MEDIA_SESSION_STARTED}, that is when the conference creates new media
48 68
      * session. It doesn't mean it's already active though. For example the JVB connection may be created after
@@ -56,7 +76,7 @@ export default class SendVideoController {
56 76
             MediaSessionEvents.REMOTE_VIDEO_CONSTRAINTS_CHANGED,
57 77
             session => {
58 78
                 if (session === this._conference.getActiveMediaSession()) {
59
-                    this._propagateSendMaxFrameHeight();
79
+                    this._configureConstraintsForLocalSources();
60 80
                 }
61 81
             });
62 82
     }
@@ -65,6 +85,8 @@ export default class SendVideoController {
65 85
      * Propagates the video constraints if they have changed.
66 86
      *
67 87
      * @param {Object} videoConstraints - The sender video constraints received from the bridge.
88
+     * @returns {Promise<void[]>}
89
+     * @private
68 90
      */
69 91
     _onSenderConstraintsReceived(videoConstraints) {
70 92
         if (FeatureFlags.isSourceNameSignalingEnabled()) {
@@ -88,7 +110,7 @@ export default class SendVideoController {
88 110
     }
89 111
 
90 112
     /**
91
-     * Figures out the send video constraint as specified by {@link selectSendMaxFrameHeight} and sets it on all media
113
+     * Figures out the send video constraint as specified by {@link _selectSendMaxFrameHeight} and sets it on all media
92 114
      * sessions for the reasons mentioned in this class description.
93 115
      *
94 116
      * @param {string} sourceName - The source for which sender constraints have changed.
@@ -99,7 +121,7 @@ export default class SendVideoController {
99 121
         if (FeatureFlags.isSourceNameSignalingEnabled() && !sourceName) {
100 122
             throw new Error('sourceName missing for calculating the sendMaxHeight for video tracks');
101 123
         }
102
-        const sendMaxFrameHeight = this.selectSendMaxFrameHeight(sourceName);
124
+        const sendMaxFrameHeight = this._selectSendMaxFrameHeight(sourceName);
103 125
         const promises = [];
104 126
 
105 127
         if (sendMaxFrameHeight >= 0) {
@@ -117,8 +139,9 @@ export default class SendVideoController {
117 139
      *
118 140
      * @param {string} sourceName - The source for which sender constraints have changed.
119 141
      * @returns {number|undefined}
142
+     * @private
120 143
      */
121
-    selectSendMaxFrameHeight(sourceName = null) {
144
+    _selectSendMaxFrameHeight(sourceName = null) {
122 145
         if (FeatureFlags.isSourceNameSignalingEnabled() && !sourceName) {
123 146
             throw new Error('sourceName missing for calculating the sendMaxHeight for video tracks');
124 147
         }

+ 14
- 4
types/auto/modules/qualitycontrol/SendVideoController.d.ts Näytä tiedosto

@@ -15,12 +15,20 @@ export default class SendVideoController {
15 15
      */
16 16
     constructor(conference: any, rtc: any);
17 17
     _conference: any;
18
+    _preferredSendMaxFrameHeight: number;
18 19
     _rtc: any;
19 20
     /**
20 21
      * Source name based sender constraints.
21 22
      * @type {Map<string, number>};
22 23
      */
23 24
     _sourceSenderConstraints: Map<string, number>;
25
+    /**
26
+     * Configures the video encodings on the local sources when a media connection is established or becomes active.
27
+     *
28
+     * @returns {Promise<void[]>}
29
+     * @private
30
+     */
31
+    private _configureConstraintsForLocalSources;
24 32
     /**
25 33
      * Handles the {@link JitsiConferenceEvents.MEDIA_SESSION_STARTED}, that is when the conference creates new media
26 34
      * session. It doesn't mean it's already active though. For example the JVB connection may be created after
@@ -34,11 +42,13 @@ export default class SendVideoController {
34 42
      * Propagates the video constraints if they have changed.
35 43
      *
36 44
      * @param {Object} videoConstraints - The sender video constraints received from the bridge.
45
+     * @returns {Promise<void[]>}
46
+     * @private
37 47
      */
38
-    _onSenderConstraintsReceived(videoConstraints: any): void;
48
+    private _onSenderConstraintsReceived;
39 49
     _senderVideoConstraints: any;
40 50
     /**
41
-     * Figures out the send video constraint as specified by {@link selectSendMaxFrameHeight} and sets it on all media
51
+     * Figures out the send video constraint as specified by {@link _selectSendMaxFrameHeight} and sets it on all media
42 52
      * sessions for the reasons mentioned in this class description.
43 53
      *
44 54
      * @param {string} sourceName - The source for which sender constraints have changed.
@@ -52,8 +62,9 @@ export default class SendVideoController {
52 62
      *
53 63
      * @param {string} sourceName - The source for which sender constraints have changed.
54 64
      * @returns {number|undefined}
65
+     * @private
55 66
      */
56
-    selectSendMaxFrameHeight(sourceName?: string): number | undefined;
67
+    private _selectSendMaxFrameHeight;
57 68
     /**
58 69
      * Sets local preference for max send video frame height.
59 70
      *
@@ -61,5 +72,4 @@ export default class SendVideoController {
61 72
      * @returns {Promise<void[]>} - resolved when the operation is complete.
62 73
      */
63 74
     setPreferredSendMaxFrameHeight(maxFrameHeight: number): Promise<void[]>;
64
-    _preferredSendMaxFrameHeight: number;
65 75
 }

Loading…
Peruuta
Tallenna