gnash-commit
[Top][All Lists]
Advanced

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

[Gnash-commit] gnash testsuite/Makefile.am libamf/Makefile.am ...


From: Rob Savoye
Subject: [Gnash-commit] gnash testsuite/Makefile.am libamf/Makefile.am ...
Date: Fri, 16 Mar 2007 15:00:49 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Rob Savoye <rsavoye>    07/03/16 15:00:49

Modified files:
        testsuite      : Makefile.am 
        libamf         : Makefile.am README amf.cpp amf.h amftest.cpp 
                         rtmp.cpp rtmp.h 
Added files:
        testsuite/libamf.all: Makefile.am connect-object.amf 
                              connect-string.amf f03f.amf 
                              result-fail.amf result-success.amf 
                              test_number.cpp test_object.cpp 
                              test_string.cpp 

Log message:
                * libamf/amf.cpp, amf.h: Use capitols for enum values. Fix
                encoding and decoding of numbers, strings, and objects.
                * libamf/rtmp.cpp, rtmp.h: Use capitols for enum values. 
                * libamf/Makefile.am: Remove amftest.cpp, it's now in testsuites
                where it belongs.
                * testsuite/Makefile.am: Add libamf.all directory.
                * testsuite/libamf.all/Makefile.am: Build test cases, do "make
                check".
                * testsuite/libamf.all/test_number.cpp: Test case for AMF 
numbers.
                * testsuite/libamf.all/test_object.cpp: Test case for AMF 
objects.
                * testsuite/libamf.all/test_string.cpp: Test case for AMF 
strings.
                * testsuite/libamf.all/f03f.amf: Binary test file for number 
format.
                * testsuite/libamf.all/connect-object.amf: Binary test file for
                object format. 
                * testsuite/libamf.all/connect-string.amf: Binary test file for
                string format.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/Makefile.am?cvsroot=gnash&r1=1.32&r2=1.33
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/Makefile.am?cvsroot=gnash&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/README?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amftest.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.cpp?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/connect-object.amf?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/connect-string.amf?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/f03f.amf?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/result-fail.amf?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/result-success.amf?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_number.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_object.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/libamf.all/test_string.cpp?cvsroot=gnash&rev=1.1

Patches:
Index: testsuite/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/testsuite/Makefile.am,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -b -r1.32 -r1.33
--- testsuite/Makefile.am       7 Mar 2007 15:11:24 -0000       1.32
+++ testsuite/Makefile.am       16 Mar 2007 15:00:49 -0000      1.33
@@ -8,6 +8,7 @@
        libgeometry             \
        server                  \
        samples                 \
+       libamf.all \
        misc-ming.all           \
        misc-mtasc.all          \
        movies.all              \

Index: libamf/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libamf/Makefile.am,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- libamf/Makefile.am  21 Jan 2007 22:41:02 -0000      1.20
+++ libamf/Makefile.am  16 Mar 2007 15:00:49 -0000      1.21
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-# $Id: Makefile.am,v 1.20 2007/01/21 22:41:02 rsavoye Exp $
+# $Id: Makefile.am,v 1.21 2007/03/16 15:00:49 rsavoye Exp $
 
 AUTOMAKE_OPTIONS = 
 
@@ -40,10 +40,6 @@
 
 noinst_HEADERS = amfutf8.h amf.h rtmp.h protocol.h
 
-EXTRA_PROGRAMS = amftest
-amftest_SOURCES = amftest.cpp
-amftest_LDADD = $(AM_LDFLAGS) libgnashamf.la
-
 # Rebuild with GCC 4.x Mudflap support
 mudflap:
        @echo "Rebuilding with GCC Mudflap support"

Index: libamf/README
===================================================================
RCS file: /sources/gnash/gnash/libamf/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libamf/README       12 Aug 2006 15:11:53 -0000      1.2
+++ libamf/README       16 Mar 2007 15:00:49 -0000      1.3
@@ -530,3 +530,7 @@
 
  00 00 09 00
  end of array
+
+
+Good examples for SharedObj
+http://www.flash-communications.net/technotes/sharedObjectEditor/editor.html

Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- libamf/amf.cpp      1 Mar 2007 08:00:41 -0000       1.24
+++ libamf/amf.cpp      16 Mar 2007 15:00:49 -0000      1.25
@@ -1,6 +1,6 @@
 //
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   Copyright (C) 2005, 2006, 2007 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
@@ -14,11 +14,9 @@
 // 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
-
-// 
 //
 
