gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash Makefile.am configure.ac ChangeLog gui/Ma...


From: Rob Savoye
Subject: [Gnash-commit] gnash Makefile.am configure.ac ChangeLog gui/Ma...
Date: Tue, 01 Aug 2006 16:57:36 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    06/08/01 16:57:36

Modified files:
        .              : Makefile.am configure.ac ChangeLog 
        gui            : Makefile.am gnash.cpp 
        libamf         : Makefile.am amf.h 
        libbase        : Thread.cpp network.cpp network.h rc.cpp rc.h 
        utilities      : Makefile.am 
        server/asobj   : Makefile.am NetConnection.cpp NetConnection.h 
Added files:
        libamf         : protocol.h rtmp.cpp rtmp.h 

Log message:
                * configure.ac: Change testing to disabled by default.
                * Makefile.am: Always build libamf now, the networking code
                requires it.
                * gui/Makefile.am: Add libamf to the link line.
                * gui/gnash.cpp: Add support for reading the config file.
                * libamf/Makefile.am: Add RTMP support files.
                * libbase/network.cpp: Add = operator. Add support for passing a
                timeout to all functions using select().
                * libamf/rtmp.h, rtmp.cpp: New RTMP protocol support, both 
client
                side and server side.
                * libamf/protocol.h: Bases class for network protocols.
                * libbase/network.h: Always compile in the accesors, the =
                operator needs them.
                * libbase/rc.cpp, rc.h: Add documentroot variable.
                * plugin/Makefile.am: Add libamf to the link line.
                * server/asobj/Makefile.am: Add libamf to the link line.
                * server/asobj/NetConnection.cpp: Add establishing the RTMP
                connection for connect().
                * utilities/Makefile.am: Add libamf to the link line.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/Makefile.am?cvsroot=gnash&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.98&r2=1.99
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.570&r2=1.571
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Makefile.am?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/gnash.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/Makefile.am?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/protocol.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/Thread.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.h?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.cpp?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/rc.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/utilities/Makefile.am?cvsroot=gnash&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Makefile.am?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.1&r2=1.2

Patches:
Index: Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/Makefile.am,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- Makefile.am 29 Jul 2006 13:27:50 -0000      1.31
+++ Makefile.am 1 Aug 2006 16:57:35 -0000       1.32
@@ -37,7 +37,14 @@
 AUTOMAKE_OPTIONS = dejagnu 1.6.0
 ACLOCAL_AMFLAGS = -I macros
 
-STD_DIRS = libbase libgeometry server backend utilities gui
+STD_DIRS = \
+       libbase \
+       libgeometry \
+       libamf \
+       server \
+       backend \
+       gui \
+       utilities
 
 if PLUGIN
 PLUGIN_DIRS = plugin

Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -b -r1.98 -r1.99
--- configure.ac        1 Aug 2006 10:59:30 -0000       1.98
+++ configure.ac        1 Aug 2006 16:57:35 -0000       1.99
@@ -113,9 +113,9 @@
   yes) testing=yes ;;
   no)  testing=no ;;
   *)   AC_MSG_ERROR([bad value ${enableval} for enable-testing option]) ;;
-esac], testing=yes)
+esac], testing=no)
 
-if test x"${testing}" != x"no"; then
+if test x"${testing}" = x"yes"; then
   AC_DEFINE([ENABLE_TESTING], [], [Unit testing support])
 fi
 AM_CONDITIONAL(TESTING, test x$testing = xyes)

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.570
retrieving revision 1.571
diff -u -b -r1.570 -r1.571
--- ChangeLog   1 Aug 2006 11:01:52 -0000       1.570
+++ ChangeLog   1 Aug 2006 16:57:35 -0000       1.571
@@ -1,3 +1,24 @@
+2006-08-01  Rob Savoye  <address@hidden>
+
+       * configure.ac: Change testing to disabled by default.
+       * Makefile.am: Always build libamf now, the networking code
+       requires it.
+       * gui/Makefile.am: Add libamf to the link line.
+       * gui/gnash.cpp: Add support for reading the config file.
+       * libamf/Makefile.am: Add RTMP support files.
+       * libbase/network.cpp: Add = operator. Add support for passing a
+       timeout to all functions using select().
+       * libamf/rtmp.h, rtmp.cpp: New RTMP protocol support, both client
+       side and server side.
+       * libamf/protocol.h: Bases class for network protocols.
+       * libbase/network.h: Always compile in the accesors, the =
+       operator needs them.
+       * libbase/rc.cpp, rc.h: Add documentroot variable.
+       * plugin/Makefile.am: Add libamf to the link line.
+       * server/asobj/Makefile.am: Add libamf to the link line.
+       * server/asobj/NetConnection.cpp: Add establishing the RTMP
+       connection for connect().
+       * utilities/Makefile.am: Add libamf to the link line.
 
 2006-08-01 Sandro Santilli <address@hidden>
 
