From 41bdfa0755d3c7eef6fffc2577b501226fde7cd2 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Sun, 13 Apr 2025 19:39:37 +0800 Subject: [PATCH] =?UTF-8?q?addStreamProxy=E3=80=81addStreamPusherProxy?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=A1=AE=E4=BF=9D=E7=BA=BF=E7=A8=8B=E8=B4=9F?= =?UTF-8?q?=E8=BD=BD=E5=9D=87=E8=A1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 74 +++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index bfa3c235..b5139bef 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1191,25 +1191,27 @@ void installWebApi() { auto dst_url = allArgs["dst_url"]; auto retry_count = allArgs["retry_count"].empty() ? -1 : allArgs["retry_count"].as(); - addStreamPusherProxy(allArgs["schema"], - allArgs["vhost"], - allArgs["app"], - allArgs["stream"], - allArgs["dst_url"], - retry_count, - allArgs["rtp_type"], - allArgs["timeout_sec"], - args, - [invoker, val, headerOut, dst_url](const SockException &ex, const string &key) mutable { - if (ex) { - val["code"] = API::OtherFailed; - val["msg"] = ex.what(); - } else { - val["data"]["key"] = key; - InfoL << "Publish success, please play with player:" << dst_url; - } - invoker(200, headerOut, val.toStyledString()); - }); + EventPollerPool::Instance().getPoller(false)->async([=](){ + addStreamPusherProxy(allArgs["schema"], + allArgs["vhost"], + allArgs["app"], + allArgs["stream"], + allArgs["dst_url"], + retry_count, + allArgs["rtp_type"], + allArgs["timeout_sec"], + args, + [invoker, val, headerOut, dst_url](const SockException &ex, const string &key) mutable { + if (ex) { + val["code"] = API::OtherFailed; + val["msg"] = ex.what(); + } else { + val["data"]["key"] = key; + InfoL << "Publish success, please play with player:" << dst_url; + } + invoker(200, headerOut, val.toStyledString()); + }); + }); }); // 关闭推流代理 [AUTO-TRANSLATED:91602b75] @@ -1258,22 +1260,24 @@ void installWebApi() { vhost = allArgs["vhost"]; } auto tuple = MediaTuple { vhost, allArgs["app"], allArgs["stream"], "" }; - addStreamProxy(tuple, - allArgs["url"], - retry_count, - option, - allArgs["rtp_type"], - allArgs["timeout_sec"], - args, - [invoker,val,headerOut](const SockException &ex,const string &key) mutable{ - if (ex) { - val["code"] = API::OtherFailed; - val["msg"] = ex.what(); - } else { - val["data"]["key"] = key; - } - invoker(200, headerOut, val.toStyledString()); - }); + EventPollerPool::Instance().getPoller(false)->async([=]() { + addStreamProxy(tuple, + allArgs["url"], + retry_count, + option, + allArgs["rtp_type"], + allArgs["timeout_sec"], + args, + [invoker,val,headerOut](const SockException &ex,const string &key) mutable{ + if (ex) { + val["code"] = API::OtherFailed; + val["msg"] = ex.what(); + } else { + val["data"]["key"] = key; + } + invoker(200, headerOut, val.toStyledString()); + }); + }); }); // 关闭拉流代理 [AUTO-TRANSLATED:5204f128]