-/* $Id: amf.cpp,v 1.24 2007/03/01 08:00:41 zoulunkai Exp $ */
+/* $Id: amf.cpp,v 1.25 2007/03/16 15:00:49 rsavoye Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -164,7 +162,7 @@
 
     char *x = static_cast<char *>(in);
 
-    while (*x != ObjectEnd) {
+    while (*x != OBJECT_END) {
         x = readElement(x);
     }
                return true;
@@ -187,15 +185,15 @@
 
     x++;                        // skip the type byte
     switch (type) {
-      case Number:
+      case NUMBER:
           num = *(amfnum_t *)swapBytes(x+1, 8);
           log_msg("Number is " AMFNUM_F, num);
           break;
-      case Boolean:
+      case BOOLEAN:
           boolshift = *x;
           log_msg("Boolean is %d\n", boolshift);
           break;
-      case String:
+      case STRING:
 //        int length = *(short *)swapBytes(x, 2);
           length = *(short *)x;
           x+=2;                  // skip the length bytes
@@ -208,39 +206,39 @@
 //          mbsrtowcs
           log_msg("String is %s\n", mstr);
           break;
-      case Object:
+      case OBJECT:
 //          readElement();
           log_msg("Object is unimplemented\n");
           break;
-      case MovieClip:
+      case MOVIECLIP:
         log_msg("MovieClip is unimplemented\n");
           break;
-      case Unsupported:
+      case UNSUPPORTED:
         log_msg("MovieClip is unimplemented\n");
           break;
-      case Null: 
+      case NULL_VALUE: 
           log_msg("Null is unimplemented\n");
           break;
-      case Undefined:
+      case UNDEFINED:
           log_msg("Endefined element");
           break;
-      case Reference:
+      case REFERENCE:
           log_msg("Reference is unimplemented\n");
           break;
-      case ECMAArray:
+      case ECMA_ARRAY:
           log_msg("ECMAArray is unimplemented\n");
           break;
-      case ObjectEnd:
+      case OBJECT_END:
           log_msg("ObjectEnd is unimplemented\n");
           break;
-      case StrictArray:
+      case STRICT_ARRAY:
           log_msg("StrictArray is unimplemented\n");
           break;
-      case Date:
+      case DATE:
           nanosecs = *(amfnum_t *)swapBytes(x+1, 8);
           log_msg("Date is " AMFNUM_F " nanoseconds\n", nanosecs);
           break;
-      case LongString:
+      case LONG_STRING:
 //          int length = *(short *)swapBytes(x, 4);
           x+=4;                  // skip the length bytes
 //        mstr = new char[length+1];
@@ -250,13 +248,13 @@
 //       case Unsupported:
           log_msg("Unsupported is unimplemented\n");
 //           break;
-      case Recordset:
+      case RECORD_SET:
           log_msg("Recordset is unimplemented\n");
           break;
-      case XMLObject:
+      case XML_OBJECT:
           log_msg("XMLObject is unimplemented\n");
           break;
-      case TypedObject:
+      case TYPED_OBJECT:
           log_msg("TypedObject is unimplemented\n");
           break;
     }
@@ -300,152 +298,154 @@
 
     // Packets are of varying lenght. A few pass in a byte count, but
     // most packets have a hardcoded size.
-    if (nbytes == 0) {
         switch (type) {
             // Encode the data as a 64 bit, big-endian, numeric value
-          case Number:
-              pktsize = 9;          // one 64 bit number
+      case NUMBER:
+          // one 64 bit number
+          pktsize = AMF_NUMBER_SIZE + AMF_HEADER_SIZE;
               break;
-          case Boolean:
+      case BOOLEAN:
               pktsize = 2;          // just one data byte
               break;
-          case String:
+      case STRING:
               pktsize = nbytes + 3; // two length bytes after the header
               break;
-          case Object:
+      case OBJECT:
               pktsize = 0;          // look for the terminator
               break;
-          case MovieClip:
+      case MOVIECLIP:
               pktsize = -1;         // FIXME: no clue
               break;
-          case Null: 
+      case NULL_VALUE: 
               pktsize = -1;         // FIXME: no clue
               break;
-          case Undefined:
+      case UNDEFINED:
               pktsize = 1;          // just the header, no data
               break;
-          case Reference:
+      case REFERENCE:
               pktsize = -1;         // FIXME: no clue
               break;
-          case ECMAArray:
+      case ECMA_ARRAY:
               pktsize = 0;          // look for the terminator
               break;
-          case ObjectEnd:
+      case OBJECT_END:
               pktsize = -1;         // FIXME: no clue
               break;
-          case StrictArray:
+      case STRICT_ARRAY:
               pktsize = nbytes + 5; // 4 length bytes, then data
               break;
-          case Date:
+      case DATE:
               pktsize = 9;          // one 64 bit number
               break;
-          case LongString:
+      case LONG_STRING:
               pktsize = nbytes + 5; // 4 length bytes, then data
               break;
-          case Unsupported:
+      case UNSUPPORTED:
               pktsize = -1;         // FIXME: no clue
               break;
-          case Recordset:
+      case RECORD_SET:
               pktsize = -1;         // FIXME: no clue
               break;
-          case XMLObject:
+      case XML_OBJECT:
               pktsize = nbytes + 5;// 4 length bytes, then data
               break;
-          case TypedObject:
+      case TYPED_OBJECT:
               pktsize = 0;          // look for the terminator
               break;
         };
-    }
     
     switch (type) {
         // Encode the data as a 64 bit, big-endian, numeric value
-      case Number:
-          out = (char *)new char[pktsize];
-          memset(out, 0, pktsize);
-          x = out;    
-          *x++ = (char)AMF::Number;
-          num = *(amfnum_t *)in;
-          swapBytes(&num, 8);
-          memcpy(x, &num, 8);
+      case NUMBER:
+          x = out = (char *)new char[pktsize];
+          memset(x, 0, pktsize);
+          *x++ = (char)AMF::NUMBER;
+          memcpy(&num, in, AMF_NUMBER_SIZE);
+          swapBytes(&num, AMF_NUMBER_SIZE);
+          memcpy(x, &num, AMF_NUMBER_SIZE);
           break;
-      case Boolean:
+      case BOOLEAN:
           // Encode a boolean value. 0 for false, 1 for true
           out = (char *)new char[pktsize];
           x = out;    
-          *x++ = (char)AMF::Boolean;
+          *x++ = (char)AMF::BOOLEAN;
           *x = *(char *)in;
           break;
-      case String:
+      case STRING:
           // Encode a string value. The data follows a 2 byte length
           // field. (which must be big-endian)
-          out = (char *)new char[pktsize];
-          memset(out, 0, pktsize);
-          *out++ = String;
+          x = out = (char *)new char[pktsize];
+          memset(x, 0, pktsize);
+          *x++ = AMF::STRING;
           num = nbytes;
           swapBytes(&num, 2);
-          memcpy(out, in, nbytes);
+          memcpy(x, &num, 2);
+          x+=2;
+          memcpy(x, in, nbytes);
           break;
-      case Object:
+      case OBJECT:
           log_msg("Object unimplemented\n");
           break;
-      case MovieClip:
+      case MOVIECLIP:
           log_msg("MovieClip unimplemented\n");
           break;
-      case Null: 
+      case NULL_VALUE: 
           log_msg("Null unimplemented\n");
           break;
-      case Undefined:
+      case UNDEFINED:
           out = (char *)new char[pktsize];
           memset(out, 0, pktsize);
-          *out++ = Undefined;
+          *out++ = AMF::UNDEFINED;
           break;
-      case Reference:
+      case REFERENCE:
           log_msg("Reference unimplemented\n");
           break;
-      case ECMAArray:
+      case ECMA_ARRAY:
           log_msg("ECMAArray unimplemented\n");
           break;
-      case ObjectEnd:
+      case OBJECT_END:
           log_msg("ObjectEnd unimplemented\n");
           break;
-      case StrictArray:
+      case STRICT_ARRAY:
           log_msg("StrictArray unimplemented\n");
           break;
           // Encode the date as a 64 bit, big-endian, numeric value
-      case Date:
+      case DATE:
           out = (char *)new char[pktsize];
           memset(out, 0, pktsize);
-          *out++ = Date;
+          *out++ = AMF::DATE;
           num = *(amfnum_t *)in;
           swapBytes(&num, 8);
           memcpy(out, &num, 8);
           break;
-      case LongString:
+      case LONG_STRING:
           log_msg("LongString unimplemented\n");
           break;
-      case Unsupported:
+      case UNSUPPORTED:
           log_msg("Unsupported unimplemented\n");
           break;
-      case Recordset:
+      case RECORD_SET:
           log_msg("Recordset unimplemented\n");
           break;
-      case XMLObject:
+      case XML_OBJECT:
           // Encode an XML object. The data follows a 4 byte length
           // field. (which must be big-endian)
           out = (char *)new char[pktsize];
           memset(out, 0, pktsize);
-          *out++ = String;
+          *out++ = AMF::STRING;
           num = nbytes;
           swapBytes(&num, 4);
           memcpy(out, in, nbytes);
           break;
-      case TypedObject:
+      case TYPED_OBJECT:
           log_msg("TypedObject unimplemented\n");
           break;
     };
     
     return out;
 }
+
+#if 0
 /// \brief Each header consists of the following:
 ///
 /// * UTF string (including length bytes) - name
@@ -530,7 +530,7 @@
 /// The third and fourth bytes form an integer value that specifies the
 /// number of headers. 
 amfpacket_t *
-AMF::encodePacket(std::vector<amfhead_t *> messages)
+AMF::encodePacket(std::vector<amfpacket_t *> messages)
 {
     GNASH_REPORT_FUNCTION;
 
@@ -563,6 +563,7 @@
 
     return out;
 }
+#endif
 
 
 AMF::astype_e
@@ -583,62 +584,62 @@
     x++;                        // skip the header byte
     
     switch (type) {
-      case Number:              // a 64 bit numeric value
+      case NUMBER:              // a 64 bit numeric value
           return 8;
           break;
-      case Boolean:             // a single byte
+      case BOOLEAN:             // a single byte
           return 1;
           break;
-      case String:              // the length is a 2 byte value
+      case STRING:              // the length is a 2 byte value
           return (short)*(short *)x;
           break;
-      case Object:
+      case OBJECT:
           return x - strchr(x, TERMINATOR);
           break;
-      case MovieClip:
+      case MOVIECLIP:
           return -1;
           log_msg("MovieClip unimplemented");
           break;
-      case Null: 
+      case NULL_VALUE: 
           return -1;
           log_msg("Null unimplemented");
           break;
-      case Undefined:
+      case UNDEFINED:
           return 0;
           break;
-      case Reference:
+      case REFERENCE:
           return -1;
           log_msg("Reference unimplemented");
           break;
-      case ECMAArray:
+      case ECMA_ARRAY:
           return x - strchr(x, TERMINATOR);
           break;
-      case ObjectEnd:
+      case OBJECT_END:
           return -1;
           log_msg("ObjectEnd unimplemented");
           break;
-      case StrictArray:         // the length is a 4 byte value
+      case STRICT_ARRAY:         // the length is a 4 byte value
 //          return (int *)x;
           break;
-      case Date:              // a 64 bit numeric value
+      case DATE:              // a 64 bit numeric value
           return 8;
           break;
-      case LongString:
+      case LONG_STRING:
           return -1;
           log_msg("LongString unimplemented");
           break;
-      case Unsupported:
+      case UNSUPPORTED:
           return -1;
           log_msg("Unsupported unimplemented");
           break;
-      case Recordset:
+      case RECORD_SET:
           return -1;
           log_msg("Recordset unimplemented");
           break;
-      case XMLObject:           // the length is a 4 byte value
+      case XML_OBJECT:           // the length is a 4 byte value
 //          return (int)*(int *)x;
           break;
-      case TypedObject:
+      case TYPED_OBJECT:
           return x - strchr(x, TERMINATOR);
           break;
     };
@@ -646,24 +647,45 @@
     return 0;
 }
 
-std::string
+char *
 AMF::extractString(const char *in)
 {
     GNASH_REPORT_FUNCTION;
+    char *buf = NULL;
+    char *x = const_cast<char *>(in);
+    short length;
 
-    int length;
-    
-    if (*in == 0) {
-        length = *(in+1);        
+    if (*x == AMF::STRING) {
+        x++;
+        length = *(reinterpret_cast<short *>(x));
+        x += sizeof(short);
+        buf = new char[length+1];
+        memset(buf, 0, length+1);
+        memcpy(buf, x, length);
+    } else {
+        log_warning("Tried to extract AMF string from non String object!");
     }
-               return "";
+    
+    return buf;
 }
 
-int
-AMF::extractNumber(const char * /* in */)
+amfnum_t *
+AMF::extractNumber(const char *in)
 {
     GNASH_REPORT_FUNCTION;    
-               return 0;       
+    char *x = const_cast<char *>(in);
+    amfnum_t *num = new amfnum_t;
+    memset(num, 0, AMF_NUMBER_SIZE+1);
+    
+    if (*x == AMF::NUMBER) {
+        x++;
+        memcpy(num, x, AMF_NUMBER_SIZE);
+        swapBytes(num, AMF_NUMBER_SIZE);
+    } else {
+        log_warning("Tried to extract AMF Number from non Number object!");
+    }
+
+    return num;
 }
 
 int
