Browse Source

fix(codec-selection): Include visitor codecs.

Include visitor codecs published by Jicofo while calculating the intersection set for the conference.
release-8443
Jaya Allamsetty 1 year ago
parent
commit
311766e3e2
4 changed files with 44 additions and 0 deletions
  1. 14
    0
      JitsiConference.js
  2. 2
    0
      JitsiConferenceEvents.spec.ts
  3. 6
    0
      JitsiConferenceEvents.ts
  4. 22
    0
      modules/RTC/CodecSelection.js

+ 14
- 0
JitsiConference.js View File

3087
             }
3087
             }
3088
         });
3088
         });
3089
 
3089
 
3090
+        // Handle changes to aggregate list of visitor codecs.
3091
+        let publishedCodecs = this.properties['visitor-codecs']?.split(',');
3092
+
3093
+        if (publishedCodecs?.length) {
3094
+            publishedCodecs = publishedCodecs.filter(codec => typeof codec === 'string'
3095
+                && codec.trim().length
3096
+                && Object.values(CodecMimeType).find(val => val === codec));
3097
+        }
3098
+
3099
+        if (this._visitorCodecs !== publishedCodecs) {
3100
+            this._visitorCodecs = publishedCodecs;
3101
+            this.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_VISITOR_CODECS_CHANGED, this._visitorCodecs);
3102
+        }
3103
+
3090
         const oldValue = this._hasVisitors;
3104
         const oldValue = this._hasVisitors;
3091
 
3105
 
3092
         this._hasVisitors = this.properties['visitor-count'] > 0;
3106
         this._hasVisitors = this.properties['visitor-count'] > 0;

+ 2
- 0
JitsiConferenceEvents.spec.ts View File

14
         CONFERENCE_JOINED,
14
         CONFERENCE_JOINED,
15
         CONFERENCE_LEFT,
15
         CONFERENCE_LEFT,
16
         CONFERENCE_UNIQUE_ID_SET,
16
         CONFERENCE_UNIQUE_ID_SET,
17
+        CONFERENCE_VISITOR_CODECS_CHANGED,
17
         CONNECTION_ESTABLISHED,
18
         CONNECTION_ESTABLISHED,
18
         CONNECTION_INTERRUPTED,
19
         CONNECTION_INTERRUPTED,
19
         CONNECTION_RESTORED,
20
         CONNECTION_RESTORED,
98
         expect( CONFERENCE_JOINED ).toBe( 'conference.joined' );
99
         expect( CONFERENCE_JOINED ).toBe( 'conference.joined' );
99
         expect( CONFERENCE_LEFT ).toBe( 'conference.left' );
100
         expect( CONFERENCE_LEFT ).toBe( 'conference.left' );
100
         expect( CONFERENCE_UNIQUE_ID_SET ).toBe( 'conference.unique_id_set' );
101
         expect( CONFERENCE_UNIQUE_ID_SET ).toBe( 'conference.unique_id_set' );
102
+        expect( CONFERENCE_VISITOR_CODECS_CHANGED ).toBe( 'conference.visitor_codecs_changed' );
101
         expect( CONNECTION_ESTABLISHED ).toBe( 'conference.connectionEstablished' );
103
         expect( CONNECTION_ESTABLISHED ).toBe( 'conference.connectionEstablished' );
102
         expect( CONNECTION_INTERRUPTED ).toBe( 'conference.connectionInterrupted' );
104
         expect( CONNECTION_INTERRUPTED ).toBe( 'conference.connectionInterrupted' );
103
         expect( CONNECTION_RESTORED ).toBe( 'conference.connectionRestored' );
105
         expect( CONNECTION_RESTORED ).toBe( 'conference.connectionRestored' );

+ 6
- 0
JitsiConferenceEvents.ts View File

136
      */
136
      */
137
     CONFERENCE_UNIQUE_ID_SET = 'conference.unique_id_set',
137
     CONFERENCE_UNIQUE_ID_SET = 'conference.unique_id_set',
138
 
138
 
