Merge branch 'development' into LTS_development

This commit is contained in:
Thulinma 2018-01-02 13:24:37 +01:00
commit 1d70ab288a
2 changed files with 16 additions and 6 deletions

View file

@ -455,7 +455,7 @@ bool RTMPStream::Chunk::Parse(Socket::Buffer & buffer) {
DEBUG_MSG(DLVL_DONTEVEN, "Parsing RTMP chunk result: len_left=%d, real_len=%d", len_left, real_len); DEBUG_MSG(DLVL_DONTEVEN, "Parsing RTMP chunk result: len_left=%d, real_len=%d", len_left, real_len);
//read extended timestamp, if necessary //read extended timestamp, if necessary
if (ts_header == 0x00ffffff && headertype != 0xC0) { if (ts_header == 0x00ffffff) {
if (!buffer.available(i + 4)) { if (!buffer.available(i + 4)) {
return false; return false;
} //can't read timestamp } //can't read timestamp

View file

@ -420,30 +420,40 @@ namespace Mist{
//send the header //send the header
myConn.setBlocking(true); myConn.setBlocking(true);
myConn.SendNow(rtmpheader, header_len); myConn.SendNow(rtmpheader, header_len);
RTMPStream::snd_cnt += header_len; //update the sent data counter
//set the header's first byte to the "continue" type chunk, for later use //set the header's first byte to the "continue" type chunk, for later use
rtmpheader[0] = 0xC4; rtmpheader[0] = 0xC4;
if (timestamp >= 0x00ffffff){
rtmpheader[1] = timestamp & 0xff;
rtmpheader[2] = (timestamp >> 8) & 0xff;
rtmpheader[3] = (timestamp >> 16) & 0xff;
rtmpheader[4] = (timestamp >> 24) & 0xff;
}
//sent actual data - never send more than chunk_snd_max at a time //sent actual data - never send more than chunk_snd_max at a time
//interleave blocks of max chunk_snd_max bytes with 0xC4 bytes to indicate continue //interleave blocks of max chunk_snd_max bytes with 0xC4 bytes to indicate continue
unsigned int len_sent = 0; unsigned int len_sent = 0;
unsigned int steps = 0;
while (len_sent < data_len){ while (len_sent < data_len){
unsigned int to_send = std::min(data_len - len_sent, RTMPStream::chunk_snd_max); unsigned int to_send = std::min(data_len - len_sent, RTMPStream::chunk_snd_max);
if (!len_sent){ if (!len_sent){
myConn.SendNow(dataheader, dheader_len); myConn.SendNow(dataheader, dheader_len);
RTMPStream::snd_cnt += dheader_len; //update the sent data counter
to_send -= dheader_len; to_send -= dheader_len;
len_sent += dheader_len; len_sent += dheader_len;
} }
myConn.SendNow(tmpData+len_sent-dheader_len, to_send); myConn.SendNow(tmpData+len_sent-dheader_len, to_send);
len_sent += to_send; len_sent += to_send;
if (len_sent < data_len){ if (len_sent < data_len){
myConn.SendNow(rtmpheader, 1); if (timestamp >= 0x00ffffff){
++steps; myConn.SendNow(rtmpheader, 5);
RTMPStream::snd_cnt += 5; //update the sent data counter
}else{
myConn.SendNow(rtmpheader, 1);
RTMPStream::snd_cnt += 1; //update the sent data counter
}
} }
} }
myConn.setBlocking(false); myConn.setBlocking(false);
//update the sent data counter
RTMPStream::snd_cnt += header_len + data_len + steps;
} }
void OutRTMP::sendHeader(){ void OutRTMP::sendHeader(){