优化代码

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();
}
weak_ptr<MediaSink> weakSelf = shared_from_this();
track->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([weakSelf](const Frame::Ptr &frame){
auto strongSelf = weakSelf.lock();
if(!strongSelf){
return;
}
if(!strongSelf->_anyTrackUnReady){
strongSelf->onTrackFrame(frame);
track->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([this](const Frame::Ptr &frame){
if(!_anyTrackUnReady){
onTrackFrame(frame);
}
}));
}

View File

@ -60,7 +60,7 @@ public:
* Track ready()true也就是就绪后再通知派生类进行下一步的操作
* 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:
typedef std::shared_ptr<MediaSink> Ptr;
MediaSink(){}