Improved RTMP cross-server compatibility
This commit is contained in:
parent
771fad390a
commit
a8c7bc5d27
3 changed files with 14 additions and 6 deletions
|
@ -250,7 +250,7 @@ std::string &RTMPStream::SendMedia(FLV::Tag &tag){
|
||||||
std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data){
|
std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data){
|
||||||
static RTMPStream::Chunk ch;
|
static RTMPStream::Chunk ch;
|
||||||
ch.cs_id = 2;
|
ch.cs_id = 2;
|
||||||
ch.timestamp = Util::getMS();
|
ch.timestamp = 0;
|
||||||
ch.msg_type_id = type;
|
ch.msg_type_id = type;
|
||||||
ch.msg_stream_id = 0;
|
ch.msg_stream_id = 0;
|
||||||
ch.len_left = 0;
|
ch.len_left = 0;
|
||||||
|
@ -265,6 +265,7 @@ std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data){
|
||||||
ch.data.resize(4);
|
ch.data.resize(4);
|
||||||
}
|
}
|
||||||
*(int *)((char *)ch.data.data()) = htonl(data);
|
*(int *)((char *)ch.data.data()) = htonl(data);
|
||||||
|
lastsend.erase(2u);
|
||||||
return ch.Pack();
|
return ch.Pack();
|
||||||
}// SendCTL
|
}// SendCTL
|
||||||
|
|
||||||
|
@ -272,7 +273,7 @@ std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data){
|
||||||
std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data, unsigned char data2){
|
std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data, unsigned char data2){
|
||||||
static RTMPStream::Chunk ch;
|
static RTMPStream::Chunk ch;
|
||||||
ch.cs_id = 2;
|
ch.cs_id = 2;
|
||||||
ch.timestamp = Util::getMS();
|
ch.timestamp = 0;
|
||||||
ch.len = 5;
|
ch.len = 5;
|
||||||
ch.real_len = 5;
|
ch.real_len = 5;
|
||||||
ch.len_left = 0;
|
ch.len_left = 0;
|
||||||
|
@ -281,6 +282,7 @@ std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data, unsigned
|
||||||
ch.data.resize(5);
|
ch.data.resize(5);
|
||||||
*(unsigned int *)((char *)ch.data.c_str()) = htonl(data);
|
*(unsigned int *)((char *)ch.data.c_str()) = htonl(data);
|
||||||
ch.data[4] = data2;
|
ch.data[4] = data2;
|
||||||
|
lastsend.erase(2u);
|
||||||
return ch.Pack();
|
return ch.Pack();
|
||||||
}// SendCTL
|
}// SendCTL
|
||||||
|
|
||||||
|
@ -288,7 +290,7 @@ std::string &RTMPStream::SendCTL(unsigned char type, unsigned int data, unsigned
|
||||||
std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data){
|
std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data){
|
||||||
static RTMPStream::Chunk ch;
|
static RTMPStream::Chunk ch;
|
||||||
ch.cs_id = 2;
|
ch.cs_id = 2;
|
||||||
ch.timestamp = Util::getMS();
|
ch.timestamp = 0;
|
||||||
ch.len = 6;
|
ch.len = 6;
|
||||||
ch.real_len = 6;
|
ch.real_len = 6;
|
||||||
ch.len_left = 0;
|
ch.len_left = 0;
|
||||||
|
@ -298,6 +300,7 @@ std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data){
|
||||||
*(unsigned int *)(((char *)ch.data.c_str()) + 2) = htonl(data);
|
*(unsigned int *)(((char *)ch.data.c_str()) + 2) = htonl(data);
|
||||||
ch.data[0] = 0;
|
ch.data[0] = 0;
|
||||||
ch.data[1] = type;
|
ch.data[1] = type;
|
||||||
|
lastsend.erase(2u);
|
||||||
return ch.Pack();
|
return ch.Pack();
|
||||||
}// SendUSR
|
}// SendUSR
|
||||||
|
|
||||||
|
@ -305,7 +308,7 @@ std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data){
|
||||||
std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data, unsigned int data2){
|
std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data, unsigned int data2){
|
||||||
static RTMPStream::Chunk ch;
|
static RTMPStream::Chunk ch;
|
||||||
ch.cs_id = 2;
|
ch.cs_id = 2;
|
||||||
ch.timestamp = Util::getMS();
|
ch.timestamp = 0;
|
||||||
ch.len = 10;
|
ch.len = 10;
|
||||||
ch.real_len = 10;
|
ch.real_len = 10;
|
||||||
ch.len_left = 0;
|
ch.len_left = 0;
|
||||||
|
@ -316,6 +319,7 @@ std::string &RTMPStream::SendUSR(unsigned char type, unsigned int data, unsigned
|
||||||
*(unsigned int *)(((char *)ch.data.c_str()) + 6) = htonl(data2);
|
*(unsigned int *)(((char *)ch.data.c_str()) + 6) = htonl(data2);
|
||||||
ch.data[0] = 0;
|
ch.data[0] = 0;
|
||||||
ch.data[1] = type;
|
ch.data[1] = type;
|
||||||
|
lastsend.erase(2u);
|
||||||
return ch.Pack();
|
return ch.Pack();
|
||||||
}// SendUSR
|
}// SendUSR
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace Mist{
|
namespace Mist{
|
||||||
OutRTMP::OutRTMP(Socket::Connection &conn) : Output(conn){
|
OutRTMP::OutRTMP(Socket::Connection &conn) : Output(conn){
|
||||||
|
lastAck = Util::bootSecs();
|
||||||
lastOutTime = 0;
|
lastOutTime = 0;
|
||||||
setRtmpOffset = false;
|
setRtmpOffset = false;
|
||||||
rtmpOffset = 0;
|
rtmpOffset = 0;
|
||||||
|
@ -1151,7 +1152,8 @@ namespace Mist{
|
||||||
while (next.Parse(inputBuffer)){
|
while (next.Parse(inputBuffer)){
|
||||||
|
|
||||||
// send ACK if we received a whole window
|
// send ACK if we received a whole window
|
||||||
if ((RTMPStream::rec_cnt - RTMPStream::rec_window_at > RTMPStream::rec_window_size)){
|
if ((RTMPStream::rec_cnt - RTMPStream::rec_window_at > RTMPStream::rec_window_size) || Util::bootSecs() > lastAck+15){
|
||||||
|
lastAck = Util::bootSecs();
|
||||||
RTMPStream::rec_window_at = RTMPStream::rec_cnt;
|
RTMPStream::rec_window_at = RTMPStream::rec_cnt;
|
||||||
myConn.SendNow(RTMPStream::SendCTL(3, RTMPStream::rec_cnt)); // send ack (msg 3)
|
myConn.SendNow(RTMPStream::SendCTL(3, RTMPStream::rec_cnt)); // send ack (msg 3)
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1205,7 @@ namespace Mist{
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
MEDIUM_MSG("CTRL: UCM PingRequest %" PRIu32, Bit::btohl(next.data.data() + 2));
|
MEDIUM_MSG("CTRL: UCM PingRequest %" PRIu32, Bit::btohl(next.data.data() + 2));
|
||||||
myConn.SendNow(RTMPStream::SendUSR(7, 1)); // send UCM PingResponse (7)
|
myConn.SendNow(RTMPStream::SendUSR(7, Bit::btohl(next.data.data() + 2))); // send UCM PingResponse (7)
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
MEDIUM_MSG("CTRL: UCM PingResponse %" PRIu32, Bit::btohl(next.data.data() + 2));
|
MEDIUM_MSG("CTRL: UCM PingResponse %" PRIu32, Bit::btohl(next.data.data() + 2));
|
||||||
|
@ -1216,6 +1218,7 @@ namespace Mist{
|
||||||
RTMPStream::rec_window_size = Bit::btohl(next.data.data());
|
RTMPStream::rec_window_size = Bit::btohl(next.data.data());
|
||||||
RTMPStream::rec_window_at = RTMPStream::rec_cnt;
|
RTMPStream::rec_window_at = RTMPStream::rec_cnt;
|
||||||
myConn.SendNow(RTMPStream::SendCTL(3, RTMPStream::rec_cnt)); // send ack (msg 3)
|
myConn.SendNow(RTMPStream::SendCTL(3, RTMPStream::rec_cnt)); // send ack (msg 3)
|
||||||
|
lastAck = Util::bootSecs();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
MEDIUM_MSG("CTRL: Set peer bandwidth");
|
MEDIUM_MSG("CTRL: Set peer bandwidth");
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Mist{
|
||||||
void parseAMFCommand(AMF::Object &amfData, int messageType, int streamId);
|
void parseAMFCommand(AMF::Object &amfData, int messageType, int streamId);
|
||||||
void sendCommand(AMF::Object &amfReply, int messageType, int streamId);
|
void sendCommand(AMF::Object &amfReply, int messageType, int streamId);
|
||||||
void startPushOut(const char *args);
|
void startPushOut(const char *args);
|
||||||
|
uint64_t lastAck;
|
||||||
HTTP::URL pushApp, pushUrl;
|
HTTP::URL pushApp, pushUrl;
|
||||||
uint8_t authAttempts;
|
uint8_t authAttempts;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue