gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash libmedia/Makefile.am ChangeLog libamf/Mak...


From: Rob Savoye
Subject: [Gnash-commit] gnash libmedia/Makefile.am ChangeLog libamf/Mak...
Date: Sat, 29 Mar 2008 19:35:54 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    08/03/29 19:35:54

Modified files:
        libmedia       : Makefile.am 
        .              : ChangeLog 
        libamf         : Makefile.am amf.cpp amf.h element.cpp 
                         protocol.h sol.cpp 
        libnet         : Makefile.am buffer.cpp buffer.h handler.cpp 
                         handler.h http.cpp http.h rtmp.cpp rtmp.h 

Log message:
                * libamf/Makefile.am: Add libnet to include paths.
                * libamf/amf.cpp: Include network.h. Use Network::byte_t instead
                of boost::uint8_t. Move headerSize() and parseHeader to rtmp.h, 
as
                they're really an RTMP thing, not an AMF one.
                * libamf/amf.h: Move amfsource_e, amf_headersize_e,
                content_types_e to rtmp.h, as they're an RTMP thing, not an AMF
                one. Define the filetypes here. Use Network::byte_t instead
                of boost::uint8_t. Move headerSize() and parseHeader to rtmp.h.
                * libmedia/Makefile.am: Include libnet in include paths.
                * libnet/Makefile.am: Build rtmp_server too.
                * libnet/buffer.{h,cpp}: Find a byte in a buffer. Remove a 
byte(s)
                from a buffer for filtering.
                * libnet/handler.cpp: Compare incoming message size to 
NETBUFSIZE
                instead of the buffer size itself.
                * libnet/handler.h: Add support for merging buffers in the 
queues.
                * libnet/http.cpp: Change to new prefixed enums.
                * libnet/rtmp.{h,cpp}: Use Elements and byte_t for all
                paramaters. Move all server sid efunctionality to 
rtmp_server.cpp.
                * libnet/rtmp_server.{h,cpp}: New RTMPServer class for server 
side
                only code.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/libmedia/Makefile.am?cvsroot=gnash&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6078&r2=1.6079
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/Makefile.am?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/element.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/protocol.h?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/Makefile.am?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/buffer.cpp?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/buffer.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/handler.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/handler.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/http.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/http.h?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/rtmp.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libnet/rtmp.h?cvsroot=gnash&r1=1.2&r2=1.3

Patches:
Index: libmedia/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libmedia/Makefile.am,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- libmedia/Makefile.am        6 Mar 2008 05:22:51 -0000       1.17
+++ libmedia/Makefile.am        29 Mar 2008 19:35:52 -0000      1.18
@@ -35,6 +35,7 @@
        -I.. -I$(srcdir) \
        -I$(top_srcdir) \
        -I$(top_srcdir)/libamf  \
+       -I$(top_srcdir)/libnet \
        -I$(top_srcdir)/backend \
        -I$(top_srcdir)/libbase \
        -I$(top_srcdir)/server  \

Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6078
retrieving revision 1.6079
diff -u -b -r1.6078 -r1.6079
--- ChangeLog   29 Mar 2008 15:41:42 -0000      1.6078
+++ ChangeLog   29 Mar 2008 19:35:52 -0000      1.6079
@@ -1,3 +1,26 @@
+2008-03-29  Rob Savoye  <address@hidden>
+
+       * libamf/Makefile.am: Add libnet to include paths.
+       * libamf/amf.cpp: Include network.h. Use Network::byte_t instead
+       of boost::uint8_t. Move headerSize() and parseHeader to rtmp.h, as
+       they're really an RTMP thing, not an AMF one.
+       * libamf/amf.h: Move amfsource_e, amf_headersize_e,
+       content_types_e to rtmp.h, as they're an RTMP thing, not an AMF
+       one. Define the filetypes here. Use Network::byte_t instead
+       of boost::uint8_t. Move headerSize() and parseHeader to rtmp.h.
+       * libmedia/Makefile.am: Include libnet in include paths.
+       * libnet/Makefile.am: Build rtmp_server too.
+       * libnet/buffer.{h,cpp}: Find a byte in a buffer. Remove a byte(s)
+       from a buffer for filtering.
+       * libnet/handler.cpp: Compare incoming message size to NETBUFSIZE
+       instead of the buffer size itself.
+       * libnet/handler.h: Add support for merging buffers in the queues.
+       * libnet/http.cpp: Change to new prefixed enums.
+       * libnet/rtmp.{h,cpp}: Use Elements and byte_t for all
+       paramaters. Move all server sid efunctionality to rtmp_server.cpp.
+       * libnet/rtmp_server.{h,cpp}: New RTMPServer class for server side
+       only code.
+       
 2008-03-29 Sandro Santilli <address@hidden>
 
        * testsuite/actionscript.all/: Function.as,

Index: libamf/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libamf/Makefile.am,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- libamf/Makefile.am  5 Mar 2008 03:55:52 -0000       1.33
+++ libamf/Makefile.am  29 Mar 2008 19:35:53 -0000      1.34
@@ -33,9 +33,11 @@
 # noinst_HEADERS = amf.h amfutf8.h
 
 AM_CPPFLAGS = -I.. -I$(srcdir) \
+       -I$(top_srcdir)/libnet \
        -I$(top_srcdir)/server \
        -I$(top_srcdir)/libbase \
        $(BOOST_CFLAGS) \
+       $(PTHREAD_CFLAGS) \
         $(LIBXML_CFLAGS)
 
 AM_LDFLAGS = $(BOOST_LIBS)
@@ -45,7 +47,6 @@
        amf.h \
        element.h \
        lcshm.h \
-       rtmp.h \
        protocol.h \
        sol.h
 

Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- libamf/amf.cpp      22 Feb 2008 09:59:57 -0000      1.61
+++ libamf/amf.cpp      29 Mar 2008 19:35:53 -0000      1.62
@@ -32,6 +32,7 @@
 
 #include "log.h"
 #include "amf.h"
+#include "network.h"
 #include "element.h"
 #include "amfutf8.h"
 #include <boost/cstdint.hpp> // for boost::?int??_t
