From 39f15ba3daf95cfad7babb11d376342abefe46a3 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 19 Feb 2014 14:54:04 +0800 Subject: [PATCH] refine the comments, fix bug of parse message --- trunk/src/core/srs_core_client.cpp | 4 ++-- trunk/src/core/srs_core_protocol.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/trunk/src/core/srs_core_client.cpp b/trunk/src/core/srs_core_client.cpp index d6730d888..e464ba804 100644 --- a/trunk/src/core/srs_core_client.cpp +++ b/trunk/src/core/srs_core_client.cpp @@ -215,7 +215,7 @@ int SrsClient::stream_service_cycle() rtmp->set_recv_timeout(SRS_RECV_TIMEOUT_US); rtmp->set_send_timeout(SRS_SEND_TIMEOUT_US); - // set timeout to larger. + // set chunk size to larger. int chunk_size = config->get_chunk_size(req->vhost); if ((ret = rtmp->set_chunk_size(chunk_size)) != ERROR_SUCCESS) { srs_error("set chunk_size=%d failed. ret=%d", chunk_size, ret); @@ -223,7 +223,7 @@ int SrsClient::stream_service_cycle() } srs_trace("set chunk_size=%d success", chunk_size); - // find a source to publish. + // find a source to serve. SrsSource* source = SrsSource::find(req); srs_assert(source != NULL); diff --git a/trunk/src/core/srs_core_protocol.cpp b/trunk/src/core/srs_core_protocol.cpp index a17e632cf..c599811bf 100644 --- a/trunk/src/core/srs_core_protocol.cpp +++ b/trunk/src/core/srs_core_protocol.cpp @@ -173,7 +173,8 @@ messages. * independently for each direction. */ #define RTMP_DEFAULT_CHUNK_SIZE 128 -#define RTMP_MIN_CHUNK_SIZE 2 +#define RTMP_MIN_CHUNK_SIZE 128 +#define RTMP_MAX_CHUNK_SIZE 65536 /** * 6.1. Chunk Format @@ -1279,6 +1280,9 @@ int SrsCommonMessage::decode_packet(SrsProtocol* protocol) // reset stream, for header read completed. stream->reset(); + if (header.is_amf3_command()) { + stream->skip(1); + } std::string request_name = protocol->get_request_name(transactionId); if (request_name.empty()) { @@ -3201,6 +3205,12 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream) ERROR_RTMP_CHUNK_SIZE, chunk_size, ret); return ret; } + if (chunk_size > RTMP_MAX_CHUNK_SIZE) { + ret = ERROR_RTMP_CHUNK_SIZE; + srs_error("invalid chunk size. max=%d, actual=%d, ret=%d", + RTMP_MAX_CHUNK_SIZE, chunk_size, ret); + return ret; + } return ret; }