From a13b8417e5f267936e60f634d3eacc0d52743277 Mon Sep 17 00:00:00 2001 From: Jovial Young <1105180740@qq.com> Date: Sun, 19 Nov 2023 14:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Drtmps=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E4=B8=8D=E5=AF=B9=E5=AF=BC=E8=87=B4=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=8E=A8/=E6=8B=89=E6=B5=81=E9=97=AE=E9=A2=98=20(#299?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在使用rtmps推流或者拉流时,端口被默认设置成了1935,正确的端口应该是443. --- src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtmp/RtmpPusher.cpp | 2 +- tests/test_pusherMp4.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 13c0131b..4f2239ba 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -69,7 +69,7 @@ void RtmpPlayer::play(const string &url) { } DebugL << host_url << " " << _app << " " << _stream_id; - uint16_t port = 1935; + uint16_t port = start_with(url, "rtmps") ? 443 : 1935; splitUrl(host_url, host_url, port); if (!(*this)[Client::kNetAdapter].empty()) { diff --git a/src/Rtmp/RtmpPusher.cpp b/src/Rtmp/RtmpPusher.cpp index c48f3820..79de34b3 100644 --- a/src/Rtmp/RtmpPusher.cpp +++ b/src/Rtmp/RtmpPusher.cpp @@ -82,7 +82,7 @@ void RtmpPusher::publish(const string &url) { } DebugL << host_url << " " << _app << " " << _stream_id; - uint16_t port = 1935; + uint16_t port = start_with(url, "rtmps") ? 443 : 1935; splitUrl(host_url, host_url, port); weak_ptr weakSelf = static_pointer_cast(shared_from_this()); diff --git a/tests/test_pusherMp4.cpp b/tests/test_pusherMp4.cpp index cc096fe7..51298899 100644 --- a/tests/test_pusherMp4.cpp +++ b/tests/test_pusherMp4.cpp @@ -116,5 +116,6 @@ int domain(const string &file, const string &url) { int main(int argc, char *argv[]) { // 可以使用test_server生成的mp4文件 // 文件使用绝对路径,推流url支持rtsp和rtmp - return domain("/Users/xiongziliang/Downloads/mp4/Quantum.mp4", "rtsp://127.0.0.1/live/rtsp_push"); + // return domain("/Users/xiongziliang/Downloads/mp4/Quantum.mp4", "rtsp://127.0.0.1/live/rtsp_push"); + return domain(argv[1], argv[2]); }