139
+    /**
140
+     * Indicates that the aggregate set of codecs supported by the visitors has changed.
141
+     */
142
+    CONFERENCE_VISITOR_CODECS_CHANGED = 'conference.visitor_codecs_changed',
143
+
139
     /**
144
     /**
140
      * Indicates that the connection to the conference has been established
145
      * Indicates that the connection to the conference has been established
141
      * XXX This is currently fired when the *ICE* connection enters 'connected'
146
      * XXX This is currently fired when the *ICE* connection enters 'connected'
501
 export const CONFERENCE_JOINED = JitsiConferenceEvents.CONFERENCE_JOINED;
506
 export const CONFERENCE_JOINED = JitsiConferenceEvents.CONFERENCE_JOINED;
502
 export const CONFERENCE_LEFT = JitsiConferenceEvents.CONFERENCE_LEFT;
507
 export const CONFERENCE_LEFT = JitsiConferenceEvents.CONFERENCE_LEFT;
503
 export const CONFERENCE_UNIQUE_ID_SET = JitsiConferenceEvents.CONFERENCE_UNIQUE_ID_SET;
508
 export const CONFERENCE_UNIQUE_ID_SET = JitsiConferenceEvents.CONFERENCE_UNIQUE_ID_SET;
509
+export const CONFERENCE_VISITOR_CODECS_CHANGED = JitsiConferenceEvents.CONFERENCE_VISITOR_CODECS_CHANGED;
504
 export const CONNECTION_ESTABLISHED = JitsiConferenceEvents.CONNECTION_ESTABLISHED;
510
 export const CONNECTION_ESTABLISHED = JitsiConferenceEvents.CONNECTION_ESTABLISHED;
505
 export const CONNECTION_INTERRUPTED = JitsiConferenceEvents.CONNECTION_INTERRUPTED;
511
 export const CONNECTION_INTERRUPTED = JitsiConferenceEvents.CONNECTION_INTERRUPTED;
506
 export const CONNECTION_RESTORED = JitsiConferenceEvents.CONNECTION_RESTORED;
512
 export const CONNECTION_RESTORED = JitsiConferenceEvents.CONNECTION_RESTORED;

+ 22
- 0
modules/RTC/CodecSelection.js View File

33
         this.conference = conference;
33
         this.conference = conference;
34
         this.options = options;
34
         this.options = options;
35
         this.codecPreferenceOrder = {};
35
         this.codecPreferenceOrder = {};
36
+        this.visitorCodecs = [];
36
 
37
 
37
         for (const connectionType of Object.keys(options)) {
38
         for (const connectionType of Object.keys(options)) {
38
             // eslint-disable-next-line prefer-const
39
             // eslint-disable-next-line prefer-const
93
         this.conference.on(
94
         this.conference.on(
94
             JitsiConferenceEvents._MEDIA_SESSION_STARTED,
95
             JitsiConferenceEvents._MEDIA_SESSION_STARTED,
95
             session => this._selectPreferredCodec(session));
96
             session => this._selectPreferredCodec(session));
97
+        this.conference.on(
98
+            JitsiConferenceEvents.CONFERENCE_VISITOR_CODECS_CHANGED,
99
+            codecList => this._updateVisitorCodecs(codecList));
96
         this.conference.on(
100
         this.conference.on(
97
             JitsiConferenceEvents.USER_JOINED,
101
             JitsiConferenceEvents.USER_JOINED,
98
             () => this._selectPreferredCodec());
102
             () => this._selectPreferredCodec());
162
             return [];
166
             return [];
163
         });
167
         });
164
 
168
 
169
+        // Include the visitor codecs.
170
+        this.visitorCodecs.length && remoteCodecsPerParticipant.push(this.visitorCodecs);
171
+
165
         const selectedCodecOrder = localPreferredCodecOrder.reduce((acc, localCodec) => {
172
         const selectedCodecOrder = localPreferredCodecOrder.reduce((acc, localCodec) => {
166
             let codecNotSupportedByRemote = false;
173
             let codecNotSupportedByRemote = false;
167
 
174
 
198
         }
205
         }
199
     }
206
     }
200
 
207
 
208
+    /**
209
+     * Updates the aggregate list of the codecs supported by all the visitors in the call and calculates the
210
+     * selected codec if needed.
211
+     * @param {Array} codecList - visitor codecs.
212
+     * @returns {void}
213
+     */
214
+    _updateVisitorCodecs(codecList) {
215
+        if (this.visitorCodecs === codecList) {
216
+            return;
217
+        }
218
+
219
+        this.visitorCodecs = codecList;
220
+        this._selectPreferredCodec();
221
+    }
222
+
201
     /**
223
     /**
202
      * Returns the current codec preference order for the given connection type.
224
      * Returns the current codec preference order for the given connection type.
203
      *
225
      *

Loading…
Cancel
Save