修复写两次Track的bug

This commit is contained in:
xiongziliang 2018-10-26 22:07:01 +08:00
parent c03ea1d893
commit affc98f927
3 changed files with 7 additions and 5 deletions

View File

@ -49,8 +49,9 @@ public:
* @param track
*/
void addTrack(const Track::Ptr & track) {
_rtmp->addTrack(track);
_rtsp->addTrack(track);
//克隆track的目的是防止inputFrame时由于用的同一个track而导致写入两次数据
_rtmp->addTrack(track->clone());
_rtsp->addTrack(track->clone());
}
/**
@ -58,6 +59,7 @@ public:
* @param frame
*/
void inputFrame(const Frame::Ptr &frame) override {
//_rtmp和_rtsp对象不能使用相同的Track否则会触发两次inputFrame操作
_rtmp->inputFrame(frame);
_rtsp->inputFrame(frame);
}

View File

@ -68,7 +68,6 @@ public:
typedef std::shared_ptr<RtmpRing> Ptr;
RtmpRing(){
_rtmpRing = std::make_shared<RingType>();
}
virtual ~RtmpRing(){}
@ -81,7 +80,9 @@ public:
}
bool inputRtmp(const RtmpPacket::Ptr &rtmp, bool key_pos) override{
_rtmpRing->write(rtmp,key_pos);
if(_rtmpRing){
_rtmpRing->write(rtmp,key_pos);
}
return key_pos;
}
protected:

View File

@ -85,7 +85,6 @@ public:
typedef std::shared_ptr<RtpRing> Ptr;
RtpRing(){
_rtpRing = std::make_shared<RingType>();
}
virtual ~RtpRing(){}