gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] [SCM] Gnash branch, master, updated. 82d98c1e60ca6381845e


From: Benjamin Wolsey
Subject: [Gnash-commit] [SCM] Gnash branch, master, updated. 82d98c1e60ca6381845e35bab72b524756fcfa21
Date: Tue, 26 Oct 2010 14:00:54 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Gnash".

The branch, master has been updated
       via  82d98c1e60ca6381845e35bab72b524756fcfa21 (commit)
       via  09a900a5d6d182d0e31bd716dabad66fe62a1175 (commit)
       via  20af1a489cf893f590fb5630caaece7b7a9e011c (commit)
       via  c965625df2dc52d39a20909b1f1b48209e10f247 (commit)
       via  b514a186cd0b8254c1888dbe7a687b44472aca18 (commit)
       via  734c54fea4fc23957581da11b43f757d6fd4d38c (commit)
       via  acd20fcc20ee7eed564480a139235fb8e71c1a04 (commit)
       via  0ab0cdb064e7254c956f1e8348cc57730d68ac00 (commit)
       via  f1fcdde71ae761ec4a9a90dc35a4a5fd71c0524f (commit)
       via  8f96b7ac52583741b4cd538d83ef882aaa79cfa2 (commit)
       via  c8400f6ea799e23eae5529d5e6af7667b4d65806 (commit)
       via  ae38f1240c04c7aee327202bf1d39173da341553 (commit)
       via  c4bf3d3d77c8090413a82cb84a30e3e270749a07 (commit)
       via  8940803f71a5247b41bf7428373ce570eb558ff2 (commit)
       via  dddbbd7b3816ce6934997923f4d9f85bcc4166b2 (commit)
      from  170b4df66f8a53b48596a7ea86ee8a2b48304950 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit//commit/?id=82d98c1e60ca6381845e35bab72b524756fcfa21


commit 82d98c1e60ca6381845e35bab72b524756fcfa21
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 15:37:48 2010 +0200

    Silence debugging.

