重写mp4录制驱动机制

This commit is contained in:
xiongziliang
2019-12-04 18:36:30 +08:00
parent d5a81d7105
commit b3fcb4c038
8 changed files with 384 additions and 52 deletions

View File

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