gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] /srv/bzr/gnash/rtmp r9802: merge from upstream strk's rtm


From: rob
Subject: [Gnash-commit] /srv/bzr/gnash/rtmp r9802: merge from upstream strk's rtmpget patches.
Date: Sat, 29 Nov 2008 12:38:51 -0700
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 9802
committer: address@hidden
branch nick: rtmp
timestamp: Sat 2008-11-29 12:38:51 -0700
message:
  merge from upstream strk's rtmpget patches.
modified:
  libnet/network.cpp
  libnet/rtmp_client.cpp
  utilities/rtmpget.cpp
    ------------------------------------------------------------
    revno: 9798.1.1
    committer: strk <address@hidden>
    branch nick: rtmp
    timestamp: Sat 2008-11-29 02:40:58 +0100
    message:
      cleanup encodeStreamOp
    modified:
      libnet/rtmp_client.cpp
    ------------------------------------------------------------
    revno: 9798.1.2
    committer: strk <address@hidden>
    branch nick: rtmp
    timestamp: Sat 2008-11-29 02:43:18 +0100
    message:
      Better error handling for rtmpget
    modified:
      utilities/rtmpget.cpp
    ------------------------------------------------------------
    revno: 9798.1.3
    committer: strk <address@hidden>
    branch nick: rtmp
    timestamp: Sat 2008-11-29 02:49:32 +0100
    message:
      Fix compiler warnings; don't block SIGINT while debuggin.
    modified:
      libnet/network.cpp
=== modified file 'libnet/network.cpp'
--- a/libnet/network.cpp        2008-11-29 01:08:41 +0000
+++ b/libnet/network.cpp        2008-11-29 01:49:32 +0000
@@ -282,10 +282,10 @@
 
 #ifdef HAVE_PSELECT
        struct timespec tval;
-       sigset_t sigset, emptyset, blockset, pending;
-       sigemptyset(&blockset);         /* Block SIGINT */
-//        sigaddset(&blockset, SIGINT);
-        sigaddset(&blockset, SIGPIPE);
+       sigset_t sigset, blockset, pending;
+       sigemptyset(&blockset);        
+//        sigaddset(&blockset, SIGINT); /* Block SIGINT */
+        sigaddset(&blockset, SIGPIPE); /* Block SIGPIPE */
        sigprocmask(SIG_BLOCK, &blockset, &sigset);
 #else
        struct timeval tval;
@@ -834,9 +834,9 @@
 
 #ifdef HAVE_PSELECT
        struct timespec tval;
-       sigset_t pending, emptyset, blockset;
-       sigemptyset(&blockset);         /* Block SIGINT */
-        sigaddset(&blockset, SIGINT);
+       sigset_t pending, blockset;
+       sigemptyset(&blockset);        
+        // sigaddset(&blockset, SIGINT); /* Block SIGINT */
         sigprocmask(SIG_BLOCK, &blockset, NULL);
 
        // Trap ^C (SIGINT) so we can kill all the threads
@@ -995,10 +995,10 @@
 
 #ifdef HAVE_PSELECT
        struct timespec tval;
-       sigset_t pending, emptyset, blockset;
-       sigemptyset(&blockset);         /* Block SIGINT */
-        sigaddset(&blockset, SIGINT);
-//        sigaddset(&blockset, SIGPIPE);
+       sigset_t pending, blockset;
+       sigemptyset(&blockset);        
+        // sigaddset(&blockset, SIGINT); /* Block SIGINT */
+        sigaddset(&blockset, SIGPIPE);
         sigprocmask(SIG_BLOCK, &blockset, NULL);
 #else
        struct timeval tval;
@@ -1276,6 +1276,7 @@
     _connected = net.connected();
     _debug = net.netDebug();
     _timeout = net.getTimeout();
+    return *this;
 }
 
 void

=== modified file 'libnet/rtmp_client.cpp'
--- a/libnet/rtmp_client.cpp    2008-11-19 07:53:39 +0000
+++ b/libnet/rtmp_client.cpp    2008-11-29 01:40:58 +0000
@@ -275,43 +275,47 @@
     boost::shared_ptr<Buffer> nullobj = null.encode();    
 
     // Set the BOOLEAN object element that is the last field in the packet