@@ -711,7 +733,10 @@
     dbglogfile << "AMF header byte is: 0x" << hexint << endl;
 
     _amf_index = *tmpptr & AMF_INDEX_MASK;
+    dbglogfile << "The AMF channel index is " << _amf_index << endl;
+    
     _header_size = headerSize(*tmpptr++);
+    dbglogfile << "The header size is " << _header_size << endl;
 
 #if 1
     hexify((unsigned char *)hexint, (unsigned char *)in, _header_size, false);
@@ -731,9 +756,9 @@
         _total_size = *tmpptr++;
         _total_size = (_total_size << 12) + *tmpptr++;
         _total_size = (_total_size << 8) + *tmpptr++;
-        _total_size = _total_size & 0x0000ff;
+        _total_size = _total_size & 0xffffff;
         dbglogfile << "The body size is: " << _total_size
-                   << " Hex value is: 0x" << hexint << endl;
+                   << " Hex value is: " << (void *) _total_size << endl;
         _amf_data = new unsigned char(_total_size+1);
         _seekptr = _amf_data;
 //        memset(_amf_data, 0, _total_size+1);
@@ -813,7 +838,7 @@
 //    unsigned char hexint[(bytes*2)+1];
     unsigned char* hexint;
 
-    char buffer[AMF_VIDEO_PACKET_SIZE+1];
+    char buffer[500];
 //    char *name;
     short length;
     amf_element_t el;
@@ -827,7 +852,7 @@
         return -1;
     }
 
-    hexint =  (unsigned char*) malloc((bytes * 2) + 12);
+    hexint =  (unsigned char*) malloc((bytes * 3) + 12);
 
 //     memcpy(_amf_data +_read_size, in, AMF_VIDEO_PACKET_SIZE);
 //     _read_size += bytes;
@@ -846,22 +871,21 @@
 // If it's a String type, then there is a count of characters, then the string 
value    
     
     while (tmpptr  != (in + bytes)) {
-        memset(buffer, 0, AMF_VIDEO_PACKET_SIZE+1);
+        memset(buffer, 0, 500);
         // Check the type of the element data
         char type = *(astype_e *)tmpptr;
         tmpptr++;                        // skip the header byte
 
         switch ((astype_e)type) {
-          case Number:
+          case NUMBER:
 //              memcpy(buffer, tmpptr, 8);
               tmpptr += 8;
               continue;
               break;
-          case Boolean:
-          case String:
-              dbglogfile << "AMF type: " << astype_str[(int)type] << ": a work 
in progress!" << endl;
+          case BOOLEAN:
+          case STRING:
               // get the length of the name
-              length = ntohs(*(short *)tmpptr);
+              length = ntohs((*(short *)tmpptr) & 0xffff);
               tmpptr += 2;
               dbglogfile << "AMF String length is: " << length << endl;
               // get the name of the element
@@ -872,28 +896,27 @@
               dbglogfile << "AMF String is: " << buffer << endl;              
               el.name = buffer;
               break;
-          case Object:
-              dbglogfile << "AMF type: " << astype_str[(int)type] << ": a work 
in progress!" << endl;
+          case OBJECT:
               do {
                   tmpptr = extractVariables(el, tmpptr);
-              } while (el.type != ObjectEnd);
+              } while (el.type != AMF::OBJECT_END);
               break;
-          case MovieClip:
-          case Null: 
-          case Undefined:
-          case Reference:
-          case ECMAArray:
-          case ObjectEnd:
-          case StrictArray:
-          case Date:
-          case LongString:
-          case Unsupported:
-          case Recordset:
-          case XMLObject:
-          case TypedObject:
+          case MOVIECLIP:
+          case NULL_VALUE: 
+          case UNDEFINED:
+          case REFERENCE:
+          case ECMA_ARRAY:
+          case OBJECT_END:
+          case STRICT_ARRAY:
+          case DATE:
+          case LONG_STRING:
+          case UNSUPPORTED:
+          case RECORD_SET:
+          case XML_OBJECT:
+          case TYPED_OBJECT:
           default:
 //          dbglogfile << astype_str[(int)type] << ": unimplemented!" << endl;
-              dbglogfile << (int)type << ": unimplemented!" << endl;
+              dbglogfile << __PRETTY_FUNCTION__ << (int)type << ": 
unimplemented!" << endl;
               return -1;
         }
     }
