webrtc新增对av1的支持

This commit is contained in:
ziyue 2021-06-16 11:14:10 +08:00
parent a67246f57e
commit 807f9626d5
4 changed files with 68 additions and 74 deletions

View File

@ -108,45 +108,25 @@ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){
TrackType getTrackType(CodecId codecId) { TrackType getTrackType(CodecId codecId) {
switch (codecId) { switch (codecId) {
case CodecVP8: #define XX(name, type, value, str) case name : return type;
case CodecVP9: CODEC_MAP(XX)
case CodecH264: #undef XX
case CodecH265: return TrackVideo;
case CodecAAC:
case CodecG711A:
case CodecG711U:
case CodecOpus:
case CodecL16: return TrackAudio;
default : return TrackInvalid; default : return TrackInvalid;
} }
} }
const char *getCodecName(CodecId codec) { const char *getCodecName(CodecId codec) {
switch (codec) { switch (codec) {
case CodecH264 : return "H264"; #define XX(name, type, value, str) case name : return str;
case CodecH265 : return "H265"; CODEC_MAP(XX)
case CodecAAC : return "mpeg4-generic"; #undef XX
case CodecG711A : return "PCMA";
case CodecG711U : return "PCMU";
case CodecOpus : return "opus";
case CodecVP8 : return "VP8";
case CodecVP9 : return "VP9";
case CodecL16 : return "L16";
default : return "invalid"; default : return "invalid";
} }
} }
static map<string, CodecId, StrCaseCompare> codec_map = { #define XX(name, type, value, str) {str, name},
{"H264", CodecH264}, static map<string, CodecId, StrCaseCompare> codec_map = {CODEC_MAP(XX)};
{"H265", CodecH265}, #undef XX
{"mpeg4-generic", CodecAAC},
{"PCMA", CodecG711A},
{"PCMU", CodecG711U},
{"opus", CodecOpus},
{"VP8", CodecVP8},
{"VP9", CodecVP9},
{"L16", CodecL16}
};
CodecId getCodecId(const string &str){ CodecId getCodecId(const string &str){
auto it = codec_map.find(str); auto it = codec_map.find(str);

View File

@ -21,20 +21,6 @@ using namespace toolkit;
namespace mediakit{ namespace mediakit{
typedef enum {
CodecInvalid = -1,
CodecH264 = 0,
CodecH265,
CodecAAC,
CodecG711A,
CodecG711U,
CodecOpus,
CodecL16,
CodecVP8,
CodecVP9,
CodecMax
} CodecId;
typedef enum { typedef enum {
TrackInvalid = -1, TrackInvalid = -1,
TrackVideo = 0, TrackVideo = 0,
@ -44,6 +30,26 @@ typedef enum {
TrackMax TrackMax
} TrackType; } TrackType;
#define CODEC_MAP(XX) \
XX(CodecH264, TrackVideo, 0, "H264") \
XX(CodecH265, TrackVideo, 1, "H265") \
XX(CodecAAC, TrackAudio, 2, "mpeg4-generic") \
XX(CodecG711A, TrackAudio, 3, "PCMA") \
XX(CodecG711U, TrackAudio, 4, "PCMU") \
XX(CodecOpus, TrackAudio, 5, "opus") \
XX(CodecL16, TrackAudio, 6, "L16") \
XX(CodecVP8, TrackVideo, 7, "VP8") \
XX(CodecVP9, TrackVideo, 8, "VP9") \
XX(CodecAV1, TrackVideo, 9, "AV1X")
typedef enum {
CodecInvalid = -1,
#define XX(name, type, value, str) name = value,
CODEC_MAP(XX)
#undef XX
CodecMax
} CodecId;
/** /**
* *
*/ */

View File

@ -1421,7 +1421,7 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){
} }
case TrackVideo: { case TrackVideo: {
//此处调整偏好的编码格式优先级 //此处调整偏好的编码格式优先级
preferred_codec = {CodecH264, CodecH265}; preferred_codec = {CodecH264, CodecH265, CodecAV1};
rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb, "nack", "ccm fir", "nack pli"}; rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb, "nack", "ccm fir", "nack pli"};
extmap = { extmap = {
RtpExtType::abs_send_time, RtpExtType::abs_send_time,

View File

@ -1,5 +1,5 @@
v=0 v=0
o=- 257973874652185302 2 IN IP4 127.0.0.1 o=- 8056465047193717905 2 IN IP4 127.0.0.1
s=- s=-
t=0 0 t=0 0
a=group:BUNDLE 0 1 a=group:BUNDLE 0 1
@ -8,10 +8,10 @@ a=msid-semantic: WMS
m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126 m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126
c=IN IP4 0.0.0.0 c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:w2IN a=ice-ufrag:LtFR
a=ice-pwd:X7kCoPoI2NqW8kxuV9LHRR78 a=ice-pwd:sUVVlvhNoL2g/GL36TyfZGwP
a=ice-options:trickle a=ice-options:trickle
a=fingerprint:sha-256 7A:A7:A4:9A:BC:37:64:68:9C:48:E5:E9:9B:97:BD:88:17:3E:E5:44:29:4D:6D:BB:AB:2C:85:B8:DE:7A:15:B1 a=fingerprint:sha-256 21:21:07:E8:3C:D0:3B:45:87:9A:31:86:DE:4F:C1:BA:E1:0E:96:BA:41:36:6E:3A:3F:C6:C8:92:95:5B:71:5F
a=setup:actpass a=setup:actpass
a=mid:0 a=mid:0
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
@ -21,7 +21,7 @@ a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv a=sendrecv
a=msid:- 56049f63-4b19-45c4-aa0a-8895049b5430 a=msid:- 2ebeb64c-2eb3-4c4f-b5d5-d578245b969e
a=rtcp-mux a=rtcp-mux
a=rtpmap:111 opus/48000/2 a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc a=rtcp-fb:111 transport-cc
@ -38,17 +38,17 @@ a=rtpmap:110 telephone-event/48000
a=rtpmap:112 telephone-event/32000 a=rtpmap:112 telephone-event/32000
a=rtpmap:113 telephone-event/16000 a=rtpmap:113 telephone-event/16000
a=rtpmap:126 telephone-event/8000 a=rtpmap:126 telephone-event/8000
a=ssrc:3304267696 cname:sCv+hHL1+2UbfMTB a=ssrc:905965261 cname:7iEkMV0/MMfqSEce
a=ssrc:3304267696 msid:- 56049f63-4b19-45c4-aa0a-8895049b5430 a=ssrc:905965261 msid:- 2ebeb64c-2eb3-4c4f-b5d5-d578245b969e
a=ssrc:3304267696 mslabel:- a=ssrc:905965261 mslabel:-
a=ssrc:3304267696 label:56049f63-4b19-45c4-aa0a-8895049b5430 a=ssrc:905965261 label:2ebeb64c-2eb3-4c4f-b5d5-d578245b969e
m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 124 119 123 118 114 115 116 m=video 9 UDP/TLS/RTP/SAVPF 96 97 98 99 100 101 102 121 127 120 125 107 108 109 35 36 124 119 123 118 114 115 116
c=IN IP4 0.0.0.0 c=IN IP4 0.0.0.0
a=rtcp:9 IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0
a=ice-ufrag:w2IN a=ice-ufrag:LtFR
a=ice-pwd:X7kCoPoI2NqW8kxuV9LHRR78 a=ice-pwd:sUVVlvhNoL2g/GL36TyfZGwP
a=ice-options:trickle a=ice-options:trickle
a=fingerprint:sha-256 7A:A7:A4:9A:BC:37:64:68:9C:48:E5:E9:9B:97:BD:88:17:3E:E5:44:29:4D:6D:BB:AB:2C:85:B8:DE:7A:15:B1 a=fingerprint:sha-256 21:21:07:E8:3C:D0:3B:45:87:9A:31:86:DE:4F:C1:BA:E1:0E:96:BA:41:36:6E:3A:3F:C6:C8:92:95:5B:71:5F
a=setup:actpass a=setup:actpass
a=mid:1 a=mid:1
a=extmap:14 urn:ietf:params:rtp-hdrext:toffset a=extmap:14 urn:ietf:params:rtp-hdrext:toffset
@ -63,7 +63,7 @@ a=extmap:4 urn:ietf:params:rtp-hdrext:sdes:mid
a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id a=extmap:5 urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id
a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=extmap:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id
a=sendrecv a=sendrecv
a=msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 a=msid:- f36bb41d-d05d-4310-b05b-7913d0029b18
a=rtcp-mux a=rtcp-mux
a=rtcp-rsize a=rtcp-rsize
a=rtpmap:96 VP8/90000 a=rtpmap:96 VP8/90000
@ -128,13 +128,21 @@ a=rtcp-fb:108 nack pli
a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f a=fmtp:108 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f
a=rtpmap:109 rtx/90000 a=rtpmap:109 rtx/90000
a=fmtp:109 apt=108 a=fmtp:109 apt=108
a=rtpmap:35 AV1X/90000
a=rtcp-fb:35 goog-remb
a=rtcp-fb:35 transport-cc
a=rtcp-fb:35 ccm fir
a=rtcp-fb:35 nack
a=rtcp-fb:35 nack pli
a=rtpmap:36 rtx/90000
a=fmtp:36 apt=35
a=rtpmap:124 H264/90000 a=rtpmap:124 H264/90000
a=rtcp-fb:124 goog-remb a=rtcp-fb:124 goog-remb
a=rtcp-fb:124 transport-cc a=rtcp-fb:124 transport-cc
a=rtcp-fb:124 ccm fir a=rtcp-fb:124 ccm fir
a=rtcp-fb:124 nack a=rtcp-fb:124 nack
a=rtcp-fb:124 nack pli a=rtcp-fb:124 nack pli
a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d001f a=fmtp:124 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=4d0032
a=rtpmap:119 rtx/90000 a=rtpmap:119 rtx/90000
a=fmtp:119 apt=124 a=fmtp:119 apt=124
a=rtpmap:123 H264/90000 a=rtpmap:123 H264/90000
@ -143,19 +151,19 @@ a=rtcp-fb:123 transport-cc
a=rtcp-fb:123 ccm fir a=rtcp-fb:123 ccm fir
a=rtcp-fb:123 nack a=rtcp-fb:123 nack
a=rtcp-fb:123 nack pli a=rtcp-fb:123 nack pli
a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=64001f a=fmtp:123 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032
a=rtpmap:118 rtx/90000 a=rtpmap:118 rtx/90000
a=fmtp:118 apt=123 a=fmtp:118 apt=123
a=rtpmap:114 red/90000 a=rtpmap:114 red/90000
a=rtpmap:115 rtx/90000 a=rtpmap:115 rtx/90000
a=fmtp:115 apt=114 a=fmtp:115 apt=114
a=rtpmap:116 ulpfec/90000 a=rtpmap:116 ulpfec/90000
a=ssrc-group:FID 1128910219 3552306261 a=ssrc-group:FID 2678501654 361960375
a=ssrc:1128910219 cname:sCv+hHL1+2UbfMTB a=ssrc:2678501654 cname:7iEkMV0/MMfqSEce
a=ssrc:1128910219 msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 a=ssrc:2678501654 msid:- f36bb41d-d05d-4310-b05b-7913d0029b18
a=ssrc:1128910219 mslabel:- a=ssrc:2678501654 mslabel:-
a=ssrc:1128910219 label:a73b3f5f-007a-4a46-ac8b-582ca7fee460 a=ssrc:2678501654 label:f36bb41d-d05d-4310-b05b-7913d0029b18
a=ssrc:3552306261 cname:sCv+hHL1+2UbfMTB a=ssrc:361960375 cname:7iEkMV0/MMfqSEce
a=ssrc:3552306261 msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 a=ssrc:361960375 msid:- f36bb41d-d05d-4310-b05b-7913d0029b18
a=ssrc:3552306261 mslabel:- a=ssrc:361960375 mslabel:-
a=ssrc:3552306261 label:a73b3f5f-007a-4a46-ac8b-582ca7fee460 a=ssrc:361960375 label:f36bb41d-d05d-4310-b05b-7913d0029b18