diff --git a/src/Extension/Frame.cpp b/src/Extension/Frame.cpp index 9d826543..b43206db 100644 --- a/src/Extension/Frame.cpp +++ b/src/Extension/Frame.cpp @@ -106,47 +106,27 @@ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){ return std::make_shared(frame); } -TrackType getTrackType(CodecId codecId){ - switch (codecId){ - case CodecVP8: - case CodecVP9: - case CodecH264: - case CodecH265: return TrackVideo; - case CodecAAC: - case CodecG711A: - case CodecG711U: - case CodecOpus: - case CodecL16: return TrackAudio; - default: return TrackInvalid; +TrackType getTrackType(CodecId codecId) { + switch (codecId) { +#define XX(name, type, value, str) case name : return type; + CODEC_MAP(XX) +#undef XX + default : return TrackInvalid; } } -const char* getCodecName(CodecId codec){ +const char *getCodecName(CodecId codec) { switch (codec) { - case CodecH264 : return "H264"; - case CodecH265 : return "H265"; - case CodecAAC : return "mpeg4-generic"; - 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"; +#define XX(name, type, value, str) case name : return str; + CODEC_MAP(XX) +#undef XX + default : return "invalid"; } } -static map codec_map = { - {"H264", CodecH264}, - {"H265", CodecH265}, - {"mpeg4-generic", CodecAAC}, - {"PCMA", CodecG711A}, - {"PCMU", CodecG711U}, - {"opus", CodecOpus}, - {"VP8", CodecVP8}, - {"VP9", CodecVP9}, - {"L16", CodecL16} -}; +#define XX(name, type, value, str) {str, name}, +static map codec_map = {CODEC_MAP(XX)}; +#undef XX CodecId getCodecId(const string &str){ auto it = codec_map.find(str); diff --git a/src/Extension/Frame.h b/src/Extension/Frame.h index ce242f71..ca8a2b39 100644 --- a/src/Extension/Frame.h +++ b/src/Extension/Frame.h @@ -21,20 +21,6 @@ using namespace toolkit; namespace mediakit{ -typedef enum { - CodecInvalid = -1, - CodecH264 = 0, - CodecH265, - CodecAAC, - CodecG711A, - CodecG711U, - CodecOpus, - CodecL16, - CodecVP8, - CodecVP9, - CodecMax -} CodecId; - typedef enum { TrackInvalid = -1, TrackVideo = 0, @@ -44,6 +30,26 @@ typedef enum { TrackMax } 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; + /** * 字符串转媒体类型转 */ diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 5bd993b3..369b3ca8 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1421,7 +1421,7 @@ void RtcConfigure::RtcTrackConfigure::setDefaultSetting(TrackType type){ } case TrackVideo: { //此处调整偏好的编码格式优先级 - preferred_codec = {CodecH264, CodecH265}; + preferred_codec = {CodecH264, CodecH265, CodecAV1}; rtcp_fb = {SdpConst::kTWCCRtcpFb, SdpConst::kRembRtcpFb, "nack", "ccm fir", "nack pli"}; extmap = { RtpExtType::abs_send_time, diff --git a/webrtc/offer.sdp b/webrtc/offer.sdp index 762150d8..c3b09302 100644 --- a/webrtc/offer.sdp +++ b/webrtc/offer.sdp @@ -1,5 +1,5 @@ v=0 -o=- 257973874652185302 2 IN IP4 127.0.0.1 +o=- 8056465047193717905 2 IN IP4 127.0.0.1 s=- t=0 0 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 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 -a=ice-ufrag:w2IN -a=ice-pwd:X7kCoPoI2NqW8kxuV9LHRR78 +a=ice-ufrag:LtFR +a=ice-pwd:sUVVlvhNoL2g/GL36TyfZGwP 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=mid:0 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:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=sendrecv -a=msid:- 56049f63-4b19-45c4-aa0a-8895049b5430 +a=msid:- 2ebeb64c-2eb3-4c4f-b5d5-d578245b969e a=rtcp-mux a=rtpmap:111 opus/48000/2 a=rtcp-fb:111 transport-cc @@ -38,17 +38,17 @@ a=rtpmap:110 telephone-event/48000 a=rtpmap:112 telephone-event/32000 a=rtpmap:113 telephone-event/16000 a=rtpmap:126 telephone-event/8000 -a=ssrc:3304267696 cname:sCv+hHL1+2UbfMTB -a=ssrc:3304267696 msid:- 56049f63-4b19-45c4-aa0a-8895049b5430 -a=ssrc:3304267696 mslabel:- -a=ssrc:3304267696 label:56049f63-4b19-45c4-aa0a-8895049b5430 -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 +a=ssrc:905965261 cname:7iEkMV0/MMfqSEce +a=ssrc:905965261 msid:- 2ebeb64c-2eb3-4c4f-b5d5-d578245b969e +a=ssrc:905965261 mslabel:- +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 35 36 124 119 123 118 114 115 116 c=IN IP4 0.0.0.0 a=rtcp:9 IN IP4 0.0.0.0 -a=ice-ufrag:w2IN -a=ice-pwd:X7kCoPoI2NqW8kxuV9LHRR78 +a=ice-ufrag:LtFR +a=ice-pwd:sUVVlvhNoL2g/GL36TyfZGwP 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=mid:1 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:6 urn:ietf:params:rtp-hdrext:sdes:repaired-rtp-stream-id a=sendrecv -a=msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 +a=msid:- f36bb41d-d05d-4310-b05b-7913d0029b18 a=rtcp-mux a=rtcp-rsize 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=rtpmap:109 rtx/90000 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=rtcp-fb:124 goog-remb a=rtcp-fb:124 transport-cc a=rtcp-fb:124 ccm fir a=rtcp-fb:124 nack 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=fmtp:119 apt=124 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 nack 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=fmtp:118 apt=123 a=rtpmap:114 red/90000 a=rtpmap:115 rtx/90000 a=fmtp:115 apt=114 a=rtpmap:116 ulpfec/90000 -a=ssrc-group:FID 1128910219 3552306261 -a=ssrc:1128910219 cname:sCv+hHL1+2UbfMTB -a=ssrc:1128910219 msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 -a=ssrc:1128910219 mslabel:- -a=ssrc:1128910219 label:a73b3f5f-007a-4a46-ac8b-582ca7fee460 -a=ssrc:3552306261 cname:sCv+hHL1+2UbfMTB -a=ssrc:3552306261 msid:- a73b3f5f-007a-4a46-ac8b-582ca7fee460 -a=ssrc:3552306261 mslabel:- -a=ssrc:3552306261 label:a73b3f5f-007a-4a46-ac8b-582ca7fee460 \ No newline at end of file +a=ssrc-group:FID 2678501654 361960375 +a=ssrc:2678501654 cname:7iEkMV0/MMfqSEce +a=ssrc:2678501654 msid:- f36bb41d-d05d-4310-b05b-7913d0029b18 +a=ssrc:2678501654 mslabel:- +a=ssrc:2678501654 label:f36bb41d-d05d-4310-b05b-7913d0029b18 +a=ssrc:361960375 cname:7iEkMV0/MMfqSEce +a=ssrc:361960375 msid:- f36bb41d-d05d-4310-b05b-7913d0029b18 +a=ssrc:361960375 mslabel:- +a=ssrc:361960375 label:f36bb41d-d05d-4310-b05b-7913d0029b18 \ No newline at end of file