From 78a6f041a817dbef94cdede0376a209e93fe6911 Mon Sep 17 00:00:00 2001 From: huangcaichun <34204760+huangcaichun@users.noreply.github.com> Date: Sun, 10 Mar 2024 16:17:29 +0800 Subject: [PATCH] Fixed issue that set use_ps in startSendRtp api does not take effect (#3353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复使用startSendRtp接口转发ps流,设置use_ps为1后,还发送es流的问题 --------- Co-authored-by: huangcaichun --- server/WebApi.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 4ca72759..6956c5a2 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1299,9 +1299,10 @@ void installWebApi() { if (!src) { throw ApiRetException("can not find the source stream", API::NotFound); } + auto type = allArgs["type"].as(); if (!allArgs["use_ps"].empty()) { // 兼容之前的use_ps参数 - allArgs["type"] = allArgs["use_ps"].as(); + type = allArgs["use_ps"].as(); } MediaSourceEvent::SendRtpArgs args; args.passive = false; @@ -1312,11 +1313,11 @@ void installWebApi() { args.is_udp = allArgs["is_udp"]; args.src_port = allArgs["src_port"]; args.pt = allArgs["pt"].empty() ? 96 : allArgs["pt"].as(); - args.type = (MediaSourceEvent::SendRtpArgs::Type)(allArgs["type"].as()); + args.type = (MediaSourceEvent::SendRtpArgs::Type)type; args.only_audio = allArgs["only_audio"].as(); args.udp_rtcp_timeout = allArgs["udp_rtcp_timeout"]; args.recv_stream_id = allArgs["recv_stream_id"]; - TraceL << "startSendRtp, pt " << int(args.pt) << " rtp type " << args.type << " audio " << args.only_audio; + TraceL << "startSendRtp, pt " << int(args.pt) << " rtp type " << type << " audio " << args.only_audio; src->getOwnerPoller()->async([=]() mutable { src->startSendRtp(args, [val, headerOut, invoker](uint16_t local_port, const SockException &ex) mutable { @@ -1338,10 +1339,10 @@ void installWebApi() { if (!src) { throw ApiRetException("can not find the source stream", API::NotFound); } - + auto type = allArgs["type"].as(); if (!allArgs["use_ps"].empty()) { // 兼容之前的use_ps参数 - allArgs["type"] = allArgs["use_ps"].as(); + type = allArgs["use_ps"].as(); } MediaSourceEvent::SendRtpArgs args; @@ -1350,12 +1351,12 @@ void installWebApi() { args.is_udp = false; args.src_port = allArgs["src_port"]; args.pt = allArgs["pt"].empty() ? 96 : allArgs["pt"].as(); - args.type = (MediaSourceEvent::SendRtpArgs::Type)(allArgs["type"].as()); + args.type = (MediaSourceEvent::SendRtpArgs::Type)type; args.only_audio = allArgs["only_audio"].as(); args.recv_stream_id = allArgs["recv_stream_id"]; //tcp被动服务器等待链接超时时间 args.tcp_passive_close_delay_ms = allArgs["close_delay_ms"]; - TraceL << "startSendRtpPassive, pt " << int(args.pt) << " rtp type " << args.type << " audio " << args.only_audio; + TraceL << "startSendRtpPassive, pt " << int(args.pt) << " rtp type " << type << " audio " << args.only_audio; src->getOwnerPoller()->async([=]() mutable { src->startSendRtp(args, [val, headerOut, invoker](uint16_t local_port, const SockException &ex) mutable {