Selaa lähdekoodia

fix unit tests and some clean-up

dev1
Jaya Allamsetty 4 vuotta sitten
vanhempi
commit
c46b230f11

+ 19
- 19
modules/RTC/CodecSelection.js Näytä tiedosto

31
      */
31
      */
32
     constructor(conference, options) {
32
     constructor(conference, options) {
33
         this.conference = conference;
33
         this.conference = conference;
34
+        this.options = options;
34
 
35
 
35
         // VP8 cannot be disabled and it will be the default codec when no preference is set.
36
         // VP8 cannot be disabled and it will be the default codec when no preference is set.
36
         this.disabledCodec = options.disabledCodec === CodecMimeType.VP8
37
         this.disabledCodec = options.disabledCodec === CodecMimeType.VP8
43
 
44
 
44
         this.jvbPreferredCodec = jvbCodec && this._isCodecSupported(jvbCodec) ? jvbCodec : CodecMimeType.VP8;
45
         this.jvbPreferredCodec = jvbCodec && this._isCodecSupported(jvbCodec) ? jvbCodec : CodecMimeType.VP8;
45
         this.p2pPreferredCodec = p2pCodec && this._isCodecSupported(p2pCodec) ? p2pCodec : CodecMimeType.VP8;
46
         this.p2pPreferredCodec = p2pCodec && this._isCodecSupported(p2pCodec) ? p2pCodec : CodecMimeType.VP8;
46
-        this.enforcePreferredCodec = options.enforcePreferredCodec;
47
+        logger.debug(`Codec preferences for the conference are JVB: ${this.jvbPreferredCodec},
48
+            P2P: ${this.p2pPreferredCodec}`);
47
 
49
 
48
         // Do not prefer VP9 on Firefox because of the following bug.
50
         // Do not prefer VP9 on Firefox because of the following bug.
49
         // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
51
         // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
129
     _onParticipantJoined(id) {
131
     _onParticipantJoined(id) {
130
         const session = this.conference.jvbJingleSession;
132
         const session = this.conference.jvbJingleSession;
131
 
133
 
132
-        if (session && !this.enforcePreferredCodec) {
134
+        if (session && !this.options.enforcePreferredCodec) {
133
             const peerMediaInfo = session.signalingLayer.getPeerMediaInfo(id, MediaType.VIDEO);
135
             const peerMediaInfo = session.signalingLayer.getPeerMediaInfo(id, MediaType.VIDEO);
134
 
136
 
135
-            if (peerMediaInfo) {
136
-                const newCodec = peerMediaInfo.codecType;
137
-                const currentCodec = session.getConfiguredVideoCodec();
138
-
139
-                // Add the participant to the list of participants that
140
-                // don't support the preferred codec.
141
-                if (newCodec !== this.jvbPreferredCodec) {
142
-                    this.nonPreferredParticipants.push(id);
143
-                }
144
-                logger.warn(`Current: ${currentCodec}, new: ${newCodec}`);
145
-                if (newCodec
146
-                    && newCodec !== this.jvbPreferredCodec
147
-                    && newCodec !== currentCodec
148
-                    && this._isCodecSupported(newCodec)) {
149
-                    session.setVideoCodecs(newCodec);
150
-                }
137
+            if (!peerMediaInfo) {
138
+                return;
139
+            }
140
+            const newCodec = peerMediaInfo.codecType;
141
+            const currentCodec = session.getConfiguredVideoCodec();
142
+
143
+            if (newCodec
144
+                && newCodec !== this.jvbPreferredCodec
145
+                && newCodec !== currentCodec
146
+                && this._isCodecSupported(newCodec)) {
147
+
148
+                // Add the participant to the list of participants that don't support the preferred codec.
149
+                this.nonPreferredParticipants.push(id);
150
+                session.setVideoCodecs(newCodec);
151
             }
151
             }
152
         }
152
         }
153
     }
153
     }
164
     _onParticipantLeft(id) {
164
     _onParticipantLeft(id) {
165
         const session = this.conference.jvbJingleSession;
165
         const session = this.conference.jvbJingleSession;
166
 
166
 
167
-        if (session && !this.enforcePreferredCodec) {
167
+        if (session && !this.options.enforcePreferredCodec) {
168
             const index = this.nonPreferredParticipants.findIndex(participantId => participantId === id);
168
             const index = this.nonPreferredParticipants.findIndex(participantId => participantId === id);
169
 
169
 
170
             if (index > -1) {
170
             if (index > -1) {

+ 9
- 0
modules/RTC/MockClasses.js Näytä tiedosto

35
         return Promise.resolve(/* answer */{});
35
         return Promise.resolve(/* answer */{});
36
     }
36
     }
37
 
37
 
38
+    /**
39
+     * {@link TraceablePeerConnection.getConfiguredVideoCodec}.
40
+     *
41
+     * @returns {CodecMimeType}
42
+     */
43
+    getConfiguredVideoCodec() {
44
+        return 'vp8';
45
+    }
46
+
38
     /**
47
     /**
39
      * {@link TraceablePeerConnection.setLocalDescription}.
48
      * {@link TraceablePeerConnection.setLocalDescription}.
40
      *
49
      *

+ 1
- 1
modules/xmpp/ChatRoom.js Näytä tiedosto

167
         this.addVideoInfoToPresence(false);
167
         this.addVideoInfoToPresence(false);
168
 
168
 
169
         // Set the default codec.
169
         // Set the default codec.
170
-        this.addCodecInfoToPresence(this.options.preferredCodec);
170
+        this.addCodecInfoToPresence(options.preferredCodec);
171
 
171
 
172
         if (options.deploymentInfo && options.deploymentInfo.userRegion) {
172
         if (options.deploymentInfo && options.deploymentInfo.userRegion) {
173
             this.presMap.nodes.push({
173
             this.presMap.nodes.push({

+ 1
- 1
modules/xmpp/ChatRoom.spec.js Näytä tiedosto

146
                 'jid',
146
                 'jid',
147
                 'password',
147
                 'password',
148
                 xmpp,
148
                 xmpp,
149
-                {} /* options */);
149
+                { preferredCodec: 'vp8' } /* options */);
150
             emitterSpy = spyOn(room.eventEmitter, 'emit');
150
             emitterSpy = spyOn(room.eventEmitter, 'emit');
151
         });
151
         });