@@ -44,6 +65,7 @@
 
 2006-07-30  Rob Savoye  <address@hidden>
 
+       * libbase/Thread.h, Thread.cpp: Base class for handling threads.
        * server/network.h, network.cpp: Remove as they now live in
        libbase.
        * server/Makefile.am: Remove network.

Index: gui/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/gui/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- gui/Makefile.am     31 Jul 2006 03:13:43 -0000      1.10
+++ gui/Makefile.am     1 Aug 2006 16:57:35 -0000       1.11
@@ -150,7 +150,9 @@
        NullGui.cpp \
        NullGui.h
 
-libgnashgui_la_LIBADD = ../server/libgnashserver.la
+libgnashgui_la_LIBADD = \
+       ../server/libgnashserver.la \
+       ../libamf/libgnashamf.la
 
 if USE_GUI_KDE
 bin_PROGRAMS = gnash klash

Index: gui/gnash.cpp
===================================================================
RCS file: /sources/gnash/gnash/gui/gnash.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- gui/gnash.cpp       31 Jul 2006 23:26:33 -0000      1.24
+++ gui/gnash.cpp       1 Aug 2006 16:57:35 -0000       1.25
@@ -64,6 +64,7 @@
 #include "movie_definition.h"
 
 #include "URL.h"
+#include "rc.h"
 #include "GnashException.h"
 
 using namespace std;
@@ -144,6 +145,31 @@
     }
 
     dbglogfile.setWriteDisk(false);
+    rcfile.loadFiles();
+//    rcfile.dump();
+
+    if (rcfile.useWriteLog()) {
+        dbglogfile.setWriteDisk(true);
+    }
+    
+    if (rcfile.verbosityLevel() > 0) {
+        dbglogfile.setVerbosity(rcfile.verbosityLevel());
+    }
+    
+    if (rcfile.useActionDump()) {
+        dbglogfile.setActionDump(true);
+        dbglogfile.setVerbosity();
+    }
+    
+    if (rcfile.useParserDump()) {
+        dbglogfile.setParserDump(true);
+        dbglogfile.setVerbosity();
+    }
+    
+    if (rcfile.getTimerDelay() > 0) {
+        delay = rcfile.getTimerDelay();
+        dbglogfile << "Timer delay set to " << delay << "milliseconds" << endl;
+    }    
     
     while ((c = getopt (argc, argv, "hvaps:cfd:x:r:t:b:1ewj:k:u:")) != -1) {
        switch (c) {

Index: libamf/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libamf/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libamf/Makefile.am  7 Jul 2006 15:10:15 -0000       1.7
+++ libamf/Makefile.am  1 Aug 2006 16:57:35 -0000       1.8
@@ -57,13 +57,16 @@
 # AM_LDFLAGS  = $(OPENGL_LIBNS) $(SDL_LIBS)
 
 lib_LTLIBRARIES = libgnashamf.la
-libgnashamf_la_SOURCES = amf.cpp amfutf8.h amf.h
+libgnashamf_la_SOURCES = amf.cpp rtmp.cpp
 # noinst_HEADERS = amf.h amfutf8.h
 
 INCLUDES = -I.. -I$(srcdir) \
-       -I$(top_srcdir)/server
+       -I$(top_srcdir)/server \
+       -I$(top_srcdir)/libbase \
+        $(LIBXML_CFLAGS)
 
 noinst_PROGRAMS = amftest
+noinst_HEADERS = amfutf8.h amf.h rtmp.h
 
 amftest_SOURCES = amftest.cpp
 amftest_LDADD = $(AM_LDFLAGS) libgnashamf.la

Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libamf/amf.h        24 Apr 2006 23:05:55 -0000      1.3
+++ libamf/amf.h        1 Aug 2006 16:57:35 -0000       1.4
@@ -97,8 +97,7 @@
     amfutf8_t response;
     AMF_Long_t length;
     void *data;
-}
- amfbody_t;
+} amfbody_t;
 
 // Each packet consists of the following:
 //

