gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash ./ChangeLog ./configure.ac testsuite/acti...


From: Rob Savoye
Subject: [Gnash-commit] gnash ./ChangeLog ./configure.ac testsuite/acti...
Date: Sat, 04 Feb 2006 07:12:57 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Branch:         
Changes by:     Rob Savoye <address@hidden>     06/02/04 07:12:56

Modified files:
        .              : ChangeLog configure.ac 
        testsuite/actionscript.all: NetConnection.as 
        server         : NetConnection.cpp NetConnection.h 

Log message:
        * server/NetConnection.cpp: Implement part of the connect()
        method. Add C++ accessor methods as AS methods, and we can call
        our custom methods from testing code to examine the internal state
        of a class.
        * server/NetConnection.h: Add C++ accessor methods as AS methods,
        * testsuite/actionscript.all/NetConnection.as: Test the connect()
        method to make sure the URL gets parsed correctly, if specified.
        * configure.ac: Add --disble-testing option to not build
        additional code used for testing.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/ChangeLog.diff?tr1=1.79&tr2=1.80&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/configure.ac.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/testsuite/actionscript.all/NetConnection.as.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/NetConnection.cpp.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/gnash/gnash/server/NetConnection.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnash/ChangeLog
diff -u gnash/ChangeLog:1.79 gnash/ChangeLog:1.80
--- gnash/ChangeLog:1.79        Sat Feb  4 04:35:54 2006
+++ gnash/ChangeLog     Sat Feb  4 07:12:56 2006
@@ -1,3 +1,15 @@
+2006-02-04  Rob Savoye  <address@hidden>
+
+       * server/NetConnection.cpp: Implement part of the connect()
+       method. Add C++ accessor methods as AS methods, and we can call
+       our custom methods from testing code to examine the internal state
+       of a class.
+       * server/NetConnection.h: Add C++ accessor methods as AS methods,
+       * testsuite/actionscript.all/NetConnection.as: Test the connect()
+       method to make sure the URL gets parsed correctly, if specified.
+       * configure.ac: Add --disble-testing option to not build
+       additional code used for testing.
+
 2006-02-04 Michael Carlson <address@hidden>
 
        * server/Date.cpp: Clean up Date, and implement getDate()
Index: gnash/configure.ac
diff -u gnash/configure.ac:1.29 gnash/configure.ac:1.30
--- gnash/configure.ac:1.29     Fri Feb  3 20:50:27 2006
+++ gnash/configure.ac  Sat Feb  4 07:12:56 2006
@@ -53,7 +53,7 @@
     AC_DEFINE([FIX_I810_LOD_BIAS], [], [Fix i810 LOD bias problem])
 fi
 
-dnl Fix the Intel 810 LOD bias problem
+dnl Install the headers to make Gnash an SDK
 AC_ARG_ENABLE(sdkinstall, [  --enable-sdk-install  Enable installing the 
libraries and headers as an SDK],
 [case "${enableval}" in
   yes) sdkinstall=yes ;;
@@ -63,6 +63,19 @@
 
 AM_CONDITIONAL(SDKINSTALL, test x$sdkinstall = xyes)
 
+dnl Add methods to enable testing
+AC_ARG_ENABLE(testing, [  --enable-testing  Enable testing specific methods],
+[case "${enableval}" in
+  yes) testing=yes ;;
+  no)  testing=no ;;
+  *)   AC_MSG_ERROR([bad value ${enableval} for enable-testing option]) ;;
+esac], testing=yes)
+
+if test x"${testing}" != x"no"; then
+  AC_DEFINE([ENABLE_TESTING], [], [Unit testing support])
+fi
+AM_CONDITIONAL(TESTING, test x$testing = xyes)
+
 dnl Use the Dom parser from libxml2, not the xmlReader one
 dnl The default is to use the Dom parser
 dom=yes
@@ -138,6 +151,7 @@
 GNASH_PATH_PTHREADS
 GNASH_PATH_GHELP
 GNASH_DOCBOOK
+AM_CONDITIONAL(DOCBOOK, test x$docbook = xyes)
 AC_PROG_LIBTOOL
 
 dnl Define winsock if we're on windows. We could do something complicated,
@@ -164,7 +178,8 @@
 )
 dnl config.mk
 dnl plugin/test/Makefile
-dnl plugin/test/unix/Makefile
+dnl plugin/test/unix
+/Makefile
 
 echo ""
 echo "Configurable options are:"
@@ -188,7 +203,8 @@
 fi
 
 if test x"$http" = x"yes"; then
-  echo "        Web server support enabled"
+  echo "        Web 
+server support enabled"
 else
   echo "        Web server support disabled (default)"
 fi
@@ -198,7 +214,7 @@
   echo "        For a list of the command-line options enter: dmalloc --usage"
 
 else
-  echo "        DMalloc support disabled (default)"
+  echo "       AM_CONDITIONAL(DOCBOOK, test x$docbook = xyes)   DMalloc 
support disabled (default)"
 fi
 
 if test x$enable_xml = xno; then
@@ -219,6 +235,13 @@
   echo "        GNOME help disabled (default)"
 fi
 
