gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/rtmp r10056: red5 eants the connect packet


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r10056: red5 eants the connect packet as part of the final handshake, or it refuses to connect.
Date: Thu, 26 Mar 2009 18:39:34 -0600
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10056
committer: address@hidden
branch nick: rtmp
timestamp: Thu 2009-03-26 18:39:34 -0600
message:
  red5 eants the connect packet as part of the final handshake, or it refuses 
to connect.
modified:
  libnet/rtmp_client.cpp
  libnet/rtmp_client.h
=== modified file 'libnet/rtmp_client.cpp'
--- a/libnet/rtmp_client.cpp    2009-03-13 01:44:38 +0000
+++ b/libnet/rtmp_client.cpp    2009-03-27 00:39:34 +0000
@@ -119,7 +119,7 @@
     swfUrlnode->makeString("swfUrl", swfUrl);
     obj->addProperty(swfUrlnode);
 
-//    filespec = "rtmp://localhost/oflaDemo";
+//    filespec = "rtmp://localhost:5935/oflaDemo";
     ElementSharedPtr tcUrlnode(new amf::Element);
     tcUrlnode->makeString("tcUrl", tcUrl);
     obj->addProperty(tcUrlnode);
@@ -148,10 +148,11 @@
     pageUrlnode->makeString("pageUrl", pageUrl);
     obj->addProperty(pageUrlnode);
 
+#if 0
     ElementSharedPtr objencodingnode(new Element);
     objencodingnode->makeNumber("objectEncoding", 0.0);
     obj->addProperty(objencodingnode);
-    
+#endif
 //    size_t total_size = 227;
 //     Buffer *out = encodeHeader(0x3, RTMP::HEADER_12, total_size,
 //                                      RTMP::INVOKE, RTMP::FROM_CLIENT);
@@ -360,13 +361,21 @@
 RTMPClient::clientFinish()
 {
     GNASH_REPORT_FUNCTION;
+    amf::Buffer data;
+    return clientFinish(data);
+}
+
+bool
+RTMPClient::clientFinish(amf::Buffer &data)
+{
+    GNASH_REPORT_FUNCTION;
 
     int ret = 0;
-    _handshake->clear();
     
-    gnashSleep(1000000); // FIXME: why do we still need a delay here, when 
readNet() does a select ?
+//     gnashSleep(1000000); // FIXME: why do we still need a delay here, when 
readNet() does a select ?
     ret = readNet(_handshake->reference(), RTMP_HANDSHAKE_SIZE);
     if (ret == RTMP_HANDSHAKE_SIZE) {
+       _handshake->setSeekPointer(_handshake->reference() + ret);
         log_debug (_("Read first data block in handshake"));
     } else {
         log_error (_("Couldn't read first data block in handshake"));
@@ -375,6 +384,7 @@
     if (ret > RTMP_HANDSHAKE_SIZE) {
        ret = readNet(_handshake->reference(), RTMP_HANDSHAKE_SIZE);
        if (ret == RTMP_HANDSHAKE_SIZE) {        
+           _handshake->setSeekPointer(_handshake->reference() + ret);
            log_debug (_("Read second data block in handshake"));
        } else {
            log_error (_("Couldn't read second data block in handshake"));
@@ -383,26 +393,28 @@
     }
     ret = readNet(_handshake->reference(), RTMP_HANDSHAKE_SIZE);
     if (ret == RTMP_HANDSHAKE_SIZE) {        
+       _handshake->setSeekPointer(_handshake->reference() + ret);
         log_debug (_("Read second data block in handshake"));
     } else {
         log_error (_("Couldn't read second data block in handshake"));
 //        return false;
     }
-    if (ret > RTMP_HANDSHAKE_SIZE) {
-       ret = readNet(_handshake->reference(), RTMP_HANDSHAKE_SIZE);
-       if (ret == RTMP_HANDSHAKE_SIZE) {        
-           log_debug (_("Read second data block in handshake"));
-       } else {
-           log_error (_("Couldn't read second data block in handshake"));
-//        return false;
-       }
-    }
-
-    ret = writeNet(_handshake->reference(), RTMP_HANDSHAKE_SIZE);
+    
+    // For some reason, Red5 won't connect unless the connect packet is
+    // part of the final handshake packet. Sending the identical data with
+    // two writeNet()s won't connect. Go figure...
+    _handshake->resize(RTMP_HANDSHAKE_SIZE + data.size());
+    // FIXME: unless the handshake is all zeros, Gnash won't connect to
+    // Red5 for some reason. Cygnal isn't so picky.
+    _handshake->clear();
+    _handshake->setSeekPointer(_handshake->reference() + RTMP_HANDSHAKE_SIZE);
+    // Add the NetConnection::connect() packet
+    _handshake->append(data.reference(), data.allocated());
+    ret = writeNet(_handshake->reference(), _handshake->allocated());
     if ( ret <= 0 ) {
        return false;
     }
-
+    
     // Since the handshake completed sucessfully, we're connected.
     _connected == true;
 

=== modified file 'libnet/rtmp_client.h'
--- a/libnet/rtmp_client.h      2009-03-20 00:00:54 +0000
+++ b/libnet/rtmp_client.h      2009-03-27 00:39:34 +0000
@@ -44,6 +44,7 @@
     bool handShakeWait();
 //    bool handShakeResponse();
     bool clientFinish();
+    bool clientFinish(amf::Buffer &data);
     bool handShakeRequest();
     
     // These are used for creating the primary objects


reply via email to

[Prev in Thread] Current Thread [Next in Thread]