Fixed RTMP packet timestamp delta handling.
This commit is contained in:
parent
a0197ad7f1
commit
d98f14fa04
2 changed files with 14 additions and 4 deletions
|
@ -283,7 +283,7 @@ std::string & RTMPStream::Chunk::Pack() {
|
|||
if (len == prev.len) {
|
||||
if (msg_type_id == prev.msg_type_id) {
|
||||
chtype = 0x80; //do not send len and msg_type_id
|
||||
if (timestamp == prev.timestamp) {
|
||||
if (timestamp - prev.timestamp == prev.ts_delta) {
|
||||
chtype = 0xC0; //do not send timestamp
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +314,7 @@ std::string & RTMPStream::Chunk::Pack() {
|
|||
} else {
|
||||
tmpi = timestamp - prev.timestamp;
|
||||
}
|
||||
ts_delta = tmpi;
|
||||
if (tmpi >= 0x00ffffff) {
|
||||
ntime = tmpi;
|
||||
tmpi = 0x00ffffff;
|
||||
|
@ -543,6 +544,7 @@ bool RTMPStream::Chunk::Parse(std::string & indata) {
|
|||
timestamp = indata[i++ ] * 256 * 256;
|
||||
timestamp += indata[i++ ] * 256;
|
||||
timestamp += indata[i++ ];
|
||||
ts_delta = timestamp;
|
||||
len = indata[i++ ] * 256 * 256;
|
||||
len += indata[i++ ] * 256;
|
||||
len += indata[i++ ];
|
||||
|
@ -562,7 +564,8 @@ bool RTMPStream::Chunk::Parse(std::string & indata) {
|
|||
timestamp += indata[i++ ] * 256;
|
||||
timestamp += indata[i++ ];
|
||||
if (timestamp != 0x00ffffff) {
|
||||
timestamp += prev.timestamp;
|
||||
ts_delta = timestamp;
|
||||
timestamp = prev.timestamp + ts_delta;
|
||||
}
|
||||
len = indata[i++ ] * 256 * 256;
|
||||
len += indata[i++ ] * 256;
|
||||
|
@ -580,7 +583,8 @@ bool RTMPStream::Chunk::Parse(std::string & indata) {
|
|||
timestamp += indata[i++ ] * 256;
|
||||
timestamp += indata[i++ ];
|
||||
if (timestamp != 0x00ffffff) {
|
||||
timestamp += prev.timestamp;
|
||||
ts_delta = timestamp;
|
||||
timestamp = prev.timestamp + ts_delta;
|
||||
}
|
||||
len = prev.len;
|
||||
len_left = prev.len_left;
|
||||
|
@ -591,9 +595,13 @@ bool RTMPStream::Chunk::Parse(std::string & indata) {
|
|||
if (!allow_short) {
|
||||
DEBUG_MSG(DLVL_WARN, "Warning: Header type 0xC0 with no valid previous chunk!");
|
||||
}
|
||||
timestamp = prev.timestamp;
|
||||
timestamp = prev.timestamp + prev.ts_delta;
|
||||
ts_delta = prev.ts_delta;
|
||||
len = prev.len;
|
||||
len_left = prev.len_left;
|
||||
if (len_left > 0){
|
||||
timestamp = prev.timestamp;
|
||||
}
|
||||
msg_type_id = prev.msg_type_id;
|
||||
msg_stream_id = prev.msg_stream_id;
|
||||
break;
|
||||
|
@ -616,6 +624,7 @@ bool RTMPStream::Chunk::Parse(std::string & indata) {
|
|||
timestamp += indata[i++ ] * 256 * 256;
|
||||
timestamp += indata[i++ ] * 256;
|
||||
timestamp += indata[i++ ];
|
||||
ts_delta = timestamp;
|
||||
}
|
||||
|
||||
//read data if length > 0, and allocate it
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace RTMPStream {
|
|||
unsigned char headertype; ///< For input chunks, the type of header. This is calculated automatically for output chunks.
|
||||
unsigned int cs_id; ///< ContentStream ID
|
||||
unsigned int timestamp; ///< Timestamp of this chunk.
|
||||
unsigned int ts_delta; ///< Last timestamp delta.
|
||||
unsigned int len; ///< Length of the complete chunk.
|
||||
unsigned int real_len; ///< Length of this particular part of it.
|
||||
unsigned int len_left; ///< Length not yet received, out of complete chunk.
|
||||
|
|
Loading…
Add table
Reference in a new issue