diff --git a/libcore/asobj/TextField_as.cpp b/libcore/asobj/TextField_as.cpp
index 7e48dbd..2d6ca94 100644
--- a/libcore/asobj/TextField_as.cpp
+++ b/libcore/asobj/TextField_as.cpp
@@ -872,11 +872,9 @@ textfield_text(const fn_call& fn)
 as_value
 textfield_htmlText(const fn_call& fn)
 {
-    GNASH_REPORT_FUNCTION;
 
     TextField* ptr = ensure<IsDisplayObject<TextField> >(fn);
-    if (!fn.nargs)
-    {
+    if (!fn.nargs) {
         // Getter
         return as_value(ptr->get_htmltext_value());
     }
diff --git a/libcore/vm/VM.cpp b/libcore/vm/VM.cpp
index c7c9f9f..b078550 100644
--- a/libcore/vm/VM.cpp
+++ b/libcore/vm/VM.cpp
@@ -400,22 +400,14 @@ newLessThan(const as_value& op1, const as_value& op2, 
const VM& vm)
     as_value operand2(op2);
 
     try { operand1 = op1.to_primitive(as_value::NUMBER); }
-    catch (ActionTypeError& e)
-    {
-        log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
-            op1);
-    }
+    catch (const ActionTypeError& e) {}
     
     if (operand1.is_object() && !operand1.is_sprite()) {
         return false;
     }
 
     try { operand2 = op2.to_primitive(as_value::NUMBER); }
-    catch (ActionTypeError& e)
-    {
-        log_debug("%s.to_primitive() threw an error during ActionNewLessThen",
-            op2);
-    }
+    catch (const ActionTypeError& e) {}
     
     if (operand2.is_object() && !operand2.is_sprite()) {
         return false;

http://git.savannah.gnu.org/cgit//commit/?id=09a900a5d6d182d0e31bd716dabad66fe62a1175


commit 09a900a5d6d182d0e31bd716dabad66fe62a1175
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 15:35:48 2010 +0200

    Drop local reading functions.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 1a7e03f..cc4ed2f 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -45,6 +45,7 @@
 #include "fn_call.h"
 #include "Global_as.h"
 #include "AMFConverter.h"
+#include "AMF.h"
 #include "smart_ptr.h"
 #include "RunResources.h"
 #include "IOChannel.h"
@@ -72,13 +73,6 @@ namespace {
 
 }
 
-namespace {
-
-    boost::uint16_t readNetworkShort(const boost::uint8_t* buf);
-    boost::uint32_t readNetworkLong(const boost::uint8_t* buf);
-
-}
-
 //---- ConnectionHandler -------------------------------------------------
 
 /// Abstract connection handler class
@@ -351,7 +345,7 @@ HTTPRemotingHandler::advance()
                 b += 2; // skip version indicator and client id
 
                 // NOTE: this looks much like parsing of an OBJECT_AMF0
-                boost::int16_t si = readNetworkShort(b);
+                boost::int16_t si = amf::readNetworkShort(b);
                 b += 2; // number of headers
                 uint8_t headers_ok = 1;
                 if (si != 0) {
@@ -366,7 +360,7 @@ HTTPRemotingHandler::advance()
                             headers_ok = 0;
                             break;
                         }
-                        si = readNetworkShort(b); b += 2; // name length
+                        si = amf::readNetworkShort(b); b += 2; // name length
                         if(b + si > end) {
                             headers_ok = 0;
                             break;
@@ -405,7 +399,7 @@ HTTPRemotingHandler::advance()
 
                 if(headers_ok == 1) {
 
-                    si = readNetworkShort(b); b += 2; // number of replies
+                    si = amf::readNetworkShort(b); b += 2; // number of replies
 
                     // TODO consider counting number of replies we
                     // actually parse and doing something if it
@@ -415,7 +409,8 @@ HTTPRemotingHandler::advance()
                         // we reach the end of the buffer
                         while(b < end) {
                             if(b + 2 > end) break;
-                            si = readNetworkShort(b); b += 2; // reply length
+                            si = amf::readNetworkShort(b);
+                            b += 2; // reply length
                             if(si < 4) { // shorted valid response is '/1/a'
                                 log_error("NetConnection::call(): "
                                         "reply message name too short");
@@ -454,7 +449,8 @@ HTTPRemotingHandler::advance()
 
                             // parse past unused string in header
                             if (b + 2 > end) break;
-                            si = readNetworkShort(b); b += 2; // reply length
+                            si = amf::readNetworkShort(b);
+                            b += 2; // reply length
                             if (b + si > end) break;
                             b += si;
 
@@ -465,7 +461,8 @@ HTTPRemotingHandler::advance()
                             // in the adobe player) sends
                             // 0xffffffff. So we just ignore it
                             if (b + 4 > end) break;
-                            li = readNetworkLong(b); b += 4; // reply length
+                            li = amf::readNetworkLong(b);
+                            b += 4; // reply length
 
                             // this updates b to point to the next unparsed 
byte
                             as_value replyval;
@@ -1126,26 +1123,6 @@ NetConnection_as::update()
     }
 }
 
-/// Anonymous namespace for NetConnection AMF-reading helper functions
-/// (shouldn't be here).
-
-namespace {
-
-boost::uint16_t
-readNetworkShort(const boost::uint8_t* buf) {
-    boost::uint16_t s = buf[0] << 8 | buf[1];
-    return s;
-}
-
-boost::uint32_t
-readNetworkLong(const boost::uint8_t* buf) {
-    boost::uint32_t s = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
-    return s;
-}
-
-}
-
-
 // Anonymous namespace for NetConnection interface implementation.
 namespace {
 

http://git.savannah.gnu.org/cgit//commit/?id=20af1a489cf893f590fb5630caaece7b7a9e011c


commit 20af1a489cf893f590fb5630caaece7b7a9e011c
Merge: 170b4df c965625
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 15:26:15 2010 +0200

    Merge branch 'rtmp'


http://git.savannah.gnu.org/cgit//commit/?id=c965625df2dc52d39a20909b1f1b48209e10f247


commit c965625df2dc52d39a20909b1f1b48209e10f247
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 15:24:56 2010 +0200

    Set connected without using the callback function.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 5304873..1a7e03f 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -49,7 +49,6 @@
 #include "RunResources.h"
 #include "IOChannel.h"
 #include "RTMP.h"
-#include "NativeFunction.h"
 
 //#define GNASH_DEBUG_REMOTING
 
@@ -438,12 +437,12 @@ HTTPRemotingHandler::advance()
 
                             std::string id(reinterpret_cast<const char*>(b + 
1),
                                     ns - 1);
-                            log_debug("ID: %s", id);
                             size_t callbackID = 0;
                             try {
                                 callbackID = boost::lexical_cast<size_t>(id);
                             }
                             catch (const boost::bad_lexical_cast&) {
+                                log_error(_("Callback ID was not a number"));
                                 break;
                             }
 
@@ -691,7 +690,6 @@ public:
             if (!_rtmp.connected()) return true;
             
             _connectionComplete = true;
-
             log_debug("Initial connection complete");
 
             const RunResources& r = getRunResources(_nc.owner());
@@ -702,8 +700,9 @@ public:
             const int flags = 0;
             o->init_member("app", _url.path().substr(1), flags);
 
-            // TODO: use $version.
-            o->init_member("flashVer", "LNX 10,0,22,87", flags);
+            // TODO: check where it gets these data from.
+            o->init_member("flashVer", getVM(_nc.owner()).getPlayerVersion(),
+                    flags);
             o->init_member("swfUrl", r.streamProvider().originalURL().str(),
                     flags);
             o->init_member("tcUrl", _url.str(), flags);
@@ -717,18 +716,18 @@ public:
             o->init_member("pageUrl", as_value(), flags);
 
             const size_t id = callNo();
-            log_debug("Call %s", id);
             SimpleBuffer buf;
 
+            // Write the connect object.
             amf::Writer aw(buf);
             aw.writeString("connect");
             aw.writeNumber(id);
             aw.writeObject(o);
 
+            // Set up the callback object.
             as_object* cb = createObject(getGlobal(_nc.owner()));
-            log_debug("Object cb: %s", cb);
             cb->init_member(NSV::PROP_ON_RESULT,
-                    new NativeFunction(gl, local_onResult), 0);
+                    gl.createFunction(local_onResult), 0);
 
             cb->init_member("_conn", &_nc.owner(), 0);
 
@@ -737,13 +736,18 @@ public:
             pushCallback(id, cb);
             _rtmp.call(buf);
 
-            // Send bandwidth check; this seems to be required.
+            // Send bandwidth check; the pp appears to do this
+            // automatically.
             sendServerBW(_rtmp);
 
         }
         
         boost::shared_ptr<SimpleBuffer> b = _rtmp.getMessage();
 
+        if (b && !_nc.isConnected()) {
+            _nc.setConnected();
+        }
+
         /// Retrieve messages.
         while (b.get()) {
             handleInvoke(b->data() + rtmp::RTMPHeader::headerSize,
@@ -852,9 +856,6 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t* 
payload,
     
 }
 
-
-//----- NetConnection_as ----------------------------------------------------
-
 NetConnection_as::NetConnection_as(as_object* owner)
     :
     ActiveRelay(owner),
@@ -1325,7 +1326,6 @@ netconnection_addHeader(const fn_call& fn)
 /// We don't know if this is the best way to do it, but:
 //
 /// 1. the connect call *does* return a callback ID.
-/// 2. if it is done like this, it has to be a native function.
 as_value
 local_onResult(const fn_call& fn)
 {
@@ -1337,10 +1337,6 @@ local_onResult(const fn_call& fn)
         as_value f = getMember(*obj, conn);
         as_object* nc = toObject(f, getVM(fn));
         if (nc) {
-            NetConnection_as* co;
-            if (isNativeType(nc, co)) {
-                co->setConnected();
-            }
         }
         const as_value arg = fn.nargs ? fn.arg(0) : as_value();
         callMethod(nc, NSV::PROP_ON_STATUS, arg);

http://git.savannah.gnu.org/cgit//commit/?id=b514a186cd0b8254c1888dbe7a687b44472aca18


commit b514a186cd0b8254c1888dbe7a687b44472aca18
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 13:55:20 2010 +0200

    Update documentation, but there may be a better way to do this.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 9bca3bd..5304873 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -49,6 +49,7 @@
 #include "RunResources.h"
 #include "IOChannel.h"
 #include "RTMP.h"
+#include "NativeFunction.h"
 
 //#define GNASH_DEBUG_REMOTING
 
@@ -66,6 +67,7 @@ namespace {
     as_value netconnection_call(const fn_call& fn);
     as_value netconnection_addHeader(const fn_call& fn);
     as_value netconnection_new(const fn_call& fn);
+    as_value local_onResult(const fn_call& fn);
     std::pair<std::string, std::string>
         getStatusCodeInfo(NetConnection_as::StatusCode code);
 
@@ -632,29 +634,6 @@ replyBWCheck(rtmp::RTMP& r, double txn)
     r.call(buf);
 }
 
-as_value
-local_onResult(const fn_call& fn)
-{
-    log_debug("local onResult called");
-    as_object* obj = fn.this_ptr;
-    string_table& st = getStringTable(fn);
-    const ObjectURI conn(st.find("_conn"));
-
-    if (obj) {
-        as_value f = getMember(*obj, conn);
-        as_object* nc = toObject(f, getVM(fn));
-        if (nc) {
-            NetConnection_as* co;
-            if (isNativeType(nc, co)) {
-                co->setConnected();
-            }
-        }
-        const as_value arg = fn.nargs ? fn.arg(0) : as_value();
-        callMethod(nc, NSV::PROP_ON_STATUS, arg);
-    }
-    return as_value();
-}
-
 class RTMPRemotingHandler : public ConnectionHandler
 {
 public:
@@ -749,7 +728,7 @@ public:
             as_object* cb = createObject(getGlobal(_nc.owner()));
             log_debug("Object cb: %s", cb);
             cb->init_member(NSV::PROP_ON_RESULT,
-                    gl.createFunction(local_onResult), 0);
+                    new NativeFunction(gl, local_onResult), 0);
 
             cb->init_member("_conn", &_nc.owner(), 0);
 
@@ -1227,8 +1206,7 @@ netconnection_close(const fn_call& fn)
     return as_value();
 }
 
-
-/// Read-only
+// Read-only
 as_value
 netconnection_isConnected(const fn_call& fn)
 {
@@ -1336,6 +1314,41 @@ netconnection_addHeader(const fn_call& fn)
     return as_value();
 }
 
+/// This creates a local callback function to handle the return from connect()
+//
+/// NetStream does this using a builtin function, but this is more complicated
+/// because it needs the native NetConnection type.
+//
+/// This stores the NetConnection object so that it can be updated when
+/// connect returns.
+//
+/// We don't know if this is the best way to do it, but:
+//
+/// 1. the connect call *does* return a callback ID.
+/// 2. if it is done like this, it has to be a native function.
+as_value
+local_onResult(const fn_call& fn)
+{
+    as_object* obj = fn.this_ptr;
+
+    if (obj) {
+        string_table& st = getStringTable(fn);
+        const ObjectURI conn(st.find("_conn"));
+        as_value f = getMember(*obj, conn);
+        as_object* nc = toObject(f, getVM(fn));
+        if (nc) {
+            NetConnection_as* co;
+            if (isNativeType(nc, co)) {
+                co->setConnected();
+            }
+        }
+        const as_value arg = fn.nargs ? fn.arg(0) : as_value();
+        callMethod(nc, NSV::PROP_ON_STATUS, arg);
+    }
+    return as_value();
+}
+
+
 std::pair<std::string, std::string>
 getStatusCodeInfo(NetConnection_as::StatusCode code)
 {

http://git.savannah.gnu.org/cgit//commit/?id=734c54fea4fc23957581da11b43f757d6fd4d38c


commit 734c54fea4fc23957581da11b43f757d6fd4d38c
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 13:42:38 2010 +0200

    Clean up HTTP remoting class.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index e50f7a2..9bca3bd 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -240,15 +240,6 @@ private:
         _postdata.append(amf.data(), amf.size());
         ++queued_count;
     }
-
-    void enqueue(const SimpleBuffer &amf, size_t id, as_object* callback) {
-        push_amf(amf);
-        pushCallback(id, callback);
-    }
-
-    void enqueue(const SimpleBuffer &amf) {
-        push_amf(amf);
-    }
     
 };
 
@@ -419,15 +410,17 @@ HTTPRemotingHandler::advance()
                     // actually parse and doing something if it
                     // doesn't match this value (does it matter?
                     if(si > 0) {
-                        // parse replies until we get a parse error or we 
reach the end of the buffer
+                        // parse replies until we get a parse error or
+                        // we reach the end of the buffer
                         while(b < end) {
                             if(b + 2 > end) break;
                             si = readNetworkShort(b); b += 2; // reply length
                             if(si < 4) { // shorted valid response is '/1/a'
-                                log_error("NetConnection::call(): reply 
message name too short");
+                                log_error("NetConnection::call(): "
+                                        "reply message name too short");
                                 break;
                             }
-                            if(b + si > end) break;
+                            if (b + si > end) break;
 
                             // Reply message is: '/id/methodName'
 
@@ -473,9 +466,6 @@ HTTPRemotingHandler::advance()
                             if (b + 4 > end) break;
                             li = readNetworkLong(b); b += 4; // reply length
 
-#ifdef GNASH_DEBUG_REMOTING
-                            log_debug("about to parse amf value");
-#endif
                             // this updates b to point to the next unparsed 
byte
                             as_value replyval;
                             if (!rd(replyval)) {
@@ -487,9 +477,6 @@ HTTPRemotingHandler::advance()
                                 // don't know how to parse
                                 break;
                             }
-#ifdef GNASH_DEBUG_REMOTING
-                            log_debug("parsed amf");
-#endif
 
                             // update variable to show how much we've parsed
                             reply_start = b - reply.data();
@@ -603,7 +590,6 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
         os << callID; 
     }
     const std::string callNumberString = os.str();
-
     buf.appendNetworkShort(callNumberString.size());
     buf.append(callNumberString.c_str(), callNumberString.size());
 
@@ -628,12 +614,10 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
     *(reinterpret_cast<uint32_t*>(buf.data() + total_size_offset)) = 
         htonl(buf.size() - 4 - total_size_offset);
 
+    push_amf(buf);
+
     if (asCallback) {
-        enqueue(buf, callID, asCallback);
-    }
-    
-    else {
-        enqueue(buf);
+        pushCallback(callID, asCallback);
     }
 }
 
@@ -848,7 +832,7 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t* 
payload,
         return;
     }
     
-    /// These are remote function calls initiated by the server .
+    /// These are remote function calls initiated by the server.
     const double id = amf::readNumber(payload, end);
     log_debug("Received server call %s %s",
             boost::io::group(std::setprecision(15), id),

http://git.savannah.gnu.org/cgit//commit/?id=acd20fcc20ee7eed564480a139235fb8e71c1a04


commit acd20fcc20ee7eed564480a139235fb8e71c1a04
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 13:35:44 2010 +0200

    Send BW request and pass arguments as expected.

diff --git a/libbase/RTMP.cpp b/libbase/RTMP.cpp
index 2da76f2..c29e031 100644
--- a/libbase/RTMP.cpp
+++ b/libbase/RTMP.cpp
@@ -45,9 +45,6 @@ namespace {
 
     bool sendBytesReceived(RTMP* r);
 
-    // Not sure we ever want to do this.
-    bool sendServerBW(RTMP& r);
-
     void handleMetadata(RTMP& r, const boost::uint8_t *payload,
             unsigned int len);
     void handleChangeChunkSize(RTMP& r, const RTMPPacket& packet);
@@ -369,7 +366,7 @@ RTMP::readSocket(boost::uint8_t* buffer, int n)
 
     const std::streamsize bytesRead = _socket.read(buffer, n);
     
-    if (_socket.bad()) {
+    if (_socket.bad() || _socket.eof() || !_socket.connected()) {
         _error = true;
         return 0;
     }
@@ -403,6 +400,24 @@ RTMP::play(const SimpleBuffer& buf, int streamID)
     sendPacket(packet);
 }
 
+/// Send the server bandwidth.
+//
+/// Why would we want to send this?
+bool
+sendServerBW(RTMP& r)
+{
+    RTMPPacket packet(4);
+  
+    packet.header.channel = CHANNEL_CONTROL1;
+    packet.header.packetType = PACKET_TYPE_SERVERBW;
+  
+    SimpleBuffer& buf = *packet.buffer;
+  
+    buf.appendNetworkLong(r.serverBandwidth());
+    return r.sendPacket(packet);
+}
+
+
 /// Fills a pre-existent RTMPPacket with information.
 //
 /// This is either read entirely from incoming data, or copied from a
@@ -1058,23 +1073,6 @@ sendCtrl(RTMP& r, ControlType t, unsigned int nObject, 
unsigned int nTime)
 
 namespace {
 
-/// Send the server bandwidth.
-//
-/// Why would we want to send this?
-bool
-sendServerBW(RTMP& r)
-{
-    RTMPPacket packet(4);
-  
-    packet.header.channel = CHANNEL_CONTROL1;
-    packet.header.packetType = PACKET_TYPE_SERVERBW;
-  
-    SimpleBuffer& buf = *packet.buffer;
-  
-    buf.appendNetworkLong(r.serverBandwidth());
-    return r.sendPacket(packet);
-}
-
 
 bool
 sendBytesReceived(RTMP* r)
diff --git a/libbase/RTMP.h b/libbase/RTMP.h
index 473507e..9af5eb4 100644
--- a/libbase/RTMP.h
+++ b/libbase/RTMP.h
@@ -542,6 +542,9 @@ private:
 
 };
 
+/// Send a bandwidth ping to the server.
+bool sendServerBW(RTMP& r);
+
 /// Send a control packet
 bool sendCtrl(RTMP& r, ControlType, unsigned int nObject, unsigned int nTime);
 
diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 5267af8..e50f7a2 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -651,17 +651,22 @@ replyBWCheck(rtmp::RTMP& r, double txn)
 as_value
 local_onResult(const fn_call& fn)
 {
+    log_debug("local onResult called");
     as_object* obj = fn.this_ptr;
     string_table& st = getStringTable(fn);
-    const ObjectURI _conn(st.find("_conn"));
+    const ObjectURI conn(st.find("_conn"));
 
     if (obj) {
-        as_value f = getMember(*obj, _conn);
+        as_value f = getMember(*obj, conn);
         as_object* nc = toObject(f, getVM(fn));
         if (nc) {
-            nc->set_member(st.find("isConnected"), true);
+            NetConnection_as* co;
+            if (isNativeType(nc, co)) {
+                co->setConnected();
+            }
         }
-        callMethod(nc, NSV::PROP_ON_STATUS, "oh");
+        const as_value arg = fn.nargs ? fn.arg(0) : as_value();
+        callMethod(nc, NSV::PROP_ON_STATUS, arg);
     }
     return as_value();
 }
@@ -701,20 +706,19 @@ public:
     }
 
     bool hasPendingCalls() const {
-        return true;
+        return false;
     }
 
     virtual bool advance() {
 
         _rtmp.update();
 
-        if (_rtmp.error()) {
-            if (!_connectionComplete) {
-                _nc.notifyStatus(NetConnection_as::CONNECT_FAILED);
-            }
-            else {
-                _nc.notifyStatus(NetConnection_as::CONNECT_CLOSED);
-            }
+        if (_rtmp.error() && !_connectionComplete) {
+            _nc.notifyStatus(NetConnection_as::CONNECT_FAILED);
+            return false;
+        }
+        if (_connectionComplete && _rtmp.error()) {
+            _nc.notifyStatus(NetConnection_as::CONNECT_CLOSED);
             return false;
         }
 
@@ -759,7 +763,10 @@ public:
             aw.writeObject(o);
 
             as_object* cb = createObject(getGlobal(_nc.owner()));
-            cb->init_member("onResult", gl.createFunction(local_onResult), 0);
+            log_debug("Object cb: %s", cb);
+            cb->init_member(NSV::PROP_ON_RESULT,
+                    gl.createFunction(local_onResult), 0);
+
             cb->init_member("_conn", &_nc.owner(), 0);
 
             // When this call returns, the onResult function of the callback
@@ -767,6 +774,9 @@ public:
             pushCallback(id, cb);
             _rtmp.call(buf);
 
+            // Send bandwidth check; this seems to be required.
+            sendServerBW(_rtmp);
+
         }
         
         boost::shared_ptr<SimpleBuffer> b = _rtmp.getMessage();
@@ -796,8 +806,6 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t* 
payload,
         const boost::uint8_t* end)
 {
 
-    GNASH_REPORT_FUNCTION;
-
     assert(payload != end);
 
     // make sure it is a string method name we start with
@@ -824,8 +832,19 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t* 
payload,
         const double id = amf::readNumber(payload, end);
         log_debug("Received result for method call %s",
                 boost::io::group(std::setprecision(15), id));
+
+        as_value arg;
+
+        amf::Reader rd(payload, end, getGlobal(_nc.owner()));
+
+        // TODO: use all args and check the order! We currently only use
+        // the last one!
+        while (rd(arg)) {
+            log_debug("Value: %s", arg);
+        }
+
         as_object* o = popCallback(id);
-        callMethod(o, NSV::PROP_ON_RESULT);
+        callMethod(o, NSV::PROP_ON_RESULT, arg);
         return;
     }
     
diff --git a/libcore/asobj/NetConnection_as.h b/libcore/asobj/NetConnection_as.h
index 3939d04..704c2b7 100644
--- a/libcore/asobj/NetConnection_as.h
+++ b/libcore/asobj/NetConnection_as.h
@@ -78,6 +78,10 @@ public:
     /// Carry out the connect(null) method.
     void connect();
 
+    void setConnected() {
+        _isConnected = true;
+    }
+
     bool isConnected() const {
         return _isConnected;
     }

http://git.savannah.gnu.org/cgit//commit/?id=0ab0cdb064e7254c956f1e8348cc57730d68ac00


commit 0ab0cdb064e7254c956f1e8348cc57730d68ac00
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 12:11:10 2010 +0200

    Not much progress yet.

diff --git a/libcore/AMFConverter.cpp b/libcore/AMFConverter.cpp
index 166da8a..a152e99 100644
--- a/libcore/AMFConverter.cpp
+++ b/libcore/AMFConverter.cpp
@@ -39,7 +39,7 @@
 //#define GNASH_DEBUG_AMF_DESERIALIZE 1
 
 // Define this macto to make AMF writing verbose
- #define GNASH_DEBUG_AMF_SERIALIZE 1
+// #define GNASH_DEBUG_AMF_SERIALIZE 1
 
 namespace gnash {
 namespace amf {
diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 9ddda95..5267af8 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -648,6 +648,24 @@ replyBWCheck(rtmp::RTMP& r, double txn)
     r.call(buf);
 }
 
+as_value
+local_onResult(const fn_call& fn)
+{
+    as_object* obj = fn.this_ptr;
+    string_table& st = getStringTable(fn);
+    const ObjectURI _conn(st.find("_conn"));
+
+    if (obj) {
+        as_value f = getMember(*obj, _conn);
+        as_object* nc = toObject(f, getVM(fn));
+        if (nc) {
+            nc->set_member(st.find("isConnected"), true);
+        }
+        callMethod(nc, NSV::PROP_ON_STATUS, "oh");
+    }
+    return as_value();
+}
+
 class RTMPRemotingHandler : public ConnectionHandler
 {
 public:
@@ -659,9 +677,8 @@ public:
         _url(url)
     {
         // Throw exception if this fails.
-        GNASH_REPORT_FUNCTION;
         const bool ret = _rtmp.connect(url);
-        log_debug("ConnectioN: %s", ret);
+        if (!ret) throw GnashException("Connection failed");
     }
 
     virtual void call(as_object* asCallback, const std::string& methodName,
@@ -692,7 +709,12 @@ public:
         _rtmp.update();
 
         if (_rtmp.error()) {
-            _nc.notifyStatus(NetConnection_as::CONNECT_CLOSED);
+            if (!_connectionComplete) {
+                _nc.notifyStatus(NetConnection_as::CONNECT_FAILED);
+            }
+            else {
+                _nc.notifyStatus(NetConnection_as::CONNECT_CLOSED);
+            }
             return false;
         }
 
@@ -703,33 +725,48 @@ public:
             
             _connectionComplete = true;
 
-            log_debug("Connection complete");
+            log_debug("Initial connection complete");
+
             const RunResources& r = getRunResources(_nc.owner());
+            Global_as& gl = getGlobal(_nc.owner());
+            
+            as_object* o = createObject(gl);
 
-            as_object* o = createObject(getGlobal(_nc.owner()));
             const int flags = 0;
             o->init_member("app", _url.path().substr(1), flags);
+
+            // TODO: use $version.
             o->init_member("flashVer", "LNX 10,0,22,87", flags);
             o->init_member("swfUrl", r.streamProvider().originalURL().str(),
                     flags);
             o->init_member("tcUrl", _url.str(), flags);
+
+            // TODO: implement this properly
             o->init_member("fpad", false, flags);
             o->init_member("capabilities", 15.0, flags);
             o->init_member("audioCodecs", 3191.0, flags);
             o->init_member("videoCodecs", 252.0, flags);
+            o->init_member("videoFunction", 1.0, flags);
+            o->init_member("pageUrl", as_value(), flags);
 
             const size_t id = callNo();
+            log_debug("Call %s", id);
             SimpleBuffer buf;
 
-            amf::write(buf, "connect");
-            amf::write(buf, static_cast<double>(id));
-
-            log_debug("Buf size: %s", buf.size());
             amf::Writer aw(buf);
+            aw.writeString("connect");
+            aw.writeNumber(id);
             aw.writeObject(o);
-            log_debug("Buf size: %s", buf.size());
+
+            as_object* cb = createObject(getGlobal(_nc.owner()));
+            cb->init_member("onResult", gl.createFunction(local_onResult), 0);
+            cb->init_member("_conn", &_nc.owner(), 0);
+
+            // When this call returns, the onResult function of the callback
+            // handles onStatus etc.
+            pushCallback(id, cb);
             _rtmp.call(buf);
-            pushCallback(id, &_nc.owner());
+
         }
         
         boost::shared_ptr<SimpleBuffer> b = _rtmp.getMessage();
@@ -758,6 +795,9 @@ void
 RTMPRemotingHandler::handleInvoke(const boost::uint8_t* payload,
         const boost::uint8_t* end)
 {
+
+    GNASH_REPORT_FUNCTION;
+
     assert(payload != end);
 
     // make sure it is a string method name we start with
@@ -820,6 +860,7 @@ RTMPRemotingHandler::handleInvoke(const boost::uint8_t* 
payload,
     }
 
     if (method ==  "_error") {
+        _nc.notifyStatus(NetConnection_as::CALL_FAILED);
         log_error( "rtmp server sent error");
         return;
     }
@@ -952,7 +993,14 @@ NetConnection_as::connect(const std::string& uri)
         _currentConnection.reset(new HTTPRemotingHandler(*this, url));
     }
     else if (url.protocol() == "rtmp") {
-        _currentConnection.reset(new RTMPRemotingHandler(*this, url));
+        try {
+            _currentConnection.reset(new RTMPRemotingHandler(*this, url));
+        }
+        catch (const GnashException&) {
+            // This happens if the connect cannot even be attempted.
+            notifyStatus(CONNECT_FAILED);
+            return;
+        }
         startAdvanceTimer();
     }
     else if (url.protocol() == "rtmpt" || url.protocol() == "rtmpts") {
@@ -1084,7 +1132,7 @@ NetConnection_as::update()
     // Advancement of a connection might trigger creation
     // of a new connection, so we won't stop the advance
     // timer in that case
-    if (_queuedConnections.empty() && ! _currentConnection.get()) {
+    if (_queuedConnections.empty() && !_currentConnection.get()) {
 #ifdef GNASH_DEBUG_REMOTING
         log_debug("stopping advance timer");
 #endif

http://git.savannah.gnu.org/cgit//commit/?id=f1fcdde71ae761ec4a9a90dc35a4a5fd71c0524f


commit f1fcdde71ae761ec4a9a90dc35a4a5fd71c0524f
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 11:14:42 2010 +0200

    Send correct connect packet.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 99972eb..9ddda95 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -91,23 +91,12 @@ public:
     
     typedef std::map<size_t, as_object*> CallbacksMap;
 
-    /// @param methodName
-    ///     A string identifying the remote procedure to call
-    ///
-    /// @param responseHandler
-    ///     Object to invoke response methods on.
-    ///
-    /// @param args
-    ///     A vector of arguments
-    ///
-    /// @param firstArg
-    ///     Index of first argument in the args vector
-    ///
-    ///
+    /// @param methodName      A string identifying the remote procedure to 
call
+    /// @param responseHandler  Object to invoke response methods on.
+    /// @param args             A vector of arguments
     /// @return true if the call is queued, false otherwise
-    ///
     virtual void call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg) = 0;
+            const std::vector<as_value>& args) = 0;
 
     /// Get an stream by name
     //
@@ -228,7 +217,7 @@ public:
 
     // See dox in NetworkHandler class
     virtual void call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg);
+            const std::vector<as_value>& args);
 
 private:
 
@@ -568,7 +557,7 @@ HTTPRemotingHandler::advance()
                 _postdata.size());
 #ifdef GNASH_DEBUG_REMOTING
         log_debug("NetConnection.call(): encoded args from %1% calls: %2%",
-                queued_count, hexify(postdata.data(), postdata.size(), false));
+                queued_count, hexify(_postdata.data(), _postdata.size(), 
false));
 #endif
         queued_count = 0;
 
@@ -595,7 +584,7 @@ HTTPRemotingHandler::advance()
 
 void
 HTTPRemotingHandler::call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg)
+            const std::vector<as_value>& args)
 {
     SimpleBuffer buf(32);
 
@@ -623,16 +612,15 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
 
     // encode array of arguments to remote method
     buf.appendByte(amf::STRICT_ARRAY_AMF0);
-    buf.appendNetworkLong(args.size() - firstArg);
+    buf.appendNetworkLong(args.size());
 
     // STRICT_ARRAY encoding is allowed for remoting
     amf::Writer w(buf, true);
 
-    for (size_t i = firstArg; i < args.size(); ++i) {
+    for (size_t i = 0; i < args.size(); ++i) {
         const as_value& arg = args[i];
         if (!arg.writeAMF0(w)) {
-            log_error("Could not serialize NetConnection.call argument %d",
-                    i);
+            log_error("Could not serialize NetConnection.call argument %d", i);
         }
     }
 
@@ -649,21 +637,36 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
     }
 }
 
+void
+replyBWCheck(rtmp::RTMP& r, double txn)
+{
+    SimpleBuffer buf;
+    amf::write(buf, "_result");
+    amf::write(buf, txn);
+    buf.appendByte(amf::NULL_AMF0);
+    amf::write(buf, 0.0);
+    r.call(buf);
+}
+
 class RTMPRemotingHandler : public ConnectionHandler
 {
 public:
 
     RTMPRemotingHandler(NetConnection_as& nc, const URL& url)
         :
-        ConnectionHandler(nc)
+        ConnectionHandler(nc),
+        _connectionComplete(false),
+        _url(url)
     {
-        _rtmp.connect(url);
+        // Throw exception if this fails.
+        GNASH_REPORT_FUNCTION;
+        const bool ret = _rtmp.connect(url);
+        log_debug("ConnectioN: %s", ret);
     }
 
     virtual void call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg)
+            const std::vector<as_value>& args)
     {
-        // Infofield1?
         SimpleBuffer buf;
         amf::Writer aw(buf);
         aw.writeString(methodName);
@@ -671,7 +674,7 @@ public:
         aw.writeNumber(id);
         buf.appendByte(amf::NULL_AMF0);
 
-        for (size_t i = firstArg; i < args.size(); ++i) {
+        for (size_t i = 0; i < args.size(); ++i) {
             args[i].writeAMF0(aw);
         }
         _rtmp.call(buf);
@@ -681,30 +684,152 @@ public:
     }
 
     bool hasPendingCalls() const {
-        // Nothing is going to come back...
-        if (!_rtmp.connected()) return false;
-        // TODO: implement this.
-        return false;
+        return true;
     }
 
-    bool advance() {
+    virtual bool advance() {
+
         _rtmp.update();
 
-        // Nothing to do yet, but we don't want to be dropped.
-        if (!_rtmp.connected()) return true;
+        if (_rtmp.error()) {
+            _nc.notifyStatus(NetConnection_as::CONNECT_CLOSED);
+            return false;
+        }
 
-        boost::shared_ptr<SimpleBuffer> m = _rtmp.getMessage();
-        if (!m) return true;
+        // Nothing to do yet, but we don't want to be dropped.
+        if (!_connectionComplete) {
+
+            if (!_rtmp.connected()) return true;
+            
+            _connectionComplete = true;
+
+            log_debug("Connection complete");
+            const RunResources& r = getRunResources(_nc.owner());
+
+            as_object* o = createObject(getGlobal(_nc.owner()));
+            const int flags = 0;
+            o->init_member("app", _url.path().substr(1), flags);
+            o->init_member("flashVer", "LNX 10,0,22,87", flags);
+            o->init_member("swfUrl", r.streamProvider().originalURL().str(),
+                    flags);
+            o->init_member("tcUrl", _url.str(), flags);
+            o->init_member("fpad", false, flags);
+            o->init_member("capabilities", 15.0, flags);
+            o->init_member("audioCodecs", 3191.0, flags);
+            o->init_member("videoCodecs", 252.0, flags);
+
+            const size_t id = callNo();
+            SimpleBuffer buf;
+
+            amf::write(buf, "connect");
+            amf::write(buf, static_cast<double>(id));
+
+            log_debug("Buf size: %s", buf.size());
+            amf::Writer aw(buf);
+            aw.writeObject(o);
+            log_debug("Buf size: %s", buf.size());
+            _rtmp.call(buf);
+            pushCallback(id, &_nc.owner());
+        }
+        
+        boost::shared_ptr<SimpleBuffer> b = _rtmp.getMessage();
+
+        /// Retrieve messages.
+        while (b.get()) {
+            handleInvoke(b->data() + rtmp::RTMPHeader::headerSize,
+                    b->data() + b->size());
+            b = _rtmp.getMessage();
+        }
 
         return true;
     }
 
 private:
 
+    void handleInvoke(const boost::uint8_t* payload, const boost::uint8_t* 
end);
+
     rtmp::RTMP _rtmp;
+    bool _connectionComplete;
+    const URL _url;
 
 };
 
+void
+RTMPRemotingHandler::handleInvoke(const boost::uint8_t* payload,
+        const boost::uint8_t* end)
+{
+    assert(payload != end);
+
+    // make sure it is a string method name we start with
+    if (payload[0] != 0x02) {
+        log_error( "Sanity failed. no string method in invoke packet");
+        return;
+    }
+
+    ++payload;
+    std::string method = amf::readString(payload, end);
+
+    log_debug("Invoke: read method string %s", method);
+    if (*payload != amf::NUMBER_AMF0) return;
+    ++payload;
+
+    log_debug( "Server invoking <%s>", method);
+    
+    string_table& st = getStringTable(_nc.owner());
+    const ObjectURI methodname(st.find(method));
+
+    // _result means it's the answer to a remote method call initiated
+    // by us.
+    if (method == "_result") {
+        const double id = amf::readNumber(payload, end);
+        log_debug("Received result for method call %s",
+                boost::io::group(std::setprecision(15), id));
+        as_object* o = popCallback(id);
+        callMethod(o, NSV::PROP_ON_RESULT);
+        return;
+    }
+    
+    /// These are remote function calls initiated by the server .
+    const double id = amf::readNumber(payload, end);
+    log_debug("Received server call %s %s",
+            boost::io::group(std::setprecision(15), id),
+            id ? "" : "(no reply expected)");
+
+    /// If the server sends this, we reply (the call should contain a
+    /// callback object!).
+    if (method == "_onbwcheck") {
+        if (id) replyBWCheck(_rtmp, id);
+        else {
+            log_error("Server called _onbwcheck without a callback");
+        }
+        return;
+    }
+
+    if (method == "_onbwdone") {
+
+        if (*payload != amf::NULL_AMF0) return;
+        ++payload;
+#if GNASH_DEBUG_REMOTING
+        log_debug("AMF buffer for _onbwdone: %s\n",
+                hexify(payload, end - payload, false));
+#endif
+        double latency = amf::readNumber(payload, end);
+        double bandwidth = amf::readNumber(payload, end);
+        log_debug("Latency: %s, bandwidth %s", latency, bandwidth);
+        return;
+    }
+
+    if (method ==  "_error") {
+        log_error( "rtmp server sent error");
+        return;
+    }
+    
+    // Call method on the NetConnection object.    
+    callMethod(&_nc.owner(), methodname);
+    
+}
+
+
 //----- NetConnection_as ----------------------------------------------------
 
 NetConnection_as::NetConnection_as(as_object* owner)
@@ -827,8 +952,8 @@ NetConnection_as::connect(const std::string& uri)
         _currentConnection.reset(new HTTPRemotingHandler(*this, url));
     }
     else if (url.protocol() == "rtmp") {
-        // TODO: fix this to work properly.
         _currentConnection.reset(new RTMPRemotingHandler(*this, url));
+        startAdvanceTimer();
     }
     else if (url.protocol() == "rtmpt" || url.protocol() == "rtmpts") {
         log_unimpl("NetConnection.connect(%s): unsupported connection "
@@ -886,14 +1011,14 @@ NetConnection_as::setURI(const std::string& uri)
 
 void
 NetConnection_as::call(as_object* asCallback, const std::string& methodName,
-        const std::vector<as_value>& args, size_t firstArg)
+        const std::vector<as_value>& args)
 {
     if (!_currentConnection.get()) {
         log_aserror("NetConnection.call: can't call while not connected");
         return;
     }
 
-    _currentConnection->call(asCallback, methodName, args, firstArg);
+    _currentConnection->call(asCallback, methodName, args);
 
     startAdvanceTimer();
 }
@@ -935,10 +1060,9 @@ NetConnection_as::stopAdvanceTimer()
 void
 NetConnection_as::update()
 {
-    // Advance
 #ifdef GNASH_DEBUG_REMOTING
     log_debug("NetConnection_as::advance: %d calls to advance",
-            _queuedConnections.size());
+            _queuedConnections.size() + _currentConnection.get() ? 1 : 0);
 #endif
 
     while (!_queuedConnections.empty()) {
@@ -1034,8 +1158,12 @@ netconnection_call(const fn_call& fn)
         }
     }
 