Index: libbase/Thread.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/Thread.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libbase/Thread.cpp  30 Jul 2006 15:57:53 -0000      1.1
+++ libbase/Thread.cpp  1 Aug 2006 16:57:35 -0000       1.2
@@ -71,7 +71,7 @@
 {
     pthread_attr_init(&_tattr);
 
-    if (pthread_attr_setscope(&_tattr, PTHREAD_SCOPE_PROCESS)) {
+    if (pthread_attr_setscope(&_tattr, PTHREAD_SCOPE_SYSTEM)) {
         log_msg("Couldn't set thread scope, %s\n", strerror(errno));
     }
 

Index: libbase/network.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libbase/network.cpp 30 Jul 2006 15:54:00 -0000      1.1
+++ libbase/network.cpp 1 Aug 2006 16:57:35 -0000       1.2
@@ -65,7 +65,7 @@
 # include <arpa/inet.h>
 # include <sys/socket.h>
 # include <netdb.h>
-# include <errno.h>
+# include <cerrno>
 # include <sys/param.h>
 # include <sys/select.h>
 #endif
@@ -109,9 +109,21 @@
     //log_msg("%s: \n", __PRETTY_FUNCTION__);
 #ifdef HAVE_WINSOCK_H
     WSACleanup();
+#else
+    closeNet();
 #endif
 }
 
+Network &
+Network::operator = (Network &net)
+{
+    _sockfd = net.getFileFd();
+    _port = net.getPort();
+    _host = net.getHost();
+    _connected = net.connected();
+    _timeout = net.getTimeout();
+}
+
 // Description: Create a tcp/ip network server. This creates a server
 //              that listens for incoming socket connections. This
 //              support IP aliasing on the host, and will sequntially
@@ -572,6 +584,10 @@
         FD_SET(fd, &fdset);
 
         // Reset the timeout value, since select modifies it on return
+        // Reset the timeout value, since select modifies it on return
+        if (timeout <= 0) {
+            timeout = 5;
+        }
         tval.tv_sec = timeout;
         tval.tv_usec = 0;
         ret = select(fd+1, &fdset, NULL, NULL, &tval);
@@ -595,6 +611,8 @@
         }
     
         ret = read(fd, buffer, nbytes);
+        dbglogfile << "read " << ret << " bytes from fd #"
+                   << fd << endl;
     }
     
     return ret;
@@ -654,6 +672,9 @@
         FD_SET(fd, &fdset);
         
         // Reset the timeout value, since select modifies it on return
+        if (timeout <= 0) {
+            timeout = 5;
+        }
         tval.tv_sec = timeout;
         tval.tv_usec = 0;
         ret = select(fd+1, NULL, &fdset, NULL, &tval);