@@ -908,7 +931,7 @@
 {
     GNASH_REPORT_FUNCTION;
     
-    unsigned char buffer[AMF_VIDEO_PACKET_SIZE+1];
+    unsigned char buffer[300];
     unsigned char *tmpptr = in;
     short length = 0;
 
@@ -918,65 +941,59 @@
         el.data = 0;
     }
     
-    memset(buffer, 0, AMF_VIDEO_PACKET_SIZE+1);
+    memset(buffer, 0, 300);
     // @@ casting generic pointers to bigger types may be dangerous
     //    due to memory alignment constraints
-    length = ntohs(*(const short *)tmpptr);
+    length = ntohs((*(const short *)tmpptr) & 0xffff);
     el.length = length;
     if (length == 0) {
-        if (*(tmpptr+2) == ObjectEnd) {
+        if (*(tmpptr+2) == AMF::OBJECT_END) {
             dbglogfile << "End of Object definition." << endl;
             el.length = 0;
-            el.type = ObjectEnd;
+            el.type = AMF::OBJECT_END;
             tmpptr+=3;
             return tmpptr;
         }
     }
     
-#if 1
-    unsigned char hexint[25];
-    hexify((unsigned char *)hexint, (unsigned char *)tmpptr, length+2, true);
+#if 0
+    unsigned char hexint[500];
+    hexify((unsigned char *)hexint, (unsigned char *)tmpptr, length*3, true);
     dbglogfile << "The element is: 0x" << hexint << endl;
 #endif
     tmpptr += 2;
-    dbglogfile << "AMF element length is: " << length << endl;
     // get the name of the element
-    if (length) {
+    if (length > 0) {
+        dbglogfile << "AMF element length is: " << length << endl;
         memcpy(buffer, tmpptr, length);
         el.name = reinterpret_cast<char *>(buffer);
         tmpptr += length;
-    } else {
-        // when reading in an object definition, a byte of 0x9 after
-        // a length of zero instead of the variable name.
-        if (*tmpptr == ObjectEnd) {
-            dbglogfile << "End of Object definition." << endl;
-            tmpptr++;
-            el.type = ObjectEnd;
-            el.name.erase();
-            el.length = 0;
-            el.data = 0;
-           // @@ we're dropping constness of input here..
-           //    it might be a problem, but strchr does it as well...
-            return tmpptr;
-        }
     }
     
 //    dbglogfile << "AMF element name is: " << buffer << endl;
     char type = *(const astype_e *)tmpptr++;
 
-    if (type <= TypedObject) {
+    if (type <= AMF::TYPED_OBJECT) {
         dbglogfile << "AMF type is: " << astype_str[(int)type] << endl;
     }
     
     switch ((astype_e)type) {
-      case Number:
-          memcpy(buffer, tmpptr, 8);
-          swap64((uint64)*buffer);
-          dbglogfile << "Number \"" << el.name.c_str() << "\" is: " << 
reinterpret_cast<long>(buffer) << endl;
+      case NUMBER:
+          memcpy(buffer, tmpptr, AMF_NUMBER_SIZE);
+          swapBytes(buffer, AMF_NUMBER_SIZE);
+          unsigned char hexint[AMF_NUMBER_SIZE*3];
+          hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 
AMF_NUMBER_SIZE, false);
+          dbglogfile << "Number \"" << el.name.c_str() << "\" is: 0x" << 
hexint << endl;
+//          amfnum_t *num = extractNumber(tmpptr);
           tmpptr += 8;
           break;
-      case Boolean:
-      case String:
+      case BOOLEAN:
+//          int value = *tmpptr;
+           el.data = (const unsigned char*)tmpptr; 
+           dbglogfile << "Boolean \"" << el.name.c_str() << "\" is: " << ( 
(*tmpptr == 0) ? "true" :"false") << endl;
+           tmpptr += 1;
+           break;
+      case STRING:
           length = ntohs(*reinterpret_cast<const short *>(tmpptr)); // @@ this 
cast is dangerous due to memory alignment constraints
           tmpptr += sizeof(short);
           el.data = (const unsigned char*)tmpptr; 
@@ -984,22 +1001,28 @@
           tmpptr += length;
           el.length = length;
           break;
-      case Object:
-      case MovieClip:
-      case Null: 
-      case Undefined:
-      case Reference:
-      case ECMAArray:
-      case ObjectEnd:
-      case StrictArray:
-      case Date:
-      case LongString:
-      case Unsupported:
-      case Recordset:
-      case XMLObject:
-      case TypedObject:
-//       default:
-//           dbglogfile << "astype_e of value: " << (int)type << " is 
unimplemented!" << endl;
+      case OBJECT:
+      case MOVIECLIP:
+      case NULL_VALUE: 
+      case UNDEFINED:
+      case REFERENCE:
+      case ECMA_ARRAY:
+      case OBJECT_END:
+          dbglogfile << "End of Object definition." << endl;
+          el.name.erase();
+          el.length = 0;
+          el.data = 0;
+          el.type = AMF::OBJECT_END;
+          break;
+      case STRICT_ARRAY:
+      case DATE:
+      case LONG_STRING:
+      case UNSUPPORTED:
+      case RECORD_SET:
+      case XML_OBJECT:
+      case TYPED_OBJECT:
+      default:
+          dbglogfile << "astype_e of value: " << (int)type << " is 
unimplemented!" << endl;
           break;
     }
     
@@ -1007,3 +1030,8 @@
 }
 
 } // end of amf namespace
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libamf/amf.h        29 Oct 2006 18:34:18 -0000      1.11
+++ libamf/amf.h        16 Mar 2007 15:00:49 -0000      1.12
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   Copyright (C) 2005, 2006, 2007 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
@@ -14,9 +14,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 _AMF_H_
 #define _AMF_H_
 
@@ -40,6 +37,7 @@
 typedef long long amfnum_t;
 #define AMFNUM_F "%lld"
 #endif
+const char AMF_NUMBER_SIZE = 0x08;
 
 // These are the data types defined by AMF
 typedef char AMF_Byte_t;
@@ -59,39 +57,17 @@
 
 const char AMF_VERSION = 0;
 const int  AMF_HEADSIZE_MASK = 0xc0;
-const char AMF_INDEX_MASK = 0x03;
+const char AMF_HEADER_SIZE = 0x03;
+const char AMF_INDEX_MASK = 0x03f;
 const int  AMF_VIDEO_PACKET_SIZE = 128;
 const int  AMF_AUDIO_PACKET_SIZE = 64;
+// This is the sized used when reading from the network to
+// be the most efficient
+const int  AMF_PACKET_SIZE = 7096;
 
 // For terminating sequences, a byte with value 0x09 is used.
 const char TERMINATOR = 0x09;
 
-// Each header consists of the following:
-//
-// * UTF string (including length bytes) - name
-// * Boolean - specifies if understanding the header is `required'
-// * Long - Length in bytes of header
-// * Variable - Actual data (including a type code)
-typedef struct {
-    amfutf8_t name;
-    AMF_Byte_t required;
-    AMF_Long_t length;
-    void *data;
-} amfhead_t;
-
-// Each body consists of the following:
-//
-// * UTF String - Target
-// * UTF String - Response
-// * Long - Body length in bytes
-// * Variable - Actual data (including a type code)
-typedef struct {
-    amfutf8_t target;
-    amfutf8_t response;
-    AMF_Long_t length;
-    void *data;
-} amfbody_t;
-
 // Each packet consists of the following:
 //
 // The first byte of the AMF file/stream is believed to be a version
