|
@@ -52,10 +52,14 @@ const SD_BITRATE = 700000;
|
52
|
52
|
* @param {boolean} options.capScreenshareBitrate if set to 'true' simulcast will
|
53
|
53
|
* be disabled for screenshare and a max bitrate of 500Kbps will applied on the
|
54
|
54
|
* stream.
|
|
55
|
+ * @param {string} options.disabledCodec the mime type of the code that should
|
|
56
|
+ * not be negotiated on the peerconnection.
|
55
|
57
|
* @param {boolean} options.disableH264 If set to 'true' H264 will be
|
56
|
|
- * disabled by removing it from the SDP.
|
|
58
|
+ * disabled by removing it from the SDP (deprecated)
|
57
|
59
|
* @param {boolean} options.preferH264 if set to 'true' H264 will be preferred
|
58
|
|
- * over other video codecs.
|
|
60
|
+ * over other video codecs. (deprecated)
|
|
61
|
+ * @param {string} options.preferredCodec the mime type of the codec that needs
|
|
62
|
+ * to be made the preferred codec for the connection.
|
59
|
63
|
* @param {boolean} options.startSilent If set to 'true' no audio will be sent or received.
|
60
|
64
|
*
|
61
|
65
|
* FIXME: initially the purpose of TraceablePeerConnection was to be able to
|
|
@@ -270,53 +274,42 @@ export default function TraceablePeerConnection(
|
270
|
274
|
this.senderVideoMaxHeight = null;
|
271
|
275
|
|
272
|
276
|
// 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;
|
|
277
|
+ const getCodecMimeType = codec => {
|
|
278
|
+ if (typeof codec === 'string') {
|
|
279
|
+ return Object.values(CodecMimeType).find(value => value === codec.toLowerCase());
|
|
280
|
+ }
|
279
|
281
|
|
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);
|
|
282
|
+ return null;
|
|
283
|
+ };
|
284
|
284
|
|
285
|
|
- if (!(browser.isFirefox() && mimeType === CodecMimeType.VP9)) {
|
286
|
|
- prefferedCodec = mimeType;
|
287
|
|
- }
|
288
|
|
- }
|
|
285
|
+ // Set the codec preference that will be applied on the SDP based on the config.js settings.
|
|
286
|
+ let preferredCodec = getCodecMimeType(
|
|
287
|
+ this.options.preferredCodec || (this.options.preferH264 && CodecMimeType.H264)
|
|
288
|
+ );
|
289
|
289
|
|
290
|
|
- this.codecPreference = {
|
291
|
|
- enable: true,
|
292
|
|
- mediaType: MediaType.VIDEO,
|
293
|
|
- mimeType: this.options.preferH264
|
294
|
|
- ? CodecMimeType.H264
|
295
|
|
- : prefferedCodec
|
296
|
|
- };
|
|
290
|
+ // Do not prefer VP9 on Firefox because of the following bug.
|
|
291
|
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
|
|
292
|
+ if (browser.isFirefox() && preferredCodec === CodecMimeType.VP9) {
|
|
293
|
+ preferredCodec = null;
|
297
|
294
|
}
|
298
|
295
|
|
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);
|
|
296
|
+ // Determine the codec that needs to be disabled based on config.js settings.
|
|
297
|
+ let disabledCodec = getCodecMimeType(
|
|
298
|
+ this.options.disabledCodec || (this.options.disableH264 && CodecMimeType.H264)
|
|
299
|
+ );
|
306
|
300
|
|
307
|
|
- if (mimeType === CodecMimeType.VP8) {
|
308
|
|
- logger.warn('Disabling VP8 is not permitted, setting is ignored!');
|
309
|
|
- } else {
|
310
|
|
- disabledCodec = mimeType;
|
311
|
|
- }
|
312
|
|
- }
|
|
301
|
+ // Make sure we don't disable VP8 since it is a mandatory codec.
|
|
302
|
+ if (disabledCodec === CodecMimeType.VP8) {
|
|
303
|
+ logger.warn('Disabling VP8 is not permitted, setting is ignored!');
|
|
304
|
+ disabledCodec = null;
|
|
305
|
+ }
|
313
|
306
|
|
|
307
|
+ if (preferredCodec || disabledCodec) {
|
|
308
|
+ // If both enable and disable are set for the same codec, disable setting will prevail.
|
314
|
309
|
this.codecPreference = {
|
315
|
|
- enable: false,
|
|
310
|
+ enable: disabledCodec === null,
|
316
|
311
|
mediaType: MediaType.VIDEO,
|
317
|
|
- mimeType: this.options.disableH264
|
318
|
|
- ? CodecMimeType.H264
|
319
|
|
- : disabledCodec
|
|
312
|
+ mimeType: disabledCodec ? disabledCodec : preferredCodec
|
320
|
313
|
};
|
321
|
314
|
}
|
322
|
315
|
|
|
@@ -1531,7 +1524,7 @@ TraceablePeerConnection.prototype._getSSRC = function(rtcId) {
|
1531
|
1524
|
* @returns {RTCSessionDescription} the munged description.
|
1532
|
1525
|
*/
|
1533
|
1526
|
TraceablePeerConnection.prototype._mungeCodecOrder = function(description) {
|
1534
|
|
- if (!(this.codecPreference && this.codecPreference.mimeType) || browser.supportsCodecPreferences()) {
|
|
1527
|
+ if (!this.codecPreference || browser.supportsCodecPreferences()) {
|
1535
|
1528
|
return description;
|
1536
|
1529
|
}
|
1537
|
1530
|
|
|
@@ -1969,8 +1962,7 @@ TraceablePeerConnection.prototype.setLocalDescription = function(description) {
|
1969
|
1962
|
this.trace('setLocalDescription::preTransform', dumpSDP(localSdp));
|
1970
|
1963
|
|
1971
|
1964
|
// Munge the order of the codecs based on the preferences set through config.js
|
1972
|
|
- // eslint-disable-next-line no-param-reassign
|
1973
|
|
- description = this._mungeCodecOrder(localSdp);
|
|
1965
|
+ localSdp = this._mungeCodecOrder(localSdp);
|
1974
|
1966
|
|
1975
|
1967
|
if (browser.usesPlanB()) {
|
1976
|
1968
|
localSdp = this._adjustLocalMediaDirection(localSdp);
|