@@ -678,7 +699,8 @@
 
         if (ret == 0) {
             dbglogfile
-                << "Couldn't write any bytes to fd #." << fd << endl;
+                << "Couldn't write any bytes to fd #: " << fd
+                << strerror(errno) << endl;
             return ret;
         }
         if (ret < 0) {

Index: libbase/network.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libbase/network.h   30 Jul 2006 15:54:00 -0000      1.1
+++ libbase/network.h   1 Aug 2006 16:57:35 -0000       1.2
@@ -118,7 +118,7 @@
     void toggleDebug(bool val);
     
     bool send(const char *str);
-#ifdef ENABLE_TESTING 
+    //#ifdef ENABLE_TESTING 
     // Accessors for testing
     bool connected()            { return _connected; };
     int getFileFd()             { return _sockfd; };
@@ -129,8 +129,10 @@
     std::string getHost()       { return _host; }
     std::string getPortStr()    { return _portstr; }
     std::string getPath()       { return _path; }    
-#endif
-protected:
+    int getTimeout()            { return _timeout; }
+    //#endif
+    Network &operator = (Network &net);
+ protected:
     in_addr_t   _ipaddr;
     int         _sockfd;
     int         _listenfd;

Index: libbase/rc.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libbase/rc.cpp      12 Jun 2006 17:15:10 -0000      1.5
+++ libbase/rc.cpp      1 Aug 2006 16:57:35 -0000       1.6
@@ -193,6 +193,10 @@
                 extractNumber(&_delay, "delay", variable, value);
                 extractNumber(&_verbosity, "verbosity", variable, value);
                 
+                if (variable == "documentroot") {
+                    _wwwroot = value;
+                }
+                
                 if (variable == "blacklist") {
                     string::size_type pos;
                     while ((pos = value.find(':', 0)) != string::npos) {

Index: libbase/rc.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/rc.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/rc.h        8 Jun 2006 04:16:19 -0000       1.4
+++ libbase/rc.h        1 Aug 2006 16:57:35 -0000       1.5
@@ -76,6 +76,7 @@
     void verbosityLevel(int value) { _verbosity = value; };
     
     std::string getDebugLog() { return _log; };
+    std::string getDocumentRoot() { return _wwwroot; };
     
     bool useDebugger() { return _debugger; };
     void useDebugger(bool value) { _debugger = value; }
@@ -116,6 +117,7 @@
     std::vector<std::string> _blacklist; // domains we don't allow
     std::string _log;           // the name of the debug log
     bool _writelog;             // enable writing the debug log to disk
+    std::string _wwwroot;       // the root path for the streaming server
 };
 
 extern RcInitFile rcfile;

Index: utilities/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/utilities/Makefile.am,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- utilities/Makefile.am       29 Jul 2006 23:01:14 -0000      1.23
+++ utilities/Makefile.am       1 Aug 2006 16:57:35 -0000       1.24
@@ -33,7 +33,8 @@
        ../server/libgnashserver.la \
        ../server/asobj/libgnashasobjs.la \
        ../libgeometry/libgnashgeo.la \
-       ../libbase/libgnashbase.la 
+       ../libbase/libgnashbase.la \
+       ../libamf/libgnashamf.la 
 
 AM_CPPFLAGS = # -Wall
 

Index: server/asobj/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/asobj/Makefile.am    22 Jul 2006 23:47:56 -0000      1.1
+++ server/asobj/Makefile.am    1 Aug 2006 16:57:36 -0000       1.2
@@ -47,6 +47,7 @@
        -I$(top_srcdir)/server \
        -I$(top_srcdir)/server/swf \
         -I$(top_srcdir)/libbase \
+        -I$(top_srcdir)/libamf \
         -I$(top_srcdir)        \
        $(PTHREAD_CFLAGS) \
         $(ENGINE_INCLUDE) \
@@ -115,7 +116,6 @@
        TextSnapshot.h  \
        Video.h
 
-
 # Rebuild with GCC 4.x Mudflap support
 mudflap:
        @echo "Rebuilding with GCC Mudflap support"

Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/asobj/NetConnection.cpp      22 Jul 2006 23:47:56 -0000      1.1
+++ server/asobj/NetConnection.cpp      1 Aug 2006 16:57:36 -0000       1.2
@@ -40,12 +40,16 @@
 #include "config.h"
 #endif
 
+#include <iostream>
 #include <string>
 #include "log.h"
 #include "NetConnection.h"
 #include "fn_call.h"
+#include "rtmp.h"
 
 using namespace std;
+using namespace amf;
+using namespace rtmp;
 
 namespace gnash {
 
@@ -83,10 +87,10 @@
 /// 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
+bool
 NetConnection::connect(const char *arg)
 {
-    log_msg("%s: \n", __PRETTY_FUNCTION__);
+    GNASH_REPORT_FUNCTION;
     
     string::size_type first_colon;
     string::size_type second_colon;
@@ -96,7 +100,7 @@
     if (arg != 0) {
         if (strcmp(arg, "null") == 0) {
             log_warning("No URL specified!\n");
-            return;
+            return false;
         }
         _url = arg;
         // protocol:[//host][:port]/appname/[instanceName]
@@ -108,23 +112,42 @@
         if (second_colon != string::npos) {
             _host = _url.substr(double_slash, second_colon - double_slash);
             _portstr = _url.substr(second_colon + 1, single_slash - 
second_colon - 1);
+            _port = (short)strtol(_portstr.c_str(), NULL, 0);
         } else {
             _host = _url.substr(double_slash, single_slash - double_slash);
+            if (_protocol == "rtmp") {
+                _port = RTMP;
+            }
+            if (_protocol == "http") {
+                _port = RTMPT;
+            }
         }
         _path = _url.substr(single_slash, _url.size());
 
+        
         if (_portstr.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(), _portstr.c_str(), 
_path.c_str());
+                    _protocol.c_str(), _host.c_str(),
+                    _portstr.c_str(), _path.c_str());
         }
     } else {
         log_msg("Connecting to localhost\n");
     }
     
-    log_msg("%s:unimplemented \n", __FUNCTION__);
+    RTMPproto proto;
+
+    if (proto.createClient(_host.c_str(), _port)) {
+        proto.handShakeRequest();
+        proto.clientFinish();
+    } else {
+        dbglogfile << "ERROR: Couldn't connect to server!" << endl;
+        return false;
+    }
+
+    return true;
 }
 
 /// \brief callback to instantiate a new NetConnection object.
@@ -134,8 +157,8 @@
 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);
+    GNASH_REPORT_FUNCTION;
+//    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
         
     netconnection_as_object *netconnection_obj = new netconnection_as_object;
 
@@ -152,7 +175,8 @@
 
 void netconnection_connect(const fn_call& fn)
 {
-    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
+    GNASH_REPORT_FUNCTION;
+//    log_msg("%s: %d args\n", __PRETTY_FUNCTION__, fn.nargs);
     
     string filespec;
     netconnection_as_object *ptr = (netconnection_as_object*)fn.this_ptr;
@@ -164,8 +188,6 @@
     } else {
         ptr->obj.connect(0);
     }