-    Element boolean;
-    boolean.makeBoolean(flag);
-    boost::shared_ptr<Buffer> boolobj = boolean.encode();    
-    
+    // (SEEK and PLAY don't use the boolean flag)
+    boost::shared_ptr<Buffer> boolobj;
+    if ((op != STREAM_SEEK) && (op != STREAM_PLAY)) {
+        Element boolean;
+        boolean.makeBoolean(flag);
+        boolobj = boolean.encode();    
+    }
+
+    // The seek command also may have an optional location to seek to
+    boost::shared_ptr<Buffer> posobj;
+    if ((op == STREAM_PAUSE) || (op == STREAM_SEEK)) {
+        Element seek;
+        seek.makeNumber(pos);
+        posobj = seek.encode();
+    }
+
+    // The play command has an optional field, which is the name of the file
+    // used for the stream. A Play command without this name set play an
+    // existing stream that is already open.
+    boost::shared_ptr<Buffer> fileobj; 
+    if (!name.empty()) {
+        Element filespec;
+        filespec.makeString(name);
+        fileobj = filespec.encode();
+    }
+
     // Calculate the packet size, rather than use the default as we want to
     // to be concious of the memory usage. The command name and the optional
     // file name are the only two dynamically sized fields.
-    size_t pktsize = strobj->size() + name.size();
-    // Add 2 bytes for the Boolean, and 16 bytes for the two doubles, which are
-    // 8 bytes apiece.
-    pktsize += (sizeof(double) * 2) + 2;
+    size_t pktsize = strobj->size() + stridobj->size() + nullobj->size();
+    if ( boolobj ) pktsize += boolobj->size();
+    if ( fileobj ) pktsize += fileobj->size();
+    if ( posobj ) pktsize += posobj->size();
+
     boost::shared_ptr<Buffer> buf(new Buffer(pktsize));    
     *buf += strobj;
     *buf += stridobj;
     *buf += nullobj;
-    // Seek doesn't use the boolean flag
-    if ((op != STREAM_SEEK) && (op != STREAM_PLAY)) {
-       *buf += boolobj;
-    }
-
-    // The play command has an optional field, which is the name of the file
-    // used for the stream. A Play command without this name set play an
-    // existing stream that is already open.
-    if (!name.empty()) {
-       Element filespec;
-       filespec.makeString(name);
-       boost::shared_ptr<Buffer> fileobj = filespec.encode();
-       *buf += fileobj;
-    }
-    
-    // The seek command also may have an optional location to seek to
-    if ((op == STREAM_PAUSE) || (op == STREAM_SEEK)) {
-       Element seek;
-       seek.makeNumber(pos);
-       boost::shared_ptr<Buffer> posobj = seek.encode();
-       *buf += posobj;
-    }
+    if ( boolobj ) *buf += boolobj;
+    if ( fileobj ) *buf += fileobj;
+    if ( posobj ) *buf += posobj;
 
     return buf;
 }
@@ -391,7 +395,8 @@
        }
     }
 
-    writeNet(_handshake->reference(), RTMP_BODY_SIZE);
+    ret = writeNet(_handshake->reference(), RTMP_BODY_SIZE);
+    if ( ret <= 0 ) return false;
 
     return true;
 }

=== modified file 'utilities/rtmpget.cpp'
--- a/utilities/rtmpget.cpp     2008-11-20 22:15:11 +0000
+++ b/utilities/rtmpget.cpp     2008-11-29 01:43:18 +0000
@@ -312,9 +312,17 @@
         exit(-1);
     }
     
-    client.handShakeRequest();
+    if ( ! client.handShakeRequest() )
+    {
+        log_error("RTMP handshake request failed");
+        exit(EXIT_FAILURE);
+    }
     
