Bläddra i källkod

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 år sedan
förälder
incheckning
311766e3e2
4 ändrade filer med 44 tillägg och 0 borttagningar
  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 Visa fil

@@ -3087,6 +3087,20 @@ JitsiConference.prototype._updateProperties = function(properties = {}) {
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 3104
         const oldValue = this._hasVisitors;
3091 3105
 
3092 3106
         this._hasVisitors = this.properties['visitor-count'] > 0;

+ 2
- 0
JitsiConferenceEvents.spec.ts Visa fil

@@ -14,6 +14,7 @@ describe( "/JitsiConferenceEvents members", () => {
14 14
         CONFERENCE_JOINED,
15 15
         CONFERENCE_LEFT,
16 16
         CONFERENCE_UNIQUE_ID_SET,
17
+        CONFERENCE_VISITOR_CODECS_CHANGED,
17 18
         CONNECTION_ESTABLISHED,
18 19
         CONNECTION_INTERRUPTED,
19 20
         CONNECTION_RESTORED,
@@ -98,6 +99,7 @@ describe( "/JitsiConferenceEvents members", () => {
98 99
         expect( CONFERENCE_JOINED ).toBe( 'conference.joined' );
99 100
         expect( CONFERENCE_LEFT ).toBe( 'conference.left' );
100 101
         expect( CONFERENCE_UNIQUE_ID_SET ).toBe( 'conference.unique_id_set' );
102
+        expect( CONFERENCE_VISITOR_CODECS_CHANGED ).toBe( 'conference.visitor_codecs_changed' );
101 103
         expect( CONNECTION_ESTABLISHED ).toBe( 'conference.connectionEstablished' );
102 104
         expect( CONNECTION_INTERRUPTED ).toBe( 'conference.connectionInterrupted' );
103 105
         expect( CONNECTION_RESTORED ).toBe( 'conference.connectionRestored' );

+ 6
- 0
JitsiConferenceEvents.ts Visa fil

@@ -136,6 +136,11 @@ export enum JitsiConferenceEvents {
136 136
      */
137 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 145
      * Indicates that the connection to the conference has been established
141 146
      * XXX This is currently fired when the *ICE* connection enters 'connected'
@@ -501,6 +506,7 @@ export const CONFERENCE_JOIN_IN_PROGRESS = JitsiConferenceEvents.CONFERENCE_JOIN
501 506
 export const CONFERENCE_JOINED = JitsiConferenceEvents.CONFERENCE_JOINED;
502 507
 export const CONFERENCE_LEFT = JitsiConferenceEvents.CONFERENCE_LEFT;
503 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 510
 export const CONNECTION_ESTABLISHED = JitsiConferenceEvents.CONNECTION_ESTABLISHED;
505 511
 export const CONNECTION_INTERRUPTED = JitsiConferenceEvents.CONNECTION_INTERRUPTED;
506 512
 export const CONNECTION_RESTORED = JitsiConferenceEvents.CONNECTION_RESTORED;

+ 22
- 0
modules/RTC/CodecSelection.js Visa fil

@@ -33,6 +33,7 @@ export class CodecSelection {
33 33
         this.conference = conference;
34 34
         this.options = options;
35 35
         this.codecPreferenceOrder = {};
36
+        this.visitorCodecs = [];
36 37
 
37 38
         for (const connectionType of Object.keys(options)) {
38 39
             // eslint-disable-next-line prefer-const
@@ -93,6 +94,9 @@ export class CodecSelection {
93 94
         this.conference.on(
94 95
             JitsiConferenceEvents._MEDIA_SESSION_STARTED,
95 96
             session => this._selectPreferredCodec(session));
97
+        this.conference.on(
98
+            JitsiConferenceEvents.CONFERENCE_VISITOR_CODECS_CHANGED,
99
+            codecList => this._updateVisitorCodecs(codecList));
96 100
         this.conference.on(
97 101
             JitsiConferenceEvents.USER_JOINED,
98 102
             () => this._selectPreferredCodec());
@@ -162,6 +166,9 @@ export class CodecSelection {
162 166
             return [];
163 167
         });
164 168
 
169
+        // Include the visitor codecs.
170
+        this.visitorCodecs.length && remoteCodecsPerParticipant.push(this.visitorCodecs);
171
+
165 172
         const selectedCodecOrder = localPreferredCodecOrder.reduce((acc, localCodec) => {
166 173
             let codecNotSupportedByRemote = false;
167 174
 
@@ -198,6 +205,21 @@ export class CodecSelection {
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 224
      * Returns the current codec preference order for the given connection type.
203 225
      *

Laddar…
Avbryt
Spara