mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-06-30 01:57:49 +08:00
Compare commits
2 Commits
427bb56507
...
37ea51a2ec
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37ea51a2ec | ||
|
|
ca0f122938 |
@ -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() {
|
MediaSource &MediaSource::NullMediaSource() {
|
||||||
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
static std::shared_ptr<MediaSource> s_null = std::make_shared<MediaSourceNull>();
|
||||||
return *s_null;
|
return *s_null;
|
||||||
|
|||||||
@ -573,5 +573,11 @@ private:
|
|||||||
toolkit::ObjectStatistic<MediaSource> _statistic;
|
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 */
|
} /* namespace mediakit */
|
||||||
#endif //ZLMEDIAKIT_MEDIASOURCE_H
|
#endif //ZLMEDIAKIT_MEDIASOURCE_H
|
||||||
|
|||||||
@ -206,6 +206,7 @@ void MultiMediaSourceMuxer::forEachRtpSender(const std::function<void(const std:
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_RTPPROXY
|
#endif // ENABLE_RTPPROXY
|
||||||
MultiMediaSourceMuxer::MultiMediaSourceMuxer(const MediaTuple& tuple, float dur_sec, const ProtocolOption &option): _tuple(tuple) {
|
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()) {
|
if (!option.stream_replace.empty()) {
|
||||||
// 支持在on_publish hook中替换stream_id [AUTO-TRANSLATED:375eb2ff]
|
// 支持在on_publish hook中替换stream_id [AUTO-TRANSLATED:375eb2ff]
|
||||||
// Support replacing stream_id in on_publish hook
|
// 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) {
|
if (_option.mp4_as_player && type == Recorder::type_mp4) {
|
||||||
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
// 开启关闭mp4录制,触发观看人数变化相关事件 [AUTO-TRANSLATED:b63a8deb]
|
||||||
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
// Turn on/off mp4 recording, trigger events related to changes in the number of viewers
|
||||||
onReaderChanged(*getAnyMediaSource(), totalReaderCount());
|
onReaderChanged(*_null_src, totalReaderCount());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -908,24 +909,6 @@ bool MultiMediaSourceMuxer::onTrackFrame_l(const Frame::Ptr &frame_in) {
|
|||||||
return ret;
|
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(){
|
bool MultiMediaSourceMuxer::isEnabled(){
|
||||||
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
|
GET_CONFIG(uint32_t, stream_none_reader_delay_ms, General::kStreamNoneReaderDelayMS);
|
||||||
if (!_is_enable || _last_check.elapsedTime() > stream_none_reader_delay_ms) {
|
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(const Frame::Ptr &frame) override;
|
||||||
bool onTrackFrame_l(const Frame::Ptr &frame);
|
bool onTrackFrame_l(const Frame::Ptr &frame);
|
||||||
|
|
||||||
MediaSource::Ptr getAnyMediaSource() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createGopCacheIfNeed(size_t gop_count);
|
void createGopCacheIfNeed(size_t gop_count);
|
||||||
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);
|
std::shared_ptr<MediaSinkInterface> makeRecorder(Recorder::type type);
|
||||||
@ -267,9 +265,8 @@ private:
|
|||||||
HlsFMP4Recorder::Ptr _hls_fmp4;
|
HlsFMP4Recorder::Ptr _hls_fmp4;
|
||||||
toolkit::EventPoller::Ptr _poller;
|
toolkit::EventPoller::Ptr _poller;
|
||||||
RingType::Ptr _ring;
|
RingType::Ptr _ring;
|
||||||
|
|
||||||
MediaSinkInterface::Ptr _delegate;
|
MediaSinkInterface::Ptr _delegate;
|
||||||
|
MediaSourceNull::Ptr _null_src;
|
||||||
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
|
// 对象个数统计 [AUTO-TRANSLATED:3b43e8c2]
|
||||||
// Object count statistics
|
// Object count statistics
|
||||||
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;
|
toolkit::ObjectStatistic<MultiMediaSourceMuxer> _statistic;
|
||||||
|
|||||||
@ -59,7 +59,7 @@ void OnvifSearcher::sendSearchBroadcast(std::string subnet_prefix, onDevice cb,
|
|||||||
_poller->async([weak_self, cb, timeout_ms, subnet_prefix]() mutable {
|
_poller->async([weak_self, cb, timeout_ms, subnet_prefix]() mutable {
|
||||||
auto strong_self = weak_self.lock();
|
auto strong_self = weak_self.lock();
|
||||||
if (strong_self) {
|
if (strong_self) {
|
||||||
strong_self->sendSearchBroadcast_l(move(subnet_prefix), std::move(cb), timeout_ms);
|
strong_self->sendSearchBroadcast_l(std::move(subnet_prefix), std::move(cb), timeout_ms);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user