mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-11-24 17:07:22 +08:00
整理webrtc c接口
This commit is contained in:
@@ -1114,27 +1114,23 @@ void WebRtcPluginManager::registerPlugin(const string &type, Plugin cb) {
|
||||
_map_creator[type] = std::move(cb);
|
||||
}
|
||||
|
||||
void WebRtcPluginManager::getAnswerSdp(
|
||||
Session &sender, const string &type, const string &offer, const WebRtcArgs &args, const onCreateRtc &cb) {
|
||||
void WebRtcPluginManager::getAnswerSdp(Session &sender, const string &type, const WebRtcArgs &args, const onCreateRtc &cb) {
|
||||
lock_guard<mutex> lck(_mtx_creator);
|
||||
auto it = _map_creator.find(type);
|
||||
if (it == _map_creator.end()) {
|
||||
cb(WebRtcException(SockException(Err_other, "the type can not supported")));
|
||||
return;
|
||||
}
|
||||
it->second(sender, offer, args, cb);
|
||||
it->second(sender, args, cb);
|
||||
}
|
||||
|
||||
void echo_plugin(
|
||||
Session &sender, const string &offer, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
void echo_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
cb(*WebRtcEchoTest::create(EventPollerPool::Instance().getPoller()));
|
||||
}
|
||||
|
||||
void push_plugin(
|
||||
Session &sender, const string &offer_sdp, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
void push_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
MediaInfo info(args["url"]);
|
||||
Broadcast::PublishAuthInvoker invoker = [cb, offer_sdp,
|
||||
info](const string &err, const ProtocolOption &option) mutable {
|
||||
Broadcast::PublishAuthInvoker invoker = [cb, info](const string &err, const ProtocolOption &option) mutable {
|
||||
if (!err.empty()) {
|
||||
cb(WebRtcException(SockException(Err_other, err)));
|
||||
return;
|
||||
@@ -1173,26 +1169,23 @@ void push_plugin(
|
||||
push_src_ownership = push_src->getOwnership();
|
||||
push_src->setProtocolOption(option);
|
||||
}
|
||||
auto rtc
|
||||
= WebRtcPusher::create(EventPollerPool::Instance().getPoller(), push_src, push_src_ownership, info, option);
|
||||
auto rtc = WebRtcPusher::create(EventPollerPool::Instance().getPoller(), push_src, push_src_ownership, info, option);
|
||||
push_src->setListener(rtc);
|
||||
cb(*rtc);
|
||||
};
|
||||
|
||||
// rtsp推流需要鉴权
|
||||
auto flag = NoticeCenter::Instance().emitEvent(
|
||||
Broadcast::kBroadcastMediaPublish, MediaOriginType::rtc_push, info, invoker, static_cast<SockInfo &>(sender));
|
||||
auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPublish, MediaOriginType::rtc_push, info, invoker, static_cast<SockInfo &>(sender));
|
||||
if (!flag) {
|
||||
// 该事件无人监听,默认不鉴权
|
||||
invoker("", ProtocolOption());
|
||||
}
|
||||
}
|
||||
|
||||
void play_plugin(
|
||||
Session &sender, const string &offer_sdp, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginManager::onCreateRtc &cb) {
|
||||
MediaInfo info(args["url"]);
|
||||
auto session_ptr = sender.shared_from_this();
|
||||
Broadcast::AuthInvoker invoker = [cb, offer_sdp, info, session_ptr](const string &err) mutable {
|
||||
Broadcast::AuthInvoker invoker = [cb, info, session_ptr](const string &err) mutable {
|
||||
if (!err.empty()) {
|
||||
cb(WebRtcException(SockException(Err_other, err)));
|
||||
return;
|
||||
@@ -1214,8 +1207,7 @@ void play_plugin(
|
||||
};
|
||||
|
||||
// 广播通用播放url鉴权事件
|
||||
auto flag = NoticeCenter::Instance().emitEvent(
|
||||
Broadcast::kBroadcastMediaPlayed, info, invoker, static_cast<SockInfo &>(sender));
|
||||
auto flag = NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastMediaPlayed, info, invoker, static_cast<SockInfo &>(sender));
|
||||
if (!flag) {
|
||||
// 该事件无人监听,默认不鉴权
|
||||
invoker("");
|
||||
|
||||
Reference in New Issue
Block a user