-    client.clientFinish();
+    if ( ! client.clientFinish() )
+    {
+        log_error("RTMP handshake completion failed");
+        exit(EXIT_FAILURE);
+    }
     
     // Make a buffer to hold the handshake data.
     Buffer buf(1537);
@@ -324,18 +332,21 @@
     BufferSharedPtr buf2 = client.encodeConnect(app.c_str(), swfUrl.c_str(), 
tcUrl.c_str(), 615, 124, 1, pageUrl.c_str());
 //    BufferSharedPtr buf2 = 
client.encodeConnect("video/2006/sekt/gate06/tablan_valentin", 
"mediaplayer.swf", 
"rtmp://velblod.videolectures.net/video/2006/sekt/gate06/tablan_valentin", 615, 
124, 1, "http://gnashdev.org";);
 //    BufferSharedPtr buf2 = client.encodeConnect("oflaDemo", 
"http://192.168.1.70/software/gnash/tests/ofla_demo.swf";, 
"rtmp://localhost/oflaDemo/stream", 615, 124, 1, 
"http://192.168.1.70/software/gnash/tests/index.html";);
-    buf2->resize(buf2->size() - 6); // FIXME: encodeConnect returns the wrong 
size for the buffer!
+    //buf2->resize(buf2->size() - 6); // FIXME: encodeConnect returns the 
wrong size for the buffer!
     size_t total_size = buf2->size();    
     RTMPMsg *msg1 = client.sendRecvMsg(0x3, RTMP::HEADER_12, total_size, 
RTMP::INVOKE, RTMPMsg::FROM_CLIENT, buf2);
     
-    if (msg1) {
-        msg1->dump();
-        if (msg1->getStatus() ==  RTMPMsg::NC_CONNECT_SUCCESS) {
-            log_debug("Sent NetConnection Connect message sucessfully");
-        } else {
+    if (!msg1) {
+        log_error("No response from INVOKE of NetConnection connect");
+        exit(-1);
+    }
+
+    msg1->dump();
+    if (msg1->getStatus() ==  RTMPMsg::NC_CONNECT_SUCCESS) {
+        log_debug("Sent NetConnection Connect message sucessfully");
+    } else {
         log_error("Couldn't send NetConnection Connect message,");
-    //      exit(-1);
-        }
+        //exit(-1);
     }
     
     // make the createStream for ID 3 encoded object
@@ -345,25 +356,27 @@
     total_size = buf3->size();
     RTMPMsg *msg2 = client.sendRecvMsg(0x3, RTMP::HEADER_12, total_size, 
RTMP::INVOKE, RTMPMsg::FROM_CLIENT, buf3);
     double streamID = 0.0;
-    if (msg2) {
-        msg2->dump();
-        log_debug("Sent NetStream::createStream message successfully.");
-        std::vector<ElementSharedPtr> hell = msg2->getElements();
-        if (hell.size() > 0) {
-            streamID = hell[0]->to_number();
-        } else {
-            if (msg2->getMethodName() == "close") { 
+
+    if (!msg2) {
+        log_error("No response from INVOKE of NetStream::createStream");
+        exit(-1);
+    }
+
+    log_debug("Sent NetStream::createStream message successfully:"); 
msg2->dump();
+    std::vector<ElementSharedPtr> hell = msg2->getElements();
+    if (hell.size() > 0) {
+        streamID = hell[0]->to_number();
+        log_debug("Stream ID returned from createStream is: %d", streamID);
+    } else {
+        if (msg2->getMethodName() == "close") { 
             log_debug("Got close packet!!! Exiting...");
             exit(0);
-            }
-            streamID = 0.0;
         }
-    } else {
-        log_error("Couldn't send NetStream::createStream message,");
-    //  exit(-1);
+        log_error("Got no properties from NetStream::createStream invocation, 
arbitrarily taking 0 as streamID");
+        streamID = 0.0;
     }
+
     int id = int(streamID);
-    log_debug("Stream ID returned from createStream is: %d", id);
     
     // make the NetStream::play() operations for ID 2 encoded object
 //    log_debug("Sending NetStream play message,");


reply via email to

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