|
@@ -4,6 +4,7 @@ import { Interop } from '@jitsi/sdp-interop';
|
4
|
4
|
import { getLogger } from 'jitsi-meet-logger';
|
5
|
5
|
import transform from 'sdp-transform';
|
6
|
6
|
|
|
7
|
+import * as CodecMimeType from '../../service/RTC/CodecMimeType';
|
7
|
8
|
import * as MediaType from '../../service/RTC/MediaType';
|
8
|
9
|
import RTCEvents from '../../service/RTC/RTCEvents';
|
9
|
10
|
import * as SignalingEvents from '../../service/RTC/SignalingEvents';
|
|
@@ -268,27 +269,54 @@ export default function TraceablePeerConnection(
|
268
|
269
|
*/
|
269
|
270
|
this.senderVideoMaxHeight = null;
|
270
|
271
|
|
271
|
|
- // Set the codec preference that will be applied on the SDP
|
272
|
|
- // based on the config.js settings.
|
273
|
|
- if (this.options.preferH264 || this.options.preferVP9) {
|
|
272
|
+ // We currently support preferring/disabling video codecs only.
|
|
273
|
+ const getCodecMimeType
|
|
274
|
+ = codec => Object.values(CodecMimeType).find(value => value === codec.toLowerCase());
|
|
275
|
+
|
|
276
|
+ // Set the codec preference that will be applied on the SDP based on the config.js settings.
|
|
277
|
+ if (this.options.preferH264 || this.options.preferredCodec) {
|
|
278
|
+ let prefferedCodec = null;
|
|
279
|
+
|
|
280
|
+ // Do not prefer VP9 on Firefox because of the following bug.
|
|
281
|
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
|
|
282
|
+ if (this.options.preferredCodec) {
|
|
283
|
+ const mimeType = getCodecMimeType(this.options.preferredCodec);
|
|
284
|
+
|
|
285
|
+ if (!(browser.isFirefox() && mimeType === CodecMimeType.VP9)) {
|
|
286
|
+ prefferedCodec = mimeType;
|
|
287
|
+ }
|
|
288
|
+ }
|
|
289
|
+
|
274
|
290
|
this.codecPreference = {
|
275
|
291
|
enable: true,
|
276
|
292
|
mediaType: MediaType.VIDEO,
|
277
|
293
|
mimeType: this.options.preferH264
|
278
|
|
- ? 'h264'
|
279
|
|
- : 'vp9'
|
|
294
|
+ ? CodecMimeType.H264
|
|
295
|
+ : prefferedCodec
|
280
|
296
|
};
|
281
|
297
|
}
|
282
|
298
|
|
283
|
|
- // If both enable and disable are set for the same codec, disable
|
284
|
|
- // setting will prevail.
|
285
|
|
- if (this.options.disableH264 || this.options.disableVP9) {
|
|
299
|
+ // If both enable and disable are set for the same codec, disable setting will prevail.
|
|
300
|
+ if (this.options.disableH264 || this.options.disabledCodec) {
|
|
301
|
+ let disabledCodec = null;
|
|
302
|
+
|
|
303
|
+ // Make sure we don't disable VP8 since it is a mandatory codec.
|
|
304
|
+ if (this.options.disabledCodec) {
|
|
305
|
+ const mimeType = getCodecMimeType(this.options.disabledCodec);
|
|
306
|
+
|
|
307
|
+ if (mimeType === CodecMimeType.VP8) {
|
|
308
|
+ logger.warn('Disabling VP8 is not permitted, setting is ignored!');
|
|
309
|
+ } else {
|
|
310
|
+ disabledCodec = mimeType;
|
|
311
|
+ }
|
|
312
|
+ }
|
|
313
|
+
|
286
|
314
|
this.codecPreference = {
|
287
|
315
|
enable: false,
|
288
|
316
|
mediaType: MediaType.VIDEO,
|
289
|
317
|
mimeType: this.options.disableH264
|
290
|
|
- ? 'h264'
|
291
|
|
- : 'vp9'
|
|
318
|
+ ? CodecMimeType.H264
|
|
319
|
+ : disabledCodec
|
292
|
320
|
};
|
293
|
321
|
}
|
294
|
322
|
|
|
@@ -1503,14 +1531,14 @@ TraceablePeerConnection.prototype._getSSRC = function(rtcId) {
|
1503
|
1531
|
* @returns {RTCSessionDescription} the munged description.
|
1504
|
1532
|
*/
|
1505
|
1533
|
TraceablePeerConnection.prototype._mungeCodecOrder = function(description) {
|
1506
|
|
- if (!this.codecPreference || browser.supportsCodecPreferences()) {
|
|
1534
|
+ if (!(this.codecPreference && this.codecPreference.mimeType) || browser.supportsCodecPreferences()) {
|
1507
|
1535
|
return description;
|
1508
|
1536
|
}
|
1509
|
1537
|
|
1510
|
1538
|
const parsedSdp = transform.parse(description.sdp);
|
1511
|
1539
|
const mLine = parsedSdp.media.find(m => m.type === this.codecPreference.mediaType);
|
1512
|
1540
|
|
1513
|
|
- if (this.codecPreference.enable && this.codecPreference.mimeType) {
|
|
1541
|
+ if (this.codecPreference.enable) {
|
1514
|
1542
|
SDPUtil.preferCodec(mLine, this.codecPreference.mimeType);
|
1515
|
1543
|
|
1516
|
1544
|
// Strip the high profile H264 codecs on mobile clients for p2p connection.
|
|
@@ -1518,10 +1546,10 @@ TraceablePeerConnection.prototype._mungeCodecOrder = function(description) {
|
1518
|
1546
|
// we do not want on mobile clients.
|
1519
|
1547
|
// Jicofo offers only the baseline code for the jvb connection.
|
1520
|
1548
|
// TODO - add check for mobile browsers once js-utils provides that check.
|
1521
|
|
- if (this.codecPreference.mimeType === 'h264' && browser.isReactNative() && this.isP2P) {
|
|
1549
|
+ if (this.codecPreference.mimeType === CodecMimeType.H264 && browser.isReactNative() && this.isP2P) {
|
1522
|
1550
|
SDPUtil.stripCodec(mLine, this.codecPreference.mimeType, true /* high profile */);
|
1523
|
1551
|
}
|
1524
|
|
- } else if (this.codecPreference.mimeType) {
|
|
1552
|
+ } else {
|
1525
|
1553
|
SDPUtil.stripCodec(mLine, this.codecPreference.mimeType);
|
1526
|
1554
|
}
|
1527
|
1555
|
|