mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-19 06:42:21 +08:00
rtmp点播采用简单握手,发送心跳包,兼容fms服务器: #2007
This commit is contained in:
@@ -288,12 +288,14 @@ const char *RtmpProtocol::onSearchPacketTail(const char *data,size_t len){
|
||||
}
|
||||
|
||||
////for client////
|
||||
void RtmpProtocol::startClientSession(const function<void()> &func) {
|
||||
void RtmpProtocol::startClientSession(const function<void()> &func, bool complex) {
|
||||
//发送 C0C1
|
||||
char handshake_head = HANDSHAKE_PLAINTEXT;
|
||||
onSendRawData(obtainBuffer(&handshake_head, 1));
|
||||
RtmpHandshake c1(0);
|
||||
c1.create_complex_c0c1();
|
||||
if (complex) {
|
||||
c1.create_complex_c0c1();
|
||||
}
|
||||
onSendRawData(obtainBuffer((char *) (&c1), sizeof(c1)));
|
||||
_next_step_func = [this, func](const char *data, size_t len) {
|
||||
//等待 S0+S1+S2
|
||||
@@ -754,7 +756,8 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
|
||||
|
||||
case MSG_WIN_SIZE: {
|
||||
//如果窗口太小,会导致发送sendAcknowledgement时无限递归:https://github.com/ZLMediaKit/ZLMediaKit/issues/1839
|
||||
_windows_size = max(load_be32(&chunk_data.buffer[0]), 32 * 1024U);
|
||||
//窗口太大,也可能导致fms服务器认为播放器心跳超时
|
||||
_windows_size = min(max(load_be32(&chunk_data.buffer[0]), 32 * 1024U), 1280 * 1024U);
|
||||
TraceL << "MSG_WIN_SIZE:" << _windows_size;
|
||||
break;
|
||||
}
|
||||
@@ -806,7 +809,15 @@ void RtmpProtocol::handle_chunk(RtmpPacket::Ptr packet) {
|
||||
break;
|
||||
}
|
||||
|
||||
default: onRtmpChunk(std::move(packet)); break;
|
||||
default: {
|
||||
_bytes_recv += packet->size();
|
||||
if (_windows_size > 0 && _bytes_recv - _bytes_recv_last >= _windows_size) {
|
||||
_bytes_recv_last = _bytes_recv;
|
||||
sendAcknowledgement(_bytes_recv);
|
||||
}
|
||||
onRtmpChunk(std::move(packet));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user