-    
-    log_msg("%s: partially implemented\n", __FUNCTION__);
 }
 
 } // end of gnash namespace

Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- server/asobj/NetConnection.h        22 Jul 2006 23:47:56 -0000      1.1
+++ server/asobj/NetConnection.h        1 Aug 2006 16:57:36 -0000       1.2
@@ -55,7 +55,7 @@
 public:
     NetConnection();
     ~NetConnection();
-    void connect(const char *arg);
+    bool connect(const char *arg);
 };
 
 struct netconnection_as_object : public as_object

Index: libamf/protocol.h
===================================================================
RCS file: libamf/protocol.h
diff -N libamf/protocol.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libamf/protocol.h   1 Aug 2006 16:57:35 -0000       1.1
@@ -0,0 +1,66 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+// 
+//
+
+#ifndef _PROTOCOL_H_
+#define _PROTOCOL_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <string>
+#include "network.h"
+
+class Protocol : public gnash::Network {
+public:
+    Protocol() { };
+    virtual ~Protocol() { };
+    
+    virtual bool handShakeWait() = 0;
+    virtual bool handShakeRequest() = 0;
+    virtual bool handShakeResponse() = 0;
+    virtual bool clientFinish() = 0;
+    virtual bool serverFinish() = 0;
+    virtual bool packetRequest() = 0;
+    virtual bool packetSend() = 0;
+    virtual bool packetRead() = 0;
+private:
+    std::string _name;
+};  
+
+// end of _PROTOCOL_H_
+#endif

