From 3a80b1de1e21ef3c2d7b1258c7c354de8726a6ad Mon Sep 17 00:00:00 2001 From: waken <33921191+mc373906408@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:59:09 +0800 Subject: [PATCH] =?UTF-8?q?openRtpServer=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9Elocal=5Fip=E5=8F=82=E6=95=B0=20(#3224)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/ZLMediaKit/ZLMediaKit/issues/3218 ipv4环境下,修改local_ip为0.0.0.0后可实现在openRtpServer后startSendRtp复用端口 仅测试windows服务端,sip与sip通话 --- postman/ZLMediaKit.postman_collection.json | 25 ++++++++++++++++------ server/WebApi.cpp | 14 ++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/postman/ZLMediaKit.postman_collection.json b/postman/ZLMediaKit.postman_collection.json index 59840416..a6dc237f 100644 --- a/postman/ZLMediaKit.postman_collection.json +++ b/postman/ZLMediaKit.postman_collection.json @@ -1,10 +1,11 @@ { "info": { - "_postman_id": "509e5f6b-728c-4d5f-b3e8-521d76b2cc7a", + "_postman_id": "08e3bc35-5318-4949-81bb-90d854706194", "name": "ZLMediaKit", "description": "媒体服务器", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "29185956" + "_exporter_id": "29185956", + "_collection_link": "https://lively-station-598157.postman.co/workspace/%E6%B5%81%E5%AA%92%E4%BD%93%E6%9C%8D%E5%8A%A1~1e119172-45b0-4ed6-b1fc-8a15d0e2d5f8/collection/29185956-08e3bc35-5318-4949-81bb-90d854706194?action=share&source=collection_link&creator=29185956" }, "item": [ { @@ -1216,7 +1217,7 @@ "method": "GET", "header": [], "url": { - "raw": "{{ZLMediaKit_URL}}/index/api/seekRecordStamp?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=live&stream=obs&stamp", + "raw": "{{ZLMediaKit_URL}}/index/api/seekRecordStamp?secret={{ZLMediaKit_secret}}&vhost={{defaultVhost}}&app=live&stream=obs&stamp=1000", "host": [ "{{ZLMediaKit_URL}}" ], @@ -1473,6 +1474,12 @@ "value": "1", "description": "是否为单音频track,用于语音对讲", "disabled": true + }, + { + "key": "local_ip", + "value": "::", + "description": "指定创建RTP的本地ip,ipv4可填”0.0.0.0“,ipv6可填”::“,一般保持默认", + "disabled": true } ] } @@ -1485,14 +1492,14 @@ "method": "GET", "header": [], "url": { - "raw": "{{ZLMediaKit_URL}}/index/api/openRtpServer?secret={{ZLMediaKit_secret}}&port=0&tcp_mode=1&stream_id=test", + "raw": "{{ZLMediaKit_URL}}/index/api/openRtpServerMultiplex?secret={{ZLMediaKit_secret}}&port=0&tcp_mode=1&stream_id=test", "host": [ "{{ZLMediaKit_URL}}" ], "path": [ "index", "api", - "openRtpServer" + "openRtpServerMultiplex" ], "query": [ { @@ -1520,6 +1527,12 @@ "value": "0", "description": "是否为单音频track,用于语音对讲", "disabled": true + }, + { + "key": "local_ip", + "value": "::", + "description": "指定创建RTP的本地ip,ipv4可填”0.0.0.0“,ipv6可填”::“,一般保持默认", + "disabled": true } ] } @@ -2252,4 +2265,4 @@ "value": "__defaultVhost__" } ] -} +} \ No newline at end of file diff --git a/server/WebApi.cpp b/server/WebApi.cpp index aa3df337..14b654c3 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -1197,7 +1197,11 @@ void installWebApi() { //兼容老版本请求,新版本去除enable_tcp参数并新增tcp_mode参数 tcp_mode = 1; } - auto port = openRtpServer(allArgs["port"], stream_id, tcp_mode, "::", allArgs["re_use_port"].as(), + std::string local_ip = "::"; + if (!allArgs["local_ip"].empty()) { + local_ip = allArgs["local_ip"]; + } + auto port = openRtpServer(allArgs["port"], stream_id, tcp_mode, local_ip, allArgs["re_use_port"].as(), allArgs["ssrc"].as(), allArgs["only_audio"].as()); if (port == 0) { throw InvalidArgsException("该stream_id已存在"); @@ -1215,9 +1219,11 @@ void installWebApi() { // 兼容老版本请求,新版本去除enable_tcp参数并新增tcp_mode参数 tcp_mode = 1; } - - auto port = openRtpServer( - allArgs["port"], stream_id, tcp_mode, "::", true, 0, allArgs["only_audio"].as(),true); + std::string local_ip = "::"; + if (!allArgs["local_ip"].empty()) { + local_ip = allArgs["local_ip"]; + } + auto port = openRtpServer(allArgs["port"], stream_id, tcp_mode, local_ip, true, 0, allArgs["only_audio"].as(),true); if (port == 0) { throw InvalidArgsException("该stream_id已存在"); }