mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-10 04:27:49 +08:00
彻底解决mp4_as_player设置为1时,on_stream_none_reader回调无效流信息的问题 (#4725)
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
DockerPy / build (push) Has been cancelled
Linux / build (push) Has been cancelled
Linux_Python / build (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS_Python / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows_Python / build (push) Has been cancelled
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
DockerPy / build (push) Has been cancelled
Linux / build (push) Has been cancelled
Linux_Python / build (push) Has been cancelled
macOS / build (push) Has been cancelled
macOS_Python / build (push) Has been cancelled
Windows / build (push) Has been cancelled
Windows_Python / build (push) Has been cancelled
This commit is contained in:
parent
ca0f122938
commit
37ea51a2ec
@ -66,11 +66,6 @@ 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;
|
||||
|
||||
@ -573,5 +573,11 @@ 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,6 +206,7 @@ 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
|
||||
@ -319,7 +320,7 @@ bool MultiMediaSourceMuxer::setupRecord(Recorder::type type, bool start, const s
|
||||
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(*getAnyMediaSource(), totalReaderCount());
|
||||
onReaderChanged(*_null_src, totalReaderCount());
|
||||
}
|
||||
});
|
||||
switch (type) {
|
||||
@ -908,24 +909,6 @@ bool MultiMediaSourceMuxer::onTrackFrame_l(const Frame::Ptr &frame_in) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define TRY_SRC(muxer) \
|
||||
if (muxer) { \
|
||||
auto src = muxer->getMediaSource(); \
|
||||
if (src) { \
|
||||
return src; \
|
||||
} \
|
||||
}
|
||||
|
||||
MediaSource::Ptr MultiMediaSourceMuxer::getAnyMediaSource() const {
|
||||
TRY_SRC(_fmp4)
|
||||
TRY_SRC(_rtmp)
|
||||
TRY_SRC(_rtsp)
|
||||
TRY_SRC(_ts)
|
||||
TRY_SRC(_hls)
|
||||
TRY_SRC(_hls_fmp4)
|
||||
return MediaSource::NullMediaSource().shared_from_this();
|
||||
}
|
||||
|
||||
bool MultiMediaSourceMuxer::isEnabled(){
|
||||
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
|
||||
if (!_is_enable || _last_check.elapsedTime() > stream_none_reader_delay_ms) {
|
||||
|
||||
@ -237,8 +237,6 @@ protected:
|
||||
bool onTrackFrame(const Frame::Ptr &frame) override;
|
||||
bool onTrackFrame_l(const Frame::Ptr &frame);
|
||||
|
||||
MediaSource::Ptr getAnyMediaSource() const;
|
||||
|
||||
private:
|
||||
void createGopCacheIfNeed(size_t gop_count);
|
||||
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);
|
||||
@ -267,9 +265,8 @@ private:
|
||||
HlsFMP4Recorder::Ptr _hls_fmp4;
|
||||
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