+if test x"$testing" = x"yes"; then
+  echo "        Unit testing support enabled (default)"
+else
+  echo "        Unit testing support disabled"
+fi
+
+
 echo ""
 echo "Configured paths for ${build} are:"
 
Index: gnash/server/NetConnection.cpp
diff -u gnash/server/NetConnection.cpp:1.1 gnash/server/NetConnection.cpp:1.2
--- gnash/server/NetConnection.cpp:1.1  Wed Feb  1 23:52:44 2006
+++ gnash/server/NetConnection.cpp      Sat Feb  4 07:12:56 2006
@@ -20,35 +20,164 @@
 #include "config.h"
 #endif
 
+#include <string>
 #include "log.h"
 #include "NetConnection.h"
 
+using namespace std;
+
 namespace gnash {
 
+/// \class NetConnection
+/// \brief Opens a local connection through which you can play
+/// back video (FLV) files from an HTTP address or from the local file
+/// system.
+
+/// First introduced for swf v7
+
+/// protocol:[//host][:port]/appname/[instanceName]
+
+/// For protocol, specify either rtmp or rtmpt. If rtmp is specified,
+/// Flash Player will create a persistent Communication Server. If
+/// rtmpt is specified, Flash Player will create an HTTP "tunneling"
+/// connection to the server. For more information on RTMP and RTMPT,
+/// see the description section below.
+//
+/// You can omit the host parameter if the Flash movie is served from
+/// the same host where Flash Communication Server is installed.
+/// If the instanceName parameter is omitted, Flash Player connects to
+/// the application's default instance (_definst_).
+/// By default, RTMP connections use port 1935, and RTMPT connections
+/// use port 80.
 NetConnection::NetConnection() {
 }
 
 NetConnection::~NetConnection() {
 }
 
-
+/// \fn void NetConnection::connect(const char *arg)
+/// \brief Open a connection to stream FLV files.
+/// \param the URL
+/// \return nothing
+/// \note Older Flash movies can only take a NULL value as
+/// the parameter, which therefor only connects to the localhost using
+/// RTMP. Newer Flash movies have a parameter to connect which is a
+/// URL string like rtmp://foobar.com/videos/bar.flv
 void
-NetConnection::connect()
+NetConnection::connect(const char *arg)
 {
+    log_msg("%s: \n", __PRETTY_FUNCTION__);
+    
+    string::size_type first_colon;
+    string::size_type second_colon;
+    string::size_type single_slash;
+    string::size_type double_slash;
+
+    if (arg != 0) {
+        _url = arg;
+        // protocol:[//host][:port]/appname/[instanceName]
+        first_colon = _url.find(':', 0);
+        second_colon = _url.find(':', first_colon + 1);
+        double_slash = _url.find("//", 0) + 2;
+        single_slash = _url.find("/", double_slash);
+        _protocol = _url.substr(0, first_colon);
+        if (second_colon != string::npos) {
+            _host = _url.substr(double_slash, second_colon - double_slash);
+            _port = _url.substr(second_colon + 1, single_slash - second_colon 
- 1);
+        } else {
+            _host = _url.substr(double_slash, single_slash - double_slash);
+        }
+        _path = _url.substr(single_slash, _url.size());
+
+        if (_port.size() == 0) {
+            log_msg("Loading FLV file from: %s://%s%s\n",
+                    _protocol.c_str(), _host.c_str(), _path.c_str());
+        } else {
+            log_msg("Loading FLV file from: %s://%s:%s%s\n",
+                    _protocol.c_str(), _host.c_str(), _port.c_str(), 
_path.c_str());
+        }
+    } else {
+        log_msg("Connecting to localhost\n");
+    }
+    
     log_msg("%s:unimplemented \n", __FUNCTION__);
 }
+
+/// \fn void netconnection_new(const fn_call& fn)
+/// \brief callback to instantiate a new NetConnection object.
+/// \param fn the parameters from the Flash movie
+/// \return nothing from the function call.
+/// \note The return value is returned through the fn.result member.
 void
 netconnection_new(const fn_call& fn)
 {
+        log_msg("%s:unimplemented %d\n", __FUNCTION__, __LINE__);
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
+        
     netconnection_as_object *netconnection_obj = new netconnection_as_object;
 
     netconnection_obj->set_member("connect", &netconnection_connect);
-
+#ifdef ENABLE_TESTING
+    netconnection_obj->set_member("geturl",  &netconnection_geturl);
+    netconnection_obj->set_member("gethost", &netconnection_gethost);
+    netconnection_obj->set_member("getprotocol",  &netconnection_getprotocol);
+    netconnection_obj->set_member("getport", &netconnection_getport);
+    netconnection_obj->set_member("getpath", &netconnection_getpath);
+#endif
     fn.result->set_as_object_interface(netconnection_obj);
 }
-void netconnection_connect(const fn_call& fn) {
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+
+void netconnection_connect(const fn_call& fn)
+{
+    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
+    
+    string filespec;
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    
+    assert(ptr);
+    if (fn.nargs != 0) {
+        filespec = fn.env->bottom(fn.first_arg_bottom_index).to_string();
+        ptr->obj.connect(filespec.c_str());
+    } else {
+        ptr->obj.connect(0);
+    }
+    
+    log_msg("%s:unimplemented %d\n", __FUNCTION__);
+}
+
+#ifdef ENABLE_TESTING
+void netconnection_geturl(const fn_call& fn)
+{
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    assert(ptr);
+    fn.result->set_tu_string(ptr->obj.getURL().c_str());
+}
+void
+netconnection_getprotocol(const fn_call& fn){
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    assert(ptr);
+
+    fn.result->set_tu_string(ptr->obj.getProtocol().c_str());
+}
+void
+netconnection_gethost(const fn_call& fn){
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    assert(ptr);
+    fn.result->set_tu_string(ptr->obj.getHost().c_str());
+}
+void
+netconnection_getport(const fn_call& fn){
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    assert(ptr);
+    fn.result->set_tu_string(ptr->obj.getPort().c_str());
+}
+void
+netconnection_getpath(const fn_call& fn){
+    netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
+    assert(ptr);
+    fn.result->set_tu_string(ptr->obj.getPath().c_str());
 }
 
+#endif
 } // end of gnaash namespace
 
Index: gnash/server/NetConnection.h
diff -u gnash/server/NetConnection.h:1.1 gnash/server/NetConnection.h:1.2
--- gnash/server/NetConnection.h:1.1    Wed Feb  1 23:52:44 2006
+++ gnash/server/NetConnection.h        Sat Feb  4 07:12:56 2006
@@ -23,29 +23,64 @@
 #include "config.h"
 #endif
 
+#include <string>
+
 #include "impl.h"
 #include "log.h"
 
 namespace gnash {
-  
+
+// Define the ports for the RTMP protocols
+const int RTMP = 1935;
+const int RTMPT = 80;
+
 class NetConnection {
 public:
     NetConnection();
     ~NetConnection();
-   void connect();
+    void connect(const char *arg);
+
+    // Accessors for testing, not supported by Flash
+    bool connected() { return _connected; }
+    bool connected(bool state) { _connected = state; }
+
+#ifdef ENABLE_TESTING
+    std::string getURL()        { return _url; }
+    std::string getProtocol()   { return _protocol; }
+    std::string getHost()       { return _host; }
+    std::string getPort()       { return _port; }
+    std::string getPath()       { return _path; }
+    
+    void setURL(std::string url) { _url = url; };
+    void setProtocol(std::string proto) { _protocol = proto; };
+    void setHost(std::string host) { _host = host; };
+    void setPort(std::string port) { _port = port; };
+    void setPath(std::string path) { _path = path; };
+#endif
 private:
+    bool        _connected;
+    std::string _url;
+    std::string _protocol;
+    std::string _host;
+    std::string _port;
+    std::string _path;
 };
 
 struct netconnection_as_object : public as_object
 {
     NetConnection obj;
 };
-
 void netconnection_new(const fn_call& fn);
 void netconnection_connect(const fn_call& fn);
 
+#ifdef ENABLE_TESTING
+void netconnection_geturl(const fn_call& fn);
+void netconnection_getprotocol(const fn_call& fn);
+void netconnection_gethost(const fn_call& fn);
+void netconnection_getport(const fn_call& fn);
+void netconnection_getpath(const fn_call& fn);
+#endif
 } // end of gnash namespace
 
 // __NETCONNECTION_H__
 #endif
-
Index: gnash/testsuite/actionscript.all/NetConnection.as
diff -u gnash/testsuite/actionscript.all/NetConnection.as:1.1 
gnash/testsuite/actionscript.all/NetConnection.as:1.2
--- gnash/testsuite/actionscript.all/NetConnection.as:1.1       Thu Feb  2 
00:03:02 2006
+++ gnash/testsuite/actionscript.all/NetConnection.as   Sat Feb  4 07:12:56 2006
@@ -23,6 +23,7 @@
 
 var tmp = new NetConnection;
 
+
 // test the NetConnection constuctor
 if (tmp) {
        trace("PASSED: NetConnection::NetConnection() constructor");
@@ -36,3 +37,22 @@
 } else {
        trace("FAILED: NetConnection::connect() doesn't exist");
 }
+
+// test the NetConnection::connect method
+tmp.connect();
+tmp.connect("rmtp://www.mediacollege.com/flash/media-player/testclip-4sec.flv");
+
+// Check the see if the URL got parsed right
+var url = tmp.geturl();
+var protocol = tmp.getprotocol();
+var host = tmp.gethost();
+var port = tmp.getport();
+var path = tmp.getpath();
+if (url == "rmtp://www.mediacollege.com/flash/media-player/testclip-4sec.flv"
+        && protocol == "rmtp"
+        && host == "www.mediacollege.com"
+        && path == "/flash/media-player/testclip-4sec.flv") {
+       trace("PASSED: NetConnection::connect() initialized correctly");
+} else {
+       trace("FAILED: NetConnection::connect() didn't initialized correctly");
+}




reply via email to

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