修复开启转协议后,无人观看掐流延时不定期的bug

This commit is contained in:
xiongziliang 2020-06-19 10:19:42 +08:00
parent f881108dfe
commit e76bc65243
5 changed files with 28 additions and 2 deletions

View File

@ -240,6 +240,15 @@ int FFmpegSource::totalReaderCount(MediaSource &sender) {
return sender.readerCount(); return sender.readerCount();
} }
void FFmpegSource::onNoneReader(MediaSource &sender){
auto listener = _listener.lock();
if(listener){
listener->onNoneReader(sender);
return;
}
MediaSourceEvent::onNoneReader(sender);
}
void FFmpegSource::onGetMediaSource(const MediaSource::Ptr &src) { void FFmpegSource::onGetMediaSource(const MediaSource::Ptr &src) {
_listener = src->getListener(); _listener = src->getListener();
src->setListener(shared_from_this()); src->setListener(shared_from_this());

View File

@ -61,6 +61,8 @@ private:
//MediaSourceEvent override //MediaSourceEvent override
bool close(MediaSource &sender,bool force) override; bool close(MediaSource &sender,bool force) override;
int totalReaderCount(MediaSource &sender) override; int totalReaderCount(MediaSource &sender) override;
void onNoneReader(MediaSource &sender) override;
private: private:
Process _process; Process _process;
Timer::Ptr _timer; Timer::Ptr _timer;

View File

@ -53,9 +53,9 @@ public:
virtual bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path) { return false; }; virtual bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path) { return false; };
// 获取录制状态 // 获取录制状态
virtual bool isRecording(MediaSource &sender, Recorder::type type) { return false; }; virtual bool isRecording(MediaSource &sender, Recorder::type type) { return false; };
private:
// 通知无人观看 // 通知无人观看
void onNoneReader(MediaSource &sender); virtual void onNoneReader(MediaSource &sender);
private: private:
Timer::Ptr _async_close_timer; Timer::Ptr _async_close_timer;
}; };

View File

@ -278,6 +278,15 @@ int MultiMediaSourceMuxer::totalReaderCount(MediaSource &sender) {
return listener->totalReaderCount(sender); return listener->totalReaderCount(sender);
} }
void MultiMediaSourceMuxer::onNoneReader(MediaSource &sender){
auto listener = _listener.lock();
if (!listener) {
MediaSourceEvent::onNoneReader(sender);
return;
}
listener->onNoneReader(sender);
}
bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path) { bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path) {
return _muxer->setupRecord(sender,type,start,custom_path); return _muxer->setupRecord(sender,type,start,custom_path);
} }

View File

@ -131,6 +131,12 @@ public:
*/ */
int totalReaderCount(MediaSource &sender) override; int totalReaderCount(MediaSource &sender) override;
/**
*
* @param sender
*/
void onNoneReader(MediaSource &sender) override;
/** /**
* *
* @param type * @param type