From cfd5957c25ec82a7f51290ccb17ee37cd7e05d6e Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Sat, 16 Oct 2021 17:07:21 +0800 Subject: [PATCH] =?UTF-8?q?webrtc=20echo=20test=E4=B8=8D=E6=A3=80=E6=9F=A5?= =?UTF-8?q?app/stream=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index d5bb071d..181eebf6 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1187,11 +1187,8 @@ void installWebApi() { #ifdef ENABLE_WEBRTC api_regist("/index/api/webrtc",[](API_ARGS_STRING_ASYNC){ - CHECK_ARGS("app", "stream"); - auto offer_sdp = allArgs.getArgs(); auto type = allArgs["type"]; - MediaInfo info(StrPrinter << "rtc://" << allArgs["Host"] << "/" << allArgs["app"] << "/" << allArgs["stream"] << "?" << allArgs.getParser().Params()); //设置返回类型 headerOut["Content-Type"] = HttpFileManager::getContentType(".json"); @@ -1199,6 +1196,9 @@ void installWebApi() { headerOut["Access-Control-Allow-Origin"] = "*"; if (type.empty() || !strcasecmp(type.data(), "play")) { + CHECK_ARGS("app", "stream"); + MediaInfo info(StrPrinter << "rtc://" << allArgs["Host"] << "/" << allArgs["app"] << "/" << allArgs["stream"] << "?" << allArgs.getParser().Params()); + auto session = static_cast(&sender); auto session_ptr = session->shared_from_this(); Broadcast::AuthInvoker authInvoker = [invoker, offer_sdp, val, info, headerOut, session_ptr](const string &err) mutable { @@ -1238,6 +1238,9 @@ void installWebApi() { } if (!strcasecmp(type.data(), "push")) { + CHECK_ARGS("app", "stream"); + MediaInfo info(StrPrinter << "rtc://" << allArgs["Host"] << "/" << allArgs["app"] << "/" << allArgs["stream"] << "?" << allArgs.getParser().Params()); + Broadcast::PublishAuthInvoker authInvoker = [invoker, offer_sdp, val, info, headerOut](const string &err, bool enableHls, bool enableMP4) mutable { try { auto src = dynamic_pointer_cast(MediaSource::find(RTSP_SCHEMA, info._vhost, info._app, info._streamid));