@@ -42,8 +43,28 @@
 namespace amf 
 {
 
+// These are used to print more intelligent debug messages
+const char *amftype_str[] = {
+    "Number",
+    "Boolean",
+    "String",
+    "Object",
+    "MovieClip",
+    "Null",
+    "Undefined",
+    "Reference",
+    "ECMAArray",
+    "ObjectEnd",
+    "StrictArray",
+    "Date",
+    "LongString",
+    "Unsupported",
+    "Recordset",
+    "XMLObject",
+    "TypedObject"
+};
+
 AMF::AMF() 
-    : _type(NONE),
 #if 0
       _amf_index(0),
       _header_size(0),
@@ -52,7 +73,6 @@
       _amf_data(0),
       _seekptr(0),
 #endif
-      _mystery_word(0)
 {
 //    GNASH_REPORT_FUNCTION;
 }
@@ -97,8 +117,8 @@
     union {
        boost::uint16_t s;
        struct {
-           boost::uint8_t c0;
-           boost::uint8_t c1;
+           Network::byte_t c0;
+           Network::byte_t c1;
        } c;
     } u;
           
@@ -111,25 +131,25 @@
     // Little-endian machine: byte-swap the word
 
     // A conveniently-typed pointer to the source data
-    boost::uint8_t *x = static_cast<boost::uint8_t *>(word);
+    Network::byte_t *x = static_cast<Network::byte_t *>(word);
 
     switch (size) {
     case 2: // 16-bit integer
       {
-       boost::uint8_t c;
+       Network::byte_t c;
        c=x[0]; x[0]=x[1]; x[1]=c;
        break;
       }
     case 4: // 32-bit integer
       {
-       boost::uint8_t c;
+       Network::byte_t c;
        c=x[0]; x[0]=x[3]; x[3]=c;
        c=x[1]; x[1]=x[2]; x[2]=c;
        break;
       }
     case 8: // 64-bit integer
       {
-       boost::uint8_t c;
+       Network::byte_t c;
        c=x[0]; x[0]=x[7]; x[7]=c;
        c=x[1]; x[1]=x[6]; x[6]=c;
        c=x[2]; x[2]=x[5]; x[5]=c;
@@ -143,12 +163,12 @@
 
 #if 0
 bool
-AMF::parseAMF(boost::uint8_t * /* in */)
+AMF::parseAMF(Network::byte_t * /* in */)
 {
 //    GNASH_REPORT_FUNCTION;
 
 #if 0
-    boost::uint8_t *x = in;
+    Network::byte_t *x = in;
 
     while (*x != Element::OBJECT_END) {
         x = readElements(x);
@@ -159,10 +179,10 @@
 }
 
 vector<AMF::amf_element_t *> *
-AMF::readElements(boost::uint8_t *in)
+AMF::readElements(Network::byte_t *in)
 {
     GNASH_REPORT_FUNCTION;
-    boost::uint8_t *x = in;
+    Network::byte_t *x = in;
     astype_e type = (astype_e)*x;
     bool boolshift;
     const char *mstr = NULL;
@@ -269,15 +289,15 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeNumber(double indata)
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_NUMBER_SIZE + AMF_HEADER_SIZE;
     double num;
     // Encode the data as a 64 bit, big-endian, numeric value
-    boost::uint8_t *ptr = new boost::uint8_t[pktsize + 1];
-    boost::uint8_t *x = ptr;
+    Network::byte_t *ptr = new Network::byte_t[pktsize + 1];
+    Network::byte_t *x = ptr;
     memset(x, 0, pktsize);
     *x++ = (char)Element::NUMBER;
     memcpy(&num, &indata, AMF_NUMBER_SIZE);
@@ -295,14 +315,14 @@
 ///
 /// Although a boolean is one byte in size, swf uses 16bit short integers
 /// heavily, so this value is also a short.
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeBoolean(bool flag)
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_HEADER_SIZE;
 
-    boost::uint8_t*ptr = new boost::uint8_t[pktsize + 1];
-    boost::uint8_t* x = ptr;
+    Network::byte_t*ptr = new Network::byte_t[pktsize + 1];
+    Network::byte_t* x = ptr;
     memset(x, 0, pktsize);
     // Encode a boolean value. 0 for false, 1 for true
     *x++ = (char)Element::BOOLEAN;
@@ -319,15 +339,15 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeObject(const boost::uint8_t *data, int size)
+Network::byte_t *
+AMF::encodeObject(const Network::byte_t *data, int size)
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_HEADER_SIZE + size;
 
     // Encode an XML object. The data follows a 4 byte length
     // field. (which must be big-endian)
-    boost::uint8_t *x = new boost::uint8_t[pktsize + 1];
+    Network::byte_t *x = new Network::byte_t[pktsize + 1];
     memset(x, 0, pktsize);
     *x++ = Element::OBJECT;
     uint32_t num = size;
@@ -342,12 +362,12 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeUndefined()
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_HEADER_SIZE;;
-    boost::uint8_t* x = new boost::uint8_t[pktsize + 1];
+    Network::byte_t* x = new Network::byte_t[pktsize + 1];
     memset(x, 0, pktsize);
     *x++ = (char)Element::UNDEFINED;
 //    *x = *static_cast<const char *>(flag);
@@ -361,12 +381,12 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeUnsupported()
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_HEADER_SIZE;;
-    boost::uint8_t* x = new boost::uint8_t[pktsize + 1];
+    Network::byte_t* x = new Network::byte_t[pktsize + 1];
     memset(x, 0, pktsize);
     *x++ = (char)Element::UNSUPPORTED;
 //    *x = *static_cast<const char *>(flag);
@@ -380,11 +400,11 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *encodeDate(boost::uint8_t *data)
+Network::byte_t *encodeDate(Network::byte_t *data)
 {
 //    GNASH_REPORT_FUNCTION;
     int pktsize = AMF_HEADER_SIZE;;
-    boost::uint8_t *x = new boost::uint8_t[pktsize + 1];
+    Network::byte_t *x = new Network::byte_t[pktsize + 1];
     memset(x, 0, pktsize);
     *x++ = Element::DATE;
     double num = *reinterpret_cast<const double*>(data);
@@ -398,7 +418,7 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeNull()
 {
 //    GNASH_REPORT_FUNCTION;
@@ -412,8 +432,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeXMLObject(boost::uint8_t * /*data */, int /* size */)
+Network::byte_t *
+AMF::encodeXMLObject(Network::byte_t * /*data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("XML AMF objects not supported yet");
@@ -426,8 +446,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeTypedObject(boost::uint8_t * /* data */, int /* size */)
+Network::byte_t *
+AMF::encodeTypedObject(Network::byte_t * /* data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Typed AMF objects not supported yet");
@@ -440,8 +460,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeReference(boost::uint8_t * /* data */, int /* size */)
+Network::byte_t *
+AMF::encodeReference(Network::byte_t * /* data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Reference AMF objects not supported yet");
@@ -454,8 +474,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeMovieClip(boost::uint8_t * /*data */, int /* size */)
+Network::byte_t *
+AMF::encodeMovieClip(Network::byte_t * /*data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Movie Clip AMF objects not supported yet");
@@ -468,8 +488,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeECMAArray(boost::uint8_t * /*data */, int /* size */)
+Network::byte_t *
+AMF::encodeECMAArray(Network::byte_t * /*data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("ECMA Array AMF objects not supported yet");
@@ -482,8 +502,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeLongString(boost::uint8_t * /* data */, int /* size */)
+Network::byte_t *
+AMF::encodeLongString(Network::byte_t * /* data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Long String AMF objects not supported yet");
@@ -496,8 +516,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeRecordSet(boost::uint8_t * /* data */, int /* size */)
+Network::byte_t *
+AMF::encodeRecordSet(Network::byte_t * /* data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Reecord Set AMF objects not supported yet");
@@ -511,8 +531,8 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
-AMF::encodeStrictArray(boost::uint8_t * /* data */, int /* size */)
+Network::byte_t *
+AMF::encodeStrictArray(Network::byte_t * /* data */, int /* size */)
 {
 //    GNASH_REPORT_FUNCTION;
     log_unimpl("Strict Array AMF objects not supported yet");
@@ -525,7 +545,7 @@
 /// @return a binary AMF packet in big endian format (header,data) which
 /// needs to be deleted[] after being used.
 ///
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeElement(const char *str)
 {
 //    GNASH_REPORT_FUNCTION;
@@ -534,8 +554,8 @@
     int pktsize = strlen(str) + AMF_HEADER_SIZE;
     // Encode a string value. The data follows a 2 byte length
     // field. (which must be big-endian)
-    boost::uint8_t *ptr = new boost::uint8_t[pktsize + 1];
-    boost::uint8_t *x = ptr;
+    Network::byte_t *ptr = new Network::byte_t[pktsize + 1];
+    Network::byte_t *x = ptr;
     memset(x, 0, pktsize);
     *x++ = Element::STRING;
     length = strlen(str);
@@ -566,7 +586,7 @@
 /// normal ASCII. It may be that these need to be converted to wide
 /// characters, but for now we just leave them as standard multibyte
 /// characters.
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeElement(Element *el)
 {
 //    GNASH_REPORT_FUNCTION;
@@ -648,7 +668,7 @@
 /// @return a newly allocated byte array.
 /// to be deleted by caller using delete [] operator, or NULL
 ///
-vector<boost::uint8_t> *
+vector<Network::byte_t> *
 AMF::encodeElement(vector<amf::Element *> &data)
 {
     GNASH_REPORT_FUNCTION;
@@ -664,21 +684,21 @@
        size += el->getLength() + AMF_HEADER_SIZE;
 //        el->dump();
     }
-    vector<boost::uint8_t> *vec = new vector<boost::uint8_t>;
-    boost::uint8_t* ptr = new boost::uint8_t[size + 1];
+    vector<Network::byte_t> *vec = new vector<Network::byte_t>;
+    Network::byte_t* ptr = new Network::byte_t[size + 1];
     memset(ptr, 0, size + 1);
     
-//    boost::uint8_t *x = ptr;
+//    Network::byte_t *x = ptr;
     size = 0;
     for (ait = data.begin(); ait != data.end(); ait++) {
        amf::Element *el = (*(ait));
 //     el->dump();
-       boost::uint8_t *tmp = encodeElement(el);
-       boost::uint8_t *y = tmp;
+       Network::byte_t *tmp = encodeElement(el);
+       Network::byte_t *y = tmp;
 #if 0
-       boost::uint8_t *hexint;
-       hexint = new boost::uint8_t[(el->getLength() + 4) *3];
-       hexify((boost::uint8_t *)hexint, (boost::uint8_t *)tmp,
+       Network::byte_t *hexint;
+       hexint = new Network::byte_t[(el->getLength() + 4) *3];
+       hexify((Network::byte_t *)hexint, (Network::byte_t *)tmp,
               el->getLength() + AMF_HEADER_SIZE, true);
        log_debug(_("The packet head is: 0x%s"), hexint);
 #endif
@@ -709,7 +729,7 @@
            size = 3;
        }
        for (int i=0; i<size; i++) {
-           boost::uint8_t c = *y;
+           Network::byte_t c = *y;
            y++;
 //         printf("0x%x(%c) ", c, (isalpha(c)) ? c : '.');
            vec->push_back(c);
@@ -974,11 +994,11 @@
 }
 
 char *
-AMF::extractString(const boost::uint8_t *in)
+AMF::extractString(const Network::byte_t *in)
 {
 //    GNASH_REPORT_FUNCTION;
     boost::int8_t *buf = NULL;
-    boost::uint8_t *x = const_cast<boost::uint8_t *>(in);
+    Network::byte_t *x = const_cast<Network::byte_t *>(in);
     
     if (*x == Element::STRING) {
         x++;
@@ -997,10 +1017,10 @@
 }
 
 double
-AMF::extractNumber(const boost::uint8_t *in)
+AMF::extractNumber(const Network::byte_t *in)
 {
 //    GNASH_REPORT_FUNCTION;    
-    boost::uint8_t *x = const_cast<uint8_t *>(in);
+    Network::byte_t *x = const_cast<uint8_t *>(in);
 //    double *num = new double;
     double num = 0.0;
 //    memset(num, 0, AMF_NUMBER_SIZE);
@@ -1018,7 +1038,7 @@
 
 Element &
 AMF::createElement(amf_element_t *el, astype_e type,
-                 const std::string &name, boost::uint8_t *data, int nbytes)
+                 const std::string &name, Network::byte_t *data, int nbytes)
 {
 //    GNASH_REPORT_FUNCTION;
     log_debug("Creating element %s", name.c_str());
@@ -1048,7 +1068,7 @@
 //     el->name = name;
 //     el->length = AMF_NUMBER_SIZE;
 // //    char *numptr = (char *)&data;
-//     el->data = new boost::uint8_t[AMF_NUMBER_SIZE + 1];
+//     el->data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
 //     memset(el->data, 0, AMF_NUMBER_SIZE + 1);
 //     memcpy(el->data, &data, AMF_NUMBER_SIZE);
 
@@ -1073,7 +1093,7 @@
     el->name = name;
     el->length = AMF_NUMBER_SIZE;
 //    char *numptr = (char *)&data;
-    el->data = new boost::uint8_t[AMF_NUMBER_SIZE + 1];
+    el->data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
     memset(el->data, 0, AMF_NUMBER_SIZE + 1);
     memcpy(el->data, &data, AMF_NUMBER_SIZE);
 
@@ -1090,7 +1110,7 @@
     el->name = name;
     el->length = strlen(data);
     char *str = const_cast<char *>(data);
-    el->data = reinterpret_cast<boost::uint8_t *>(str);
+    el->data = reinterpret_cast<Network::byte_t *>(str);
     return el;
 }
 
@@ -1104,7 +1124,7 @@
     el->name = name;
     el->length = data.size();
     char *str = const_cast<char *>(data.c_str());
-    el->data = reinterpret_cast<boost::uint8_t *>(str);
+    el->data = reinterpret_cast<Network::byte_t *>(str);
     return el;
 }
 
@@ -1125,7 +1145,7 @@
     el->type = AMF::BOOLEAN;
     el->name = name;
     el->length = 1;
-    el->data = new boost::uint8_t[sizeof(uint16_t)];
+    el->data = new Network::byte_t[sizeof(uint16_t)];
     memset(el->data, 0, sizeof(uint16_t));
     *el->data = data;
     return el;
@@ -1164,11 +1184,11 @@
     GNASH_REPORT_FUNCTION;
     outsize = el->getName().size() + el->getLength() + 5; // why +5 here ?
 
-    boost::uint8_t *out = new boost::uint8_t[outsize + 4]; // why +4 here ?
-    boost::uint8_t *end = out + outsize+4; // why +4 ?
+    Network::byte_t *out = new Network::byte_t[outsize + 4]; // why +4 here ?
+    Network::byte_t *end = out + outsize+4; // why +4 ?
 
     memset(out, 0, outsize + 2); // why +2 here ?
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *tmpptr = out;
 
     // Add the length of the string for the name of the variable
     size_t length = el->getName().size();
@@ -1215,14 +1235,14 @@
 }
 
 #if 0
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeVariable(const char *name, bool flag)
 {
 //    GNASH_REPORT_FUNCTION;
     
     int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-    boost::uint8_t *out = new uint8_t[outsize];
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *out = new uint8_t[outsize];
+    Network::byte_t *tmpptr = out;
 
     size_t length = strlen(name);
     short enclength = length;
@@ -1238,13 +1258,13 @@
     return out;    
 }
 
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeVariable(const char *name)
 {
 //    GNASH_REPORT_FUNCTION;
     size_t outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-    boost::uint8_t *out = new boost::uint8_t[outsize];
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *out = new Network::byte_t[outsize];
+    Network::byte_t *tmpptr = out;
 
     size_t length = strlen(name);
     short enclength = length;
@@ -1259,13 +1279,13 @@
     return out;    
 }
 
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeVariable(const char *name, double bignum)
 {
 //    GNASH_REPORT_FUNCTION;
     int outsize = strlen(name) + AMF_NUMBER_SIZE + 5;
-    boost::uint8_t *out = new boost::uint8_t[outsize];
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *out = new Network::byte_t[outsize];
+    Network::byte_t *tmpptr = out;
     double newnum = bignum;
     char *numptr = (char *)&newnum;
 
@@ -1290,8 +1310,8 @@
 //    GNASH_REPORT_FUNCTION;
 
     int outsize = strlen(name) + strlen(val) + 5;
-    boost::uint8_t *out = new boost::uint8_t[outsize];
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *out = new Network::byte_t[outsize];
+    Network::byte_t *tmpptr = out;
 
     size_t length = strlen(name);
     short enclength = length;
@@ -1312,14 +1332,14 @@
     return out;
 }
 
-boost::uint8_t *
+Network::byte_t *
 AMF::encodeVariable(std::string &name, std::string &val)
 {
 //    GNASH_REPORT_FUNCTION;
 
     int outsize = name.size() + val.size() + 5;
-    boost::uint8_t *out = new boost::uint8_t[outsize];
-    boost::uint8_t *tmpptr = out;
+    Network::byte_t *out = new Network::byte_t[outsize];
+    Network::byte_t *tmpptr = out;
     short length;
 
     length = name.size() && 0xffff;
@@ -1339,116 +1359,8 @@
     return out;
 }
 
-int
-AMF::headerSize(boost::int8_t header)
-{
-//    GNASH_REPORT_FUNCTION;
-    
-    int headersize = -1;
-    
-    switch (header & AMF_HEADSIZE_MASK) {
-      case HEADER_12:
-          headersize = 12;
-          break;
-      case HEADER_8:
-          headersize = 8;
-          break;
-      case HEADER_4:
-          headersize = 4;
-          break;
-      case HEADER_1:
-          headersize = 11;
-          break;
-      default:
-          log_error(_("AMF Header size bits (0x%X) out of range"),
-                       header & AMF_HEADSIZE_MASK);
-          headersize = 1;
-          break;
-    };
-
-    return headersize;
-}
-
-int
-AMF::parseHeader(boost::uint8_t *in)
-{
-//    GNASH_REPORT_FUNCTION;
-
-    boost::uint8_t *tmpptr = in;
-    
-    log_debug (_("AMF header byte is: 0x%X"), *in);
-
-    _amf_index = *tmpptr & AMF_INDEX_MASK;
-    log_debug (_("The AMF channel index is %d"), _amf_index);
-    
-    _header_size = headerSize(*tmpptr++);
-    log_debug (_("The header size is %d"), _header_size);
-
-#if 1
-    boost::uint8_t *hexint;
-    hexint = new boost::uint8_t[(_header_size + 3) *3];
-    hexify((boost::uint8_t *)hexint, (uint8_t *)in, _header_size, false);
-    log_debug(_("The packet head is: 0x%s"), hexint);
-#endif
-    if (_header_size >= 4) {
-        hexify((boost::uint8_t *)hexint, (boost::uint8_t *)tmpptr, 3, false);
-        _mystery_word = *tmpptr++;
-        _mystery_word = (_mystery_word << 12) + *tmpptr++;
-        _mystery_word = (_mystery_word << 8) + *tmpptr++;
-        log_debug(_("The mystery word is: %d or 0x%s"), _mystery_word, hexint);
-    }
-
-    if (_header_size >= 8) {
-        hexify((boost::uint8_t *)hexint, (boost::uint8_t *)tmpptr, 3, false);
-        _total_size = *tmpptr++;
-        _total_size = (_total_size << 12) + *tmpptr++;
-        _total_size = (_total_size << 8) + *tmpptr++;
-        _total_size = _total_size & 0xffffff;
-        log_debug(_("The body size is: %d, or 0x%s"), _total_size, hexint);
-        _amf_data = new uint8_t(_total_size+1);
-        _seekptr = _amf_data;
-//        memset(_amf_data, 0, _total_size+1);
-    }
-
-    if (_header_size >= 8) {
-        hexify((boost::uint8_t *)hexint, (boost::uint8_t *)tmpptr, 1, false);
-        _type = *(content_types_e *)tmpptr;
-        tmpptr++;
-        log_debug(_("The type is: %d, or 0x%s"), _type, hexint);
-    }
-
-    switch(_type) {
-      case CHUNK_SIZE:
-      case BYTES_READ:
-      case PING:
-      case SERVER:
-      case CLIENT:
-      case VIDEO_DATA:
-      case NOTIFY:
-      case SHARED_OBJ:
-      case INVOKE:
-          _packet_size = AMF_VIDEO_PACKET_SIZE;
-          break;
-      case AUDIO_DATA:
-          _packet_size = AMF_AUDIO_PACKET_SIZE;
-          break;
-      default:
-          log_error (_("ERROR: Unidentified AMF header data type %d"), _type);
-          break;
-    };
-    
-    if (_header_size == 12) {
-        hexify((boost::uint8_t *)hexint, (boost::uint8_t *)tmpptr, 3, false);
-        _src_dest = *(reinterpret_cast<amfsource_e *>(tmpptr));
-        tmpptr += sizeof(unsigned int);
-        log_debug(_("The source/destination is: %d, or 0x%s"), _src_dest, 
hexint);
-    }
-
-    return _packet_size;
-}
-
-boost::uint8_t *
-AMF::addPacketData(boost::uint8_t *data, int bytes)
+Network::byte_t *
+AMF::addPacketData(Network::byte_t *data, int bytes)
 {
 //    GNASH_REPORT_FUNCTION;
     memcpy(_seekptr, data, bytes);
@@ -1465,12 +1377,12 @@
 }
 #endif
 
-boost::uint8_t *
-AMF::extractElement(Element *el, boost::uint8_t *in)
+Network::byte_t *
+AMF::extractElement(Element *el, Network::byte_t *in)
 {
 //    GNASH_REPORT_FUNCTION;
 
-    boost::uint8_t *tmpptr;
+    Network::byte_t *tmpptr;
 
 //    uint8_t hexint[(bytes*2)+1];
     short length;
@@ -1484,14 +1396,6 @@
 //         return 0;
 //     }
 
-#if 0
-    boost::uint8_t* hexint;
-    hexint =  (boost::uint8_t*) malloc((bytes * 3) + 12);
-    hexify((boost::uint8_t *)hexint, (boost::uint8_t *)in, bytes, true);
-    log_debug(_("The packet body is: 0x%s"), hexint);
-    free(hexint);
-#endif
-
     tmpptr = in;
     
 // All elements look like this:
@@ -1554,13 +1458,13 @@
     return tmpptr;
 }
 
-boost::uint8_t *
-AMF::extractVariable(Element *el, boost::uint8_t *in)
+Network::byte_t *
+AMF::extractVariable(Element *el, Network::byte_t *in)
 {
 //    GNASH_REPORT_FUNCTION;
     
-    boost::uint8_t buffer[AMF_PACKET_SIZE];
-    boost::uint8_t *tmpptr = in;
+    Network::byte_t buffer[AMF_PACKET_SIZE];
+    Network::byte_t *tmpptr = in;
     boost::int16_t length;
 
 //     if (el == 0) {
@@ -1587,11 +1491,6 @@
        return 0;
     }
     
-#if 0
-    uint8_t hexint[AMF_PACKET_SIZE];
-    hexify((uint8_t *)hexint, (uint8_t *)tmpptr, length*3, true);
-    log_debug(_("The element is: 0x%s"), hexint);
-#endif
     tmpptr += 2;
     // get the name of the element
     if (length > 0) {
@@ -1646,8 +1545,8 @@
          length = ntohs((*(const short *)tmpptr) & 0xffff);
           tmpptr += sizeof(short);
           el->setLength(length);
-         boost::uint8_t *str;
-         str = new boost::uint8_t[length + 1];
+         Network::byte_t *str;
+         str = new Network::byte_t[length + 1];
          memset(str, 0, length + 1);
          memcpy(str, tmpptr, length);
          el->setData(str);

Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- libamf/amf.h        28 Mar 2008 12:22:44 -0000      1.33
+++ libamf/amf.h        29 Mar 2008 19:35:53 -0000      1.34
@@ -28,6 +28,7 @@
 #include <map>
 #include <boost/cstdint.hpp>
 
+#include "network.h"
 #include "element.h"
 #include "amfutf8.h"
 #include "dsodefs.h"
@@ -37,11 +38,6 @@
 
 const char AMF_NUMBER_SIZE = 0x08;
 
-typedef enum {
-    CLIENT,                     // Flash player
-    SERVER                      // Flash com server
-} amfsource_e;
-
 const char AMF_VERSION = 0;
 const int  AMF_HEADSIZE_MASK = 0xc0;
 const char AMF_HEADER_SIZE = 0x03;
@@ -73,8 +69,8 @@
 // The third and fourth bytes form an integer value that specifies the
 // number of headers. 
 typedef struct {
-    boost::uint8_t version;
-    boost::uint8_t source;
+    gnash::Network::byte_t version;
+    gnash::Network::byte_t source;
     boost::uint32_t  count;
 } amfpacket_t;
 
@@ -86,13 +82,6 @@
 
 class DSOEXPORT AMF {
 public:
-    typedef enum {
-        HEADER_12 = 0x0,
-        HEADER_8  = 0x40,
-        HEADER_4  = 0x80,
-        HEADER_1  = 0xc0
-    } amf_headersize_e;    
-    
 //     typedef enum {
 //         Byte,
 //         Int,
@@ -103,22 +92,6 @@
 //         LongUTF8
 //     } amftype_e;
     typedef enum {
-        NONE = 0x0,
-        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
-    } content_types_e;
-    typedef enum {
         CONNECT = 0x01,
         DISCONNECT = 0x02,
         SET_ATTRIBUTE = 0x03,
@@ -131,7 +104,17 @@
         DELETE_ATTRIBYTE = 0x0a,
         INITIAL_DATA = 0x0b
     } shared_obj_types_e;
-
+    typedef enum {
+       FILETYPE_ERROR = -1,
+       FILETYPE_NONE = 0,
+       FILETYPE_HTML,
+       FILETYPE_SWF,
+       FILETYPE_VIDEO,
+       FILETYPE_AUDIO,
+       FILETYPE_MP3,
+       FILETYPE_FCS,
+       FILETYPE_OSCP
+    } filetype_e;
     AMF();
     AMF(int size);
     ~AMF();
@@ -145,97 +128,97 @@
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeElement(const char *str);
+    static gnash::Network::byte_t *encodeElement(const char *str);
 
     /// Encode a Boolean object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeBoolean(bool flag);
+    static gnash::Network::byte_t *encodeBoolean(bool flag);
 
     /// Encode an "Undefined" object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeUndefined();
+    static gnash::Network::byte_t *encodeUndefined();
 
     /// Encode a "NULL" object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeNull();
+    static gnash::Network::byte_t *encodeNull();
 
     /// Encode a "Unsupported" object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static  boost::uint8_t *encodeUnsupported();
+    static  gnash::Network::byte_t *encodeUnsupported();
 
     /// Encode an XML object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeXMLObject(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeXMLObject(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a Typed Object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeTypedObject(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeTypedObject(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a Reference to an object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeReference(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeReference(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a Movie Clip
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeMovieClip(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeMovieClip(gnash::Network::byte_t 
*data, int size);
 
     /// Encode an ECMA Array
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeECMAArray(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeECMAArray(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a long string
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeLongString(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeLongString(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a Record Set
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeRecordSet(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeRecordSet(gnash::Network::byte_t 
*data, int size);
 
     /// Encode a Date
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeDate(boost::uint8_t *data);
+    static gnash::Network::byte_t *encodeDate(gnash::Network::byte_t *data);
 
     /// Encode a Strict Array
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeStrictArray(boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeStrictArray(gnash::Network::byte_t 
*data, int size);
     
     /// Encode an object
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeObject(const boost::uint8_t *data, int size);
+    static gnash::Network::byte_t *encodeObject(const gnash::Network::byte_t 
*data, int size);
 
     /// Encode a 64 bit number
     ///
     /// @return a binary AMF packet in big endian format (header,data)
     ///
-    static boost::uint8_t *encodeNumber(double num);
+    static gnash::Network::byte_t *encodeNumber(double num);
     
     /// Encode a element. 
     ///
@@ -244,7 +227,7 @@
     /// @return a newly allocated byte array.
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t *encodeElement(amf::Element *el);
+    static gnash::Network::byte_t *encodeElement(amf::Element *el);
 
     /// Encode an array of elements. 
     ///
@@ -253,7 +236,7 @@
     /// @return a newly allocated byte array.
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static std::vector<boost::uint8_t> *encodeElement(std::vector<amf::Element 
*> &els);
+    static std::vector<gnash::Network::byte_t> 
*encodeElement(std::vector<amf::Element *> &els);
 
     /// Encode a variable. 
     //
@@ -265,7 +248,7 @@
     ///         in form of a newly allocated byte array.
     ///         to be deleted by caller using delete [] operator, or NULL
     ///
-    boost::uint8_t *encodeVariable(amf::Element *el, size_t& outsize);
+    gnash::Network::byte_t *encodeVariable(amf::Element *el, size_t& outsize);
 
 #if 0
     /// Encode an element
@@ -281,40 +264,40 @@
     ///
     /// @return an amf packet (header,data)
     ///
-    static boost::uint8_t* encodeElement(Element::astype_e type, const void 
*in, int nbytes);
+    static gnash::Network::byte_t* encodeElement(Element::astype_e type, const 
void *in, int nbytes);
 
     /// @return a newly allocated byte array,
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t* encodeVariable(const char *name);
+    static gnash::Network::byte_t* encodeVariable(const char *name);
 
     /// Encode a boolean variable. This is a name followed by a boolean value.
     //
     /// @return a newly allocated byte array,
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t* encodeVariable(const char *name, bool flag);
+    static gnash::Network::byte_t* encodeVariable(const char *name, bool flag);
 
     /// Encode a variable. 
     //
     /// @return a newly allocated byte array,
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t* encodeVariable(const char *name, double num);
+    static gnash::Network::byte_t* encodeVariable(const char *name, double 
num);
 
     /// Encode a variable. 
     //
     /// @return a newly allocated byte array,
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t* encodeVariable(std::string &name, std::string &val);
+    static gnash::Network::byte_t* encodeVariable(std::string &name, 
std::string &val);
 
     /// Encode a variable. 
     //
     /// @return a newly allocated byte array,
     /// to be deleted by caller using delete [] operator, or NULL
     ///
-    static boost::uint8_t* encodeVariable(const char *name, const char *val);
+    static gnash::Network::byte_t* encodeVariable(const char *name, const char 
*val);
 
     void *encodeRTMPHeader(int amf_index, amf_headersize_e head_size, int 
total_size,
                            content_types_e type, amfsource_e routing);
@@ -322,7 +305,7 @@
 //     amfbody_t *encodeBody(amfutf8_t *target, amfutf8_t *response, int 
nbytes, void *data);
 //    amfpacket_t *encodePacket(std::vector<amfhead_t *> messages);
 
-//    std::vector<amf_element_t> *readElements(boost::uint8_t *in);
+//    std::vector<amf_element_t> *readElements(gnash::Network::byte_t *in);
     
     /// Extract the string from a string-type AMF packet
     //
@@ -336,39 +319,31 @@
     //
     // Methods for extracting data from big endian formatted raw AMF data.
     //
-    amf::Element::astype_e extractElementHeader(boost::uint8_t *in)
+    amf::Element::astype_e extractElementHeader(gnash::Network::byte_t *in)
        { return *(reinterpret_cast<amf::Element::astype_e *>(in)); };
     
-    boost::uint8_t *extractElement(amf::Element *el, boost::uint8_t *in);
-    boost::uint8_t *extractVariable(amf::Element *el, boost::uint8_t *in);
+    gnash::Network::byte_t *extractElement(amf::Element *el, 
gnash::Network::byte_t *in);
+    gnash::Network::byte_t *extractVariable(amf::Element *el, 
gnash::Network::byte_t *in);
     
 #if 0
     // FIXME: these should return an Element, and then use to_*() to convert.
-    char *extractString(const boost::uint8_t* in);
+    char *extractString(const gnash::Network::byte_t* in);
 
-    double extractNumber(const boost::uint8_t *in);
-    Element &extractObject(const boost::uint8_t *in);
+    double extractNumber(const gnash::Network::byte_t *in);
+    Element &extractObject(const gnash::Network::byte_t *in);
     
 
     // FIXME: these are all for RTMP, and should be moved
-    bool parseAMF(boost::uint8_t *in);
-    static int headerSize(int8_t header);
+    bool parseAMF(gnash::Network::byte_t *in);
     int packetReadAMF(int bytes);
 
-    int parseHeader(boost::uint8_t *in);
     int parseBody();
-    int getHeaderSize()         { return _header_size; }; 
-    int getTotalSize()          { return _total_size; }; 
-    int getPacketSize()         { return _packet_size; };
-    int getMysteryWord()        { return _mystery_word; };
-    amfsource_e getRouting()    { return _src_dest; };
-    int getAMFIndex()           { return _amf_index; };
-    boost::uint8_t *addPacketData(boost::uint8_t *data, int bytes);
+    gnash::Network::byte_t *addPacketData(gnash::Network::byte_t *data, int 
bytes);
 #endif    
 
-    content_types_e getType()   { return _type; };
+//    content_types_e getType()   { return _type; };
 //    std::map<std::string, Element> *getElements() { return &_elements; };
-    boost::uint8_t *appendPtr(boost::uint8_t *data, boost::uint8_t *var,
+    gnash::Network::byte_t *appendPtr(gnash::Network::byte_t *data, 
gnash::Network::byte_t *var,
                              int bytes) {
        memcpy(data, var, bytes);
        return data += bytes;
@@ -383,11 +358,11 @@
     int                 _header_size;
     int                 _total_size;
     int                 _packet_size;
-    boost::uint8_t      *_amf_data;
-    boost::uint8_t      *_seekptr;
+    gnash::Network::byte_t      *_amf_data;
+    gnash::Network::byte_t      *_seekptr;
     amfsource_e         _src_dest;
 #endif
-    content_types_e     _type;
+//    content_types_e     _type;
     int                 _mystery_word;
 };
  

Index: libamf/element.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/element.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libamf/element.cpp  5 Mar 2008 11:54:33 -0000       1.10
+++ libamf/element.cpp  29 Mar 2008 19:35:53 -0000      1.11
@@ -590,7 +590,8 @@
       case Element::RECORD_SET:
       case Element::XML_OBJECT:
       case Element::TYPED_OBJECT:
-         cerr << "AMF data is: 0x%s" << hexify(_data, _length, false) << endl;
+//       cerr << "AMF data is: 0x" << hexify(_data, _length, false) << endl;
+         log_debug("FIXME: got a typed object!");
          break;
       case Element::VARIABLE:
       case Element::FUNCTION:

Index: libamf/protocol.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/protocol.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libamf/protocol.h   21 Jan 2008 22:55:27 -0000      1.7
+++ libamf/protocol.h   29 Mar 2008 19:35:53 -0000      1.8
@@ -15,9 +15,6 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-// 
-//
-
 #ifndef _PROTOCOL_H_
 #define _PROTOCOL_H_
 

Index: libamf/sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- libamf/sol.cpp      5 Mar 2008 11:54:33 -0000       1.24
+++ libamf/sol.cpp      29 Mar 2008 19:35:53 -0000      1.25
@@ -388,7 +388,6 @@
 void
 SOL::dump()
 {
-    uint8_t *hexint;
     vector<amf::Element *>::iterator it;
 
     cerr << "Dumping SOL file" << endl;

Index: libnet/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libnet/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libnet/Makefile.am  28 Mar 2008 21:30:24 -0000      1.2
+++ libnet/Makefile.am  29 Mar 2008 19:35:53 -0000      1.3
@@ -55,6 +55,7 @@
        network.h \
        netstats.h \
        rtmp.h \
+       rtmp_server.h \
        statistics.h
 
 libgnashnet_la_SOURCES = \
@@ -66,6 +67,7 @@
        network.cpp \
        netstats.cpp \
        rtmp.cpp \
+       rtmp_server.cpp \
        statistics.cpp
 
 # Rebuild with GCC 4.x Mudflap support

Index: libnet/buffer.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/buffer.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libnet/buffer.cpp   28 Mar 2008 21:30:24 -0000      1.2
+++ libnet/buffer.cpp   29 Mar 2008 19:35:53 -0000      1.3
@@ -80,18 +80,6 @@
     }
 }
 
-Network::byte_t *
-Buffer::find(Network::byte_t b)
-{
-//    GNASH_REPORT_FUNCTION;
-    for (size_t i=0; i< _nbytes; i++) {
-       if ( *(_ptr + i) == b) {
-           return _ptr + i;
-       }
-    }
-    return 0;
-}
-
 // Put data into the buffer
 void
 Buffer::copy(Network::byte_t *data, size_t nbytes)
@@ -159,6 +147,78 @@
     return false;
 }
 
+Network::byte_t *
+Buffer::find(Network::byte_t b, size_t start)
+{
+    GNASH_REPORT_FUNCTION;
+    for (size_t i=start; i< _nbytes; i++) {
+       if ( *(_ptr + i) == b) {
+           return _ptr + i;
+       }
+    }
+    return 0;
+}
+
+// Find a byte in the buffer
+// Network::byte_t *
+// Buffer::find(char c)
+// {
+// //    GNASH_REPORT_FUNCTION;
+//     return find(static_cast<Network::byte_t>(c), 0);
+// }
+
+Network::byte_t *
+Buffer::find(Network::byte_t c)
+{
+//    GNASH_REPORT_FUNCTION;
+    return find(static_cast<Network::byte_t>(c), 0);
+}   
+
+// // Drop a character or range of characters without resizing
+// Network::byte_t
+// Buffer::remove(char c)
+// {
+// //    GNASH_REPORT_FUNCTION;
+//     return remove(reinterpret_cast<Network::byte_t>(c));
+// }
+
+Network::byte_t *
+Buffer::remove(Network::byte_t c)
+{
+    GNASH_REPORT_FUNCTION;
+    Network::byte_t *start = find(c, 0);
+    log_debug("FRAME MARK is at %x", (void *)start);
+    if (start == 0) {
+       return 0;
+    }
+//    std::copy((start + 1), end(), start);
+    *start = '*';
+//    *end() = 0;
+//    _nbytes--;
+
+    return _ptr;
+}
+
+Network::byte_t *
+Buffer::remove(int start)
+{
+//    GNASH_REPORT_FUNCTION;
+    std::copy((_ptr + start + 1), end(), (_ptr + start)),
+    *end() = 0;
+    _nbytes--;
+    return _ptr;
+}
+
+Network::byte_t *
+Buffer::remove(int start, int stop)
+{
+//    GNASH_REPORT_FUNCTION;
+    std::copy((_ptr + start), end(), (_ptr + stop)),
+//    *end() = 0;
+    _nbytes--;
+    return _ptr;
+}
+
 // Just reset to having no data, but still having storage
 void
 Buffer::empty()

Index: libnet/buffer.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/buffer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libnet/buffer.h     29 Mar 2008 03:12:45 -0000      1.3
+++ libnet/buffer.h     29 Mar 2008 19:35:53 -0000      1.4
@@ -48,11 +48,21 @@
     void copy(gnash::Network::byte_t *data) { copy(data, _nbytes); };
     void copy(std::string &str);
     
+    // Find a byte in the buffer
+//    Network::byte_t *find(char c);
+    Network::byte_t *find(Network::byte_t b);
+    Network::byte_t *find(Network::byte_t b, size_t start);
+    
+    // Drop a byte or range of characters without resizing
+//    Network::byte_t *remove(char c);
+    Network::byte_t *remove(Network::byte_t c);
+    Network::byte_t *remove(int x);
+    Network::byte_t *remove(int x, int y);
+    
     // Accessors
-    gnash::Network::byte_t *find(gnash::Network::byte_t b);
-    gnash::Network::byte_t *begin() { return _ptr ; };
-    gnash::Network::byte_t *end() { return _ptr + _nbytes; };
-    gnash::Network::byte_t *reference() { return _ptr; }
+    Network::byte_t *begin() { return _ptr ; };
+    Network::byte_t *end() { return _ptr + _nbytes; };
+    Network::byte_t *reference() { return _ptr; }
     size_t size() { return _nbytes; }
     void setSize(size_t nbytes) { _nbytes = nbytes; };
     
@@ -63,14 +73,14 @@
     // Test against other buffers
     bool operator==(Buffer *buf);
     bool operator==(Buffer &buf);
-    gnash::Network::byte_t operator[](int x) { return *(_ptr + x); };
+    Network::byte_t operator[](int x) { return *(_ptr + x); };
     
     // debug stuff, not need for running Cygnal
     void dump();
 private:
     void *init(size_t nbytes);
-    gnash::Network::byte_t *_ptr;
-    int         _nbytes;
+    Network::byte_t *_ptr;
+    size_t         _nbytes;
 #ifdef USE_STATS_BUFFERS
     struct timespec _stamp;    // used for timing how long data stays in the 
queue.
 #endif

Index: libnet/handler.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/handler.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libnet/handler.cpp  29 Mar 2008 03:16:04 -0000      1.3
+++ libnet/handler.cpp  29 Mar 2008 19:35:53 -0000      1.4
@@ -35,6 +35,7 @@
 #include "utility.h"
 
 #include "rtmp.h"
+#include "rtmp_server.h"
 #include "http.h"
 
 using namespace gnash;
@@ -223,7 +224,7 @@
        }
        // We got data. Resize the buffer if necessary.
        if (ret > 0) {
-           if (ret != buf->size()) {
+           if (ret < NETBUFSIZE) {
                buf->resize(ret);
            }
            hand->push(buf);

Index: libnet/handler.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/handler.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libnet/handler.h    28 Mar 2008 21:30:25 -0000      1.2
+++ libnet/handler.h    29 Mar 2008 19:35:53 -0000      1.3
@@ -97,6 +97,11 @@
        { return _outgoing.peek(); };    
 
     // Removes all the buffers from the queues
+    Buffer *merge(Buffer *begin) { return _incoming.merge(begin); };
+    Buffer *mergein(Buffer *begin) { return _incoming.merge(begin); };
+    Buffer *mergeout(Buffer *begin) { return _outgoing.merge(begin); };
+
+    // Removes all the buffers from the queues
     void clear() { _incoming.clear(); };
     void clear(fifo_e direction);
     void clearin() { _incoming.clear(); };

Index: libnet/http.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/http.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libnet/http.cpp     29 Mar 2008 03:16:04 -0000      1.4
+++ libnet/http.cpp     29 Mar 2008 19:35:53 -0000      1.5
@@ -36,6 +36,7 @@
 #include <sys/stat.h>
 #include <algorithm>
 
+#include "amf.h"
 #include "http.h"
 #include "log.h"
 #include "network.h"
@@ -213,7 +214,7 @@
     _filesize = _body.str().size();
     formatContentLength(_filesize);
     formatConnection("close");
-    formatContentType(HTTP::FILETYPE_HTML);
+    formatContentType(amf::AMF::FILETYPE_HTML);
     return true;
 }
 
@@ -301,26 +302,26 @@
 }
 
 bool
-HTTP::formatContentType(filetype_e filetype)
+HTTP::formatContentType(amf::AMF::filetype_e filetype)
 {
 //    GNASH_REPORT_FUNCTION;
     
     switch (filetype) {
-      case FILETYPE_HTML:
+      case amf::AMF::FILETYPE_HTML:
          _header << "Content-Type: text/html" << "\r\n";
 //       _header << "Content-Type: text/html; charset=UTF-8" << "\r\n";
          break;
-      case FILETYPE_SWF:
+      case amf::AMF::FILETYPE_SWF:
          _header << "Content-Type: application/x-shockwave-flash" << "\r\n";
 //       _header << "Content-Type: application/futuresplash" << "\r\n";
          break;
-      case FILETYPE_VIDEO:
+      case amf::AMF::FILETYPE_VIDEO:
          _header << "Content-Type: video/flv" << "\r\n";
          break;
-      case FILETYPE_MP3:
+      case amf::AMF::FILETYPE_MP3:
          _header << "Content-Type: audio/mpeg" << "\r\n";
          break;
-      case FILETYPE_FCS:
+      case amf::AMF::FILETYPE_FCS:
          _header << "Content-Type: application/x-fcs" << "\r\n";
          break;
       default:
@@ -473,7 +474,7 @@
     _header << "HTTP/1.1 200 OK" << "\r\n";
     formatDate();
     formatServer();
-    formatContentType(HTTP::FILETYPE_FCS);
+    formatContentType(amf::AMF::FILETYPE_FCS);
     // All HTTP messages are followed by a blank line.
     terminateHeader();
     return true;
@@ -1080,7 +1081,7 @@
 
 // Get the file type, so we know how to set the
 // Content-type in the header.
-HTTP::filetype_e
+amf::AMF::filetype_e
 HTTP::getFileStats(std::string &filespec)
 {
 //    GNASH_REPORT_FUNCTION;    
@@ -1111,25 +1112,25 @@
                if (pos != string::npos) {
                    string suffix = filespec.substr(pos, filespec.size());
                    if (suffix == "html") {
-                       _filetype = FILETYPE_HTML;
+                       _filetype = amf::AMF::FILETYPE_HTML;
                        log_debug("HTML content found");
                    }
                    if (suffix == "swf") {
-                       _filetype = FILETYPE_SWF;
+                       _filetype = amf::AMF::FILETYPE_SWF;
                        log_debug("SWF content found");
                    }
                    if (suffix == "flv") {
-                       _filetype = FILETYPE_VIDEO;
+                       _filetype = amf::AMF::FILETYPE_VIDEO;
                        log_debug("FLV content found");
                    }
                    if (suffix == "mp3") {
-                       _filetype = FILETYPE_AUDIO;
+                       _filetype = amf::AMF::FILETYPE_AUDIO;
                        log_debug("MP3 content found");
                    }
                }
            }
        } else {
-           _filetype = HTTP::FILETYPE_ERROR;
+           _filetype = amf::AMF::FILETYPE_ERROR;
        } // end of stat()
     } // end of try_waiting
 
@@ -1238,7 +1239,7 @@
        parameters = url.substr(pos + 1, url.size());
        // Get the file size for the HTTP header
        
-       if (www.getFileStats(filespec) == HTTP::FILETYPE_ERROR) {
+       if (www.getFileStats(filespec) == amf::AMF::FILETYPE_ERROR) {
            www.formatErrorResponse(HTTP::NOT_FOUND);
        }
        www.sendGetReply(HTTP::LIFE_IS_GOOD);

Index: libnet/http.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/http.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libnet/http.h       29 Mar 2008 03:13:12 -0000      1.3
+++ libnet/http.h       29 Mar 2008 19:35:53 -0000      1.4
@@ -23,6 +23,7 @@
 #include <map>
 #include <vector>
 
+#include "amf.h"
 #include "rtmp.h"
 #include "handler.h"
 #include "network.h"
@@ -107,17 +108,6 @@
         const char *code;
         const char *msg;
     };
-    typedef enum {
-       FILETYPE_ERROR = -1,
-       FILETYPE_NONE = 0,
-       FILETYPE_HTML,
-       FILETYPE_SWF,
-       FILETYPE_VIDEO,
-       FILETYPE_AUDIO,
-       FILETYPE_MP3,
-       FILETYPE_FCS,
-       FILETYPE_OSCP
-    } filetype_e;
     HTTP();
     HTTP(Handler *hand);
     ~HTTP();
@@ -199,7 +189,7 @@
     bool formatContentLength();
     bool formatContentLength(int filesize);
     bool formatContentType();
-    bool formatContentType(filetype_e type);
+    bool formatContentType(amf::AMF::filetype_e type);
     bool formatHost(const std::string &data);
     bool formatAgent(const std::string &data);
     bool formatAcceptRanges(const std::string &data);
@@ -225,7 +215,7 @@
     // Get the file type, so we know how to set the
     // Content-type in the header.
 //    filetype_e getFileType(std::string &filespec);
-    filetype_e getFileStats(std::string &filespec);
+    amf::AMF::filetype_e getFileStats(std::string &filespec);
     void dump();
 
     // These accessors are used mostly just for debugging.
@@ -254,7 +244,7 @@
     std::stringstream _header;
     std::stringstream _body;
     std::string _command;
-    filetype_e  _filetype;
+    amf::AMF::filetype_e  _filetype;
     std::string _filespec;
     int         _filesize;
     std::string _url;

Index: libnet/rtmp.cpp
===================================================================
RCS file: /sources/gnash/gnash/libnet/rtmp.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libnet/rtmp.cpp     29 Mar 2008 03:16:05 -0000      1.3
+++ libnet/rtmp.cpp     29 Mar 2008 19:35:53 -0000      1.4
@@ -22,6 +22,8 @@
 #endif
 
 #include <iostream>
+#include <string>
+#include <map>
 
 #if ! (defined(_WIN32) || defined(WIN32))
 #      include <netinet/in.h>
@@ -31,6 +33,7 @@
 #include "amf.h"
 #include "rtmp.h"
 #include "network.h"
+#include "element.h"
 #include "handler.h"
 #include "utility.h"
 
@@ -43,6 +46,30 @@
 
 extern map<int, Handler *> handlers;
 
+const char *content_str[] = {
+    "None",
+    "Chunk Size",
+    "Unknown",
+    "Bytes Read",
+    "Ping",
+    "Server",
+    "Client",
+    "Unknown2",
+    "Audio Data",
+    "Video Data",
+    "Unknown3",
+    "Blank 0xb",
+    "Blank 0xc",
+    "Blank 0xd",
+    "Blank 0xe",
+    "Blank 0xf",
+    "Blank 0x10",
+    "Blank 0x11",
+    "Notify",
+    "Shared object",
+    "Invoke"
+};
+
 // These are the textual responses
 const char *response_str[] = {
     "/onStatus",
@@ -99,64 +126,33 @@
 }
 
 void
-RTMPproto::addVariable(char *name, char *value)
+RTMPproto::addVariable(amf::Element *el)
 {
-    _variables[name] = value;
+//    GNASH_REPORT_FUNCTION;
+    _variables[el->getName().c_str()] = el;
 }
 
-std::string
-RTMPproto::getVariable(char *name)
+void
+RTMPproto::addVariable(char *name, Element *el)
 {
-    return _variables[name];
+//    GNASH_REPORT_FUNCTION;
+    _variables[name] = el;
 }
 
-// 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()
+amf::Element *
+RTMPproto::getVariable(const std::string &name)
 {
-    GNASH_REPORT_FUNCTION;
-
-//     char buffer[RTMP_BODY_SIZE+16];
-//     memset(buffer, 0, RTMP_BODY_SIZE+16);
-    Buffer *buf = _handler->pop();
-
-    if (buf == 0) {
-       log_debug("Que empty, net connection dropped for fd #%d", 
_handler->getFileFd());
-       return false;
-    }    
-//     if (readNet(buffer, 1) == 1) {
-    log_debug (_("Read initial Handshake Request"));
-//     } else {
-//         log_error (_("Couldn't read initial Handshake Request"));
-//         return false;
-//     }
-//    _inbytes += 1;
-
-    if (*(buf->reference()) == 0x3) {
-        log_debug (_("Handshake is correct"));
-    } else {
-        log_error (_("Handshake isn't correct"));
-        return false;
+//    GNASH_REPORT_FUNCTION;
+//    return _variables[name.c_str()];
+    map<const char *, amf::Element *>::iterator it;
+    for (it = _variables.begin(); it != _variables.end(); it++) {
+       const char *title = it->first;
+       Element *el = it->second;
+       if (name == title) {
+//         log_debug("found variable in RTMP packet: %s", name);
+           return el;
     }
-
-//     if (buf->size() >= RTMP_BODY_SIZE) {
-//     secret = _handler->merge(buf->reference());
-//     }
-
-    if (buf->size() >= RTMP_BODY_SIZE) {
-       _handshake = new Buffer(RTMP_BODY_SIZE);
-       _handshake->copy(buf->reference() + 1, RTMP_BODY_SIZE);
-       log_debug (_("Handshake Data matched"));
-       delete buf;                     // we're done with the buffer
-       return true;
-    } else {
-       delete buf;                     // we're done with the buffer
-       log_error (_("Handshake Data didn't match"));
-       return false;
     }
-    
-    return true;
 }
 
 // A request for a handshake is initiated by sending a byte with a
@@ -192,27 +188,6 @@
     return true;
 }
 
-// The response is the gibberish sent back twice, preceeded by a byte
-// with the value of 0x3.
-bool
-RTMPproto::handShakeResponse()
-{
-    GNASH_REPORT_FUNCTION;
-
-    Buffer *buf = new Buffer((RTMP_BODY_SIZE * 2) + 1);
-    Network::byte_t *ptr = buf->reference();
-    *ptr = 0x3;
-
-    std::copy(_handshake->begin(), _handshake->end(), (ptr + 1));
-    std::copy(_handshake->begin(), _handshake->end(), ptr + _handshake->size() 
+ 1);
-    _handler->pushout(buf);
-    _handler->notifyout();
-
-    log_debug("Sent RTMP Handshake response");
-
-    return true;    
-}
-
 // The client finished the handshake process by sending the second
 // data block we get from the server as the response
 bool
@@ -249,53 +224,15 @@
 }
 
 bool
-RTMPproto::serverFinish()
-{
-    GNASH_REPORT_FUNCTION;
-
-    Buffer *buf = _handler->pop();
-    Buffer *obj = buf;
-    
-    if (buf == 0) {
-       log_debug("Que empty, net connection dropped for fd #%d", 
_handler->getFileFd());
-       return false;
-    }
-    
-    // The first data packet is often buried in with the end of the handshake.
-    // So after the handshake block, we strip that part off, and just pass on
-    // the remainder for processing.
-    if (buf->size() > RTMP_BODY_SIZE) {
-       int size = buf->size() - RTMP_BODY_SIZE;  
-       obj = new Buffer[size];
-       obj->copy(buf->begin()+RTMP_BODY_SIZE, size);
-    } else {
-       _handler->wait();
-       obj = _handler->pop();
-    }
-    
-    int diff = std::memcmp(buf->begin(), _handshake->begin(), RTMP_BODY_SIZE);
-    delete buf;                        // we're done with the buffer
-    if (diff == 0) {
-       log_debug (_("Handshake Finish Data matched"));
-    } else {
-       log_error (_("Handshake Finish Data didn't match by %d bytes"), diff);
-//        return false;
-    }
-    
-    packetRead(obj);
-    
-    return true;
-}
-
-bool
 RTMPproto::packetRequest()
 {
     GNASH_REPORT_FUNCTION;
     return false;
 }
 
+#if 0
 bool
-RTMPproto::packetSend(Buffer *buf)
+RTMPproto::packetSend(Buffer * /* buf */)
 {
     GNASH_REPORT_FUNCTION;
     return false;
@@ -306,7 +243,6 @@
 {
     GNASH_REPORT_FUNCTION;
 
-    int ret;
     int packetsize = 0;
     unsigned int amf_index, headersize;
     Network::byte_t *ptr = buf->reference();
@@ -328,11 +264,15 @@
 //         }
 //     }
 
+#if 1
+    Network::byte_t *end = buf->remove(0xc3);
+#else
     Network::byte_t *end = buf->find(0xc3);
-    log_debug("END is 0x%x", (void *)end);
+    log_debug("END is %x", (void *)end);
     *end = '*';
-    packetsize = parseHeader(ptr);
-    ptr += headersize;
+#endif
+    ptr = parseHeader(ptr);
+//     ptr += headersize;
 
     Element el;
     ptr = amf.extractElement(&el, ptr);
@@ -340,29 +280,65 @@
     ptr = amf.extractElement(&el, ptr) + 1;
     el.dump();
     log_debug (_("Reading AMF packets till we're done..."));
-//    buf->dump();
+    buf->dump();
     while (ptr < end) {
        amf::Element *el = new amf::Element;
        ptr = amf.extractVariable(el, ptr);
+       addVariable(el);
        el->dump();
-//     if (ptr != 0) {
-//         ptr += 1;    
-// //      addObj(el);
-//     } else {
-//         break;
-//         }
     }
     ptr += 1;
-    while (ptr < buf->end()) {
+    size_t actual_size = static_cast<size_t>(_total_size - AMF_HEADER_SIZE);
+    log_debug("Total size in header is %d, buffer size is: %d", _total_size, 
buf->size());
+//    buf->dump();
+    if (buf->size() < actual_size) {
+       log_debug("FIXME: MERGING");
+       buf = _handler->merge(buf);
+    }
+    while ((ptr - buf->begin()) < actual_size) {
        amf::Element *el = new amf::Element;
+       if (ptr) {
        ptr = amf.extractVariable(el, ptr);
-       el->dump();
+           addVariable(el);
+       } else {
+           return true;
+       }
+       el->dump();             // FIXME: dump the AMF objects as they are read 
in
+    }
+
+    dump();
+    
+    Element *url = getVariable("tcUrl");
+    Element *file = getVariable("swfUrl");
+    Element *app = getVariable("app");
+
+    if (file) {
+       log_debug("SWF file %s", file->getData());
+    }
+    if (url) {
+       log_debug("is Loading video %s", url->getData());
+    }
+    if (app) {
+       log_debug("is file name is %s", app->getData());
     }
     
     return true;
 }
+#endif
 
-int
+void
+RTMPproto::dump()
+{
+    cerr << "RTMP packet contains " << _variables.size() << " variables." << 
endl;
+    map<const char *, amf::Element *>::iterator it;
+    for (it = _variables.begin(); it != _variables.end(); it++) {
+//     const char *name = it->first;
+       Element *el = it->second;
+       el->dump();
+    }
+}
+
+Network::byte_t *
 RTMPproto::parseHeader(Network::byte_t *in)
 {
 //    GNASH_REPORT_FUNCTION;
@@ -394,123 +370,39 @@
     }
 
     if (_header_size >= 8) {
-        _type = *(AMF::content_types_e *)tmpptr;
+        _type = *(content_types_e *)tmpptr;
         tmpptr++;
-        log_debug(_("The type is: 0x%x"), _type);
+        log_debug(_("The type is: %s"), content_str[_type]);
     }
 
-    switch(_type) {
-      case AMF::CHUNK_SIZE:
-      case AMF::BYTES_READ:
-      case AMF::PING:
-      case AMF::SERVER:
-      case AMF::CLIENT:
-      case AMF::VIDEO_DATA:
-      case AMF::NOTIFY:
-      case AMF::SHARED_OBJ:
-      case AMF::INVOKE:
-          _packet_size = AMF_VIDEO_PACKET_SIZE;
-          break;
-      case AMF::AUDIO_DATA:
-          _packet_size = AMF_AUDIO_PACKET_SIZE;
-          break;
-      default:
-          log_error (_("ERROR: Unidentified AMF header data type 0x%x"), 
_type);
-          break;
-    };
+//     switch(_type) {
+//       case CHUNK_SIZE:
+//       case BYTES_READ:
+//       case PING:
+//       case SERVER:
+//       case CLIENT:
+//       case VIDEO_DATA:
+//       case NOTIFY:
+//       case SHARED_OBJ:
+//       case INVOKE:
+//           _packet_size = AMF_VIDEO_PACKET_SIZE;
+//           break;
+//       case AUDIO_DATA:
+//           _packet_size = AMF_AUDIO_PACKET_SIZE;
+//           break;
+//       default:
+//           log_error (_("ERROR: Unidentified AMF header data type 0x%x"), 
_type);
+//           break;
+//     };
     
     if (_header_size == 12) {
 //        hexify((Network::byte_t *)hexint, (Network::byte_t *)tmpptr, 3, 
false);
         _src_dest = *(reinterpret_cast<rtmp_source_e *>(tmpptr));
         tmpptr += sizeof(unsigned int);
-//        log_debug(_("The source/destination is: %d, or 0x%s"), _src_dest, 
hexint);
+        log_debug(_("The source/destination is: %x"), _src_dest);
     }
 
-    return _packet_size;
-}
-
-// This is the thread for all incoming RTMP connections
-void
-rtmp_handler(Handler::thread_params_t *args)
-{
-    GNASH_REPORT_FUNCTION;
-    Handler *hand = reinterpret_cast<Handler *>(args->handle);
-    RTMPproto rtmp;
-
-    rtmp.setHandler(hand);
-    string docroot = args->filespec;
-
-    log_debug(_("Starting RTMP Handler for fd #%d, tid %ld"),
-             args->netfd, get_thread_id());
-    
-    while (!hand->timetodie()) {       
-       log_debug(_("Waiting for RTMP request on fd #%d..."), args->netfd);
-       hand->wait();
-       // This thread is the last to wake up when the browser
-       // closes the network connection. When browsers do this
-       // varies, elinks and lynx are very forgiving to a more
-       // flexible HTTP protocol, which Firefox/Mozilla & Opera
-       // are much pickier, and will hang or fail to load if
-       // you aren't careful.
-       if (hand->timetodie()) {
-           log_debug("Not waiting no more, no more for RTMP data for fd 
#%d...", args->netfd);
-           map<int, Handler *>::iterator hit = handlers.find(args->netfd);
-           if ((*hit).second) {
-               log_debug("Removing handle %x for RTMP on fd #%d", (void 
*)hand), args->netfd;
-               handlers.erase(args->netfd);
-           }
-
-           return;
-       }
-#ifdef USE_STATISTICS
-       struct timespec start;
-       clock_gettime (CLOCK_REALTIME, &start);
-#endif
-       if (!rtmp.handShakeWait()) {
-           hand->clearout();   // remove all data from the outgoing que
-           hand->die();        // tell all the threads for this connection to 
die
-           hand->notifyin();
-           log_debug("Net RTMP done for fd #%d...", args->netfd);
-//         hand->closeNet(args->netfd);
-           return;
-       }
-       string url, filespec;
-       url = docroot;
-       
-       rtmp.handShakeResponse();
-
-       hand->wait();
-       // This thread is the last to wake up when the browser
-       // closes the network connection. When browsers do this
-       // varies, elinks and lynx are very forgiving to a more
-       // flexible HTTP protocol, which Firefox/Mozilla & Opera
-       // are much pickier, and will hang or fail to load if
-       // you aren't careful.
-       if (hand->timetodie()) {
-           log_debug("Not waiting no more, no more for RTMP data for fd 
#%d...", args->netfd);
-           map<int, Handler *>::iterator hit = handlers.find(args->netfd);
-           if ((*hit).second) {
-               log_debug("Removing handle %x for RTMP on fd #%d", (void 
*)hand), args->netfd;
-               handlers.erase(args->netfd);
-           }
-
-           return;
-       }
-       rtmp.serverFinish();
-    
-    // Keep track of the network statistics
-//    Statistics st;
-//    st.setFileType(NetStats::RTMP);
-//     st.stopClock();
-//     log_debug (_("Bytes read: %d"), proto.getBytesIn());
-//     log_debug (_("Bytes written: %d"), proto.getBytesOut());
-//     st.setBytes(proto.getBytesIn() + proto.getBytesOut());
-//     st.addStats();
-//     proto.resetBytesIn();
-//     proto.resetBytesOut();  
-
-//     st.dump(); 
-    }
+    return tmpptr;
 }
     
 } // end of gnash namespace

Index: libnet/rtmp.h
===================================================================
RCS file: /sources/gnash/gnash/libnet/rtmp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libnet/rtmp.h       28 Mar 2008 21:30:26 -0000      1.2
+++ libnet/rtmp.h       29 Mar 2008 19:35:53 -0000      1.3
@@ -19,9 +19,11 @@
 #define _RTMP_H_
 
 #include <boost/cstdint.hpp>
-#include <vector>
+#include <string>
+#include <map>
 
 #include "amf.h"
+#include "element.h"
 #include "handler.h"
 #include "network.h"
 
@@ -36,22 +38,38 @@
 {
 public:
     typedef enum {
-       CLIENT,                     // Flash player
-       SERVER                      // Flash com server
+       FROM_CLIENT,                     // Flash player
+       FROM_SERVER                      // Flash com server
     } rtmp_source_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;
+        NONE = 0x0,
+        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
+    } content_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;
     typedef enum {
         RTMP_STATE_HANDSHAKE_SEND,
         RTMP_STATE_HANDSHAKE_RECV,
@@ -109,20 +127,22 @@
     
     RTMPproto();
     ~RTMPproto();
-    bool handShakeWait();
+//     bool handShakeWait();
     bool handShakeRequest();
-    bool handShakeResponse();
+//    bool handShakeResponse();
     bool clientFinish();
-    bool serverFinish();
+//  bool serverFinish();
     bool packetRequest();
     bool packetSend(Buffer *buf);
     bool packetRead(Buffer *buf);
 
-    void addVariable(char *name, char *value);
-    std::string getVariable(char *name);
+    void addVariable(amf::Element *el);
+    void addVariable(char *name, amf::Element *el);
+    void addVariable(std::string &name, amf::Element *el);
+    amf::Element *getVariable(const std::string &name);
     void setHandler(Handler *hand) { _handler = hand; };
     int headerSize(gnash::Network::byte_t header);
-    int parseHeader(gnash::Network::byte_t *header);
+    Network::byte_t *parseHeader(gnash::Network::byte_t *header);
 
     int getHeaderSize()         { return _header_size; }; 
     int getTotalSize()          { return _total_size; }; 
@@ -130,10 +150,21 @@
     int getMysteryWord()        { return _mystery_word; };
     rtmp_source_e getRouting()  { return _src_dest; };
     int getAMFIndex()           { return _amf_index; };
-  private:
-    std::map<char *, std::string> _variables;
-//     unsigned char               _body[RTMP_BODY_SIZE+1];
-//     std::vector<amf::AMF *>     _amfs;
+
+    // 
+    bool chunk_size();
+    bool bytes_read();
+    bool ping();
+    bool server();
+    bool client();
+    bool audio_data();
+    bool video_data();
+    bool notify();
+    bool shared_obj();
+    bool invoke();
+    void dump();
+  protected:
+    std::map<const char *, amf::Element *> _variables;
     Buffer             *_handshake;
     Handler            *_handler;
     int                 _amf_index;
@@ -141,13 +172,10 @@
     int                 _total_size;
     int                 _packet_size;
     rtmp_source_e       _src_dest;
-    amf::AMF::content_types_e     _type;
+    content_types_e     _type;
     int                 _mystery_word;
 };
 
-// This is the thread for all incoming RTMP connections
-void rtmp_handler(Handler::thread_params_t *args);
-
 } // end of gnash namespace
 // end of _RTMP_H_
 #endif




reply via email to

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