mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for bug #199, refine the header generate
This commit is contained in:
parent
953159258c
commit
7cf855f242
1 changed files with 29 additions and 33 deletions
|
@ -600,13 +600,15 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh
|
||||||
// generate the header.
|
// generate the header.
|
||||||
char* p = cache;
|
char* p = cache;
|
||||||
|
|
||||||
|
// timestamp for c0/c3
|
||||||
|
u_int32_t timestamp = (u_int32_t)mh->timestamp;
|
||||||
|
|
||||||
if (c0) {
|
if (c0) {
|
||||||
// write new chunk stream header, fmt is 0
|
// write new chunk stream header, fmt is 0
|
||||||
*p++ = 0x00 | (mh->perfer_cid & 0x3F);
|
*p++ = 0x00 | (mh->perfer_cid & 0x3F);
|
||||||
|
|
||||||
// chunk message header, 11 bytes
|
// chunk message header, 11 bytes
|
||||||
// timestamp, 3bytes, big-endian
|
// timestamp, 3bytes, big-endian
|
||||||
u_int32_t timestamp = (u_int32_t)mh->timestamp;
|
|
||||||
if (timestamp < RTMP_EXTENDED_TIMESTAMP) {
|
if (timestamp < RTMP_EXTENDED_TIMESTAMP) {
|
||||||
pp = (char*)×tamp;
|
pp = (char*)×tamp;
|
||||||
*p++ = pp[2];
|
*p++ = pp[2];
|
||||||
|
@ -633,43 +635,37 @@ void SrsProtocol::generate_chunk_header(SrsMessageHeader* mh, bool c0, int* pnbh
|
||||||
*p++ = pp[1];
|
*p++ = pp[1];
|
||||||
*p++ = pp[2];
|
*p++ = pp[2];
|
||||||
*p++ = pp[3];
|
*p++ = pp[3];
|
||||||
|
|
||||||
// chunk extended timestamp header, 0 or 4 bytes, big-endian
|
|
||||||
if(timestamp >= RTMP_EXTENDED_TIMESTAMP) {
|
|
||||||
pp = (char*)×tamp;
|
|
||||||
*p++ = pp[3];
|
|
||||||
*p++ = pp[2];
|
|
||||||
*p++ = pp[1];
|
|
||||||
*p++ = pp[0];
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// write no message header chunk stream, fmt is 3
|
// write no message header chunk stream, fmt is 3
|
||||||
// @remark, if perfer_cid > 0x3F, that is, use 2B/3B chunk header,
|
// @remark, if perfer_cid > 0x3F, that is, use 2B/3B chunk header,
|
||||||
// SRS will rollback to 1B chunk header.
|
// SRS will rollback to 1B chunk header.
|
||||||
*p++ = 0xC0 | (mh->perfer_cid & 0x3F);
|
*p++ = 0xC0 | (mh->perfer_cid & 0x3F);
|
||||||
|
}
|
||||||
// chunk extended timestamp header, 0 or 4 bytes, big-endian
|
|
||||||
// 6.1.3. Extended Timestamp
|
// for c0
|
||||||
// This field is transmitted only when the normal time stamp in the
|
// chunk extended timestamp header, 0 or 4 bytes, big-endian
|
||||||
// chunk message header is set to 0x00ffffff. If normal time stamp is
|
//
|
||||||
// set to any value less than 0x00ffffff, this field MUST NOT be
|
// for c3:
|
||||||
// present. This field MUST NOT be present if the timestamp field is not
|
// chunk extended timestamp header, 0 or 4 bytes, big-endian
|
||||||
// present. Type 3 chunks MUST NOT have this field.
|
// 6.1.3. Extended Timestamp
|
||||||
// adobe changed for Type3 chunk:
|
// This field is transmitted only when the normal time stamp in the
|
||||||
// FMLE always sendout the extended-timestamp,
|
// chunk message header is set to 0x00ffffff. If normal time stamp is
|
||||||
// must send the extended-timestamp to FMS,
|
// set to any value less than 0x00ffffff, this field MUST NOT be
|
||||||
// must send the extended-timestamp to flash-player.
|
// present. This field MUST NOT be present if the timestamp field is not
|
||||||
// @see: ngx_rtmp_prepare_message
|
// present. Type 3 chunks MUST NOT have this field.
|
||||||
// @see: http://blog.csdn.net/win_lin/article/details/13363699
|
// adobe changed for Type3 chunk:
|
||||||
// TODO: FIXME: extract to outer.
|
// FMLE always sendout the extended-timestamp,
|
||||||
u_int32_t timestamp = (u_int32_t)mh->timestamp;
|
// must send the extended-timestamp to FMS,
|
||||||
if (timestamp >= RTMP_EXTENDED_TIMESTAMP) {
|
// must send the extended-timestamp to flash-player.
|
||||||
pp = (char*)×tamp;
|
// @see: ngx_rtmp_prepare_message
|
||||||
*p++ = pp[3];
|
// @see: http://blog.csdn.net/win_lin/article/details/13363699
|
||||||
*p++ = pp[2];
|
// TODO: FIXME: extract to outer.
|
||||||
*p++ = pp[1];
|
if (timestamp >= RTMP_EXTENDED_TIMESTAMP) {
|
||||||
*p++ = pp[0];
|
pp = (char*)×tamp;
|
||||||
}
|
*p++ = pp[3];
|
||||||
|
*p++ = pp[2];
|
||||||
|
*p++ = pp[1];
|
||||||
|
*p++ = pp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// always has header
|
// always has header
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue