浏览代码

fix unit tests and some clean-up

dev1
Jaya Allamsetty 4 年前
父节点
当前提交
c46b230f11

+ 19
- 19
modules/RTC/CodecSelection.js 查看文件

@@ -31,6 +31,7 @@ export class CodecSelection {
31 31
      */
32 32
     constructor(conference, options) {
33 33
         this.conference = conference;
34
+        this.options = options;
34 35
 
35 36
         // VP8 cannot be disabled and it will be the default codec when no preference is set.
36 37
         this.disabledCodec = options.disabledCodec === CodecMimeType.VP8
@@ -43,7 +44,8 @@ export class CodecSelection {
43 44
 
44 45
         this.jvbPreferredCodec = jvbCodec && this._isCodecSupported(jvbCodec) ? jvbCodec : CodecMimeType.VP8;
45 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 50
         // Do not prefer VP9 on Firefox because of the following bug.
49 51
         // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
@@ -129,25 +131,23 @@ export class CodecSelection {
129 131
     _onParticipantJoined(id) {
130 132
         const session = this.conference.jvbJingleSession;
131 133
 
132
-        if (session && !this.enforcePreferredCodec) {
134
+        if (session && !this.options.enforcePreferredCodec) {
133 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,7 +164,7 @@ export class CodecSelection {
164 164
     _onParticipantLeft(id) {
165 165
         const session = this.conference.jvbJingleSession;
166 166
 
167
-        if (session && !this.enforcePreferredCodec) {
167
+        if (session && !this.options.enforcePreferredCodec) {
168 168
             const index = this.nonPreferredParticipants.findIndex(participantId => participantId === id);
169 169
 
170 170
             if (index > -1) {

+ 9
- 0
modules/RTC/MockClasses.js 查看文件

@@ -35,6 +35,15 @@ export class MockPeerConnection {
35 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 48
      * {@link TraceablePeerConnection.setLocalDescription}.
40 49
      *

+ 1
- 1
modules/xmpp/ChatRoom.js 查看文件

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

+ 1
- 1
modules/xmpp/ChatRoom.spec.js 查看文件

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

+ 5
- 2
modules/xmpp/JingleSessionPC.js 查看文件

@@ -880,7 +880,7 @@ export default class JingleSessionPC extends JingleSession {
880 880
     }
881 881
 
882 882
     /**
883
-     *
883
+     * Returns the video codec configured as the preferred codec on the peerconnection.
884 884
      */
885 885
     getConfiguredVideoCodec() {
886 886
         return this.peerconnection.getConfiguredVideoCodec();
@@ -1100,8 +1100,11 @@ export default class JingleSessionPC extends JingleSession {
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 1109
     setVideoCodecs(preferred = null, disabled = null) {
1107 1110
         const current = this.peerconnection.getConfiguredVideoCodec();

+ 6
- 0
modules/xmpp/MockClasses.js 查看文件

@@ -13,6 +13,12 @@ export class MockChatRoom {
13 13
      */
14 14
     addPresenceListener() {
15 15
     }
16
+
17
+    /**
18
+     * {@link ChatRoom.sendCodecInfoPresence}.
19
+     */
20
+    sendCodecInfoPresence() {
21
+    }
16 22
 }
17 23
 
18 24
 /**

正在加载...
取消
保存