From 64417b28847aa283726a34a8fed57006a56230cd Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 17 Apr 2011 00:38:04 +0200 Subject: [PATCH] RTMP edits --- Connector_RTMP/main.cpp | 24 ++++++++++++------------ util/rtmpchunks.cpp | 9 ++++++--- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Connector_RTMP/main.cpp b/Connector_RTMP/main.cpp index 8d50081d..f3baa4a0 100644 --- a/Connector_RTMP/main.cpp +++ b/Connector_RTMP/main.cpp @@ -163,7 +163,6 @@ void Connector_RTMP::parseChunk(){ static AMF::Object amfelem("empty", AMF::AMF0_DDV_CONTAINER); 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)){ //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 & 0x400){fprintf(stderr, "AAC video support detected\n");} #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::SendUSR(0, 1));//send UCM StreamBegin (0), stream 1 //send a _result reply @@ -289,24 +287,26 @@ void Connector_RTMP::parseChunk(){ amfreply.addContent(amfdata.getContent(1));//same transaction ID // amfreply.addContent(AMFType("", (double)0, 0x05));//null - command info 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("capabilities", (double)31));//stolen from examples - amfreply.getContentP(2)->addContent(AMF::Object("mode", (double)1));//stolen from examples - amfreply.getContentP(2)->addContent(AMF::Object("objectEncoding", (double)0)); + amfreply.getContentP(2)->addContent(AMF::Object("fmsVer", "FMS/3,5,4,1004")); + amfreply.getContentP(2)->addContent(AMF::Object("capabilities", (double)127)); + amfreply.getContentP(2)->addContent(AMF::Object("mode", (double)1)); amfreply.addContent(AMF::Object(""));//info amfreply.getContentP(3)->addContent(AMF::Object("level", "status")); 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("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 amfreply.Print(); #endif Socket.write(RTMPStream::SendChunk(3, 20, next.msg_stream_id, amfreply.Pack())); - //send onBWDone packet - //amfreply = AMFType("container", (unsigned char)0xFF); - //amfreply.addContent(AMFType("", "onBWDone"));//result success - //amfreply.addContent(AMFType("", (double)0));//zero - //amfreply.addContent(AMFType("", (double)0, 0x05));//null - //SendChunk(3, 20, next.msg_stream_id, amfreply.Pack()); + //send onBWDone packet - no clue what it is, but real server sends it... + amfreply = AMFType("container", AMF::AMF0_DDV_CONTAINER); + amfreply.addContent(AMFType("", "onBWDone"));//result + amfreply.addContent(AMFType("", (double)0));//zero + amfreply.addContent(AMFType("", (double)0, AMF::AMF0_NULL));//null + SendChunk(3, 20, next.msg_stream_id, amfreply.Pack()); parsed = true; }//connect if (amfdata.getContentP(0)->StrValue() == "createStream"){ diff --git a/util/rtmpchunks.cpp b/util/rtmpchunks.cpp index eca2f9fb..a63a2380 100644 --- a/util/rtmpchunks.cpp +++ b/util/rtmpchunks.cpp @@ -18,8 +18,8 @@ unsigned int RTMPStream::getNowMS(){ unsigned int RTMPStream::chunk_rec_max = 128; unsigned int RTMPStream::chunk_snd_max = 128; -unsigned int RTMPStream::rec_window_size = 0xFA00; -unsigned int RTMPStream::snd_window_size = 1024*500; +unsigned int RTMPStream::rec_window_size = 2500000; +unsigned int RTMPStream::snd_window_size = 2500000; unsigned int RTMPStream::rec_window_at = 0; unsigned int RTMPStream::snd_window_at = 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. /// Tries to read a whole chunk, if successful it will remove /// 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. /// \warning This function will destroy the current data in this chunk! /// \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. /// 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. bool RTMPStream::doHandshake(){ char Version;