@@ -123,25 +99,25 @@
 
 class AMF {
 public:
-    // The folowing elements are defined within AMF:
+    // The following elements are defined within AMF:
     typedef enum {
-        Number=0x00,
-        Boolean=0x01,
-        String=0x02,
-        Object=0x03,
-        MovieClip=0x04,
-        Null=0x05,
-        Undefined=0x06,
-        Reference=0x07,
-        ECMAArray=0x08,
-        ObjectEnd=0x09,
-        StrictArray=0x0a,
-        Date=0x0b,
-        LongString=0x0c,
-        Unsupported=0x0d,
-        Recordset=0x0e,
-        XMLObject=0x0f,
-        TypedObject=0x10
+        NUMBER=0x00,
+        BOOLEAN=0x01,
+        STRING=0x02,
+        OBJECT=0x03,
+        MOVIECLIP=0x04,
+        NULL_VALUE=0x05,
+        UNDEFINED=0x06,
+        REFERENCE=0x07,
+        ECMA_ARRAY=0x08,
+        OBJECT_END=0x09,
+        STRICT_ARRAY=0x0a,
+        DATE=0x0b,
+        LONG_STRING=0x0c,
+        UNSUPPORTED=0x0d,
+        RECORD_SET=0x0e,
+        XML_OBJECT=0x0f,
+        TYPED_OBJECT=0x10
     } astype_e;
     typedef enum {
         HEADER_12 = 0x0,
@@ -162,19 +138,32 @@
     typedef enum {
       NONE = 0x0,
         CHUNK_SIZE = 0x1,
-//    UNKNOWN = 0x2,
+        UNKNOWN = 0x2,
         BYTES_READ = 0x3,
         PING = 0x4,
         SERVER = 0x5,
         CLIENT = 0x6,
-//    UNKNOWN2 = 0x7,
+        UNKNOWN2 = 0x7,
         AUDIO_DATA = 0x8,
         VIDEO_DATA = 0x9,
-//    UNKNOWN3 = 0xa,
+        UNKNOWN3 = 0xa,
         NOTIFY = 0x12,
         SHARED_OBJ = 0x13,
         INVOKE = 0x14
     } content_types_e;
+    typedef enum {
+        CONNECT = 0x01,
+        DISCONNECT = 0x02,
+        SET_ATTRIBUTE = 0x03,
+        UPDATE_DATA = 0x04,
+        UPDATE_ATTRIBUTE = 0x05,
+        SEND_MESSAGE = 0x06,
+        STATUS = 0x07,
+        CLEAR_DATA = 0x08,
+        DELETE_DATA = 0x09,
+        DELETE_ATTRIBYTE = 0x0a,
+        INITIAL_DATA = 0x0b
+    } shared_obj_types_e;
     typedef struct {
       astype_e       type;
       short          length;
@@ -189,15 +178,28 @@
     void *swapBytes(void *word, int size);
     
     void *encodeElement(astype_e type, void *in, int nbytes);
-    amfhead_t *encodeHeader(amfutf8_t *name, bool required, int nbytes, void 
*data);
-    amfbody_t *encodeBody(amfutf8_t *target, amfutf8_t *response, int nbytes, 
void *data);
-    amfpacket_t *encodePacket(std::vector<amfhead_t *> messages);
+    void *encodeString(char *str)  {
+        return encodeElement (STRING, str, strlen(str));
+    };
+    void *encodeString(std::string &str) {
+        return encodeElement (STRING, (void *)str.c_str(), str.size());
+    };
+    void *encodeNumber(amfnum_t num)  {
+        return encodeElement (NUMBER, &num, AMF_NUMBER_SIZE);
+    };
+    
+//     amfhead_t *encodeHeader(amfutf8_t *name, bool required, int nbytes, 
void *data);
+//     amfbody_t *encodeBody(amfutf8_t *target, amfutf8_t *response, int 
nbytes, void *data);
+//    amfpacket_t *encodePacket(std::vector<amfhead_t *> messages);
+
     char *readElement(void *in);
     bool readObject(void *in);
+    
     astype_e extractElementHeader(void *in);
     int extractElementLength(void *in);
-    std::string extractString(const char *in); // FIXME: 
-    int extractNumber(const char *in); // FIXME: 
+    char *extractString(const char *in);
+    amfnum_t *extractNumber(const char *in);
+    amf_element_t *extractObject(const char *in);
 
     unsigned char *extractVariables(amf_element_t &el, unsigned char *in);
     
@@ -211,8 +213,15 @@
     
     int getHeaderSize() {  return _header_size; }; 
     int getTotalSize() {  return _total_size; }; 
+    int getPacketSize()         { return _packet_size; };
+    int getMysteryWord()        { return _mystery_word; };
+    int getRouting()            { return _src_dest; };
+
+    content_types_e getType()   { return _type; };
+    
     unsigned char *addPacketData(unsigned char *data, int bytes);
     //    std::map<amf_element_t *, std::vector<unsigned char *> > 
*getElements() { return &_elements; };
+    
  private:
     content_types_e     _type;
 //    std::map<std::string, amf_element_t &> _elements;
@@ -231,3 +240,8 @@
 
 // end of _AMF_H_
 #endif
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

Index: libamf/amftest.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amftest.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libamf/amftest.cpp  30 Jan 2007 02:02:28 -0000      1.9
+++ libamf/amftest.cpp  16 Mar 2007 15:00:49 -0000      1.10
@@ -23,6 +23,13 @@
 #include <netinet/in.h>
 #include <string>
 #include <sys/types.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <log.h>
+#include <iostream>
+#include <string>
 
 #include "dejagnu.h"
 
@@ -47,6 +54,7 @@
 #include "amf.h"
 
 using namespace amf;
+using namespace gnash;
 using namespace std;
 
 static void usage (void);
@@ -96,23 +104,24 @@
 
     test_Number();
     test_Boolean();
-//    test_String();
+    test_String();
 
-    test_Header();
-    test_Body();
-    test_Packet();
+//     test_Header();
+//     test_Body();
+//     test_Packet();
 }
 
 void
 test_Number(void)
 {
     AMF amf_obj;
+#if 0
     amfnum_t num = 123456789;
 
     // Write a number element
     note("Test a Number element");
-    void *out = amf_obj.encodeElement(AMF::Number, &num, 0);
-    if (amf_obj.extractElementHeader(out) == AMF::Number) {
+    void *out = amf_obj.encodeElement(AMF::NUMBER, &num, 0);
+    if (amf_obj.extractElementHeader(out) == AMF::NUMBER) {
         runtest.pass("Number header correct");
     } else {
         runtest.fail("Number header not correct");
@@ -134,6 +143,46 @@
     } else {
         fail("Number swapped not correct");
     }    
+#endif
+    int fd, ret;
+    char buf[AMF_NUMBER_SIZE+1];
+    amfnum_t value = 0xf03fL;
+    amfnum_t *num;
+    
+    memset(buf, 0, AMF_NUMBER_SIZE+1);
+    fd = open("number.amf", O_RDONLY);
+    ret = read(fd, buf, 12);
+    close(fd);
+
+    num = amf_obj.extractNumber(buf);
+
+//     unsigned char hexint[32];
+//     hexify((unsigned char *)hexint, (unsigned char *)num, 8, false);
+//     cerr << "AMF number is: 0x" << hexint << endl;
+//     hexify((unsigned char *)hexint, (unsigned char *)&value, 8, false);
+//     cerr << "AMF value is: 0x" << hexint << endl;
+
+    if (((char *)num)[7] == 0x3f) {
+//    if (memcmp(num, &value, AMF_NUMBER_SIZE) == 0) {
+        runtest.pass("Extracted Number AMF object");
+    } else {
+        runtest.fail("Extracted Number AMF object");
+    }
+
+    void *out = amf_obj.encodeNumber(*num);
+//     hexify((unsigned char *)hexint, (unsigned char *)out, 9, false);
+//     cerr << "AMF encoded number is: 0x" << hexint << endl;
+
+//     hexify((unsigned char *)hexint, (unsigned char *)buf, 9, false);
+//     cerr << "AMF buff number is: 0x" << hexint << endl;
+
+    if (memcmp(out, buf, 9) == 0) {
+        runtest.pass("Encoded AMF Number");
+    } else {
+        runtest.fail("Encoded AMF Number");
+    }
+
+    delete num;
 }
 
 void
@@ -143,9 +192,8 @@
     bool bo = false;
 
     // Write a number element
-    note("Test a Boolean element");
-    void *out = amf_obj.encodeElement(AMF::Boolean, &bo, 0);
-    if (amf_obj.extractElementHeader(out) == AMF::Boolean) {
+    void *out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
+    if (amf_obj.extractElementHeader(out) == AMF::BOOLEAN) {
         runtest.pass("Boolean header correct");
     } else {
         runtest.fail("Boolean header not correct");
@@ -161,7 +209,7 @@
         runtest.fail("Boolean false returned not correct");
     }
     bo = true;
-    out = amf_obj.encodeElement(AMF::Boolean, &bo, 0);
+    out = amf_obj.encodeElement(AMF::BOOLEAN, &bo, 0);
     if (*((char *)out + 1) == 1) {
         runtest.pass("Boolean true returned correct");
     } else {
@@ -169,6 +217,42 @@
     }
 }
 
+// Make sure we can read and write binary AMF strings
+void
+test_String(void)
+{
+    AMF amf_obj;
+    int fd, ret;
+    char buf[AMF_VIDEO_PACKET_SIZE+1];
+
+    // First see if we can read strings. This file is produced by
+    // using a network packet sniffer, and should be binary correct.
+    memset(buf, 0, AMF_VIDEO_PACKET_SIZE+1);
+    fd = open("string1.amf", O_RDONLY);
+    ret = read(fd, buf, AMF_VIDEO_PACKET_SIZE);
+    close(fd);
+
+    char *str = amf_obj.extractString(buf);
+    if (strcmp(str, "connect") == 0) {
+        runtest.pass("Extracted \"connect\" string");
+    } else {
+        runtest.fail("Extracted \"connect\" string");
+    }
+
+    // Now make sure we can also create strings. We'll create the same
+    // string we just read, and make sure they match.
+    char *connect = "connect";
+    void *out = amf_obj.encodeElement(AMF::STRING, connect, strlen(connect));
+    if (memcmp(out, buf, 10) == 0) {
+        runtest.pass("Encoded \"connect\" string");
+    } else {
+        runtest.fail("Encoded \"connect\" string");
+    }
+
+    delete str;
+}
+
+#if 0
 // Each header consists of the following:
 //
 // * UTF string (including length bytes) - name
@@ -191,7 +275,7 @@
     name.length = strlen(test);
     name.data = test;
     
-    element = amf_obj.encodeElement(AMF::Number, &num, 0);
+    element = amf_obj.encodeElement(AMF::NUMBER, &num, 0);
     head = amf_obj.encodeHeader(&name, true, sizeof(amfnum_t), &num);
 
     char *ptr = ((char *)head) + 2;
@@ -202,7 +286,7 @@
     }
 
     ptr = ((char *)head) + 2 + name.length + 1;
