mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-06-11 10:07:49 +08:00
解决mp4_as_player设置为1时相关bug (#4725)
This commit is contained in:
parent
37ea51a2ec
commit
86a7204bab
@ -66,6 +66,11 @@ ProtocolOption::ProtocolOption() {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct MediaSourceNull : public MediaSource {
|
||||
MediaSourceNull() : MediaSource("schema", MediaTuple{"vhost", "app", "stream", ""}) {};
|
||||
int readerCount() override { return 0; }
|
||||
};
|
||||
|
||||
MediaSource &MediaSource::NullMediaSource() {
|
||||
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
||||
return *s_null;
|
||||
@ -272,7 +277,7 @@ bool MediaSource::setupRecord(Recorder::type type, bool start, const string &cus
|
||||
WarnL << "未设置MediaSource的事件监听者,setupRecord失败:" << getUrl();
|
||||
return false;
|
||||
}
|
||||
return listener->getMuxer(const_cast<MediaSource &>(*this))->setupRecord(type, start, custom_path, max_second);
|
||||
return listener->getMuxer(const_cast<MediaSource &>(*this))->setupRecord(*this, type, start, custom_path, max_second);
|
||||
}
|
||||
|
||||
bool MediaSource::isRecording(Recorder::type type){
|
||||
|
||||
@ -573,11 +573,5 @@ private:
|
||||
toolkit::ObjectStatistic<MediaSource> _statistic;
|
||||
};
|
||||
|
||||
struct MediaSourceNull : public MediaSource {
|
||||
MediaSourceNull(const MediaTuple &tuple = { "vhost", "app", "stream", "" })
|
||||
: MediaSource("schema", tuple) { };
|
||||
int readerCount() override { return 0; }
|
||||
};
|
||||
|
||||
} /* namespace mediakit */
|
||||
#endif //ZLMEDIAKIT_MEDIASOURCE_H
|
||||
|
||||
@ -206,7 +206,6 @@ void MultiMediaSourceMuxer::forEachRtpSender(const std::function<void(const std:
|
||||
}
|
||||
#endif // ENABLE_RTPPROXY
|
||||
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_sec, const ProtocolOption &option): _tuple(tuple) {
|
||||
_null_src = std::make_shared<MediaSourceNull>(tuple);
|
||||
if (!option.stream_replace.empty()) {
|
||||
// 支持在on_publish hook中替换stream_id [AUTO-TRANSLATED:375eb2ff]
|
||||
// Support replacing stream_id in on_publish hook
|
||||
@ -314,13 +313,13 @@ int MultiMediaSourceMuxer::totalReaderCount(MediaSource &sender) {
|
||||
|
||||
// 此函数可能跨线程调用 [AUTO-TRANSLATED:e8c5f74d]
|
||||
// This function may be called across threads
|
||||
bool MultiMediaSourceMuxer::setupRecord(Recorder::type type, bool start, const string &custom_path, size_t max_second) {
|
||||
bool MultiMediaSourceMuxer::setupRecord(MediaSource &sender, Recorder::type type, bool start, const string &custom_path, size_t max_second) {
|
||||
CHECK(getOwnerPoller(MediaSource::NullMediaSource())->isCurrentThread(), "Can only call setupRecord in it's owner poller");
|
||||
onceToken token(nullptr, [&]() {
|
||||
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
||||
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
||||
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
||||
onReaderChanged(*_null_src, totalReaderCount());
|
||||
onReaderChanged(sender, totalReaderCount());
|
||||
}
|
||||
});
|
||||
switch (type) {
|
||||
|
||||
@ -133,7 +133,7 @@ public:
|
||||
|
||||
* [AUTO-TRANSLATED:cb1fd8a9]
|
||||
*/
|
||||
bool setupRecord(Recorder::type type, bool start, const std::string &custom_path, size_t max_second);
|
||||
bool setupRecord(MediaSource &sender, Recorder::type type, bool start, const std::string &custom_path, size_t max_second);
|
||||
|
||||
/**
|
||||
* 开始录制mp4
|
||||
@ -266,7 +266,6 @@ private:
|
||||
toolkit::EventPoller::Ptr _poller;
|
||||
RingType::Ptr _ring;
|
||||
MediaSinkInterface::Ptr _delegate;
|
||||
MediaSourceNull::Ptr _null_src;
|
||||
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
|
||||
// Object count statistics
|
||||
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user