From adc6f652bd44fc58085dc10becc8a5185960e884 Mon Sep 17 00:00:00 2001 From: haorui wang <56127613+HR1025@users.noreply.github.com> Date: Wed, 29 Sep 2021 16:57:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dzlm=E6=8E=A8=E6=B5=81FMS,?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3zlm=E7=9A=84RTMP=E5=8D=8F=E8=AE=AE=20(#1140)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复zlm推流FMS,修正zlm的RTMP协议 Co-authored-by: 夏楚 <771730766@qq.com> --- src/Rtmp/Rtmp.h | 3 ++- src/Rtmp/RtmpProtocol.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Rtmp/Rtmp.h b/src/Rtmp/Rtmp.h index 3020582e..d2ceccda 100644 --- a/src/Rtmp/Rtmp.h +++ b/src/Rtmp/Rtmp.h @@ -61,7 +61,8 @@ using namespace toolkit; #define STREAM_CONTROL 0 #define STREAM_MEDIA 1 -#define CHUNK_SERVER_REQUEST 2 /*服务器像客户端发出请求时的chunkID*/ +#define CHUNK_NETWORK 2 /*网络相关的消息(参见 Protocol Control Messages)*/ +#define CHUNK_SYSTEM 3 /*向服务器发送控制消息(反之亦可)*/ #define CHUNK_CLIENT_REQUEST_BEFORE 3 /*客户端在createStream前,向服务器发出请求的chunkID*/ #define CHUNK_CLIENT_REQUEST_AFTER 4 /*客户端在createStream后,向服务器发出请求的chunkID*/ #define CHUNK_AUDIO 6 /*音频chunkID*/ diff --git a/src/Rtmp/RtmpProtocol.cpp b/src/Rtmp/RtmpProtocol.cpp index 5ce82ed6..d0c5f027 100644 --- a/src/Rtmp/RtmpProtocol.cpp +++ b/src/Rtmp/RtmpProtocol.cpp @@ -165,7 +165,13 @@ void RtmpProtocol::sendInvoke(const string &cmd, const AMFValue &val) { } void RtmpProtocol::sendRequest(int cmd, const string& str) { - sendRtmp(cmd, _stream_index, str, 0, CHUNK_SERVER_REQUEST); + if (cmd <= MSG_SET_PEER_BW) { + // 若 cmd 属于 Protocol Control Messages ,则应使用 chunk id 2 发送 + sendRtmp(cmd, _stream_index, str, 0, CHUNK_NETWORK); + } else { + // 否则使用 chunk id 发送(任意值3-128,参见 obs 及 ffmpeg 选取 3) + sendRtmp(cmd, _stream_index, str, 0, CHUNK_SYSTEM); + } } class BufferPartial : public Buffer {