-    if (*ptr == AMF::Number) {
+    if (*ptr == AMF::NUMBER) {
         runtest.pass("Header Object type correct");
     } else {
         runtest.fail("Header Object type not correct");
@@ -235,6 +319,7 @@
     // Write a number element
     note("Test the Packet");
 }
+#endif
 
 static void
 usage (void)

Index: libamf/rtmp.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/rtmp.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libamf/rtmp.cpp     11 Nov 2006 15:25:27 -0000      1.12
+++ libamf/rtmp.cpp     16 Mar 2007 15:00:49 -0000      1.13
@@ -312,3 +312,8 @@
 }
 
 } // end of cygnal namespace
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:

Index: libamf/rtmp.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/rtmp.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libamf/rtmp.h       29 Oct 2006 18:34:18 -0000      1.6
+++ libamf/rtmp.h       16 Mar 2007 15:00:49 -0000      1.7
@@ -1,5 +1,5 @@
 // 
-//   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//   Copyright (C) 2005, 2006, 2007 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
@@ -14,9 +14,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 _RTMP_H_
 #define _RTMP_H_
 
@@ -54,6 +51,55 @@
         DELETE_ATTRIBUTE = 0xa,
         INITIAL_DATA = 0xb
     } sharedobj_types_e;
+    typedef enum {
+        RTMP_STATE_HANDSHAKE_SEND,
+        RTMP_STATE_HANDSHAKE_RECV,
+        RTMP_STATE_HANDSHAKE_ACK,
+        RTMP_STATE_CONNECT,
+        RTMP_STATE_NETCONNECT,
+        RTMP_STATE_NETSTREAM,
+        RTMP_STATE_HEADER,
+        RTMP_STATE_DONE
+    } rtmp_state_t;
+    typedef enum {
+        RTMP_ERR_UNDEF=0,
+        RTMP_ERR_NOTFOUND,
+        RTMP_ERR_PERM,
+        RTMP_ERR_DISKFULL,
+        RTMP_ERR_ILLEGAL,
+        RTMP_ERR_UNKNOWNID,
+        RTMP_ERR_EXISTS,
+        RTMP_ERR_NOSUCHUSER,
+        RTMP_ERR_TIMEOUT,
+        RTMP_ERR_NORESPONSE
+    } rtmp_error_t;
+
+// Each header consists of the following:
+//
+// * UTF string (including length bytes) - name
+// * Boolean - specifies if understanding the header is `required'
+// * Long - Length in bytes of header
+// * Variable - Actual data (including a type code)
+    typedef struct {
+        amf::amfutf8_t name;
+        amf::AMF_Byte_t required;
+        amf::AMF_Long_t length;
+        void *data;
+    } rtmp_head_t;
+    
+// Each body consists of the following:
+//
+// * UTF String - Target
+// * UTF String - Response
+// * Long - Body length in bytes
+// * Variable - Actual data (including a type code)
+    typedef struct {
+        amf::amfutf8_t target;
+        amf::amfutf8_t response;
+        amf::AMF_Long_t length;
+        void *data;
+    } rtmp_body_t;
+    
     RTMPproto();
     virtual ~RTMPproto();
     virtual bool handShakeWait();
@@ -78,3 +124,9 @@
 
 // end of _RTMP_H_
 #endif
