c sdk新增on_mk_media_send_rtp_stop事件回调

This commit is contained in:
xia-chu 2023-07-08 22:34:09 +08:00
parent e6a19c4ecc
commit f55e13f9da
4 changed files with 22 additions and 4 deletions

View File

@ -166,6 +166,17 @@ typedef struct {
*/ */
void (API_CALL *on_mk_log)(int level, const char *file, int line, const char *function, const char *message); void (API_CALL *on_mk_log)(int level, const char *file, int line, const char *function, const char *message);
/**
* rtp流失败回调mk_media_source_start_send_rtp/mk_media_start_send_rtp接口触发的rtp发送
* @param vhost
* @param app
* @param stream id
* @param ssrc ssrc的10进制打印atoi转换为整型
* @param err
* @param msg
*/
void(API_CALL *on_mk_media_send_rtp_stop)(const char *vhost, const char *app, const char *stream, const char *ssrc, int err, const char *msg);
} mk_events; } mk_events;

View File

@ -160,6 +160,13 @@ API_EXPORT void API_CALL mk_events_listen(const mk_events *events){
s_events.on_mk_log((int) ctx->_level, ctx->_file.data(), ctx->_line, ctx->_function.data(), log.data()); s_events.on_mk_log((int) ctx->_level, ctx->_file.data(), ctx->_line, ctx->_function.data(), log.data());
} }
}); });
NoticeCenter::Instance().addListener(&s_tag, Broadcast::kBroadcastSendRtpStopped,[](BroadcastSendRtpStoppedArgs){
if (s_events.on_mk_media_send_rtp_stop) {
s_events.on_mk_media_send_rtp_stop(sender.getMediaTuple().vhost.c_str(), sender.getMediaTuple().app.c_str(),
sender.getMediaTuple().stream.c_str(), ssrc.c_str(), ex.getErrCode(), ex.what());
}
});
}); });
} }

View File

@ -585,7 +585,7 @@ void installWebHook() {
}); });
}); });
NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::kBroadcastSendRtpStopped, [](BroadcastSendRtpStopped) { NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::kBroadcastSendRtpStopped, [](BroadcastSendRtpStoppedArgs) {
GET_CONFIG(string, hook_send_rtp_stopped, Hook::kOnSendRtpStopped); GET_CONFIG(string, hook_send_rtp_stopped, Hook::kOnSendRtpStopped);
if (!hook_enable || hook_send_rtp_stopped.empty()) { if (!hook_enable || hook_send_rtp_stopped.empty()) {
return; return;
@ -656,7 +656,7 @@ void installWebHook() {
}); });
}); });
NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::KBroadcastRtpServerTimeout, [](BroadcastRtpServerTimeout) { NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::KBroadcastRtpServerTimeout, [](BroadcastRtpServerTimeoutArgs) {
GET_CONFIG(string, rtp_server_timeout, Hook::kOnRtpServerTimeout); GET_CONFIG(string, rtp_server_timeout, Hook::kOnRtpServerTimeout);
if (!hook_enable || rtp_server_timeout.empty()) { if (!hook_enable || rtp_server_timeout.empty()) {
return; return;

View File

@ -99,7 +99,7 @@ extern const std::string kBroadcastStreamNoneReader;
// rtp推流被动停止时触发 // rtp推流被动停止时触发
extern const std::string kBroadcastSendRtpStopped; extern const std::string kBroadcastSendRtpStopped;
#define BroadcastSendRtpStopped MultiMediaSourceMuxer &sender, const std::string &ssrc, const SockException &ex #define BroadcastSendRtpStoppedArgs MultiMediaSourceMuxer &sender, const std::string &ssrc, const SockException &ex
// 更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播 // 更新配置文件事件广播,执行loadIniConfig函数加载配置文件成功后会触发该广播
extern const std::string kBroadcastReloadConfig; extern const std::string kBroadcastReloadConfig;
@ -107,7 +107,7 @@ extern const std::string kBroadcastReloadConfig;
// rtp server 超时 // rtp server 超时
extern const std::string KBroadcastRtpServerTimeout; extern const std::string KBroadcastRtpServerTimeout;
#define BroadcastRtpServerTimeout uint16_t &local_port, const string &stream_id,int &tcp_mode, bool &re_use_port, uint32_t &ssrc #define BroadcastRtpServerTimeoutArgs uint16_t &local_port, const string &stream_id,int &tcp_mode, bool &re_use_port, uint32_t &ssrc
#define ReloadConfigTag ((void *)(0xFF)) #define ReloadConfigTag ((void *)(0xFF))
#define RELOAD_KEY(arg, key) \ #define RELOAD_KEY(arg, key) \