优化代码

This commit is contained in:
xiongziliang 2019-12-03 13:05:23 +08:00
parent b50a34bf1f
commit 68718953d4
2 changed files with 4 additions and 9 deletions

View File

@ -49,14 +49,9 @@ void MediaSink::addTrack(const Track::Ptr &track_in) {
_ticker.resetTime(); _ticker.resetTime();
} }
weak_ptr<MediaSink> weakSelf = shared_from_this(); track->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame){
track->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([weakSelf](const Frame::Ptr &frame){ if(!_anyTrackUnReady){
auto strongSelf = weakSelf.lock(); onTrackFrame(frame);
if(!strongSelf){
return;
}
if(!strongSelf->_anyTrackUnReady){
strongSelf->onTrackFrame(frame);
} }
})); }));
} }

View File

@ -60,7 +60,7 @@ public:
* Track ready()true也就是就绪后再通知派生类进行下一步的操作 * Track ready()true也就是就绪后再通知派生类进行下一步的操作
* Frame前由Track截取处理下便sps pps aa_cfg * Frame前由Track截取处理下便sps pps aa_cfg
*/ */
class MediaSink : public MediaSinkInterface , public TrackSource , public std::enable_shared_from_this<MediaSink>{ class MediaSink : public MediaSinkInterface , public TrackSource{
public: public:
typedef std::shared_ptr<MediaSink> Ptr; typedef std::shared_ptr<MediaSink> Ptr;
MediaSink(){} MediaSink(){}