+
+// local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
+

Index: testsuite/libamf.all/Makefile.am
===================================================================
RCS file: testsuite/libamf.all/Makefile.am
diff -N testsuite/libamf.all/Makefile.am
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/libamf.all/Makefile.am    16 Mar 2007 15:00:49 -0000      1.1
@@ -0,0 +1,84 @@
+## Process this file with automake to generate Makefile.in
+# 
+#   Copyright (C) 2005, 2006, 2007 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
+
+# $Id: Makefile.am,v 1.1 2007/03/16 15:00:49 rsavoye Exp $
+
+AUTOMAKE_OPTIONS = dejagnu
+
+AM_LDFLAGS = \
+       ../../libbase/libgnashbase.la \
+       ../../libamf/libgnashamf.la \
+       $(LIBLTDL) \
+       $(GLIB_LIBS) \
+       $(LIBXML_LIBS) \
+       $(CURL_LIBS) \
+       $(BOOST_LIBS) \
+       $(PTHREAD_LIBS)
+
+AM_CPPFLAGS = -DSRCDIR=\"$(srcdir)\"
+
+INCLUDES = -I.. \
+        -I$(top_srcdir)        \
+        -I$(top_srcdir)/libamf \
+        -I$(top_srcdir)/libbase \
+        -I$(top_srcdir)/server \
+        $(LIBXML_CFLAGS) \
+       $(DMALLOC_CFLAGS) \
+       $(CURL_CFLAGS) \
+       $(BOOST_CFLAGS) \
+       $(PTHREAD_CFLAGS)
+
+# AM_LDFLAGS  = $(OPENGL_LIBNS) $(SDL_LIBS)
+
+
+check_PROGRAMS = test_number test_string test_object
+test_number_SOURCES = test_number.cpp
+test_number_LDADD = $(AM_LDFLAGS)
+test_string_SOURCES = test_string.cpp
+test_string_LDADD = $(AM_LDFLAGS)
+test_object_SOURCES = test_object.cpp
+test_object_LDADD = $(AM_LDFLAGS)
+
+
+# Rebuild with GCC 4.x Mudflap support
+mudflap:
+       @echo "Rebuilding with GCC Mudflap support"
+       $(MAKE) CXXFLAGS="$(CXXFLAGS) -fmudflap" LDFLAGS="$(LDFLAGS) -lmudflap"
+
+clean-hook:
+       -rm -f core.*
+
+TEST_DRIVERS = ../simple.exp
+
+
+check-DEJAGNU: site-update $(TEST_CASES)
+       @runtest=$(RUNTEST); \
+       if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+           $$runtest $(RUNTESTFLAGS) $(TEST_DRIVERS); \
+       else \
+         echo "WARNING: could not find \`runtest'" 1>&2; \
+          for i in "$(check_PROGRAMS)"; do \
+           $(SHELL) $$i; \
+         done; \
+       fi
+
+site-update: site.exp
+       @rm -fr site.exp.bak
+       @cp site.exp site.exp.bak
+       @sed -e '/testcases/d' site.exp.bak > site.exp
+       @echo "# This is a list of the pre-compiled testcases" >> site.exp
+       @echo "set testcases \"$(check_PROGRAMS)\"" >> site.exp

Index: testsuite/libamf.all/connect-object.amf
===================================================================
RCS file: testsuite/libamf.all/connect-object.amf
diff -N testsuite/libamf.all/connect-object.amf
Binary files /dev/null and /tmp/cvsQDXrL1 differ

Index: testsuite/libamf.all/connect-string.amf
===================================================================
RCS file: testsuite/libamf.all/connect-string.amf
diff -N testsuite/libamf.all/connect-string.amf
Binary files /dev/null and /tmp/cvsrchm7Z differ

Index: testsuite/libamf.all/f03f.amf
===================================================================
RCS file: testsuite/libamf.all/f03f.amf
diff -N testsuite/libamf.all/f03f.amf
Binary files /dev/null and /tmp/cvs4YfEJ0 differ

Index: testsuite/libamf.all/result-fail.amf
===================================================================
RCS file: testsuite/libamf.all/result-fail.amf
diff -N testsuite/libamf.all/result-fail.amf
Binary files /dev/null and /tmp/cvsvMpCH3 differ

Index: testsuite/libamf.all/result-success.amf
===================================================================
RCS file: testsuite/libamf.all/result-success.amf
diff -N testsuite/libamf.all/result-success.amf
Binary files /dev/null and /tmp/cvs6nCLf4 differ

Index: testsuite/libamf.all/test_number.cpp
===================================================================
RCS file: testsuite/libamf.all/test_number.cpp
diff -N testsuite/libamf.all/test_number.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/libamf.all/test_number.cpp        16 Mar 2007 15:00:49 -0000      
1.1
@@ -0,0 +1,127 @@
+// 
+//   Copyright (C) 2005, 2006, 2007 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
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_DEJAGNU_H
+
+#include <netinet/in.h>
+#include <string>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <log.h>
+#include <iostream>
+#include <string>
+
+#include "dejagnu.h"
+
+
+#include "amf.h"
+
+using namespace amf;
+using namespace gnash;
+using namespace std;
+
+static void usage (void);
+
+static int verbosity;
+
+static TestState runtest;
+
+int
+main(int argc, char *argv[])
+{
+    bool dump = false;
+    char buffer[300];
+    int c, retries = 3;
+
+    memset(buffer, 0, 300);
+    
+    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+        switch (c) {
+          case 'h':
+            usage ();
+            break;
+            
+          case 'v':
+            verbosity++;
+            break;
+            
+          default:
+            usage ();
+            break;
+        }
+    }
+    
+    AMF amf_obj;
+    int fd, ret;
+    char buf[AMF_NUMBER_SIZE+1];
+    amfnum_t value = 0xf03fL;
+    amfnum_t *num;
+    
+    memset(buf, 0, AMF_NUMBER_SIZE+1);
+    string filespec = SRCDIR;
+    filespec += "/f03f.amf";
+    fd = open(filespec.c_str(), O_RDONLY);
+    ret = read(fd, buf, 12);
+    close(fd);
+
+    num = amf_obj.extractNumber(buf);
+
+//     unsigned char hexint[32];
+//     hexify((unsigned char *)hexint, (unsigned char *)num, 8, false);
+//     cerr << "AMF number is: 0x" << hexint << endl;
+//     hexify((unsigned char *)hexint, (unsigned char *)&value, 8, false);
+//     cerr << "AMF value is: 0x" << hexint << endl;
+
+    if (((char *)num)[7] == 0x3f) {
+//    if (memcmp(num, &value, AMF_NUMBER_SIZE) == 0) {
+        runtest.pass("Extracted Number AMF object");
+    } else {
+        runtest.fail("Extracted Number AMF object");
+    }
+
+    void *out = amf_obj.encodeNumber(*num);
+//     hexify((unsigned char *)hexint, (unsigned char *)out, 9, false);
+//     cerr << "AMF encoded number is: 0x" << hexint << endl;
+
+//     hexify((unsigned char *)hexint, (unsigned char *)buf, 9, false);
+//     cerr << "AMF buff number is: 0x" << hexint << endl;
+
+    if (memcmp(out, buf, 9) == 0) {
+        runtest.pass("Encoded AMF Number");
+    } else {
+        runtest.fail("Encoded AMF Number");
+    }
+
+    delete num;
+}
+static void
+usage (void)
+{
+    cerr << "This program tests Number support in the AMF library." << endl;
+    cerr << "Usage: test_number [hv]" << endl;
+    cerr << "-h\tHelp" << endl;
+    cerr << "-v\tVerbose" << endl;
+    exit (-1);
+}
+
+#endif

