正在显示
1 个修改的文件
包含
29 行增加
和
33 行删除
| @@ -600,13 +600,15 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh | @@ -600,13 +600,15 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh | ||
| 600 | // generate the header. | 600 | // generate the header. |
| 601 | char* p = cache; | 601 | char* p = cache; |
| 602 | 602 | ||
| 603 | + // timestamp for c0/c3 | ||
| 604 | + u_int32_t timestamp = (u_int32_t)mh->timestamp; | ||
| 605 | + | ||
| 603 | if (c0) { | 606 | if (c0) { |
| 604 | // write new chunk stream header, fmt is 0 | 607 | // write new chunk stream header, fmt is 0 |
| 605 | *p++ = 0x00 | (mh->perfer_cid & 0x3F); | 608 | *p++ = 0x00 | (mh->perfer_cid & 0x3F); |
| 606 | 609 | ||
| 607 | // chunk message header, 11 bytes | 610 | // chunk message header, 11 bytes |
| 608 | // timestamp, 3bytes, big-endian | 611 | // timestamp, 3bytes, big-endian |
| 609 | - u_int32_t timestamp = (u_int32_t)mh->timestamp; | ||
| 610 | if (timestamp < RTMP_EXTENDED_TIMESTAMP) { | 612 | if (timestamp < RTMP_EXTENDED_TIMESTAMP) { |
| 611 | pp = (char*)×tamp; | 613 | pp = (char*)×tamp; |
| 612 | *p++ = pp[2]; | 614 | *p++ = pp[2]; |
| @@ -633,43 +635,37 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh | @@ -633,43 +635,37 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh | ||
| 633 | *p++ = pp[1]; | 635 | *p++ = pp[1]; |
| 634 | *p++ = pp[2]; | 636 | *p++ = pp[2]; |
| 635 | *p++ = pp[3]; | 637 | *p++ = pp[3]; |
| 636 | - | ||
| 637 | - // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 638 | - if(timestamp >= RTMP_EXTENDED_TIMESTAMP) { | ||
| 639 | - pp = (char*)×tamp; | ||
| 640 | - *p++ = pp[3]; | ||
| 641 | - *p++ = pp[2]; | ||
| 642 | - *p++ = pp[1]; | ||
| 643 | - *p++ = pp[0]; | ||
| 644 | - } | ||
| 645 | } else { | 638 | } else { |
| 646 | // write no message header chunk stream, fmt is 3 | 639 | // write no message header chunk stream, fmt is 3 |
| 647 | // @remark, if perfer_cid > 0x3F, that is, use 2B/3B chunk header, | 640 | // @remark, if perfer_cid > 0x3F, that is, use 2B/3B chunk header, |
| 648 | // SRS will rollback to 1B chunk header. | 641 | // SRS will rollback to 1B chunk header. |
| 649 | *p++ = 0xC0 | (mh->perfer_cid & 0x3F); | 642 | *p++ = 0xC0 | (mh->perfer_cid & 0x3F); |
| 650 | - | ||
| 651 | - // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 652 | - // 6.1.3. Extended Timestamp | ||
| 653 | - // This field is transmitted only when the normal time stamp in the | ||
| 654 | - // chunk message header is set to 0x00ffffff. If normal time stamp is | ||
| 655 | - // set to any value less than 0x00ffffff, this field MUST NOT be | ||
| 656 | - // present. This field MUST NOT be present if the timestamp field is not | ||
| 657 | - // present. Type 3 chunks MUST NOT have this field. | ||
| 658 | - // adobe changed for Type3 chunk: | ||
| 659 | - // FMLE always sendout the extended-timestamp, | ||
| 660 | - // must send the extended-timestamp to FMS, | ||
| 661 | - // must send the extended-timestamp to flash-player. | ||
| 662 | - // @see: ngx_rtmp_prepare_message | ||
| 663 | - // @see: http://blog.csdn.net/win_lin/article/details/13363699 | ||
| 664 | - // TODO: FIXME: extract to outer. | ||
| 665 | - u_int32_t timestamp = (u_int32_t)mh->timestamp; | ||
| 666 | - if (timestamp >= RTMP_EXTENDED_TIMESTAMP) { | ||
| 667 | - pp = (char*)×tamp; | ||
| 668 | - *p++ = pp[3]; | ||
| 669 | - *p++ = pp[2]; | ||
| 670 | - *p++ = pp[1]; | ||
| 671 | - *p++ = pp[0]; | ||
| 672 | - } | 643 | + } |
| 644 | + | ||
| 645 | + // for c0 | ||
| 646 | + // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 647 | + // | ||
| 648 | + // for c3: | ||
| 649 | + // chunk extended timestamp header, 0 or 4 bytes, big-endian | ||
| 650 | + // 6.1.3. Extended Timestamp | ||
| 651 | + // This field is transmitted only when the normal time stamp in the | ||
| 652 | + // chunk message header is set to 0x00ffffff. If normal time stamp is | ||
| 653 | + // set to any value less than 0x00ffffff, this field MUST NOT be | ||
| 654 | + // present. This field MUST NOT be present if the timestamp field is not | ||
| 655 | + // present. Type 3 chunks MUST NOT have this field. | ||
| 656 | + // adobe changed for Type3 chunk: | ||
| 657 | + // FMLE always sendout the extended-timestamp, | ||
| 658 | + // must send the extended-timestamp to FMS, | ||
| 659 | + // must send the extended-timestamp to flash-player. | ||
| 660 | + // @see: ngx_rtmp_prepare_message | ||
| 661 | + // @see: http://blog.csdn.net/win_lin/article/details/13363699 | ||
| 662 | + // TODO: FIXME: extract to outer. | ||
| 663 | + if (timestamp >= RTMP_EXTENDED_TIMESTAMP) { | ||
| 664 | + pp = (char*)×tamp; | ||
| 665 | + *p++ = pp[3]; | ||
| 666 | + *p++ = pp[2]; | ||
| 667 | + *p++ = pp[1]; | ||
| 668 | + *p++ = pp[0]; | ||
| 673 | } | 669 | } |
| 674 | 670 | ||
| 675 | // always has header | 671 | // always has header |
-
请 注册 或 登录 后发表评论