From 41f1df3acfe80efa0fec4e511018f9e4a3623726 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 11 May 2020 12:06:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=87=AA=E5=AE=9A=E4=B9=89codec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtp/RtpDecoder.cpp | 5 +++-- src/Rtp/RtpDecoder.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Rtp/RtpDecoder.cpp b/src/Rtp/RtpDecoder.cpp index a08ada4f..a576c8fe 100644 --- a/src/Rtp/RtpDecoder.cpp +++ b/src/Rtp/RtpDecoder.cpp @@ -16,8 +16,9 @@ using namespace toolkit; namespace mediakit{ -RtpDecoder::RtpDecoder() { +RtpDecoder::RtpDecoder(const char *codec) { _buffer = std::make_shared(); + _codec = codec; } RtpDecoder::~RtpDecoder() { @@ -46,7 +47,7 @@ void RtpDecoder::decodeRtp(const void *data, int bytes) { uint8_t rtp_type = 0x7F & ((uint8_t *) data)[1]; InfoL << "rtp type:" << (int) rtp_type; - _rtp_decoder = rtp_payload_decode_create(rtp_type, "MP2P", &s_func, this); + _rtp_decoder = rtp_payload_decode_create(rtp_type, _codec.data(), &s_func, this); if (!_rtp_decoder) { WarnL << "unsupported rtp type:" << (int) rtp_type << ",size:" << bytes << ",hexdump" << hexdump(data, bytes > 16 ? 16 : bytes); } diff --git a/src/Rtp/RtpDecoder.h b/src/Rtp/RtpDecoder.h index 6f54e432..78a5b634 100644 --- a/src/Rtp/RtpDecoder.h +++ b/src/Rtp/RtpDecoder.h @@ -19,14 +19,15 @@ namespace mediakit{ class RtpDecoder { public: - RtpDecoder(); + RtpDecoder(const char *codec = "MP2P"); virtual ~RtpDecoder(); -protected: void decodeRtp(const void *data, int bytes); +protected: virtual void onRtpDecode(const uint8_t *packet, int bytes, uint32_t timestamp, int flags) = 0; private: void *_rtp_decoder = nullptr; BufferRaw::Ptr _buffer; + string _codec; }; }//namespace mediakit