Index: testsuite/libamf.all/test_object.cpp
===================================================================
RCS file: testsuite/libamf.all/test_object.cpp
diff -N testsuite/libamf.all/test_object.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/libamf.all/test_object.cpp        16 Mar 2007 15:00:49 -0000      
1.1
@@ -0,0 +1,175 @@
+// 
+//   Copyright (C) 2005, 2006, 2007 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
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_DEJAGNU_H
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <log.h>
+#include <string>
+#include <iostream>
+#include <string>
+
+#include "dejagnu.h"
+#include "rtmp.h"
+#include "amf.h"
+
+using namespace amf;
+using namespace gnash;
+using namespace std;
+
+static void usage (void);
+
+static int verbosity;
+
+TestState runtest;
+
+void test_Number(void);
+void test_Boolean(void);
+void test_String(void);
+
+void test_Header(void);
+void test_Body(void);
+void test_Packet(void);
+
+// These are used to print more intelligent debug messages
+const char *astype_str[] = {
+    "Number",
+    "Boolean",
+    "String",
+    "Object",
+    "MovieClip",
+    "Null",
+    "Undefined",
+    "Reference",
+    "ECMAArray",
+    "ObjectEnd",
+    "StrictArray",
+    "Date",
+    "LongString",
+    "Unsupported",
+    "Recordset",
+    "XMLObject",
+    "TypedObject"
+};
+
+int
+main(int argc, char *argv[])
+{
+    bool dump = false;
+    char buffer[300];
+    int c, retries = 3;
+
+    memset(buffer, 0, 300);
+    
+    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+        switch (c) {
+          case 'h':
+            usage ();
+            break;
+            
+          case 'v':
+            verbosity++;
+            break;
+            
+          default:
+            usage ();
+            break;
+        }
+    }
+
+    // get the file name from the command line
+    if (optind < argc) {
+        string filespec = argv[optind];
+        cout << "Will use \"" << filespec << "\" for test " << endl;
+    }
+
+    AMF amf_obj;
+    int fd, ret;
+    unsigned char buf[AMF_PACKET_SIZE+1];
+    unsigned char *tmpptr;
+    short length;
+    AMF::amf_element_t el;
+
+    // First see if we can read strings. This file is produced by
+    // using a network packet sniffer, and should be binary correct.
+    memset(buf, 0, AMF_PACKET_SIZE+1);
+    string filespec = SRCDIR;
+    filespec += "/connect-object.amf";
+    
+    fd = open(filespec.c_str(), O_RDONLY);
+    ret = read(fd, buf, AMF_PACKET_SIZE);
+    close(fd);
+
+    amf_obj.parseHeader(buf);
+    if (amf_obj.getTotalSize() == 269) {
+        runtest.pass("Message Header Total Size");
+    } else {
+        runtest.fail("Message Header Total Size");
+    }
+    
+    if (amf_obj.getHeaderSize() == 12) {
+        runtest.pass("Message Header Size");
+    } else {
+        runtest.fail("Message Header Size");
+    }
+    
+    if (amf_obj.getMysteryWord() == 0) {
+        runtest.pass("Message Mystery Word");
+    } else {
+        runtest.fail("Message Mystery Word");
+    }
+    
+    if (amf_obj.getRouting() == 0) {
+        runtest.pass("Message Routing");
+    } else {
+        runtest.fail("Message Routing");
+    }
+
+    amf_obj.parseBody(buf + amf_obj.getHeaderSize(), amf_obj.getTotalSize());
+
+    tmpptr = buf;
+
+    
+//    tmpptr = amf_obj.extractVariables(el, tmpptr);
+    
+//     char *str = amf_obj.extractObject(buf);
+//     if (strcmp(str, "connect") == 0) {
+//         runtest.pass("Extracted \"connect\" string");
+//     } else {
+//         runtest.fail("Extracted \"connect\" string");
+//     }
+
+}
+
+static void
+usage (void)
+{
+    cerr << "This program tests Shared Object support in the AMF library." << 
endl;
+    cerr << "Usage: test_object [hv]" << endl;
+    cerr << "-h\tHelp" << endl;
+    cerr << "-v\tVerbose" << endl;
+    exit (-1);
+}
+
+#endif

Index: testsuite/libamf.all/test_string.cpp
===================================================================
RCS file: testsuite/libamf.all/test_string.cpp
diff -N testsuite/libamf.all/test_string.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ testsuite/libamf.all/test_string.cpp        16 Mar 2007 15:00:49 -0000      
1.1
@@ -0,0 +1,113 @@
+// 
+//   Copyright (C) 2005, 2006, 2007 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
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef HAVE_DEJAGNU_H
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#include "dejagnu.h"
+#include "amf.h"
+
+using namespace amf;
+using namespace std;
+
+static void usage (void);
+
+static int verbosity;
+
+static TestState runtest;
+
+int
+main(int argc, char *argv[])
+{
+    bool dump = false;
+    char buffer[300];
+    int c, retries = 3;
+
+    memset(buffer, 0, 300);
+    
+    while ((c = getopt (argc, argv, "hdvsm:")) != -1) {
+        switch (c) {
+          case 'h':
+            usage ();
+            break;
+            
+          case 'v':
+            verbosity++;
+            break;
+            
+          default:
+            usage ();
+            break;
+        }
+    }
+    
+    // get the file name from the command line
+    if (optind < argc) {
+        string filespec = argv[optind];
+        cout << "Will use \"" << filespec << "\" for test " << endl;
+    }
+
+    AMF amf_obj;
+    int fd, ret;
+    char buf[AMF_VIDEO_PACKET_SIZE+1];
+
+    // First see if we can read strings. This file is produced by
+    // using a network packet sniffer, and should be binary correct.
+    memset(buf, 0, AMF_VIDEO_PACKET_SIZE+1);
+    string filespec = SRCDIR;
+    filespec += "/connect-string.amf";
+    fd = open(filespec.c_str(), O_RDONLY);
+    ret = read(fd, buf, AMF_VIDEO_PACKET_SIZE);
+    close(fd);
+
+    char *str = amf_obj.extractString(buf);
+    if (strcmp(str, "connect") == 0) {
+        runtest.pass("Extracted \"connect\" string");
+    } else {
+        runtest.fail("Extracted \"connect\" string");
+    }
+
+    // Now make sure we can also create strings. We'll create the same
+    // string we just read, and make sure they match.
+    char *connect = "connect";
+    void *out = amf_obj.encodeElement(AMF::STRING, connect, strlen(connect));
+    if (memcmp(out, buf, 10) == 0) {
+        runtest.pass("Encoded \"connect\" string");
+    } else {
+        runtest.fail("Encoded \"connect\" string");
+    }
+
+    delete str;
+}
+
+static void
+usage (void)
+{
+    cerr << "This program tests string support in the AMF library." << endl;
+    cerr << "Usage: test_string [hv]" << endl;
+    cerr << "-h\tHelp" << endl;
+    cerr << "-v\tVerbose" << endl;
+    exit (-1);
+}
+
+#endif




reply via email to

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