-    const std::vector<as_value>& args = fn.getArgs();
-    ptr->call(asCallback.get(), methodName, args, 2);
+    std::vector<as_value> args;
+    if (fn.nargs > 2) {
+        args = std::vector<as_value>(fn.getArgs().begin() + 2,
+                fn.getArgs().end());
+    }
+    ptr->call(asCallback.get(), methodName, args);
 
     return as_value();
 }
diff --git a/libcore/asobj/NetConnection_as.h b/libcore/asobj/NetConnection_as.h
index 549e3fe..3939d04 100644
--- a/libcore/asobj/NetConnection_as.h
+++ b/libcore/asobj/NetConnection_as.h
@@ -67,7 +67,7 @@ public:
        std::string validateURL() const;
 
     void call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg);
+            const std::vector<as_value>& args);
 
     /// Process the close() method.
     void close();

http://git.savannah.gnu.org/cgit//commit/?id=8f96b7ac52583741b4cd538d83ef882aaa79cfa2


commit 8f96b7ac52583741b4cd538d83ef882aaa79cfa2
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 11:13:57 2010 +0200

    Drop silly comment.

diff --git a/libcore/as_object.cpp b/libcore/as_object.cpp
index 9b089b3..11904f3 100644
--- a/libcore/as_object.cpp
+++ b/libcore/as_object.cpp
@@ -245,7 +245,8 @@ public:
     PropsCopier(as_object& tgt)
         :
         _tgt(tgt)
