媒体注册、重置事件改成同步触发

This commit is contained in:
xiongziliang 2020-02-01 22:57:48 +08:00
parent 075a615a92
commit 6a97fcb3de

View File

@ -78,14 +78,7 @@ vector<Track::Ptr> MediaSource::getTracks(bool trackReady) const {
void MediaSource::setTrackSource(const std::weak_ptr<TrackSource> &track_src) { void MediaSource::setTrackSource(const std::weak_ptr<TrackSource> &track_src) {
_track_source = track_src; _track_source = track_src;
weak_ptr<MediaSource> weakPtr = shared_from_this(); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaResetTracks, *this);
EventPollerPool::Instance().getPoller()->async([weakPtr,this](){
auto strongPtr = weakPtr.lock();
if (!strongPtr) {
return;
}
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaResetTracks, *this);
},false);
} }
void MediaSource::setListener(const std::weak_ptr<MediaSourceEvent> &listener){ void MediaSource::setListener(const std::weak_ptr<MediaSourceEvent> &listener){
@ -293,14 +286,7 @@ void MediaSource::regist() {
g_mapMediaSrc[_strSchema][_strVhost][_strApp][_strId] = shared_from_this(); g_mapMediaSrc[_strSchema][_strVhost][_strApp][_strId] = shared_from_this();
} }
InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId; InfoL << _strSchema << " " << _strVhost << " " << _strApp << " " << _strId;
weak_ptr<MediaSource> weakPtr = shared_from_this(); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, true, *this);
EventPollerPool::Instance().getPoller()->async([weakPtr,this](){
auto strongPtr = weakPtr.lock();
if (!strongPtr) {
return;
}
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaChanged, true, *this);
},false);
} }
bool MediaSource::unregist() { bool MediaSource::unregist() {
//反注册该源 //反注册该源