152
         it('parses status correctly', () => {
152
         it('parses status correctly', () => {

+ 5
- 2
modules/xmpp/JingleSessionPC.js Näytä tiedosto

880
     }
880
     }
881
 
881
 
882
     /**
882
     /**
883
-     *
883
+     * Returns the video codec configured as the preferred codec on the peerconnection.
884
      */
884
      */
885
     getConfiguredVideoCodec() {
885
     getConfiguredVideoCodec() {
886
         return this.peerconnection.getConfiguredVideoCodec();
886
         return this.peerconnection.getConfiguredVideoCodec();
1100
     }
1100
     }
1101
 
1101
 
1102
     /**
1102
     /**
1103
+     * Updates the codecs on the peerconnection and initiates a renegotiation for the
1104
+     * new codec config to take effect.
1103
      *
1105
      *
1104
-     * @param {*} codec
1106
+     * @param {CodecMimeType} preferred the preferred codec.
1107
+     * @param {CodecMimeType} disabled the codec that needs to be disabled.
1105
      */
1108
      */
1106
     setVideoCodecs(preferred = null, disabled = null) {
1109
     setVideoCodecs(preferred = null, disabled = null) {
1107
         const current = this.peerconnection.getConfiguredVideoCodec();
1110
         const current = this.peerconnection.getConfiguredVideoCodec();

+ 6
- 0
modules/xmpp/MockClasses.js Näytä tiedosto

13
      */
13
      */
14
     addPresenceListener() {
14
     addPresenceListener() {
15
     }
15
     }
16
+
17
+    /**
18
+     * {@link ChatRoom.sendCodecInfoPresence}.
19
+     */
20
+    sendCodecInfoPresence() {
21
+    }
16
 }
22
 }
17
 
23
 
18
 /**
24
 /**

Loading…
Peruuta
Tallenna