From 9527a2b1cf966dc67c86a86cf22ea9b673b4fe67 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 12 Mar 2022 15:07:01 +0800 Subject: [PATCH] =?UTF-8?q?addStreamProxy=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=A4=9A=E7=A7=8D=E8=BD=AC=E5=8D=8F=E8=AE=AE=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 6992d4db..9ce0d7f5 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -486,6 +486,15 @@ void addStreamProxy(const string &vhost, const string &app, const string &stream player->play(url); }; +template +static Type getArgsValue(const HttpAllArgs &allArgs, const string &key, Type default_value) { + auto val = allArgs["key"]; + if (val.empty()) { + return default_value; + } + return (Type)val; +} + /** * 安装api接口 * 所有api都支持GET和POST两种方式 @@ -906,9 +915,19 @@ void installWebApi() { api_regist("/index/api/addStreamProxy",[](API_ARGS_MAP_ASYNC){ CHECK_SECRET(); CHECK_ARGS("vhost","app","stream","url"); + ProtocolOption option; - option.enable_hls = allArgs["enable_hls"]; - option.enable_mp4 = allArgs["enable_mp4"]; + option.enable_hls = getArgsValue(allArgs, "enable_hls", option.enable_hls); + option.enable_mp4 = getArgsValue(allArgs, "enable_mp4", option.enable_mp4); + option.enable_rtsp = getArgsValue(allArgs, "enable_rtsp", option.enable_rtsp); + option.enable_rtmp = getArgsValue(allArgs, "enable_rtmp", option.enable_rtmp); + option.enable_ts = getArgsValue(allArgs, "enable_ts", option.enable_ts); + option.enable_fmp4 = getArgsValue(allArgs, "enable_mp4", option.enable_fmp4); + option.enable_audio = getArgsValue(allArgs, "enable_audio", option.enable_audio); + option.add_mute_audio = getArgsValue(allArgs, "add_mute_audio", option.add_mute_audio); + option.mp4_save_path = getArgsValue(allArgs, "mp4_save_path", option.mp4_save_path); + option.mp4_max_second = getArgsValue(allArgs, "mp4_max_second", option.mp4_max_second); + option.hls_save_path = getArgsValue(allArgs, "hls_save_path", option.hls_save_path); addStreamProxy(allArgs["vhost"], allArgs["app"],