Index: libamf/rtmp.cpp
===================================================================
RCS file: libamf/rtmp.cpp
diff -N libamf/rtmp.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libamf/rtmp.cpp     1 Aug 2006 16:57:35 -0000       1.1
@@ -0,0 +1,421 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+// 
+//
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <iostream>
+#include "rtmp.h"
+#include "log.h"
+#include "new"
+#include <netinet/in.h>
+
+using namespace gnash;
+using namespace amf;
+using namespace std;
+
+namespace rtmp
+{
+
+RTMPproto::RTMPproto() 
+    : _body(0)
+{
+//    GNASH_REPORT_FUNCTION;  
+//    _amf_data.reserve(MAX_AMF_INDEXES);
+//    memset(_amf_data, 0, MAX_AMF_INDEXES);
+    memset(_amf_size, 0, MAX_AMF_INDEXES);
+}
+
+RTMPproto::~RTMPproto()
+{
+//    GNASH_REPORT_FUNCTION;
+    delete _body;
+}
+
+
+// The handshake is a byte with the value of 0x3, followed by 1536
+// bytes of gibberish which we need to store for later.
+bool
+RTMPproto::handShakeWait()
+{
+    GNASH_REPORT_FUNCTION;
+
+    char buffer[RTMP_HEADERSIZE+1];
+    memset(buffer, 0, RTMP_HEADERSIZE+1);
+    
+    if (readNet(buffer, 1) == 1) {
+        dbglogfile << "Read initial Handshake Request" << endl;
+    } else {
+        dbglogfile << "Couldn't read initial Handshake Request" << endl;
+        return false;
+    }
+    if (*buffer == 0x3) {
+        dbglogfile << "Handshake is correct" << endl;
+    } else {
+        dbglogfile << "Handshake isn't correct" << endl;
+        dbglogfile << "Data read is: " << buffer << endl;
+//        return false;
+    }
+    
+    if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {        
+        dbglogfile << "Read Handshake Data" << endl;
+        _body = new char(RTMP_HEADERSIZE+1);
+        memcpy(_body, buffer, RTMP_HEADERSIZE);        
+    } else {
+        dbglogfile << "Couldn't read Handshake Data" << endl;
+        dbglogfile << "Data read is: " << buffer << endl;
+        return false;
+    }
+    
+    return true;
+}
+
+// A request for a handshake is initiated by sending a byte with a
+// value of 0x3, followed by a message body of unknown format.
+bool
+RTMPproto::handShakeRequest()
+{
+    GNASH_REPORT_FUNCTION;
+
+    char buffer[RTMP_HEADERSIZE+1];
+    char c = 0x3;
+    int  i, ret;
+    
+    ret = writeNet(&c, 1);
+    // something went wrong, chances are the other end of the network
+    // connection is down, or never initialized.
+    if (ret <= 0) {
+        return false;
+    }
+
+    // Since we don't know what the format is, create a pattern we can
+    // recognize if we stumble across it later on.
+    for (i=0; i<RTMP_HEADERSIZE; i++) {
+        buffer[i] = i^256;
+    }
+             
+    ret = writeNet(buffer, RTMP_HEADERSIZE);
+
+    return true;
+}
+
+// The response is the giobberish sent back twice, followed by a byte
+// with the value of 0x3.
+bool
+RTMPproto::handShakeResponse()
+{
+    GNASH_REPORT_FUNCTION;
+
+    char c = 0x3;
+    writeNet(&c, 1);
+    writeNet(_body, RTMP_HEADERSIZE);
+    writeNet(_body, RTMP_HEADERSIZE);
+    
+    return true;    
+}
+
+// The client finished the handshake process by sending the second
+// data block we get from the server as the response
+bool
+RTMPproto::clientFinish()
+{
+    GNASH_REPORT_FUNCTION;
+    
+    char buffer[RTMP_HEADERSIZE+1];
+    memset(buffer, 0, RTMP_HEADERSIZE+1);
+
+    if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {        
+        dbglogfile << "Read first data block in handshake" << endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read first data block in handshake!"
+                   << endl;
+        return false;
+    }
+    if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {        
+        dbglogfile << "Read second data block in handshake" << endl;
+//         _body = new char(RTMP_HEADERSIZE+1);
+//         memcpy(_body, buffer, RTMP_HEADERSIZE);
+    } else {
+        dbglogfile << "ERROR: Couldn't read second data block in handshake!"
+                   << endl;
+        return false;
+    }
+
+    writeNet(buffer, RTMP_HEADERSIZE);
+
+    return true;
+}
+
+bool
+RTMPproto::serverFinish()
+{
+    GNASH_REPORT_FUNCTION;
+
+    int ret;
+    char buffer[RTMP_HEADERSIZE+1];
+    memset(buffer, 0, RTMP_HEADERSIZE+1);
+    
+    if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {
+        dbglogfile << "Read Handshake Finish Data" << endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read Handshake Finish Data!" << endl;
+        return false;
+    }
+
+// FIXME: These should match, and appear to in GDB, but this triggers
+// an error of some kind.    
+//     if (memcmp(buffer, _body, 10) == 0) {
+//         dbglogfile << "Handshake Finish Data matches" << endl;
+//     } else {
+//         dbglogfile << "ERROR: Handshake Finish Data doesn't match!" << endl;
+//         return false;
+//     }
+        
+
+    packetRead();
+    
+    return true;
+}
+
+int
+RTMPproto::headerSize(char header)
+{
+    switch (header & RTMP_HEADSIZE_MASK) {
+      case HEADER_12:
+          return(12);
+          break;
+      case HEADER_8:
+          return(8);
+          break;
+      case HEADER_4:
+          return(4);
+          break;
+      case HEADER_1:
+          return(1);
+          break;
+      default:
+          dbglogfile << "ERROR: Header size bits out of range!" << endl;
+          return -1;
+          break;
+    };
+
+    return -1;
+}
+
+bool
+RTMPproto::packetRequest()
+{
+    GNASH_REPORT_FUNCTION;
+    return false;
+}
+
+bool
+RTMPproto::packetSend()
+{
+    GNASH_REPORT_FUNCTION;
+    return false;
+}
+
+bool
+RTMPproto::packetRead()
+{
+    GNASH_REPORT_FUNCTION;
+
+    int ret;
+    char buffer[AMFBODY_PACKET_SIZE+1];
+    memset(buffer, 0, AMFBODY_PACKET_SIZE+1);
+    unsigned char hexint[512];
+    int blocksize;
+    char *tmpptr;
+    char *amfdata;
+    
+//    
address@hidden@\000\000\000\000\000\000\003\000\003app\002\000#software/gnash/tests/1153948634.flv\000\bflashVer\002\000\fLNX
 
6,0,82,0\000\006swfUrl\002\000\035file:///file|address@hidden://localhost/software/gnash/tests/1153948634
+    if ((ret = readNet(buffer, 1)) > 0) {
+        dbglogfile << "Read first RTMP header byte"<< endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read first RTMP header byte!" << endl;
+        return false;
+    }
+    
+    _headersize = headerSize(*buffer);
+    _amf_number = *buffer & RTMP_AMF_INDEX;
+    dbglogfile << "The Header size is: " << _headersize << endl;
+    dbglogfile << "The AMF index is: 0x" << _amf_number << endl;
+
+    
+    if ((ret = readNet(buffer, _headersize-1)) > 0) {
+        dbglogfile << "Read first RTMP packet body of " << ret
+                   << " bytes." << endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read first RTMP packet body!" << endl;
+        return false;
+    }
+    tmpptr = buffer;
+    
+    if (_headersize >= 4) {
+        hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
+        _mystery_word = *tmpptr++;
+        _mystery_word = (_mystery_word << 12) + *tmpptr++;
+        _mystery_word = (_mystery_word << 8) + *tmpptr++;
+         dbglogfile << "The mystery word is: " << _mystery_word
+                    << " Hex value is: 0x" << hexint << endl;
+    }
+
+    if (_headersize >= 8) {
+        hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
+        _bodysize = *tmpptr++;
+        _bodysize = (_bodysize << 12) + *tmpptr++;
+        _bodysize = (_bodysize << 8) + *tmpptr++;
+        _bodysize = _bodysize & 0x0000ff;
+        dbglogfile << "The body size is: " << _bodysize
+                   << " Hex value is: 0x" << hexint << endl;
+    }
+
+    if (_headersize >= 8) {
+        hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 1);
+        _type = *(rtmp_types_e *)tmpptr;
+        tmpptr++;
+        dbglogfile << "The type is: " << _type
+                   << " Hex value is: 0x" << hexint << endl;
+    }
+
+    if (_headersize == 12) {
+        hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
+        _src_dest = ntohl(*(unsigned int *)tmpptr);
+        tmpptr += sizeof(unsigned int);
+        dbglogfile << "The source/destination is: " << _src_dest
+                   << " Hex value is: 0x" << hexint << endl;
+    }
+
+#if 0
+    if ((ret = readNet(buffer, AMFBODY_PACKET_SIZE - _headersize)) > 0) {
+        dbglogfile << "Read first RTMP packet body of " << ret
+                   << " bytes." << endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read first RTMP packet body!" << endl;
+        return false;
+    }
+    tmpptr = buffer;
+    
+//     hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 50);
+//     dbglogfile << "The AMF header is: " << hexint << endl;
+
+    if (_amf_number < MAX_AMF_INDEXES) {
+        if (_amf_size[_amf_number] == 0) {
+            dbglogfile << "New AMF object, index: " << _amf_number << endl;
+//      amfdata = new char(AMFBODY_PACKET_SIZE+1);
+//         memcpy(amfdata, tmpptr, _bodysize);
+//         _amf_data[_amf_number] = amfdata;
+            _amf_data[_amf_number] = (unsigned char *)tmpptr ;
+            _amf_size[_amf_number] = _bodysize;
+        } else {
+            int amd_headersize = headerSize(*tmpptr);
+            int amf_index = *tmpptr & RTMP_AMF_INDEX;
+            dbglogfile << "The AMF Header size is: " << amd_headersize << endl;
+            dbglogfile << "The AMF index is: 0x" << amf_index << endl;
+//         amfdata = new unsigned char(
+//             _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
+//         memcpy(amfdata, _amf_data[amf_index],
+//                _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
+//         memcpy(amfdata+_amf_size[amf_index], tmpptr,
+//                _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
+//       _amf_size[_amf_number] = _bodysize;
+        }
+        
+    }
+#endif
+    
+    packetReadAMF(0);
+    
+//    _amf_data
+    return true;
+}
+
+bool
+RTMPproto::packetReadAMF(int bytes)
+{
+    GNASH_REPORT_FUNCTION;
+
+    int ret;
+    char buffer[AMFBODY_PACKET_SIZE+1];
+    unsigned char hexint[(AMFBODY_PACKET_SIZE*2)+1];
+    char *tmpptr;
+    unsigned char *amfdata;
+
+    if (bytes == 0) {
+        bytes = AMFBODY_PACKET_SIZE;
+    }
+    
+    memset(buffer, 0, AMFBODY_PACKET_SIZE+1);
+    if ((ret = readNet(buffer, bytes)) > 0) {
+        dbglogfile << "Read AMF packet, " << ret
+                   << " bytes in size." << endl;
+    } else {
+        dbglogfile << "ERROR: Couldn't read AMF packet!" << endl;
+        return false;
+    }
+    tmpptr = buffer;
+
+//     hexify((unsigned char *)hexint, (unsigned char *)tmpptr, bytes);
+//     dbglogfile << "AMF packet: 0x" << hexint << endl;
+    
+    _headersize = headerSize(*tmpptr);
+    _amf_number = *tmpptr & RTMP_AMF_INDEX;
+    tmpptr++;
+    dbglogfile << "The Header size is: " << _headersize << endl;
+    dbglogfile << "The AMF index is: 0x" << _amf_number << endl;
+
+    if (_amf_size[_amf_number] == 0) {
+//        unsigned char *amfdata = new unsigned char(_bodysize);
+//         memcpy(amfdata, tmpptr, _bodysize);
+//         _amf_data[_amf_number] = amfdata;
+        _amf_size[_amf_number] = _bodysize;
+    } else {
+//         unsigned char *amfdata = new unsigned
+//             char(_amf_size[_amf_number] + _bodysize);
+//         memcpy(amfdata, _amf_data[_amf_number], _amf_size[_amf_number]);
+//         memcpy(amfdata +_amf_size[_amf_number], tmpptr, _bodysize);
+        _amf_size[_amf_number] += _bodysize;
+        
+//         delete _amf_data[_amf_number];
+//         _amf_data[_amf_number] = amfdata;
+    }
+}
+
+
+} // end of cygnal namespace