-       { /* do nothing */ }
+       {
+    }
 
     /// Set *inherited* properties of the given target object
     bool accept(const ObjectURI& uri, const as_value& val) {

http://git.savannah.gnu.org/cgit//commit/?id=c8400f6ea799e23eae5529d5e6af7667b4d65806


commit c8400f6ea799e23eae5529d5e6af7667b4d65806
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 11:13:19 2010 +0200

    Clean up includes.

diff --git a/libcore/AMFConverter.cpp b/libcore/AMFConverter.cpp
index 9aaa727..166da8a 100644
--- a/libcore/AMFConverter.cpp
+++ b/libcore/AMFConverter.cpp
@@ -16,12 +16,12 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
+#include "AMFConverter.h"
 
 #include <map>
 
 #include "SimpleBuffer.h"
 #include "AMF.h"
-#include "AMFConverter.h"
 #include "namedStrings.h"
 #include "as_value.h"
 #include "as_object.h"
@@ -33,15 +33,15 @@
 #include "Global_as.h"
 #include "fn_call.h"
 #include "as_function.h"
+#include "PropertyList.h"
 
 // Define this macro to make AMF parsing verbose
 //#define GNASH_DEBUG_AMF_DESERIALIZE 1
 
 // Define this macto to make AMF writing verbose
-// #define GNASH_DEBUG_AMF_SERIALIZE 1
+ #define GNASH_DEBUG_AMF_SERIALIZE 1
 
 namespace gnash {
-
 namespace amf {
 
 namespace {
@@ -60,7 +60,8 @@ public:
     
     bool success() const { return !_error; }
 
-    bool accept(const ObjectURI& uri, const as_value& val) {
+    virtual bool accept(const ObjectURI& uri, const as_value& val) {
+
         if (_error) return true;
 
         // Tested with SharedObject and AMFPHP
@@ -224,9 +225,8 @@ Writer::writeObject(as_object* obj)
         // A normal array.
 #ifdef GNASH_DEBUG_AMF_SERIALIZE
         log_debug(_("amf: serializing array of %d "
-                    "elements as ECMA_ARRAY (index %d) "
-                    "[allowStrict:%d, isStrict:%d]"),
-                    len, idx, allowStrict, isStrict);
+                    "elements as ECMA_ARRAY (index %d) "),
+                    len, idx);
 #endif
         _buf.appendByte(ECMA_ARRAY_AMF0);
         _buf.appendNetworkLong(len);

http://git.savannah.gnu.org/cgit//commit/?id=ae38f1240c04c7aee327202bf1d39173da341553


commit ae38f1240c04c7aee327202bf1d39173da341553
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 11:12:53 2010 +0200

    Drop obsolete comment.

diff --git a/libcore/PropertyList.h b/libcore/PropertyList.h
index 4ff12fb..d4afe52 100644
--- a/libcore/PropertyList.h
+++ b/libcore/PropertyList.h
@@ -150,14 +150,11 @@ public:
     ///                 Scan is by enumeration order and stops when accept()
     ///                 returns false.
     template <class U, class V>
-    void visitValues(V& visitor, U cmp = U()) const
-    {
-        // The template keyword is not required by the Standard here, but the
-        // OpenBSD compiler needs it. Use of the template keyword where it is
-        // not necessary is not an error.
+    void visitValues(V& visitor, U cmp = U()) const {
+
         for (const_iterator it = _props.begin(), ie = _props.end();
-                it != ie; ++it)
-        {
+                it != ie; ++it) {
+
             if (!cmp(*it)) continue;
             as_value val = it->getValue(_owner);
             if (!visitor.accept(it->uri(), val)) return;

http://git.savannah.gnu.org/cgit//commit/?id=c4bf3d3d77c8090413a82cb84a30e3e270749a07


commit c4bf3d3d77c8090413a82cb84a30e3e270749a07
Author: Benjamin Wolsey <address@hidden>
Date:   Tue Oct 26 11:12:19 2010 +0200

    Const correct.

diff --git a/libbase/RTMP.cpp b/libbase/RTMP.cpp
index b39d27b..2da76f2 100644
--- a/libbase/RTMP.cpp
+++ b/libbase/RTMP.cpp
@@ -216,7 +216,7 @@ RTMP::connect(const URL& url)
         try {
             port = boost::lexical_cast<boost::uint16_t>(p);
         }
-        catch (boost::bad_lexical_cast&) {}
+        catch (const boost::bad_lexical_cast&) {}
     }
 
     // Basic connection attempt.

http://git.savannah.gnu.org/cgit//commit/?id=8940803f71a5247b41bf7428373ce570eb558ff2


commit 8940803f71a5247b41bf7428373ce570eb558ff2
Author: Benjamin Wolsey <address@hidden>
Date:   Mon Oct 25 19:14:43 2010 +0200

    Basic implementation details.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index aa03225..99972eb 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -122,12 +122,9 @@ public:
     /// callbacks when needed. 
     ///
     /// Return true if wants to be advanced again, false otherwise.
-    ///
     virtual bool advance() = 0;
 
     /// ConnectionHandlers may store references to as_objects
-    //
-    /// These include callback objects.
     void setReachable() const {
         foreachSecond(_callbacks.begin(), _callbacks.end(),
                 std::mem_fun(&as_object::setReachable));
@@ -139,7 +136,6 @@ public:
     /// connection has pending calls to process it will be
     /// queued and only really dropped when advance returns
     /// false
-    ///
     virtual bool hasPendingCalls() const = 0;
 
     virtual ~ConnectionHandler() {}
@@ -288,15 +284,8 @@ bool
 HTTPRemotingHandler::advance()
 {
 
-#ifdef GNASH_DEBUG_REMOTING
-    log_debug("advancing HTTPRemotingHandler");
-#endif
     if (_connection) {
 
-#ifdef GNASH_DEBUG_REMOTING
-        log_debug("have connection");
-#endif
-
         // Fill last chunk before reading in the next
         size_t toRead = reply.capacity() - reply.size();
         if (!toRead) toRead = NCCALLREPLYCHUNK;
@@ -651,22 +640,11 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
     *(reinterpret_cast<uint32_t*>(buf.data() + total_size_offset)) = 
         htonl(buf.size() - 4 - total_size_offset);
 
-#ifdef GNASH_DEBUG_REMOTING
-    log_debug(_("NetConnection.call(): encoded args: %s"),
-            hexify(buf.data(), buf.size(), false));
-#endif
-
     if (asCallback) {
-#ifdef GNASH_DEBUG_REMOTING
-        log_debug("calling enqueue with callback");
-#endif
         enqueue(buf, callID, asCallback);
     }
     
     else {
-#ifdef GNASH_DEBUG_REMOTING
-        log_debug("calling enqueue without callback");
-#endif
         enqueue(buf);
     }
 }
@@ -689,12 +667,36 @@ public:
         SimpleBuffer buf;
         amf::Writer aw(buf);
         aw.writeString(methodName);
-        aw.writeNumber(callNo());
+        const size_t id = asCallback ? callNo() : 0;
+        aw.writeNumber(id);
         buf.appendByte(amf::NULL_AMF0);
+
         for (size_t i = firstArg; i < args.size(); ++i) {
             args[i].writeAMF0(aw);
         }
         _rtmp.call(buf);
+        if (asCallback) {
+            pushCallback(id, asCallback);
+        }
+    }
+
+    bool hasPendingCalls() const {
+        // Nothing is going to come back...
+        if (!_rtmp.connected()) return false;
+        // TODO: implement this.
+        return false;
+    }
+
+    bool advance() {
+        _rtmp.update();
+
+        // Nothing to do yet, but we don't want to be dropped.
+        if (!_rtmp.connected()) return true;
+
+        boost::shared_ptr<SimpleBuffer> m = _rtmp.getMessage();
+        if (!m) return true;
+
+        return true;
     }
 
 private:
@@ -826,7 +828,7 @@ NetConnection_as::connect(const std::string& uri)
     }
     else if (url.protocol() == "rtmp") {
         // TODO: fix this to work properly.
-        _currentConnection.reset(new HTTPRemotingHandler(*this, url));
+        _currentConnection.reset(new RTMPRemotingHandler(*this, url));
     }
     else if (url.protocol() == "rtmpt" || url.protocol() == "rtmpts") {
         log_unimpl("NetConnection.connect(%s): unsupported connection "
@@ -893,12 +895,7 @@ NetConnection_as::call(as_object* asCallback, const 
std::string& methodName,
 
     _currentConnection->call(asCallback, methodName, args, firstArg);
 
-#ifdef GNASH_DEBUG_REMOTING
-    log_debug("called enqueue");
-#endif
-
     startAdvanceTimer();
-
 }
 
 std::auto_ptr<IOChannel>
@@ -1173,12 +1170,12 @@ getStatusCodeInfo(NetConnection_as::StatusCode code)
             return std::make_pair("NetConnection.Connect.AppShutdown", 
"error");
         case NetConnection_as::CONNECT_REJECTED:
             return std::make_pair("NetConnection.Connect.Rejected", "error");
+        case NetConnection_as::CONNECT_CLOSED:
+            return std::make_pair("NetConnection.Connect.Closed", "status");
         case NetConnection_as::CALL_FAILED:
             return std::make_pair("NetConnection.Call.Failed", "error");
         case NetConnection_as::CALL_BADVERSION:
             return std::make_pair("NetConnection.Call.BadVersion", "status");
-        case NetConnection_as::CONNECT_CLOSED:
-            return std::make_pair("NetConnection.Connect.Closed", "status");
         default:
             std::abort();
     }

http://git.savannah.gnu.org/cgit//commit/?id=dddbbd7b3816ce6934997923f4d9f85bcc4166b2


commit dddbbd7b3816ce6934997923f4d9f85bcc4166b2
Author: Benjamin Wolsey <address@hidden>
Date:   Mon Oct 25 18:25:27 2010 +0200

    Move more things to the base class.

diff --git a/libcore/asobj/NetConnection_as.cpp 
b/libcore/asobj/NetConnection_as.cpp
index 33f721d..aa03225 100644
--- a/libcore/asobj/NetConnection_as.cpp
+++ b/libcore/asobj/NetConnection_as.cpp
@@ -27,8 +27,9 @@
 
 #include <iostream>
 #include <string>
-#include <boost/scoped_ptr.hpp>
 #include <utility>
+#include <boost/scoped_ptr.hpp>
+#include <boost/lexical_cast.hpp>
 
 #include "GnashSystemNetHeaders.h"
 #include "log.h"
@@ -47,6 +48,7 @@
 #include "smart_ptr.h"
 #include "RunResources.h"
 #include "IOChannel.h"
+#include "RTMP.h"
 
 //#define GNASH_DEBUG_REMOTING
 
@@ -86,6 +88,8 @@ namespace {
 class ConnectionHandler
 {
 public:
+    
+    typedef std::map<size_t, as_object*> CallbacksMap;
 
     /// @param methodName
     ///     A string identifying the remote procedure to call
@@ -103,7 +107,7 @@ public:
     /// @return true if the call is queued, false otherwise
     ///
     virtual void call(as_object* asCallback, const std::string& methodName,
-            const std::vector<as_value>& args, size_t firstArg)=0;
+            const std::vector<as_value>& args, size_t firstArg) = 0;
 
     /// Get an stream by name
     //
@@ -124,7 +128,10 @@ public:
     /// ConnectionHandlers may store references to as_objects
     //
     /// These include callback objects.
-    virtual void setReachable() const = 0;
+    void setReachable() const {
+        foreachSecond(_callbacks.begin(), _callbacks.end(),
+                std::mem_fun(&as_object::setReachable));
+    }
 
     /// Return true if the connection has pending calls 
     //
@@ -155,6 +162,22 @@ protected:
         _numCalls(0)
     {}
 
+    void pushCallback(size_t id, as_object* callback) {
+        _callbacks[id] = callback;
+    }
+
+    as_object* popCallback(size_t id) {
+        CallbacksMap::iterator it = _callbacks.find(id);
+        if (it != _callbacks.end()) {
+            as_object* callback = it->second;
+            _callbacks.erase(it);
+            return callback;
+        }
+        return 0;
+    }
+
+    CallbacksMap _callbacks;
+
     // Object handling connection status messages
     NetConnection_as& _nc;
 
@@ -207,12 +230,6 @@ public:
     // See dox in ConnectionHandler
     virtual bool advance();
 
-    // See dox in ConnectionHandler
-    virtual void setReachable() const {
-        foreachSecond(callbacks.begin(), callbacks.end(),
-                std::mem_fun(&as_object::setReachable));
-    }
-
     // See dox in NetworkHandler class
     virtual void call(as_object* asCallback, const std::string& methodName,
             const std::vector<as_value>& args, size_t firstArg);
@@ -221,9 +238,6 @@ private:
 
     static const int NCCALLREPLYCHUNK=1024*200;
 
-    typedef std::map<std::string, as_object* > CallbacksMap;
-    CallbacksMap callbacks;
-
     SimpleBuffer _postdata;
     URL _url;
     boost::scoped_ptr<IOChannel> _connection;
@@ -238,31 +252,13 @@ private:
     NetworkAdapter::RequestHeaders _headers;
 
     void push_amf(const SimpleBuffer &amf) {
-        //GNASH_REPORT_FUNCTION;
-
         _postdata.append(amf.data(), amf.size());
-        queued_count++;
-    }
-
-    void push_callback(const std::string& id, as_object* callback) {
-        callbacks[id] = callback;
-    }
-
-    as_object* pop_callback(const std::string& id) {
-        CallbacksMap::iterator it = callbacks.find(id);
-        if (it != callbacks.end()) {
-            as_object* callback = it->second;
-            callbacks.erase(it);
-            return callback;
-        }
-        return 0;
+        ++queued_count;
     }
 
-    void enqueue(const SimpleBuffer &amf, const std::string& identifier,
-                 as_object* callback) {
-
+    void enqueue(const SimpleBuffer &amf, size_t id, as_object* callback) {
         push_amf(amf);
-        push_callback(identifier, callback);
+        pushCallback(id, callback);
     }
 
     void enqueue(const SimpleBuffer &amf) {
@@ -458,8 +454,8 @@ HTTPRemotingHandler::advance()
                             // Reply message is: '/id/methodName'
 
                             int ns = 1; // next slash position
-                            while (ns < si-1 && *(b + ns) != '/') ++ns;
-                            if (ns >= si-1) {
+                            while (ns < si - 1 && *(b + ns) != '/') ++ns;
+                            if (ns >= si - 1) {
                                 std::string msg(
                                         reinterpret_cast<const char*>(b), si);
                                 log_error("NetConnection::call(): invalid "
@@ -467,8 +463,16 @@ HTTPRemotingHandler::advance()
                                 break;
                             }
 
-                            std::string id(reinterpret_cast<const char*>(b),
-                                    ns);
+                            std::string id(reinterpret_cast<const char*>(b + 
1),
+                                    ns - 1);
+                            log_debug("ID: %s", id);
+                            size_t callbackID = 0;
+                            try {
+                                callbackID = boost::lexical_cast<size_t>(id);
+                            }
+                            catch (const boost::bad_lexical_cast&) {
+                                break;
+                            }
 
                             std::string methodName(
                                     reinterpret_cast<const char*>(b+ns+1),
@@ -514,7 +518,7 @@ HTTPRemotingHandler::advance()
 
                             // if actionscript specified a callback object,
                             // call it
-                            as_object* callback = pop_callback(id);
+                            as_object* callback = popCallback(callbackID);
                             if (callback) {
 
                                 string_table::key methodKey;
@@ -610,13 +614,15 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
     buf.appendNetworkShort(methodName.size());
     buf.append(methodName.c_str(), methodName.size());
 
+    const size_t callID = callNo();
+
     // client id (result number) as counted string
     // the convention seems to be / followed by a unique (ascending) number
     std::ostringstream os;
     os << "/";
     // Call number is not used if the callback is undefined
     if (asCallback) {
-        os << callNo(); 
+        os << callID; 
     }
     const std::string callNumberString = os.str();
 
@@ -654,7 +660,7 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
 #ifdef GNASH_DEBUG_REMOTING
         log_debug("calling enqueue with callback");
 #endif
-        enqueue(buf, callNumberString, asCallback);
+        enqueue(buf, callID, asCallback);
     }
     
     else {
@@ -665,6 +671,38 @@ HTTPRemotingHandler::call(as_object* asCallback, const 
std::string& methodName,
     }
 }
 
+class RTMPRemotingHandler : public ConnectionHandler
+{
+public:
+
+    RTMPRemotingHandler(NetConnection_as& nc, const URL& url)
+        :
+        ConnectionHandler(nc)
+    {
+        _rtmp.connect(url);
+    }
+
+    virtual void call(as_object* asCallback, const std::string& methodName,
+            const std::vector<as_value>& args, size_t firstArg)
+    {
+        // Infofield1?
+        SimpleBuffer buf;
+        amf::Writer aw(buf);
+        aw.writeString(methodName);
+        aw.writeNumber(callNo());
+        buf.appendByte(amf::NULL_AMF0);
+        for (size_t i = firstArg; i < args.size(); ++i) {
+            args[i].writeAMF0(aw);
+        }
+        _rtmp.call(buf);
+    }
+
+private:
+
+    rtmp::RTMP _rtmp;
+
+};
+
 //----- NetConnection_as ----------------------------------------------------
 
 NetConnection_as::NetConnection_as(as_object* owner)
@@ -776,35 +814,33 @@ NetConnection_as::connect(const std::string& uri)
     const RunResources& r = getRunResources(owner());
     URL url(_uri, r.streamProvider().originalURL());
 
-    if ((url.protocol() != "rtmp")
-        && (url.protocol() != "rtmpt")
-        && (url.protocol() != "rtmpts")
-        && (url.protocol() != "https")
-        && (url.protocol() != "http")) {
+    if (!r.streamProvider().allow(url)) {
+        log_security(_("Gnash is not allowed to connect " "to %s"), url);
+        notifyStatus(CONNECT_FAILED);
+        return;
+    }
 
-        IF_VERBOSE_ASCODING_ERRORS(
-            log_aserror("NetConnection.connect(%s): invalid connection "
+    // Attempt connection.
+    if (url.protocol() == "https" || url.protocol() == "http") {
+        _currentConnection.reset(new HTTPRemotingHandler(*this, url));
+    }
+    else if (url.protocol() == "rtmp") {
+        // TODO: fix this to work properly.
+        _currentConnection.reset(new HTTPRemotingHandler(*this, url));
+    }
+    else if (url.protocol() == "rtmpt" || url.protocol() == "rtmpts") {
+        log_unimpl("NetConnection.connect(%s): unsupported connection "
                  "protocol", url);
-        );
         notifyStatus(CONNECT_FAILED);
         return;
     }
-    
-    // This is for HTTP remoting
-
-    if (!r.streamProvider().allow(url)) {
-        log_security(_("Gnash is not allowed to NetConnection.connect "
-                    "to %s"), url);
+    else {
+        log_error("NetConnection.connect(%s): unknown connection "
+             "protocol", url);
         notifyStatus(CONNECT_FAILED);
         return;
     }
-
-    _currentConnection.reset(new HTTPRemotingHandler(*this, url));
-
-    // FIXME: We should attempt a connection here (this is called when an
-    // argument is passed to NetConnection.connect(url).
-    // Would probably return true on success and set isConnected.
-    //
+    
     // Under certain circumstances, an an immediate failure notification
     // happens. These are:
     // a) sandbox restriction

-----------------------------------------------------------------------

Summary of changes:
 libbase/RTMP.cpp                   |   42 ++--
 libbase/RTMP.h                     |    3 +
 libcore/AMFConverter.cpp           |   12 +-
 libcore/PropertyList.h             |   11 +-
 libcore/as_object.cpp              |    3 +-
 libcore/asobj/NetConnection_as.cpp |  542 ++++++++++++++++++++++++------------
 libcore/asobj/NetConnection_as.h   |    6 +-
 libcore/asobj/TextField_as.cpp     |    4 +-
 libcore/vm/VM.cpp                  |   12 +-
 9 files changed, 413 insertions(+), 222 deletions(-)


hooks/post-receive
-- 
Gnash



reply via email to

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