From af59fdeb8629cf07d0d62a7016ffdce210788e63 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 30 Apr 2021 18:01:48 +0800 Subject: [PATCH] =?UTF-8?q?addStreamProxy=E6=8E=A5=E5=8F=A3=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=B6=85=E6=97=B6=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postman/ZLMediaKit.postman_collection.json | 6 ++++++ server/WebApi.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 75d9cbb9..93fd341e 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -512,6 +512,12 @@ "value": null, "description": "rtsp拉流时,拉流方式,0:tcp,1:udp,2:组播", "disabled": true + }, + { + "key": "timeout_sec", + "value": "10", + "description": "拉流超时时间,单位秒,float类型", + "disabled": true } ] } diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 6c88f4f5..9160c559 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -600,6 +600,7 @@ void installWebApi() { bool enable_hls, bool enable_mp4, int rtp_type, + float timeoutSec, const function &cb){ auto key = getProxyKey(vhost,app,stream); lock_guard lck(s_proxyMapMtx); @@ -614,6 +615,12 @@ void installWebApi() { //指定RTP over TCP(播放rtsp时有效) (*player)[kRtpType] = rtp_type; + + if (timeoutSec > 0.1) { + //播放握手超时时间 + (*player)[kTimeoutMS] = timeoutSec * 1000; + } + //开始播放,如果播放失败或者播放中止,将会自动重试若干次,默认一直重试 player->setPlayCallbackOnce([cb,key](const SockException &ex){ if(ex){ @@ -643,6 +650,7 @@ void installWebApi() { allArgs["enable_hls"],/* 是否hls转发 */ allArgs["enable_mp4"],/* 是否MP4录制 */ allArgs["rtp_type"], + allArgs["timeout_sec"], [invoker,val,headerOut](const SockException &ex,const string &key) mutable{ if (ex) { val["code"] = API::OtherFailed; @@ -1133,6 +1141,7 @@ void installWebApi() { true,/* 开启hls转发 */ false,/* 禁用MP4录制 */ 0,//rtp over tcp方式拉流 + 10,//10秒超时 [invoker,val,headerOut](const SockException &ex,const string &key) mutable{ if(ex){ val["code"] = API::OtherFailed;