diff --git a/src/Extension/AACRtmp.cpp b/src/Extension/AACRtmp.cpp index fd1d3733..71ea9e66 100644 --- a/src/Extension/AACRtmp.cpp +++ b/src/Extension/AACRtmp.cpp @@ -40,8 +40,6 @@ AACFrame::Ptr AACRtmpDecoder::obtainFrame() { } bool AACRtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt, bool key_pos) { - RtmpCodec::inputRtmp(pkt, false); - if (pkt->isCfgFrame()) { _aac_cfg = pkt->getAacCfg(); return false; @@ -79,8 +77,6 @@ AACRtmpEncoder::AACRtmpEncoder(const Track::Ptr &track) { } void AACRtmpEncoder::inputFrame(const Frame::Ptr &frame) { - RtmpCodec::inputFrame(frame); - if(_aac_cfg.empty()){ if(frame->prefixSize() >= 7){ //包含adts头,从adts头获取aac配置信息 diff --git a/src/Extension/AACRtp.cpp b/src/Extension/AACRtp.cpp index 69291f59..2f001959 100644 --- a/src/Extension/AACRtp.cpp +++ b/src/Extension/AACRtp.cpp @@ -40,8 +40,6 @@ AACRtpEncoder::AACRtpEncoder(uint32_t ui32Ssrc, } void AACRtpEncoder::inputFrame(const Frame::Ptr &frame) { - RtpCodec::inputFrame(frame); - GET_CONFIG(uint32_t, cycleMS, Rtp::kCycleMS); auto uiStamp = frame->stamp(); auto pcData = frame->data() + frame->prefixSize(); @@ -102,8 +100,6 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() { } bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) { - RtpCodec::inputRtp(rtppack, false); - // 获取rtp数据长度 int length = rtppack->size() - rtppack->offset; diff --git a/src/Extension/H264Rtmp.cpp b/src/Extension/H264Rtmp.cpp index 5bea72de..3ab77554 100644 --- a/src/Extension/H264Rtmp.cpp +++ b/src/Extension/H264Rtmp.cpp @@ -41,9 +41,7 @@ H264Frame::Ptr H264RtmpDecoder::obtainFrame() { } bool H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) { - key_pos = decodeRtmp(rtmp); - RtmpCodec::inputRtmp(rtmp, key_pos); - return key_pos; + return decodeRtmp(rtmp); } bool H264RtmpDecoder::decodeRtmp(const RtmpPacket::Ptr &pkt) { @@ -105,8 +103,6 @@ H264RtmpEncoder::H264RtmpEncoder(const Track::Ptr &track) { } void H264RtmpEncoder::inputFrame(const Frame::Ptr &frame) { - RtmpCodec::inputFrame(frame); - auto pcData = frame->data() + frame->prefixSize(); auto iLen = frame->size() - frame->prefixSize(); auto type = H264_TYPE(((uint8_t*)pcData)[0]); diff --git a/src/Extension/H264Rtp.cpp b/src/Extension/H264Rtp.cpp index 367b3fce..c9861f16 100644 --- a/src/Extension/H264Rtp.cpp +++ b/src/Extension/H264Rtp.cpp @@ -76,9 +76,7 @@ H264Frame::Ptr H264RtpDecoder::obtainFrame() { } bool H264RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { - key_pos = decodeRtp(rtp); - RtpCodec::inputRtp(rtp, key_pos); - return key_pos; + return decodeRtp(rtp); } bool H264RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { @@ -232,8 +230,6 @@ H264RtpEncoder::H264RtpEncoder(uint32_t ui32Ssrc, } void H264RtpEncoder::inputFrame(const Frame::Ptr &frame) { - RtpCodec::inputFrame(frame); - GET_CONFIG(uint32_t,cycleMS,Rtp::kCycleMS); auto pcData = frame->data() + frame->prefixSize(); auto uiStamp = frame->stamp(); diff --git a/src/Extension/H265Rtp.cpp b/src/Extension/H265Rtp.cpp index 6ac9e7e0..6d164dde 100644 --- a/src/Extension/H265Rtp.cpp +++ b/src/Extension/H265Rtp.cpp @@ -76,9 +76,7 @@ H265Frame::Ptr H265RtpDecoder::obtainFrame() { } bool H265RtpDecoder::inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) { - key_pos = decodeRtp(rtp); - RtpCodec::inputRtp(rtp, key_pos); - return key_pos; + return decodeRtp(rtp); } bool H265RtpDecoder::decodeRtp(const RtpPacket::Ptr &rtppack) { @@ -167,8 +165,6 @@ H265RtpEncoder::H265RtpEncoder(uint32_t ui32Ssrc, } void H265RtpEncoder::inputFrame(const Frame::Ptr &frame) { - RtpCodec::inputFrame(frame); - GET_CONFIG(uint32_t,cycleMS,Rtp::kCycleMS); uint8_t *pcData = (uint8_t*)frame->data() + frame->prefixSize(); auto uiStamp = frame->stamp(); diff --git a/src/Rtmp/RtmpCodec.h b/src/Rtmp/RtmpCodec.h index 4772a0c1..ccdb967a 100644 --- a/src/Rtmp/RtmpCodec.h +++ b/src/Rtmp/RtmpCodec.h @@ -34,25 +34,29 @@ using namespace toolkit; namespace mediakit{ -class RtmpRingInterface { +class RtmpRing{ public: + typedef std::shared_ptr Ptr; typedef RingBuffer RingType; - typedef std::shared_ptr Ptr; - RtmpRingInterface(){} - virtual ~RtmpRingInterface(){} + RtmpRing(){} + virtual ~RtmpRing(){} /** * 获取rtmp环形缓存 * @return */ - virtual RingType::Ptr getRtmpRing() const = 0; + virtual RingType::Ptr getRtmpRing() const{ + return _rtmpRing; + } /** * 设置rtmp环形缓存 * @param ring */ - virtual void setRtmpRing(const RingType::Ptr &ring) = 0; + virtual void setRtmpRing(const RingType::Ptr &ring){ + _rtmpRing = ring; + } /** * 输入rtmp包 @@ -60,26 +64,7 @@ public: * @param key_pos 是否为关键帧 * @return 是否为关键帧 */ - virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) = 0; -}; - -class RtmpRing : public RtmpRingInterface { -public: - typedef std::shared_ptr Ptr; - - RtmpRing(){ - } - virtual ~RtmpRing(){} - - RingType::Ptr getRtmpRing() const override { - return _rtmpRing; - } - - void setRtmpRing(const RingType::Ptr &ring) override { - _rtmpRing = ring; - } - - bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) override{ + virtual bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos){ if(_rtmpRing){ _rtmpRing->write(rtmp,key_pos); } diff --git a/src/Rtmp/RtmpMuxer.cpp b/src/Rtmp/RtmpMuxer.cpp index e252d410..d81a74fa 100644 --- a/src/Rtmp/RtmpMuxer.cpp +++ b/src/Rtmp/RtmpMuxer.cpp @@ -35,7 +35,7 @@ RtmpMuxer::RtmpMuxer(const TitleMeta::Ptr &title) { }else{ _metadata = title->getMetadata(); } - _rtmpRing = std::make_shared(); + _rtmpRing = std::make_shared(); } void RtmpMuxer::addTrack(const Track::Ptr &track) { @@ -82,7 +82,7 @@ const AMFValue &RtmpMuxer::getMetadata() const { return _metadata; } -RtmpRingInterface::RingType::Ptr RtmpMuxer::getRtmpRing() const { +RtmpRing::RingType::Ptr RtmpMuxer::getRtmpRing() const { return _rtmpRing; } diff --git a/src/Rtmp/RtmpMuxer.h b/src/Rtmp/RtmpMuxer.h index 3c4743b9..c1a007fa 100644 --- a/src/Rtmp/RtmpMuxer.h +++ b/src/Rtmp/RtmpMuxer.h @@ -54,7 +54,7 @@ public: * 获取rtmp环形缓存 * @return */ - RtmpRingInterface::RingType::Ptr getRtmpRing() const; + RtmpRing::RingType::Ptr getRtmpRing() const; /** * 添加ready状态的track @@ -72,7 +72,7 @@ public: */ void resetTracks() override ; private: - RtmpRingInterface::RingType::Ptr _rtmpRing; + RtmpRing::RingType::Ptr _rtmpRing; AMFValue _metadata; RtmpCodec::Ptr _encoder[TrackMax]; }; diff --git a/src/Rtsp/RtpCodec.h b/src/Rtsp/RtpCodec.h index 0ea893c8..338de751 100644 --- a/src/Rtsp/RtpCodec.h +++ b/src/Rtsp/RtpCodec.h @@ -34,25 +34,29 @@ using namespace toolkit; namespace mediakit{ -class RtpRingInterface { +class RtpRing{ public: + typedef std::shared_ptr Ptr; typedef RingBuffer RingType; - typedef std::shared_ptr Ptr; - RtpRingInterface(){} - virtual ~RtpRingInterface(){} + RtpRing(){} + virtual ~RtpRing(){} /** * 获取rtp环形缓存 * @return */ - virtual RingType::Ptr getRtpRing() const = 0; + virtual RingType::Ptr getRtpRing() const { + return _rtpRing; + } /** * 设置rtp环形缓存 * @param ring */ - virtual void setRtpRing(const RingType::Ptr &ring) = 0; + virtual void setRtpRing(const RingType::Ptr &ring){ + _rtpRing = ring; + } /** * 输入rtp包 @@ -60,26 +64,7 @@ public: * @param key_pos 是否为关键帧第一个rtp包 * @return 是否为关键帧第一个rtp包 */ - virtual bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) = 0; -}; - -class RtpRing : public RtpRingInterface { -public: - typedef std::shared_ptr Ptr; - - RtpRing(){ - } - virtual ~RtpRing(){} - - RingType::Ptr getRtpRing() const override { - return _rtpRing; - } - - void setRtpRing(const RingType::Ptr &ring) override { - _rtpRing = ring; - } - - bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos) override{ + virtual bool inputRtp(const RtpPacket::Ptr &rtp, bool key_pos){ if(_rtpRing){ _rtpRing->write(rtp,key_pos); } diff --git a/src/Rtsp/RtspMuxer.cpp b/src/Rtsp/RtspMuxer.cpp index 1e482add..04ac57dd 100644 --- a/src/Rtsp/RtspMuxer.cpp +++ b/src/Rtsp/RtspMuxer.cpp @@ -35,7 +35,7 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title){ } else{ _sdp = title->getSdp(); } - _rtpRing = std::make_shared(); + _rtpRing = std::make_shared(); } void RtspMuxer::addTrack(const Track::Ptr &track) { @@ -69,7 +69,7 @@ string RtspMuxer::getSdp() { return _sdp; } -RtpRingInterface::RingType::Ptr RtspMuxer::getRtpRing() const { +RtpRing::RingType::Ptr RtspMuxer::getRtpRing() const { return _rtpRing; } diff --git a/src/Rtsp/RtspMuxer.h b/src/Rtsp/RtspMuxer.h index 2d9a8736..18a74515 100644 --- a/src/Rtsp/RtspMuxer.h +++ b/src/Rtsp/RtspMuxer.h @@ -56,7 +56,7 @@ public: * 获取rtp环形缓存 * @return */ - RtpRingInterface::RingType::Ptr getRtpRing() const; + RtpRing::RingType::Ptr getRtpRing() const; /** * 添加ready状态的track @@ -76,7 +76,7 @@ public: private: string _sdp; RtpCodec::Ptr _encoder[TrackMax]; - RtpRingInterface::RingType::Ptr _rtpRing; + RtpRing::RingType::Ptr _rtpRing; };