浏览代码

fix(codec) Always use DD when its supported by Jicofo and browser.

The bridge is now able to use DD headers for VP8 and VP9 as well so there is no need to remove it from remote desc when the call switches from AV1 to VP8/VP9.
master
Jaya Allamsetty 5 个月前
父节点
当前提交
34a32e86a4
共有 3 个文件被更改,包括 12 次插入78 次删除
  1. 0
    52
      modules/RTC/TPCUtils.js
  2. 0
    1
      modules/RTC/TraceablePeerConnection.js
  3. 12
    25
      modules/qualitycontrol/CodecSelection.js

+ 0
- 52
modules/RTC/TPCUtils.js 查看文件

@@ -18,9 +18,6 @@ import browser from '../browser';
18 18
 import SDPUtil from '../sdp/SDPUtil';
19 19
 
20 20
 const logger = getLogger('modules/RTC/TPCUtils');
21
-const DD_HEADER_EXT_URI
22
-    = 'https://aomediacodec.github.io/av1-rtp-spec/#dependency-descriptor-rtp-header-extension';
23
-const DD_HEADER_EXT_ID = 11;
24 21
 const VIDEO_CODECS = [ CodecMimeType.AV1, CodecMimeType.H264, CodecMimeType.VP8, CodecMimeType.VP9 ];
25 22
 
26 23
 /**
@@ -921,53 +918,4 @@ export class TPCUtils {
921 918
 
922 919
         return mungedSdp;
923 920
     }
924
-
925
-    /**
926
-     * Checks if the AV1 Dependency descriptors are negotiated on the bridge peerconnection and removes them from the
927
-     * SDP when codec selected is VP8 or VP9.
928
-     *
929
-     * @param {transform.SessionDescription} parsedSdp that needs to be munged.
930
-     * @returns {string} the munged SDP.
931
-     */
932
-    updateAv1DdHeaders(parsedSdp) {
933
-        if (!browser.supportsDDExtHeaders()) {
934
-            return parsedSdp;
935
-        }
936
-        const mungedSdp = parsedSdp;
937
-        const mLines = mungedSdp.media.filter(m => m.type === MediaType.VIDEO);
938
-
939
-        mLines.forEach((mLine, idx) => {
940
-            const senderMids = Array.from(this.pc.localTrackTransceiverMids.values());
941
-            const isSender = senderMids.length
942
-                ? senderMids.find(mid => mLine.mid.toString() === mid.toString())
943
-                : idx === 0;
944
-            const payload = mLine.payloads.split(' ')[0];
945
-            let { codec } = mLine.rtp.find(rtp => rtp.payload === Number(payload));
946
-
947
-            codec = codec.toLowerCase();
948
-
949
-            if (isSender && mLine.ext?.length) {
950
-                const headerIndex = mLine.ext.findIndex(ext => ext.uri === DD_HEADER_EXT_URI);
951
-                const shouldNegotiateHeaderExts = codec === CodecMimeType.AV1 || codec === CodecMimeType.H264
952
-
953
-                    // Removing DD ext header lines from the sdp breaks the scalability for FF with version 136+.
954
-                    || (codec === CodecMimeType.VP8 && browser.isFirefox());
955
-
956
-                if (!this.supportsDDHeaderExt && headerIndex >= 0) {
957
-                    this.supportsDDHeaderExt = true;
958
-                }
959
-
960
-                if (this.supportsDDHeaderExt && shouldNegotiateHeaderExts && headerIndex < 0) {
961
-                    mLine.ext.push({
962
-                        value: DD_HEADER_EXT_ID,
963
-                        uri: DD_HEADER_EXT_URI
964
-                    });
965
-                } else if (!shouldNegotiateHeaderExts && headerIndex >= 0) {
966
-                    mLine.ext.splice(headerIndex, 1);
967
-                }
968
-            }
969
-        });
970
-
971
-        return mungedSdp;
972
-    }
973 921
 }

+ 0
- 1
modules/RTC/TraceablePeerConnection.js 查看文件

@@ -1971,7 +1971,6 @@ TraceablePeerConnection.prototype._mungeDescription = function(description) {
1971 1971
     mungedSdp = this.tpcUtils.mungeOpus(mungedSdp);
1972 1972
     mungedSdp = this.tpcUtils.mungeCodecOrder(mungedSdp);
1973 1973
     mungedSdp = this.tpcUtils.setMaxBitrates(mungedSdp, true);
1974
-    mungedSdp = this.tpcUtils.updateAv1DdHeaders(mungedSdp);
1975 1974
     const mungedDescription = {
1976 1975
         type: description.type,
1977 1976
         sdp: transform.write(mungedSdp)

+ 12
- 25
modules/qualitycontrol/CodecSelection.js 查看文件

@@ -71,37 +71,24 @@ export class CodecSelection {
71 71
                 }
72 72
             }
73 73
 
74
-            // Push VP9 to the end of the list so that the client continues to decode VP9 even if its not
75
-            // preferable to encode VP9 (because of browser bugs on the encoding side or other reasons).
74
+            // Push AV1 and VP9 to the end of the list if they are supported by the browser but has implementation bugs
75
+            // For example, 136 and newer versions of Firefox supports AV1 but only simulcast and not SVC. Even with
76
+            // simulcast, temporal scalability is not supported. This way Firefox will continue to decode AV1 from
77
+            // other endpoints but will use VP8 for encoding. Similar issues exist with VP9 on Safari and Firefox.
76 78
             const isVp9EncodeSupported = browser.supportsVP9() || (browser.isWebKitBased() && connectionType === 'p2p');
77 79
 
78
-            if (!isVp9EncodeSupported) {
79
-                const index = selectedOrder.findIndex(codec => codec === CodecMimeType.VP9);
80
+            [ CodecMimeType.AV1, CodecMimeType.VP9 ].forEach(codec => {
81
+                if ((codec === CodecMimeType.AV1 && browser.isFirefox() && !enableAV1ForFF)
82
+                    || (codec === CodecMimeType.VP9 && !isVp9EncodeSupported)) {
83
+                    const index = selectedOrder.findIndex(selectedCodec => selectedCodec === codec);
80 84
 
81
-                if (index !== -1) {
82
-                    selectedOrder.splice(index, 1);
85
+                    if (index !== -1) {
86
+                        selectedOrder.splice(index, 1);
83 87
 
84
-                    // Remove VP9 from the list when E2EE is enabled since it is not supported.
85
-                    // TODO - remove this check when support for VP9-E2EE is introduced.
86
-                    if (!this.conference.isE2EEEnabled()) {
87
-                        selectedOrder.push(CodecMimeType.VP9);
88
+                        selectedOrder.push(codec);
88 89
                     }
89 90
                 }
90
-            }
91
-
92
-            // Adding this flag for testing purposes since AV1 is not properly supported by FF (it doesn't support SVC
93
-            // and it doesn't send temporal layers with simulcast).
94
-            if (browser.isFirefox() && !enableAV1ForFF) {
95
-                // By default moving AV1 to the end of the list. This way AV1 won't be used for encoding but can be
96
-                // used for decoding.
97
-                const index = selectedOrder.findIndex(codec => codec === CodecMimeType.AV1);
98
-
99
-                if (index !== -1) {
100
-                    selectedOrder.splice(index, 1);
101
-
102
-                    selectedOrder.push(CodecMimeType.AV1);
103
-                }
104
-            }
91
+            });
105 92
 
106 93
             logger.info(`Codec preference order for ${connectionType} connection is ${selectedOrder}`);
107 94
             this.codecPreferenceOrder[connectionType] = selectedOrder;

正在加载...
取消
保存