webrtc url添加session参数,用于hook追踪会话唯一性

This commit is contained in:
xiongziliang 2022-03-27 21:12:19 +08:00
parent b0af3334c1
commit 5879947325
2 changed files with 9 additions and 5 deletions

@ -1 +1 @@
Subproject commit 03433394e9923685cd5856dc308da877b2d1e81f Subproject commit b82ceb1054581e8b54fdc8467acd04727cb417cf

View File

@ -1371,7 +1371,9 @@ void installWebApi() {
#ifdef ENABLE_WEBRTC #ifdef ENABLE_WEBRTC
class WebRtcArgsImp : public WebRtcArgs { class WebRtcArgsImp : public WebRtcArgs {
public: public:
WebRtcArgsImp(const HttpAllArgs<string> &args) : _args(args) {} WebRtcArgsImp(const HttpAllArgs<string> &args, std::string session_id)
: _args(args)
, _session_id(std::move(session_id)) {}
~WebRtcArgsImp() override = default; ~WebRtcArgsImp() override = default;
variant operator[](const string &key) const override { variant operator[](const string &key) const override {
@ -1387,11 +1389,12 @@ void installWebApi() {
CHECK_ARGS("app", "stream"); CHECK_ARGS("app", "stream");
return StrPrinter << RTC_SCHEMA << "://" << _args["Host"] << "/" << _args["app"] << "/" return StrPrinter << RTC_SCHEMA << "://" << _args["Host"] << "/" << _args["app"] << "/"
<< _args["stream"] << "?" << _args.getParser().Params(); << _args["stream"] << "?" << _args.getParser().Params() + "&session=" + _session_id;
} }
private: private:
HttpAllArgs<string> _args; HttpAllArgs<string> _args;
std::string _session_id;
}; };
api_regist("/index/api/webrtc",[](API_ARGS_STRING_ASYNC){ api_regist("/index/api/webrtc",[](API_ARGS_STRING_ASYNC){
@ -1400,7 +1403,8 @@ void installWebApi() {
auto offer = allArgs.getArgs(); auto offer = allArgs.getArgs();
CHECK(!offer.empty(), "http body(webrtc offer sdp) is empty"); CHECK(!offer.empty(), "http body(webrtc offer sdp) is empty");
WebRtcPluginManager::Instance().getAnswerSdp(*(static_cast<Session *>(&sender)), type, offer, WebRtcArgsImp(allArgs), WebRtcPluginManager::Instance().getAnswerSdp(
*(static_cast<Session *>(&sender)), type, offer, WebRtcArgsImp(allArgs, sender.getIdentifier()),
[invoker, val, offer, headerOut](const WebRtcInterface &exchanger) mutable { [invoker, val, offer, headerOut](const WebRtcInterface &exchanger) mutable {
//设置返回类型 //设置返回类型
headerOut["Content-Type"] = HttpFileManager::getContentType(".json"); headerOut["Content-Type"] = HttpFileManager::getContentType(".json");