Index: libamf/rtmp.h
===================================================================
RCS file: libamf/rtmp.h
diff -N libamf/rtmp.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ libamf/rtmp.h       1 Aug 2006 16:57:35 -0000       1.1
@@ -0,0 +1,125 @@
+// 
+//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+// 
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+// 
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+// Linking Gnash statically or dynamically with other modules is making a
+// combined work based on Gnash. Thus, the terms and conditions of the GNU
+// General Public License cover the whole combination.
+//
+// As a special exception, the copyright holders of Gnash give you
+// permission to combine Gnash with free software programs or libraries
+// that are released under the GNU LGPL and with code included in any
+// release of Talkback distributed by the Mozilla Foundation. You may
+// copy and distribute such a system following the terms of the GNU GPL
+// for all but the LGPL-covered parts and Talkback, and following the
+// LGPL for the LGPL-covered parts.
+//
+// Note that people who make modified versions of Gnash are not obligated
+// to grant this special exception for their modified versions; it is their
+// choice whether to do so. The GNU General Public License gives permission
+// to release a modified version without this exception; this exception
+// also makes it possible to release a modified version which carries
+// forward this exception.
+// 
+//
+
+#ifndef _RTMP_H_
+#define _RTMP_H_
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "amf.h"
+#include "protocol.h"
+#include <vector>
+
+namespace rtmp
+{
+
+#define RTMP_HANDSHAKE 0x3
+#define RTMP_HEADERSIZE 1536
+#define RTMP_HEADSIZE_MASK 0xc0
+#define RTMP_AMF_INDEX 0x3f
+#define MAX_AMF_INDEXES 64
+#define AMFBODY_PACKET_SIZE 128
+
+class RTMPproto : public Protocol
+{
+public:
+    typedef enum {
+        HEADER_12 = 0x0,
+        HEADER_8  = 0x1,
+        HEADER_4  = 0x2,
+        HEADER_1  = 0x3
+    } rtmp_headersize_e;    
+    
+    typedef enum {
+        CHUNK_SIZE = 0x1,
+//    UNKNOWN = 0x2,
+        BYTES_READ = 0x3,
+        PING = 0x4,
+        SERVER = 0x5,
+        CLIENT = 0x6,
+//    UNKNOWN2 = 0x7,
+        AUDIO_DATA = 0x8,
+        VIDEO_DATA = 0x9,
+//    UNKNOWN3 = 0xa,
+        NOTIFY = 0x12,
+        SHARED_OBJ = 0x13,
+        INVOKE = 0x14
+    } rtmp_types_e;
+    
+    typedef enum {
+        CONNECT = 0x1,
+        DISCONNECT = 0x2,
+        SET_ATTRIBUTE = 0x3,
+        UPDATE_DATA = 0x4,
+        UPDATE_ATTRIBUTE = 0x5,
+        SEND_MESSAGE = 0x6,
+        STATUS = 0x7,
+        CLEAR_DATA = 0x8,
+        DELETE_DATA = 0x9,
+        DELETE_ATTRIBUTE = 0xa,
+        INITIAL_DATA = 0xb
+    } sharedobj_types_e;
+    RTMPproto();
+    virtual ~RTMPproto();
+    virtual bool handShakeWait();
+    virtual bool handShakeRequest();
+    virtual bool handShakeResponse();
+    virtual bool clientFinish();
+    virtual bool serverFinish();
+    virtual bool packetRequest();
+    virtual bool packetSend();
+    virtual bool packetRead();
+    int headerSize(char header);
+    bool packetReadAMF(int bytes);
+private:
+    int         _headersize;
+    int         _amf_number;
+    char        *_body;
+    unsigned int _bodysize;
+    rtmp_types_e _type;
+    unsigned char *_amf_data[MAX_AMF_INDEXES];
+    int         _amf_size[MAX_AMF_INDEXES];
+    int         _mystery_word;
+    int         _src_dest;
+};
+
+} // end of rtmp namespace
+
+// end of _RTMP_H_
+#endif




reply via email to

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