mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-17 23:37:49 +08:00
配置文件auto_close开启后也触发无人观看hook(不处理回复)
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
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / 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
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled
This commit is contained in:
parent
8bf64e0407
commit
f524a0ebbd
@ -624,13 +624,22 @@ void installWebHook() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::kBroadcastStreamNoneReader, [](BroadcastStreamNoneReaderArgs) {
|
NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::kBroadcastStreamNoneReader, [](BroadcastStreamNoneReaderArgs) {
|
||||||
|
auto auto_close = false;
|
||||||
|
auto muxer = sender.getMuxer();
|
||||||
|
if (muxer && muxer->getOption().auto_close) {
|
||||||
|
auto_close = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!origin_urls.empty() && sender.getOriginType() == MediaOriginType::pull) {
|
if (!origin_urls.empty() && sender.getOriginType() == MediaOriginType::pull) {
|
||||||
// 边沿站无人观看时如果是拉流的则立即停止溯源 [AUTO-TRANSLATED:a1429c77]
|
// 边沿站无人观看时如果是拉流的则立即停止溯源 [AUTO-TRANSLATED:a1429c77]
|
||||||
// If no one is watching at the edge station, stop tracing immediately if it is pulling
|
// If no one is watching at the edge station, stop tracing immediately if it is pulling
|
||||||
sender.close(false);
|
if (!auto_close) {
|
||||||
WarnL << "无人观看主动关闭流:" << sender.getOriginUrl();
|
sender.close(false);
|
||||||
|
WarnL << "Auto close stream when none reader: " << sender.getOriginUrl();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_CONFIG(string, hook_stream_none_reader, Hook::kOnStreamNoneReader);
|
GET_CONFIG(string, hook_stream_none_reader, Hook::kOnStreamNoneReader);
|
||||||
if (!hook_enable || hook_stream_none_reader.empty()) {
|
if (!hook_enable || hook_stream_none_reader.empty()) {
|
||||||
return;
|
return;
|
||||||
@ -642,7 +651,11 @@ void installWebHook() {
|
|||||||
weak_ptr<MediaSource> weakSrc = sender.shared_from_this();
|
weak_ptr<MediaSource> weakSrc = sender.shared_from_this();
|
||||||
// 执行hook [AUTO-TRANSLATED:1df68201]
|
// 执行hook [AUTO-TRANSLATED:1df68201]
|
||||||
// Execute hook
|
// Execute hook
|
||||||
do_http_hook(hook_stream_none_reader, body, [weakSrc](const Value &obj, const string &err) {
|
do_http_hook(hook_stream_none_reader, body, [weakSrc, auto_close](const Value &obj, const string &err) {
|
||||||
|
if (auto_close) {
|
||||||
|
// 在上层已经关闭了
|
||||||
|
return;
|
||||||
|
}
|
||||||
bool flag = obj["close"].asBool();
|
bool flag = obj["close"].asBool();
|
||||||
auto strongSrc = weakSrc.lock();
|
auto strongSrc = weakSrc.lock();
|
||||||
if (!flag || !err.empty() || !strongSrc) {
|
if (!flag || !err.empty() || !strongSrc) {
|
||||||
|
|||||||
@ -690,16 +690,15 @@ void MediaSourceEvent::onReaderChanged(MediaSource &sender, int size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_mp4_vod) {
|
if (!is_mp4_vod) {
|
||||||
|
// 直播时触发无人观看事件,让开发者自行选择是否关闭 [AUTO-TRANSLATED:c6c75eaa]
|
||||||
|
// When live streaming, trigger the no-viewer event, allowing developers to choose whether to close it.
|
||||||
|
NOTICE_EMIT(BroadcastStreamNoneReaderArgs, Broadcast::kBroadcastStreamNoneReader, *strong_sender);
|
||||||
auto muxer = strong_sender->getMuxer();
|
auto muxer = strong_sender->getMuxer();
|
||||||
if (muxer && muxer->getOption().auto_close) {
|
if (muxer && muxer->getOption().auto_close) {
|
||||||
// 此流被标记为无人观看自动关闭流 [AUTO-TRANSLATED:64a0dac3]
|
// 此流被标记为无人观看自动关闭流 [AUTO-TRANSLATED:64a0dac3]
|
||||||
// This stream is marked as an automatically closed stream with no viewers.
|
// This stream is marked as an automatically closed stream with no viewers.
|
||||||
WarnL << "Auto cloe stream when none reader: " << strong_sender->getUrl();
|
WarnL << "Auto close stream when none reader: " << strong_sender->getUrl();
|
||||||
strong_sender->close(false);
|
strong_sender->close(false);
|
||||||
} else {
|
|
||||||
// 直播时触发无人观看事件,让开发者自行选择是否关闭 [AUTO-TRANSLATED:c6c75eaa]
|
|
||||||
// When live streaming, trigger the no-viewer event, allowing developers to choose whether to close it.
|
|
||||||
NOTICE_EMIT(BroadcastStreamNoneReaderArgs, Broadcast::kBroadcastStreamNoneReader, *strong_sender);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 这个是mp4点播,我们自动关闭 [AUTO-TRANSLATED:8a7b9a90]
|
// 这个是mp4点播,我们自动关闭 [AUTO-TRANSLATED:8a7b9a90]
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user