Commit 24eaaf68 by xiongziliang

初步支持webrtc whip/whep(推拉流)协议

whip推流地址: /index/api/whip?app=live&stream=test
whep拉流地址: /index/api/whep?app=live&stream=test
parent c090fc3e
...@@ -1615,6 +1615,29 @@ void installWebApi() { ...@@ -1615,6 +1615,29 @@ void installWebApi() {
} }
}); });
}); });
static auto whip_whep_func = [](const char *type, API_ARGS_STRING_ASYNC) {
auto offer = allArgs.getArgs();
CHECK(!offer.empty(), "http body(webrtc offer sdp) is empty");
WebRtcPluginManager::Instance().getAnswerSdp(*(static_cast<Session *>(&sender)), type,
WebRtcArgsImp(allArgs, sender.getIdentifier()),
[invoker, offer, headerOut](const WebRtcInterface &exchanger) mutable {
// 设置跨域
headerOut["Access-Control-Allow-Origin"] = "*";
try {
// 设置返回类型
headerOut["Content-Type"] = "application/sdp";
invoker(201, headerOut, const_cast<WebRtcInterface &>(exchanger).getAnswerSdp(offer));
} catch (std::exception &ex) {
headerOut["Content-Type"] = "text/plain";
invoker(406, headerOut, ex.what());
}
});
};
api_regist("/index/api/whip", [](API_ARGS_STRING_ASYNC) { whip_whep_func("push", API_ARGS_VALUE, invoker); });
api_regist("/index/api/whep", [](API_ARGS_STRING_ASYNC) { whip_whep_func("play", API_ARGS_VALUE, invoker); });
#endif #endif
#if defined(ENABLE_VERSION) #if defined(ENABLE_VERSION)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论