From 5879947325ce972f079edfcbfc64afe6b3cb7f5a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 27 Mar 2022 21:12:19 +0800 Subject: [PATCH] =?UTF-8?q?webrtc=20url=E6=B7=BB=E5=8A=A0session=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E7=94=A8=E4=BA=8Ehook=E8=BF=BD=E8=B8=AA?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E5=94=AF=E4=B8=80=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- server/WebApi.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 03433394..b82ceb10 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 03433394e9923685cd5856dc308da877b2d1e81f +Subproject commit b82ceb1054581e8b54fdc8467acd04727cb417cf diff --git a/server/WebApi.cpp b/server/WebApi.cpp index b0538d16..b44309e6 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1371,7 +1371,9 @@ void installWebApi() { #ifdef ENABLE_WEBRTC class WebRtcArgsImp : public WebRtcArgs { public: - WebRtcArgsImp(const HttpAllArgs &args) : _args(args) {} + WebRtcArgsImp(const HttpAllArgs &args, std::string session_id) + : _args(args) + , _session_id(std::move(session_id)) {} ~WebRtcArgsImp() override = default; variant operator[](const string &key) const override { @@ -1387,11 +1389,12 @@ void installWebApi() { CHECK_ARGS("app", "stream"); return StrPrinter << RTC_SCHEMA << "://" << _args["Host"] << "/" << _args["app"] << "/" - << _args["stream"] << "?" << _args.getParser().Params(); + << _args["stream"] << "?" << _args.getParser().Params() + "&session=" + _session_id; } private: HttpAllArgs _args; + std::string _session_id; }; api_regist("/index/api/webrtc",[](API_ARGS_STRING_ASYNC){ @@ -1400,8 +1403,9 @@ void installWebApi() { auto offer = allArgs.getArgs(); CHECK(!offer.empty(), "http body(webrtc offer sdp) is empty"); - WebRtcPluginManager::Instance().getAnswerSdp(*(static_cast(&sender)), type, offer, WebRtcArgsImp(allArgs), - [invoker, val, offer, headerOut](const WebRtcInterface &exchanger) mutable { + WebRtcPluginManager::Instance().getAnswerSdp( + *(static_cast(&sender)), type, offer, WebRtcArgsImp(allArgs, sender.getIdentifier()), + [invoker, val, offer, headerOut](const WebRtcInterface &exchanger) mutable { //设置返回类型 headerOut["Content-Type"] = HttpFileManager::getContentType(".json"); //设置跨域