mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-04 09:47:33 +08:00
on_publish hook新增continue_push_ms参数,用于断连续推延时控制
This commit is contained in:
@@ -26,11 +26,14 @@ ProtocolOption::ProtocolOption() {
|
||||
GET_CONFIG(bool, s_to_mp4, General::kPublishToMP4);
|
||||
GET_CONFIG(bool, s_enabel_audio, General::kEnableAudio);
|
||||
GET_CONFIG(bool, s_add_mute_audio, General::kAddMuteAudio);
|
||||
GET_CONFIG(uint32_t, s_continue_push_ms, General::kContinuePushMS);
|
||||
|
||||
|
||||
enable_hls = s_to_hls;
|
||||
enable_mp4 = s_to_mp4;
|
||||
enable_audio = s_enabel_audio;
|
||||
add_mute_audio = s_add_mute_audio;
|
||||
continue_push_ms = s_continue_push_ms;
|
||||
}
|
||||
|
||||
static std::shared_ptr<MediaSinkInterface> makeRecorder(MediaSource &sender, const vector<Track::Ptr> &tracks, Recorder::type type, const string &custom_path, size_t max_second){
|
||||
|
||||
@@ -52,6 +52,9 @@ public:
|
||||
|
||||
//hls录制保存路径
|
||||
std::string hls_save_path;
|
||||
|
||||
//断连续推延时,单位毫秒,默认采用配置文件
|
||||
uint32_t continue_push_ms;
|
||||
};
|
||||
|
||||
class MultiMediaSourceMuxer : public MediaSourceEventInterceptor, public MediaSink, public std::enable_shared_from_this<MultiMediaSourceMuxer>{
|
||||
|
||||
@@ -44,14 +44,13 @@ void RtmpSession::onError(const SockException& err) {
|
||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, is_player, static_cast<SockInfo &>(*this));
|
||||
}
|
||||
|
||||
GET_CONFIG(uint32_t, continue_push_ms, General::kContinuePushMS);
|
||||
//如果是主动关闭的,那么不延迟注销
|
||||
if (_push_src && continue_push_ms && err.getErrCode() != Err_shutdown) {
|
||||
if (_push_src && _continue_push_ms && err.getErrCode() != Err_shutdown) {
|
||||
//取消所有权
|
||||
_push_src_ownership = nullptr;
|
||||
//延时10秒注销流
|
||||
auto push_src = std::move(_push_src);
|
||||
getPoller()->doDelayTask(continue_push_ms, [push_src]() { return 0; });
|
||||
getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +183,7 @@ void RtmpSession::onCmd_publish(AMFDecoder &dec) {
|
||||
}
|
||||
|
||||
_push_src->setListener(dynamic_pointer_cast<MediaSourceEvent>(shared_from_this()));
|
||||
|
||||
_continue_push_ms = option.continue_push_ms;
|
||||
sendStatus({"level", "status",
|
||||
"code", "NetStream.Publish.Start",
|
||||
"description", "Started publishing stream.",
|
||||
|
||||
@@ -89,6 +89,8 @@ private:
|
||||
private:
|
||||
bool _set_meta_data = false;
|
||||
double _recv_req_id = 0;
|
||||
//断连续推延时
|
||||
uint32_t _continue_push_ms = 0;
|
||||
//消耗的总流量
|
||||
uint64_t _total_bytes = 0;
|
||||
std::string _tc_url;
|
||||
|
||||
@@ -86,14 +86,13 @@ void RtspSession::onError(const SockException &err) {
|
||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _media_info, _bytes_usage, duration, is_player, static_cast<SockInfo &>(*this));
|
||||
}
|
||||
|
||||
GET_CONFIG(uint32_t, continue_push_ms, General::kContinuePushMS);
|
||||
//如果是主动关闭的,那么不延迟注销
|
||||
if (_push_src && continue_push_ms && err.getErrCode() != Err_shutdown) {
|
||||
if (_push_src && _continue_push_ms && err.getErrCode() != Err_shutdown) {
|
||||
//取消所有权
|
||||
_push_src_ownership = nullptr;
|
||||
//延时10秒注销流
|
||||
auto push_src = std::move(_push_src);
|
||||
getPoller()->doDelayTask(continue_push_ms, [push_src]() { return 0; });
|
||||
getPoller()->doDelayTask(_continue_push_ms, [push_src]() { return 0; });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,6 +279,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) {
|
||||
}
|
||||
|
||||
_push_src->setListener(dynamic_pointer_cast<MediaSourceEvent>(shared_from_this()));
|
||||
_continue_push_ms = option.continue_push_ms;
|
||||
sendRtspResponse("200 OK");
|
||||
};
|
||||
|
||||
|
||||
@@ -163,6 +163,9 @@ private:
|
||||
private:
|
||||
//是否已经触发on_play事件
|
||||
bool _emit_on_play = false;
|
||||
bool _send_sr_rtcp[2] = {true, true};
|
||||
//断连续推延时
|
||||
uint32_t _continue_push_ms = 0;
|
||||
//推流或拉流客户端采用的rtp传输方式
|
||||
Rtsp::eRtpType _rtp_type = Rtsp::RTP_Invalid;
|
||||
//收到的seq,回复时一致
|
||||
@@ -213,7 +216,6 @@ private:
|
||||
toolkit::Ticker _rtcp_send_tickers[2];
|
||||
//统计rtp并发送rtcp
|
||||
std::vector<RtcpContext::Ptr> _rtcp_context;
|
||||
bool _send_sr_rtcp[2] = {true, true};
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user