openRtpServer接口新增local_ip参数 (#3224)

https://github.com/ZLMediaKit/ZLMediaKit/issues/3218

ipv4环境下,修改local_ip为0.0.0.0后可实现在openRtpServer后startSendRtp复用端口

仅测试windows服务端,sip与sip通话
This commit is contained in:
waken 2024-01-18 10:59:09 +08:00 committed by GitHub
parent 8d951f06a0
commit 3a80b1de1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 10 deletions

View File

@ -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的本地ipipv4可填”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的本地ipipv4可填”0.0.0.0“ipv6可填”::“,一般保持默认",
"disabled": true
}
]
}

View File

@ -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<bool>(),
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<bool>(),
allArgs["ssrc"].as<uint32_t>(), allArgs["only_audio"].as<bool>());
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<bool>(),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<bool>(),true);
if (port == 0) {
throw InvalidArgsException("该stream_id已存在");
}