RTMP edits

This commit is contained in:
Thulinma 2011-04-17 00:38:04 +02:00
parent 7ef92f87b5
commit f4cc2580b2
2 changed files with 18 additions and 15 deletions

View file

@ -163,7 +163,6 @@ void Connector_RTMP::parseChunk(){
static AMF::Object amfelem("empty", AMF::AMF0_DDV_CONTAINER); static AMF::Object amfelem("empty", AMF::AMF0_DDV_CONTAINER);
if (!Connector_RTMP::Socket.read(inbuffer)){return;} //try to get more data if (!Connector_RTMP::Socket.read(inbuffer)){return;} //try to get more data
fprintf(stderr, "Current buffer is %i long.\n", inbuffer.size());
while (next.Parse(inbuffer)){ while (next.Parse(inbuffer)){
//send ACK if we received a whole window //send ACK if we received a whole window
@ -280,7 +279,6 @@ void Connector_RTMP::parseChunk(){
if (tmpint & 0x04){fprintf(stderr, "MP3 audio support detected\n");} if (tmpint & 0x04){fprintf(stderr, "MP3 audio support detected\n");}
if (tmpint & 0x400){fprintf(stderr, "AAC video support detected\n");} if (tmpint & 0x400){fprintf(stderr, "AAC video support detected\n");}
#endif #endif
Socket.write(RTMPStream::SendCTL(6, RTMPStream::rec_window_size, 0));//send peer bandwidth (msg 6)
Socket.write(RTMPStream::SendCTL(5, RTMPStream::snd_window_size));//send window acknowledgement size (msg 5) Socket.write(RTMPStream::SendCTL(5, RTMPStream::snd_window_size));//send window acknowledgement size (msg 5)
Socket.write(RTMPStream::SendUSR(0, 1));//send UCM StreamBegin (0), stream 1 Socket.write(RTMPStream::SendUSR(0, 1));//send UCM StreamBegin (0), stream 1
//send a _result reply //send a _result reply
@ -289,24 +287,26 @@ void Connector_RTMP::parseChunk(){
amfreply.addContent(amfdata.getContent(1));//same transaction ID amfreply.addContent(amfdata.getContent(1));//same transaction ID
// amfreply.addContent(AMFType("", (double)0, 0x05));//null - command info // amfreply.addContent(AMFType("", (double)0, 0x05));//null - command info
amfreply.addContent(AMF::Object(""));//server properties amfreply.addContent(AMF::Object(""));//server properties
amfreply.getContentP(2)->addContent(AMF::Object("fmsVer", "FMS/3,5,2,654"));//stolen from examples amfreply.getContentP(2)->addContent(AMF::Object("fmsVer", "FMS/3,5,4,1004"));
amfreply.getContentP(2)->addContent(AMF::Object("capabilities", (double)31));//stolen from examples amfreply.getContentP(2)->addContent(AMF::Object("capabilities", (double)127));
amfreply.getContentP(2)->addContent(AMF::Object("mode", (double)1));//stolen from examples amfreply.getContentP(2)->addContent(AMF::Object("mode", (double)1));
amfreply.getContentP(2)->addContent(AMF::Object("objectEncoding", (double)0));
amfreply.addContent(AMF::Object(""));//info amfreply.addContent(AMF::Object(""));//info
amfreply.getContentP(3)->addContent(AMF::Object("level", "status")); amfreply.getContentP(3)->addContent(AMF::Object("level", "status"));
amfreply.getContentP(3)->addContent(AMF::Object("code", "NetConnection.Connect.Success")); amfreply.getContentP(3)->addContent(AMF::Object("code", "NetConnection.Connect.Success"));
amfreply.getContentP(3)->addContent(AMF::Object("description", "Connection succeeded.")); amfreply.getContentP(3)->addContent(AMF::Object("description", "Connection succeeded."));
amfreply.getContentP(3)->addContent(AMF::Object("objectEncoding", (double)0));
amfreply.getContentP(3)->addContent(AMF::Object("data", AMF::AMF0_ECMA_ARRAY));
amfreply.getContentP(3)->getContentP(4)->addContent(AMF::Object("version", "3,5,4,1004"));
#if DEBUG >= 4 #if DEBUG >= 4
amfreply.Print(); amfreply.Print();
#endif #endif
Socket.write(RTMPStream::SendChunk(3, 20, next.msg_stream_id, amfreply.Pack())); Socket.write(RTMPStream::SendChunk(3, 20, next.msg_stream_id, amfreply.Pack()));
//send onBWDone packet //send onBWDone packet - no clue what it is, but real server sends it...
//amfreply = AMFType("container", (unsigned char)0xFF); amfreply = AMF::Object("container", AMF::AMF0_DDV_CONTAINER);
//amfreply.addContent(AMFType("", "onBWDone"));//result success amfreply.addContent(AMFType("", "onBWDone"));//result
//amfreply.addContent(AMFType("", (double)0));//zero amfreply.addContent(AMFType("", (double)0));//zero
//amfreply.addContent(AMFType("", (double)0, 0x05));//null amfreply.addContent(AMFType("", (double)0, AMF::AMF0_NULL));//null
//SendChunk(3, 20, next.msg_stream_id, amfreply.Pack()); Socket.write(RTMPStream::SendChunk(3, 20, next.msg_stream_id, amfreply.Pack()));
parsed = true; parsed = true;
}//connect }//connect
if (amfdata.getContentP(0)->StrValue() == "createStream"){ if (amfdata.getContentP(0)->StrValue() == "createStream"){

View file

@ -18,8 +18,8 @@ unsigned int RTMPStream::getNowMS(){
unsigned int RTMPStream::chunk_rec_max = 128; unsigned int RTMPStream::chunk_rec_max = 128;
unsigned int RTMPStream::chunk_snd_max = 128; unsigned int RTMPStream::chunk_snd_max = 128;
unsigned int RTMPStream::rec_window_size = 0xFA00; unsigned int RTMPStream::rec_window_size = 2500000;
unsigned int RTMPStream::snd_window_size = 1024*500; unsigned int RTMPStream::snd_window_size = 2500000;
unsigned int RTMPStream::rec_window_at = 0; unsigned int RTMPStream::rec_window_at = 0;
unsigned int RTMPStream::snd_window_at = 0; unsigned int RTMPStream::snd_window_at = 0;
unsigned int RTMPStream::rec_cnt = 0; unsigned int RTMPStream::rec_cnt = 0;
@ -243,6 +243,9 @@ std::string RTMPStream::SendUSR(unsigned char type, unsigned int data, unsigned
/// Parses the argument string into the current chunk. /// Parses the argument string into the current chunk.
/// Tries to read a whole chunk, if successful it will remove /// Tries to read a whole chunk, if successful it will remove
/// the corresponding data from the input string. /// the corresponding data from the input string.
/// If only part of a chunk is read, it will remove the part and call itself again.
/// This has the effect of only causing a "true" reponse in the case a *whole* chunk
/// is read, not just part of a chunk.
/// \param indata The input string to parse and update. /// \param indata The input string to parse and update.
/// \warning This function will destroy the current data in this chunk! /// \warning This function will destroy the current data in this chunk!
/// \returns True if a whole chunk could be read, false otherwise. /// \returns True if a whole chunk could be read, false otherwise.
@ -368,7 +371,7 @@ bool RTMPStream::Chunk::Parse(std::string & indata){
/// Does the handshake. Expects handshake_in to be filled, and fills handshake_out. /// Does the handshake. Expects handshake_in to be filled, and fills handshake_out.
/// After calling this function, don't forget to read and ignore 1536 extra bytes, /// After calling this function, don't forget to read and ignore 1536 extra bytes,
/// this is the handshake response and not interesting for us because we don't do client /// these are the handshake response and not interesting for us because we don't do client
/// verification. /// verification.
bool RTMPStream::doHandshake(){ bool RTMPStream::doHandshake(){
char Version; char Version;