From 0f498acd7bf2938e2d65f8199c32dd5f24c2caf6 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 29 Apr 2014 18:16:29 +0800 Subject: [PATCH] add comments and variable for c3 extended-timestamp. to 0.9.82 --- trunk/research/librtmp/srs_play.c | 6 +++++- trunk/src/core/srs_core.hpp | 2 +- trunk/src/rtmp/srs_protocol_rtmp_stack.cpp | 13 ++++++++----- trunk/src/rtmp/srs_protocol_rtmp_stack.hpp | 18 ++++++++++++++++++ 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/trunk/research/librtmp/srs_play.c b/trunk/research/librtmp/srs_play.c index adb337d01..be38d3d89 100644 --- a/trunk/research/librtmp/srs_play.c +++ b/trunk/research/librtmp/srs_play.c @@ -42,7 +42,11 @@ int main(int argc, char** argv) printf("srs(simple-rtmp-server) client librtmp library.\n"); printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); - rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); + if (argc > 1) { + rtmp = srs_rtmp_create(argv[1]); + } else { + rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); + } if (srs_simple_handshake(rtmp) != 0) { printf("simple handshake failed.\n"); diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index f04d8bfaa..1c4eb6481 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "81" +#define VERSION_REVISION "82" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "srs" diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp index d2e1f13c8..089cdf8ad 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.cpp @@ -301,6 +301,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) skt = io; in_chunk_size = out_chunk_size = RTMP_DEFAULT_CHUNK_SIZE; + send_extended_timestamp_for_C3_chunk = true; } SrsProtocol::~SrsProtocol() @@ -519,13 +520,13 @@ int SrsProtocol::do_send_and_free_message(SrsMessage* msg, SrsPacket* packet) // present. Type 3 chunks MUST NOT have this field. // adobe changed for Type3 chunk: // FMLE always sendout the extended-timestamp, - // must send the extended-timestamp to FMS, + // must send the extended-timestamp to FMS, // must send the extended-timestamp to flash-player. // @see: ngx_rtmp_prepare_message // @see: http://blog.csdn.net/win_lin/article/details/13363699 u_int32_t timestamp = (u_int32_t)msg->header.timestamp; - if(timestamp >= RTMP_EXTENDED_TIMESTAMP){ - pp = (char*)×tamp; + if(send_extended_timestamp_for_C3_chunk && timestamp >= RTMP_EXTENDED_TIMESTAMP){ + pp = (char*)×tamp; *pheader++ = pp[3]; *pheader++ = pp[2]; *pheader++ = pp[1]; @@ -1086,7 +1087,8 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz fmt, mh_size, chunk->extended_timestamp); } - if (chunk->extended_timestamp) { + // read extended-timestamp + if (chunk->extended_timestamp && send_extended_timestamp_for_C3_chunk) { mh_size += 4; required_size = bh_size + mh_size; srs_verbose("read header ext time. fmt=%d, ext_time=%d, mh_size=%d", fmt, chunk->extended_timestamp, mh_size); @@ -1111,7 +1113,8 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz u_int32_t chunk_timestamp = chunk->header.timestamp; if (chunk_timestamp > RTMP_EXTENDED_TIMESTAMP && chunk_timestamp != timestamp) { mh_size -= 4; - srs_verbose("ignore the 4bytes extended timestamp. mh_size=%d", mh_size); + send_extended_timestamp_for_C3_chunk = false; + srs_warn("no 4bytes extended timestamp in the continued chunk"); } else { chunk->header.timestamp = timestamp; } diff --git a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp index 4f7e711b9..a36edf47c 100644 --- a/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp +++ b/trunk/src/rtmp/srs_protocol_rtmp_stack.hpp @@ -107,6 +107,24 @@ private: * value: the request command name */ std::map requests; + /** + * RTMP specification and ffmpeg/librtmp is false, + * but, adobe changed the specification, so flash/FMLE/FMS always true. + * default to true to support flash/FMLE/FMS. + * + * ffmpeg/librtmp may donot send this filed, need to detect the value. + * @see also: http://blog.csdn.net/win_lin/article/details/13363699 + * compare to the chunk timestamp, which is set by chunk message header + * type 0,1 or 2. + * + * @remark, nginx send the extended-timestamp in sequence-header, + * and timestamp delta in continue C1 chunks, and so compatible with ffmpeg, + * that is, there is no continue chunks and extended-timestamp in nginx-rtmp. + * + * @remark, srs always send the extended-timestamp, to keep simple, + * and compatible with adobe products. + */ + bool send_extended_timestamp_for_C3_chunk; // peer in private: std::map chunk_streams;