修复对象同名导致的bug

This commit is contained in:
ziyue 2021-07-16 15:54:43 +08:00
parent 8548753c28
commit 892b2d2ef9
3 changed files with 21 additions and 35 deletions

View File

@ -11,6 +11,7 @@
#if defined(ENABLE_RTPPROXY) #if defined(ENABLE_RTPPROXY)
#include "PSEncoder.h" #include "PSEncoder.h"
#include "Extension/H264.h" #include "Extension/H264.h"
#include "Rtsp/RtspMuxer.h"
namespace mediakit{ namespace mediakit{
PSEncoder::PSEncoder() { PSEncoder::PSEncoder() {
@ -147,24 +148,6 @@ void PSEncoder::inputFrame(const Frame::Ptr &frame) {
} }
} }
////////////////////////////////////////////////////////////////////////////////////////////////
class RingDelegateHelper : public RingDelegate<RtpPacket::Ptr> {
public:
typedef function<void(RtpPacket::Ptr in, bool is_key)> onRtp;
~RingDelegateHelper() override{}
RingDelegateHelper(onRtp on_rtp){
_on_rtp = std::move(on_rtp);
}
void onWrite(RtpPacket::Ptr in, bool is_key) override{
_on_rtp(std::move(in), is_key);
}
private:
onRtp _on_rtp;
};
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PSEncoderImp::PSEncoderImp(uint32_t ssrc, uint8_t payload_type) { PSEncoderImp::PSEncoderImp(uint32_t ssrc, uint8_t payload_type) {

View File

@ -13,20 +13,6 @@
namespace mediakit { namespace mediakit {
class RingDelegateHelper : public RingDelegate<RtpPacket::Ptr> {
public:
RingDelegateHelper(RtspMuxer *delegate) {
_delegate = delegate;
}
void onWrite(RtpPacket::Ptr in, bool is_key) override {
_delegate->onRtp(std::move(in), is_key);
}
private:
RtspMuxer *_delegate;
};
void RtspMuxer::onRtp(RtpPacket::Ptr in, bool is_key) { void RtspMuxer::onRtp(RtpPacket::Ptr in, bool is_key) {
if (_rtp_stamp[in->type] != in->getHeader()->stamp) { if (_rtp_stamp[in->type] != in->getHeader()->stamp) {
//rtp时间戳变化才计算ntp节省cpu资源 //rtp时间戳变化才计算ntp节省cpu资源
@ -51,7 +37,9 @@ RtspMuxer::RtspMuxer(const TitleSdp::Ptr &title) {
} }
_rtpRing = std::make_shared<RtpRing::RingType>(); _rtpRing = std::make_shared<RtpRing::RingType>();
_rtpInterceptor = std::make_shared<RtpRing::RingType>(); _rtpInterceptor = std::make_shared<RtpRing::RingType>();
_rtpInterceptor->setDelegate(std::make_shared<RingDelegateHelper>(this)); _rtpInterceptor->setDelegate(std::make_shared<RingDelegateHelper>([this](RtpPacket::Ptr in, bool is_key) {
onRtp(std::move(in), is_key);
}));
_ntp_stamp_start = getCurrentMillisecond(true); _ntp_stamp_start = getCurrentMillisecond(true);
} }

View File

@ -17,12 +17,28 @@
#include "RtpCodec.h" #include "RtpCodec.h"
namespace mediakit{ namespace mediakit{
class RingDelegateHelper : public RingDelegate<RtpPacket::Ptr> {
public:
typedef function<void(RtpPacket::Ptr in, bool is_key)> onRtp;
~RingDelegateHelper() override{}
RingDelegateHelper(onRtp on_rtp){
_on_rtp = std::move(on_rtp);
}
void onWrite(RtpPacket::Ptr in, bool is_key) override{
_on_rtp(std::move(in), is_key);
}
private:
onRtp _on_rtp;
};
/** /**
* rtsp生成器 * rtsp生成器
*/ */
class RtspMuxer : public MediaSinkInterface{ class RtspMuxer : public MediaSinkInterface{
public: public:
friend class RingDelegateHelper;
using Ptr = std::shared_ptr<RtspMuxer>; using Ptr = std::shared_ptr<RtspMuxer>;
/** /**
@ -62,7 +78,6 @@ public:
private: private:
void onRtp(RtpPacket::Ptr in, bool is_key); void onRtp(RtpPacket::Ptr in, bool is_key);
void computeNtp(const Frame::Ptr &frame);
void trySyncTrack(); void trySyncTrack();
private: private: