add comments and variable for c3 extended-timestamp. to 0.9.82
正在显示
4 个修改的文件
包含
32 行增加
和
7 行删除
| @@ -42,7 +42,11 @@ int main(int argc, char** argv) | @@ -42,7 +42,11 @@ int main(int argc, char** argv) | ||
| 42 | printf("srs(simple-rtmp-server) client librtmp library.\n"); | 42 | printf("srs(simple-rtmp-server) client librtmp library.\n"); |
| 43 | printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | 43 | printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); |
| 44 | 44 | ||
| 45 | - rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); | 45 | + if (argc > 1) { |
| 46 | + rtmp = srs_rtmp_create(argv[1]); | ||
| 47 | + } else { | ||
| 48 | + rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream"); | ||
| 49 | + } | ||
| 46 | 50 | ||
| 47 | if (srs_simple_handshake(rtmp) != 0) { | 51 | if (srs_simple_handshake(rtmp) != 0) { |
| 48 | printf("simple handshake failed.\n"); | 52 | printf("simple handshake failed.\n"); |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "81" | 34 | +#define VERSION_REVISION "82" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "srs" | 37 | #define RTMP_SIG_SRS_KEY "srs" |
| @@ -301,6 +301,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | @@ -301,6 +301,7 @@ SrsProtocol::SrsProtocol(ISrsProtocolReaderWriter* io) | ||
| 301 | skt = io; | 301 | skt = io; |
| 302 | 302 | ||
| 303 | in_chunk_size = out_chunk_size = RTMP_DEFAULT_CHUNK_SIZE; | 303 | in_chunk_size = out_chunk_size = RTMP_DEFAULT_CHUNK_SIZE; |
| 304 | + send_extended_timestamp_for_C3_chunk = true; | ||
| 304 | } | 305 | } |
| 305 | 306 | ||
| 306 | SrsProtocol::~SrsProtocol() | 307 | SrsProtocol::~SrsProtocol() |
| @@ -519,13 +520,13 @@ int SrsProtocol::do_send_and_free_message(SrsMessage* msg, SrsPacket* packet) | @@ -519,13 +520,13 @@ int SrsProtocol::do_send_and_free_message(SrsMessage* msg, SrsPacket* packet) | ||
| 519 | // present. Type 3 chunks MUST NOT have this field. | 520 | // present. Type 3 chunks MUST NOT have this field. |
| 520 | // adobe changed for Type3 chunk: | 521 | // adobe changed for Type3 chunk: |
| 521 | // FMLE always sendout the extended-timestamp, | 522 | // FMLE always sendout the extended-timestamp, |
| 522 | - // must send the extended-timestamp to FMS, | 523 | + // must send the extended-timestamp to FMS, |
| 523 | // must send the extended-timestamp to flash-player. | 524 | // must send the extended-timestamp to flash-player. |
| 524 | // @see: ngx_rtmp_prepare_message | 525 | // @see: ngx_rtmp_prepare_message |
| 525 | // @see: http://blog.csdn.net/win_lin/article/details/13363699 | 526 | // @see: http://blog.csdn.net/win_lin/article/details/13363699 |
| 526 | u_int32_t timestamp = (u_int32_t)msg->header.timestamp; | 527 | u_int32_t timestamp = (u_int32_t)msg->header.timestamp; |
| 527 | - if(timestamp >= RTMP_EXTENDED_TIMESTAMP){ | ||
| 528 | - pp = (char*)×tamp; | 528 | + if(send_extended_timestamp_for_C3_chunk && timestamp >= RTMP_EXTENDED_TIMESTAMP){ |
| 529 | + pp = (char*)×tamp; | ||
| 529 | *pheader++ = pp[3]; | 530 | *pheader++ = pp[3]; |
| 530 | *pheader++ = pp[2]; | 531 | *pheader++ = pp[2]; |
| 531 | *pheader++ = pp[1]; | 532 | *pheader++ = pp[1]; |
| @@ -1086,7 +1087,8 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz | @@ -1086,7 +1087,8 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz | ||
| 1086 | fmt, mh_size, chunk->extended_timestamp); | 1087 | fmt, mh_size, chunk->extended_timestamp); |
| 1087 | } | 1088 | } |
| 1088 | 1089 | ||
| 1089 | - if (chunk->extended_timestamp) { | 1090 | + // read extended-timestamp |
| 1091 | + if (chunk->extended_timestamp && send_extended_timestamp_for_C3_chunk) { | ||
| 1090 | mh_size += 4; | 1092 | mh_size += 4; |
| 1091 | required_size = bh_size + mh_size; | 1093 | required_size = bh_size + mh_size; |
| 1092 | srs_verbose("read header ext time. fmt=%d, ext_time=%d, mh_size=%d", fmt, chunk->extended_timestamp, mh_size); | 1094 | 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 | @@ -1111,7 +1113,8 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz | ||
| 1111 | u_int32_t chunk_timestamp = chunk->header.timestamp; | 1113 | u_int32_t chunk_timestamp = chunk->header.timestamp; |
| 1112 | if (chunk_timestamp > RTMP_EXTENDED_TIMESTAMP && chunk_timestamp != timestamp) { | 1114 | if (chunk_timestamp > RTMP_EXTENDED_TIMESTAMP && chunk_timestamp != timestamp) { |
| 1113 | mh_size -= 4; | 1115 | mh_size -= 4; |
| 1114 | - srs_verbose("ignore the 4bytes extended timestamp. mh_size=%d", mh_size); | 1116 | + send_extended_timestamp_for_C3_chunk = false; |
| 1117 | + srs_warn("no 4bytes extended timestamp in the continued chunk"); | ||
| 1115 | } else { | 1118 | } else { |
| 1116 | chunk->header.timestamp = timestamp; | 1119 | chunk->header.timestamp = timestamp; |
| 1117 | } | 1120 | } |
| @@ -107,6 +107,24 @@ private: | @@ -107,6 +107,24 @@ private: | ||
| 107 | * value: the request command name | 107 | * value: the request command name |
| 108 | */ | 108 | */ |
| 109 | std::map<double, std::string> requests; | 109 | std::map<double, std::string> requests; |
| 110 | + /** | ||
| 111 | + * RTMP specification and ffmpeg/librtmp is false, | ||
| 112 | + * but, adobe changed the specification, so flash/FMLE/FMS always true. | ||
| 113 | + * default to true to support flash/FMLE/FMS. | ||
| 114 | + * | ||
| 115 | + * ffmpeg/librtmp may donot send this filed, need to detect the value. | ||
| 116 | + * @see also: http://blog.csdn.net/win_lin/article/details/13363699 | ||
| 117 | + * compare to the chunk timestamp, which is set by chunk message header | ||
| 118 | + * type 0,1 or 2. | ||
| 119 | + * | ||
| 120 | + * @remark, nginx send the extended-timestamp in sequence-header, | ||
| 121 | + * and timestamp delta in continue C1 chunks, and so compatible with ffmpeg, | ||
| 122 | + * that is, there is no continue chunks and extended-timestamp in nginx-rtmp. | ||
| 123 | + * | ||
| 124 | + * @remark, srs always send the extended-timestamp, to keep simple, | ||
| 125 | + * and compatible with adobe products. | ||
| 126 | + */ | ||
| 127 | + bool send_extended_timestamp_for_C3_chunk; | ||
| 110 | // peer in | 128 | // peer in |
| 111 | private: | 129 | private: |
| 112 | std::map<int, SrsChunkStream*> chunk_streams; | 130 | std::map<int, SrsChunkStream*> chunk_streams; |
-
请 注册 或 登录 后发表评论