[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash gui/Makefile.am libbase/network.cpp libba...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash gui/Makefile.am libbase/network.cpp libba... |
Date: |
Sat, 12 Aug 2006 15:11:53 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 06/08/12 15:11:53
Modified files:
gui : Makefile.am
libbase : network.cpp network.h utility.h
libamf : Makefile.am README amf.cpp amf.h amftest.cpp
rtmp.cpp rtmp.h
plugin/klash : klash.cpp
Log message:
* gui/Makefile.am: Add more libraries to AM_LDFLAGS.
* libamf/Makefile.am: Remove the rest of the amftest.
* libamf/amf.cpp, amf.h, rtmp.cpp, rtmp.h: Much rearranging of
code, plus additional code till libamf actually works now.
* libamf/rtmp.h: Use gnash namespace instead of rtmp one.
* libbase/log.h, log.cpp: Add support to hexify to optionally
print ascii characters in a hex dump.
* libbase/network.cpp: Add WriteNet().
* libbase/utility.h: Include math.h for Darwin.
* macros/gtkglext.m4: Use pkg-config if it exists.
* macros/kde.m4: Add -L to KDE_LDFLAGS.
* plugin/klash/klash.cpp: External variables are now defined
here.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/gui/Makefile.am?cvsroot=gnash&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/network.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/libbase/utility.h?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/Makefile.am?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/README?cvsroot=gnash&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amftest.cpp?cvsroot=gnash&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.cpp?cvsroot=gnash&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.h?cvsroot=gnash&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/gnash/plugin/klash/klash.cpp?cvsroot=gnash&r1=1.9&r2=1.10
Patches:
Index: gui/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/gui/Makefile.am,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gui/Makefile.am 1 Aug 2006 23:12:48 -0000 1.12
+++ gui/Makefile.am 12 Aug 2006 15:11:52 -0000 1.13
@@ -114,7 +114,9 @@
## WARNING: make sure GLIB_LIBS appears first
## See: http://lists.gnu.org/archive/html/gnash-dev/2006-07/msg00076.html
AM_LDFLAGS = \
- $(GLIB_LIBS)
+ $(GLIB_LIBS) \
+ $(PANGO_LIBS) \
+ $(GLEXT_LIBS)
# ../libbase/libgnashbase.la \
# $(JPEG_LIBS) \
# $(PNG_LIBS) \
@@ -128,7 +130,6 @@
# $(GTK2_LIBS) \
# $(FLTK_LIBS) \
# $(XFT_LIBS) \
-# $(PANGO_LIBS) \
# $(CAIRO_LIBS) \
# $(ATK_LIBS) \
# $(GLIB_LIBS) \
@@ -145,6 +146,7 @@
$(SDL_SRCS) \
$(FLTK_SRCS) \
$(GTK_SRCS) \
+ $(GTK2_SRCS) \
$(KDE_SRCS) \
gui.cpp gui.h \
NullGui.cpp \
@@ -152,7 +154,9 @@
libgnashgui_la_LIBADD = \
../server/libgnashserver.la \
- ../libamf/libgnashamf.la
+ ../libamf/libgnashamf.la \
+ ../backend/libgnashbackend.la \
+ $(AM_LDFLAGS)
if USE_GUI_KDE
bin_PROGRAMS = gnash klash
Index: libbase/network.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libbase/network.cpp 6 Aug 2006 02:00:54 -0000 1.3
+++ libbase/network.cpp 12 Aug 2006 15:11:53 -0000 1.4
@@ -640,6 +640,12 @@
}
int
+Network::writeNet(const unsigned char *buffer, int nbytes)
+{
+ return writeNet(_sockfd, (char *)buffer, nbytes, _timeout);
+}
+
+int
Network::writeNet(int fd, char const *buffer)
{
return writeNet(fd, buffer, strlen(buffer), _timeout);
Index: libbase/network.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/network.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libbase/network.h 1 Aug 2006 16:57:35 -0000 1.2
+++ libbase/network.h 12 Aug 2006 15:11:53 -0000 1.3
@@ -104,6 +104,7 @@
int writeNet(std::string buffer);
int writeNet(char const *buffer);
int writeNet(char const *buffer, int nbytes);
+ int writeNet(const unsigned char *buffer, int nbytes);
int writeNet(int fd, char const *buffer);
int writeNet(int fd, char const *buffer, int nbytes);
int writeNet(int fd, char const *buffer, int nbytes, int timeout);
Index: libbase/utility.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/utility.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libbase/utility.h 7 Jun 2006 04:28:46 -0000 1.4
+++ libbase/utility.h 12 Aug 2006 15:11:53 -0000 1.5
@@ -9,6 +9,7 @@
#ifndef UTILITY_H
#define UTILITY_H
+#include "math.h"
#include "tu_config.h"
#include <assert.h>
#include "tu_math.h"
Index: libamf/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libamf/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libamf/Makefile.am 2 Aug 2006 01:34:10 -0000 1.9
+++ libamf/Makefile.am 12 Aug 2006 15:11:53 -0000 1.10
@@ -65,11 +65,11 @@
-I$(top_srcdir)/libbase \
$(LIBXML_CFLAGS)
-# noinst_PROGRAMS = amftest
noinst_HEADERS = amfutf8.h amf.h rtmp.h
-amftest_SOURCES = amftest.cpp
-amftest_LDADD = $(AM_LDFLAGS) libgnashamf.la
+# noinst_PROGRAMS = amftest
+# amftest_SOURCES = amftest.cpp
+# amftest_LDADD = $(AM_LDFLAGS) libgnashamf.la
# Rebuild with GCC 4.x Mudflap support
mudflap:
Index: libamf/README
===================================================================
RCS file: /sources/gnash/gnash/libamf/README,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- libamf/README 13 Feb 2006 01:15:59 -0000 1.1
+++ libamf/README 12 Aug 2006 15:11:53 -0000 1.2
@@ -257,3 +257,276 @@
Reference tag
16 big big-endian number follows the tag identifier 0x07.
+------------------------------------
+http://sourceforge.net/docman/display_doc.php?docid=27130&group_id=131628
+
+Flashcoders Wiki - SharedObjectFile
+SharedObjectFile
+
+The format of the shared object files
+
+ This script creates the described .sol file
+
+ so = SharedObject.getLocal("test");
+ so.data.myInt = 7;
+ so.data.myFloat = Math.PIE;
+ so.data.myString = 'ralle';
+ so.data.myIntArray = [1,2,3];
+ so.data.myStringArray = ['eins','zwei'];
+ so.data.myObject1 = {p1: 5, p2: 6};
+ so.data.myObject2 = {p3: 'hallo', p4: 8};
+ so.data.myDate = new Date();
+ so.data.myXML = new XML("<start><p>test</p><p>test2</p></start>");
+ so.data.myBool = true;
+ so.flush();
+
+ ----
+
+ header 00 BF
+ len 00 00 01 04 //length of file starting at filetype
+ filetype TCSO ... 00 04 00 00 00 00
+
+ //myInt = 7;
+ 00 05 myInt 00 40 1C 00 00 00 00 00 00 00
+ len name typ floatval end
+
+ //myFloat = Math.PI;
+ 00 07 myFloat 00 40 09 21 FB 54 44 2D 18 00
+ len name typ floatval end
+
+ //myString = "ralle";
+ 00 08 myString 02 00 05 r a l l e 00
+ len name typ lenstr str end
+
+ //myIntArray = [1,2,3];
+ 00 0A myIntArray 08 00 00 00 03
+ len name typ countidx
+
+ 00 01 '0' 00 3F F0 00 00 00 00 00 00 !! no end here
+ 00 01 '1' 00 40 00 00 00 00 00 00 00
+ 00 01 '2' 00 40 08 00 00 00 00 00 00
+ lenidx idx typ floatval
+
+ 00 00 09 00
+ end of array
+
+ //myStringArray = ["eins","zwei"];
+ 00 0D myStringArray 08 00 00 00 02
+ len name typ count
+
+ 00 10 '0' 02 00 04 e i n s
+ 00 01 '1' 02 00 04 z w e i
+ lenidx idx typ strlen string
+
+ 00 00 09 00
+ end of array
+
+ //myObject1 = {p1: 5, p2: 6};
+ 00 09 myObject1 03
+ 00 02 p2 00 40 18 00 00 00 00 00 00 !!no end here
+ 00 02 p1 00 40 14 00 00 00 00 00 00
+ lenidx idx typ floatval
+
+ 00 00 09 00
+ end of array
+
+ //myObject2 = {p3: "hallo", p4: 8};
+ 00 09 myObject2 03
+ 00 02 p4 00 40 20 00 00 00 00 00 00 00
+ lenidx idx typ floatval end
+ 00 20 p3 02 00 05 hallo
+ lenidx idx typ strlen string
+
+ 00 00 09 00
+ end of array
+
+// AlexisIsaac
+
+ It seems that the previous sample isn't exact there is no end byte on the
first property:
+ 00 09 myObject2 03
+ 00 02 p4 00 40 20 00 00 00 00 00 00 00
+ lenidx idx typ floatval end
+ 00 20 p3 02 00 05 hallo
+ lenidx idx typ strlen string
+
+ 00 00 09 00
+ end of array
+
+ //myDate = new Date();
+ 00 06 myDate 0B
+ 42 6D DA E6 18 52 C0 00 FF 88 00
+ floatval-getTime timezone (mins -ve of GMT)
+ FF88 = GMT +2 (-2 * 60)
+ FDE4 = GMT +9 (-9 * 60)
+ 0000 = GMT
+ 01E0 = GMT -8 (8 * 60)
+
+ //myXML = new XML("<start><p>test</p><p>test2</p></start>")
+ 00 05 myXML 0F
+ 00 00 00 26 <start><p>test</p><p>test2</p></start> 00
+ length xmlval end
+
+ //myBool = true;
+ 00 06 myBool 01
+ 01 00
+
+// bokel
+
+Here are all the data type ids I can find:
+
+ 00 : number
+ 01 : boolean
+ 02 : string
+ 03 : object Object
+ 05 : null
+ 06 : undefined
+ 08 : object Array
+ 0A : raw Array (amf only)
+ 0B : object Date
+ 0D : object String, Number, Boolean, TextFormat
+ 0F : object XML
+ 10 : object CustomClass
+
+Where CustomClass is a class registered with Object.registerClass
+
+ // eg
+ My
+ this.x = 1;
+ }
+ Object.registerClass("classID",MyClass);
+ myObj = new MyClass();
+
+ 00 05 m y o b j 10 00 07 c l a s s I D //len name typ class
identifier
+ 00 01 x 00 3F F0 00 00 00 00 00 00 //props
+ 00 00 09 00 //end
+
+// Peter Hall
+
+and here is a function to convert binary floats to a float
+
+ function binaryFloatStringToFloat(bfs){
+ var c0 = ord(bfs.charAt(0));
+ var c1 = ord(bfs.charAt(1));
+
+ //calculate sign
+ var sign = (c0 & (1 << 7)) ? -1 : 1; //negative if highest bit is set
+
+ //calculate exponent
+ c0 &= 0x7f; //delete sign
+ var exp = (((c0 << 8) + c1) >> 4) - 1023;
+
+ //calculate mantissa
+ var e = 4;
+ var sum = (c1 & 0x0f) / Math.pow(2, e); //delete upper four bits
+ var byteIdx = 2;
+ do {
+ e += 8;
+ var byte = ord(bfs.charAt(byteIdx));
+ sum += byte / Math.pow(2, e);
+ } while (++byteIdx < bfs.length);
+
+ //trace(sum + " " + exp + " " + sign);
+ return (1 + sum) * Math.pow(2, exp) * sign;
+ }
+
+ //some tests
+ s = String.fromCharCode(0x40,0x08,0,0,0,0,0,0); //3 //s =
String.fromCharCode(0x40,0x1c,0,0,0,0,0,0); //7 //s =
String.fromCharCode(0x40,0x0A,0x66,0x66,0x66,0x66,0x66,0x66); //3.3
+ trace(binaryFloatStringToFloat(s));
+
+// bokel
+
+
+This is the first RTMP message:
+
+(gdb) p buffer
+$10 =
"address@hidden@\000\000\000\000\000\000\003\000\003app\002\000#software/gnash/tests/1153948634.flv\000\bflashVer\002\000\fLNX
6,0,82,0\000\006swfUrl\002\000\035file:///file|address@hidden://localhost/software/gnash/tests/1153948634.flv\000\000\t\002\000\005userx"...
+(gdb) p/x buffer
+$11 = {
+ *0x3,* 0x0, 0x0, 0xf, 0x0, 0x0, *0xc9,*0x14, 0x00, 0x00, 0x00, 0x0,
0x2, 0x0, 0x7,
+ 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x00, 0x3f, 0xf0, 0x00, 0x0,
0x0, 0x0,
+ 0x0, 0x0, 0x3, 0x0, 0x3, 0x61, 0x70, 0x70, 0x02, 0x00, 0x23, 0x73,
0x6f, 0x66, 0x74,
+ 0x77, 0x61, 0x72, 0x65, 0x2f, 0x67, 0x6e, 0x61, 0x73, 0x68, 0x2f, 0x74, 0x65,
+ 0x73, 0x74, 0x73, 0x2f, 0x31, 0x31, 0x35, 0x33, 0x39, 0x34, 0x38, 0x36, 0x33,
+ 0x34, 0x2e, 0x66, 0x6c, 0x76, 0x0, 0x8, 0x66, 0x6c, 0x61, 0x73, 0x68,
0x56, 0x65,
+ 0x72, 0x2, 0x0, 0xc, 0x4c, 0x4e, 0x58, 0x20, 0x36, 0x2c, 0x30, 0x2c,
0x38, 0x32,
+ 0x2c, 0x30, 0x0, 0x6, 0x73, 0x77, 0x66, 0x55, 0x72, 0x6c, 0x02, 0x00,
0x1d, 0x66,
+ 0x69, 0x6c, 0x65, 0x3a, 0x2f, 0x2f, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x7c, 0x25,
+ 0x32, 0x46, 0x74, 0x6d, 0x70, 0x25, 0x32, 0x46, 0x6f, 0x75, 0x74, 0x2e, 0x73,
+ 0x77, 0x66,*0xc3*,0x0, 0x5, 0x74, 0x63, 0x55, 0x72, 0x6c, 0x02, 0x00,
0x34, 0x72,
+ 0x74, 0x6d, 0x70, 0x3a, 0x2f, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x68, 0x6f,
+ 0x73, 0x74, 0x2f, 0x73, 0x6f, 0x66, 0x74, 0x77, 0x61, 0x72, 0x65, 0x2f, 0x67,
+ 0x6e, 0x61, 0x73, 0x68, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x31, 0x31,
+ 0x35, 0x33, 0x39, 0x34, 0x38, 0x36, 0x33, 0x34, 0x2e, 0x66, 0x6c, 0x76, 0x0,
0x0,
+ 0x9, 0x2, 0x0, 0x5, 0x75, 0x73, 0x65, 0x72, 0x78...}
+
+
+"\003\000\000\017\000\000
+%Gï¿¿%@ \024\000\000\000\000\002\000
+\a
+connect\000
+?%G ï¿¿ %@ \000\000\000\000\000\000
+
+First byte:
+\003 = Object type
+\002 = String type
+\000 = Number type
+\008 = Video type
+\009 = Video type
+
+0x09 is also the terminating byte of and object definition
+All numbers are 64 bit big endian in AMF
+
+0xc9 0x14 0x0
+
+0x02 <--- string type
+0x00 0x07 connect
+0x00 <---- number type (64 bit big endian)
+0x3f 0xf0 0x00 0x00 0x00 0x00 0x00 0x00
+
+0x03 <--- object type
+0x00 0x03 app
+0x02 <--- string type
+0x00 0035 software/gnash/tests/1153948634.flv
+
+0x00 0x08 flashVer
+0x02 <--- string type
+0x00 0xf LNX 6,0,82,0
+
+0x00 0x06 swfUrl
+0x02 <--- string type
+0x00 0x00 35 file:///file|/%2Ftmp%2Fout.swf
+
+%G ï¿¿ %@
+0xc3 <---- header byte
+0x00 0x05 tcUrl
+0x02 <--- string type
+0x00 0x00 0x04 rtmp://localhost/software/gnash/tests/1153948634.flv
+
+0x00 0x00 0x09 <--- end of object definition
+
+0x02 0x00 0x05 userx
+
+
+//myInt = 7;
+ 00 05 myInt 00 40 1C 00 00 00 00 00 00 00
+ len name typ floatval end
+
+ //myFloat = Math.PI;
+ 00 07 myFloat 00 40 09 21 FB 54 44 2D 18 00
+ len name typ floatval end
+
+ //myString = "ralle";
+ 00 08 myString 02 00 05 r a l l e 00
+ len name typ lenstr str end
+
+ //myIntArray = [1,2,3];
+ 00 0A myIntArray 08 00 00 00 03
+ len name typ countidx
+
+ 00 01 '0' 00 3F F0 00 00 00 00 00 00 !! no end here
+ 00 01 '1' 00 40 00 00 00 00 00 00 00
+ 00 01 '2' 00 40 08 00 00 00 00 00 00
+ lenidx idx typ floatval
+
+ 00 00 09 00
+ end of array
Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- libamf/amf.cpp 8 Aug 2006 11:17:58 -0000 1.7
+++ libamf/amf.cpp 12 Aug 2006 15:11:53 -0000 1.8
@@ -41,20 +41,21 @@
#include <cstdio>
#include <cstring>
+#include <string>
+#include <vector>
+#include <iostream>
+#include <netinet/in.h>
-#if 0
#include "log.h"
-#else
-// Define this to just use printf
-#define log_msg printf
-#endif
-// #include "wchar.h"
-// #include "wctype.h"
+#include "tu_swap.h"
#include "stdlib.h"
#include "amf.h"
#include "amfutf8.h"
+using namespace std;
+using namespace gnash;
+
namespace amf
{
@@ -86,6 +87,43 @@
"/onDebugEvents"
};
+AMF::AMF()
+ : _type(NONE),
+ _amf_index(0),
+ _header_size(0),
+ _total_size(0),
+ _packet_size(0),
+ _amf_data(0),
+ _seekptr(0),
+ _mystery_word(0),
+ _src_dest(0)
+{
+ GNASH_REPORT_FUNCTION;
+}
+
+AMF::AMF(int size)
+ : _type(NONE),
+ _amf_index(0),
+ _header_size(0),
+ _total_size(0),
+ _packet_size(0),
+ _amf_data(0),
+ _mystery_word(0),
+ _src_dest(0)
+{
+ GNASH_REPORT_FUNCTION;
+ if (!_amf_data) {
+ _amf_data = new unsigned char(size+1);
+ memset(_amf_data, 0, size+1);
+ }
+ _seekptr = _amf_data;
+}
+
+AMF::~AMF()
+{
+ GNASH_REPORT_FUNCTION;
+}
+
/// \brief Swap bytes from big to little endian.
///
@@ -127,16 +165,31 @@
return word;
}
-// This returns the number of bytes read
-int
-AMF::readElement(void *out, void *in)
+
+bool
+AMF::parseAMF(char *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char *x = static_cast<char *>(in);
+
+ while (*x != ObjectEnd) {
+ x = readElement(x);
+ }
+}
+
+char *
+AMF::readElement(void *in)
{
+ GNASH_REPORT_FUNCTION;
+
char *x = static_cast<char *>(in);
astype_e type = (astype_e)*x;
bool boolshift;
const char *mstr = NULL;
amfnum_t num;
amfnum_t nanosecs;
+ short length;
log_msg("Type is %s\n", astype_str[type]);
@@ -145,76 +198,85 @@
case Number:
num = *(amfnum_t *)swapBytes(x+1, 8);
log_msg("Number is " AMFNUM_F, num);
- return 8;
break;
case Boolean:
boolshift = *x;
log_msg("Boolean is %d\n", boolshift);
- return 1;
break;
case String:
// int length = *(short *)swapBytes(x, 2);
+ length = *(short *)x;
x+=2; // skip the length bytes
-// mstr = new char[length+1];
+ mstr = new char[length+1];
+// memset(mstr, 0, length+1);
// memcpy(mstr, x, length);
// The function converts the multibyte string beginning at
// *src to a sequence of wide characters as if by repeated
// calls of the form:
// mbsrtowcs
-// log_msg("String is %s\n", mstr);
+ log_msg("String is %s\n", mstr);
break;
case Object:
-// log_msg("Object is unimplemented\n");
+// readElement();
+ log_msg("Object is unimplemented\n");
break;
case MovieClip:
-// log_msg("MovieClip is unimplemented\n");
+ log_msg("MovieClip is unimplemented\n");
+ break;
+ case Unsupported:
+ log_msg("MovieClip is unimplemented\n");
break;
case Null:
-// log_msg("Null is unimplemented\n");
+ log_msg("Null is unimplemented\n");
break;
case Undefined:
-// log_msg("Endefined element");
- return 1;
+ log_msg("Endefined element");
break;
case Reference:
-// log_msg("Reference is unimplemented\n");
+ log_msg("Reference is unimplemented\n");
break;
case ECMAArray:
-// log_msg("ECMAArray is unimplemented\n");
+ log_msg("ECMAArray is unimplemented\n");
break;
case ObjectEnd:
-// log_msg("ObjectEnd is unimplemented\n");
+ log_msg("ObjectEnd is unimplemented\n");
break;
case StrictArray:
-// log_msg("StrictArray is unimplemented\n");
+ log_msg("StrictArray is unimplemented\n");
break;
case Date:
nanosecs = *(amfnum_t *)swapBytes(x+1, 8);
log_msg("Date is " AMFNUM_F " nanoseconds\n", nanosecs);
- return 8;
break;
case LongString:
- int length = *(short *)swapBytes(x, 4);
+// int length = *(short *)swapBytes(x, 4);
x+=4; // skip the length bytes
// mstr = new char[length+1];
// memcpy(mstr, x, length);
log_msg("String is %s\n", mstr);
break;
// case Unsupported:
-// // log_msg("Unsupported is unimplemented\n");
-// break;
-// case Recordset:
-// // log_msg("Recordset is unimplemented\n");
-// break;
-// case XMLObject:
-// // log_msg("XMLObject is unimplemented\n");
-// break;
-// case TypedObject:
-// log_msg("TypedObject is unimplemented\n");
+ log_msg("Unsupported is unimplemented\n");
// break;
+ case Recordset:
+ log_msg("Recordset is unimplemented\n");
+ break;
+ case XMLObject:
+ log_msg("XMLObject is unimplemented\n");
+ break;
+ case TypedObject:
+ log_msg("TypedObject is unimplemented\n");
+ break;
}
- return 8;
+ return x;
+}
+
+bool
+AMF::readObject(void */* in */)
+{
+ GNASH_REPORT_FUNCTION;
+
}
/// \brief Write an AMF element
@@ -237,6 +299,8 @@
void *
AMF::encodeElement(astype_e type, void *in, int nbytes)
{
+ GNASH_REPORT_FUNCTION;
+
char *out = NULL, *x;
amfnum_t num;
int pktsize;
@@ -389,84 +453,6 @@
return out;
}
-
-AMF::astype_e
-AMF::extractElementHeader(void *in)
-{
- return (AMF::astype_e)*(char *)in;
-}
-
-int
-AMF::extractElementLength(void *in)
-{
- char *x = (char *)in;
- astype_e type = (astype_e)*x;
- x++; // skip the header byte
-
- switch (type) {
- case Number: // a 64 bit numeric value
- return 8;
- break;
- case Boolean: // a single byte
- return 1;
- break;
- case String: // the length is a 2 byte value
- return (short)*(short *)x;
- break;
- case Object:
- return x - strchr(x, TERMINATOR);
- break;
- case MovieClip:
- return -1;
- log_msg("MovieClip unimplemented");
- break;
- case Null:
- return -1;
- log_msg("Null unimplemented");
- break;
- case Undefined:
- return 0;
- break;
- case Reference:
- return -1;
- log_msg("Reference unimplemented");
- break;
- case ECMAArray:
- return x - strchr(x, TERMINATOR);
- break;
- case ObjectEnd:
- return -1;
- log_msg("ObjectEnd unimplemented");
- break;
- case StrictArray: // the length is a 4 byte value
-// return (int *)x;
- break;
- case Date: // a 64 bit numeric value
- return 8;
- break;
- case LongString:
- return -1;
- log_msg("LongString unimplemented");
- break;
- case Unsupported:
- return -1;
- log_msg("Unsupported unimplemented");
- break;
- case Recordset:
- return -1;
- log_msg("Recordset unimplemented");
- break;
- case XMLObject: // the length is a 4 byte value
-// return (int)*(int *)x;
- break;
- case TypedObject:
- return x - strchr(x, TERMINATOR);
- break;
- };
-
- return 0;
-}
-
/// \brief Each header consists of the following:
///
/// * UTF string (including length bytes) - name
@@ -476,6 +462,8 @@
amfhead_t *
AMF::encodeHeader(amfutf8_t *name, bool required, int nbytes, void *data)
{
+ GNASH_REPORT_FUNCTION;
+
char *ptr;
AMF_Int_t length;
length = sizeof(amfhead_t) + nbytes + name->length + 1;
@@ -520,6 +508,8 @@
amfbody_t *
AMF::encodeBody(amfutf8_t *target, amfutf8_t *response, int nbytes, void *data)
{
+ GNASH_REPORT_FUNCTION;
+
char *buf = new char[sizeof(amfbody_t) + nbytes];
memset(buf, 0, sizeof(amfbody_t) + nbytes );
amfbody_t *body = (amfbody_t *)buf;
@@ -551,6 +541,8 @@
amfpacket_t *
AMF::encodePacket(std::vector<amfhead_t *> messages)
{
+ GNASH_REPORT_FUNCTION;
+
int total = 0;
amfpacket_t pkt;
pkt.version = AMF_VERSION;
@@ -581,4 +573,421 @@
return out;
}
+
+AMF::astype_e
+AMF::extractElementHeader(void *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ return (AMF::astype_e)*(char *)in;
+}
+
+int
+AMF::extractElementLength(void *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char *x = (char *)in;
+ astype_e type = (astype_e)*x;
+ x++; // skip the header byte
+
+ switch (type) {
+ case Number: // a 64 bit numeric value
+ return 8;
+ break;
+ case Boolean: // a single byte
+ return 1;
+ break;
+ case String: // the length is a 2 byte value
+ return (short)*(short *)x;
+ break;
+ case Object:
+ return x - strchr(x, TERMINATOR);
+ break;
+ case MovieClip:
+ return -1;
+ log_msg("MovieClip unimplemented");
+ break;
+ case Null:
+ return -1;
+ log_msg("Null unimplemented");
+ break;
+ case Undefined:
+ return 0;
+ break;
+ case Reference:
+ return -1;
+ log_msg("Reference unimplemented");
+ break;
+ case ECMAArray:
+ return x - strchr(x, TERMINATOR);
+ break;
+ case ObjectEnd:
+ return -1;
+ log_msg("ObjectEnd unimplemented");
+ break;
+ case StrictArray: // the length is a 4 byte value
+// return (int *)x;
+ break;
+ case Date: // a 64 bit numeric value
+ return 8;
+ break;
+ case LongString:
+ return -1;
+ log_msg("LongString unimplemented");
+ break;
+ case Unsupported:
+ return -1;
+ log_msg("Unsupported unimplemented");
+ break;
+ case Recordset:
+ return -1;
+ log_msg("Recordset unimplemented");
+ break;
+ case XMLObject: // the length is a 4 byte value
+// return (int)*(int *)x;
+ break;
+ case TypedObject:
+ return x - strchr(x, TERMINATOR);
+ break;
+ };
+
+ return 0;
+}
+
+std::string
+AMF::extractString(const char *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ int length;
+
+ if (*in == 0) {
+ length = *(in+1);
+ }
+}
+
+int
+AMF::extractNumber(const char */* in */)
+{
+ GNASH_REPORT_FUNCTION;
+}
+
+int
+AMF::headerSize(char header)
+{
+// GNASH_REPORT_FUNCTION;
+
+ int headersize = -1;
+
+ unsigned char hexint[2];
+ 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:
+ char buf = header & AMF_HEADSIZE_MASK;
+ hexify((unsigned char *)hexint, (unsigned char *)&buf, 1, false);
+ dbglogfile << "ERROR: Header size bits out of range! was 0x"
+ << hexint << endl;
+ headersize = 1;
+ break;
+ };
+
+ return headersize;
+}
+
+int
+AMF::parseHeader(char *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char *tmpptr;
+ unsigned char hexint[32];
+
+ tmpptr = in;
+
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 1, false);
+ dbglogfile << "AMF header byte is: 0x" << hexint << endl;
+
+ _amf_index = *tmpptr & AMF_INDEX_MASK;
+ _header_size = headerSize(*tmpptr++);
+
+#if 1
+ hexify((unsigned char *)hexint, (unsigned char *)in, _header_size, false);
+ dbglogfile << "The packet head is: 0x" << hexint << endl;
+#endif
+ if (_header_size >= 4) {
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3, false);
+ _mystery_word = *tmpptr++;
+ _mystery_word = (_mystery_word << 12) + *tmpptr++;
+ _mystery_word = (_mystery_word << 8) + *tmpptr++;
+ dbglogfile << "The mystery word is: " << _mystery_word
+ << " Hex value is: 0x" << hexint << endl;
+ }
+
+ if (_header_size >= 8) {
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3, false);
+ _total_size = *tmpptr++;
+ _total_size = (_total_size << 12) + *tmpptr++;
+ _total_size = (_total_size << 8) + *tmpptr++;
+ _total_size = _total_size & 0x0000ff;
+ dbglogfile << "The body size is: " << _total_size
+ << " Hex value is: 0x" << hexint << endl;
+ }
+
+ if (_header_size >= 8) {
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 1, false);
+ _type = *(content_types_e *)tmpptr;
+ tmpptr++;
+ dbglogfile << "The type is: " << _type
+ << " Hex value is: 0x" << hexint << endl;
+ }
+
+ 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:
+ dbglogfile << "ERROR: Unidentified data type!" << endl;
+ break;
+ };
+
+ if (_header_size == 12) {
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3, false);
+ _src_dest = ntohl(*(unsigned int *)tmpptr);
+ tmpptr += sizeof(unsigned int);
+ dbglogfile << "The source/destination is: " << _src_dest
+ << " Hex value is: 0x" << hexint << endl;
+ }
+
+ return _packet_size;
+}
+
+int
+AMF::parseBody(char *in, int bytes)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char *tmpptr;
+ unsigned char hexint[(bytes*2)+1];
+ char buffer[AMF_VIDEO_PACKET_SIZE];
+ char *name;
+ short length;
+ int data_bytes = bytes;
+ amf_element_t el;
+
+ if (in == 0) {
+ dbglogfile << "ERROR: input data is NULL!" << endl;
+ return -1;
+ }
+
+ memset(buffer, 0, AMF_VIDEO_PACKET_SIZE);
+
+// memcpy(_amf_data +_read_size, in, AMF_VIDEO_PACKET_SIZE);
+// _read_size += bytes;
+#if 1
+ hexify((unsigned char *)hexint, (unsigned char *)in, bytes, true);
+ dbglogfile << "The packet body is: 0x" << hexint << endl;
+#endif
+
+ tmpptr = in;
+
+// if (!_amf_data) {
+// dbglogfile << "new amf_data block, size is: " << _total_size <<
endl;
+// _amf_data = new unsigned char(_total_size+1);
+// _seekptr = _amf_data;
+// memset(_amf_data, 0, _total_size);
+// }
+// memcpy(_seekptr, tmpptr, bytes);
+// _seekptr += bytes;
+
+// All elements look like this:
+// the first two bytes is the length of name of the element
+// Then the next bytes are the element name
+// After the element name there is a type byte. If it's a Number type, then 8
bytes are read
+// If it's a String type, then there is a count of characters, then the string
value
+
+ while (data_bytes) {
+
+ // Check the type of the element data
+ char type = *(astype_e *)tmpptr;
+ tmpptr++; // skip the header byte
+ data_bytes--;
+
+ switch ((astype_e)type) {
+ case Number:
+// memcpy(buffer, tmpptr, 8);
+ tmpptr += 8;
+ data_bytes -= 8;
+ continue;
+ break;
+ case Boolean:
+ case String:
+ dbglogfile << "AMF type: " << astype_str[(int)type] << ": a work
in progress!" << endl;
+ break;
+ case Object:
+ dbglogfile << "AMF type: " << astype_str[(int)type] << ": a work
in progress!" << endl;
+ do {
+ tmpptr = extractVariables(el, tmpptr);
+ } while (el.length > 0);
+ 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:
+ default:
+// dbglogfile << astype_str[(int)type] << ": unimplemented!" << endl;
+ dbglogfile << (int)type << ": unimplemented!" << endl;
+ break;
+ }
+
+ // get the length of the name
+ length = ntohs(*(short *)tmpptr);
+#if 0
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, length+2,
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) {
+ memcpy(buffer, tmpptr, length);
+ }
+ tmpptr += length;
+
+ dbglogfile << "AMF element name is: " << buffer << endl;
+
+ el.name = buffer;
+ data_bytes -= length - 2;
+
+//}
+ }
+
+ return -1;
+}
+
+char *
+AMF::extractVariables(amf_element_t &el, const char *in)
+{
+ GNASH_REPORT_FUNCTION;
+
+ char buffer[AMF_VIDEO_PACKET_SIZE];
+ char *tmpptr = (char *)in;
+ short length = 0;
+
+ el.length = 0;
+ el.name.erase();
+ if (el.data) {
+ el.data = 0;
+ }
+
+ memset(buffer, 0, AMF_VIDEO_PACKET_SIZE);
+ length = ntohs(*(short *)tmpptr);
+ el.length = length;
+ if (length == 0) {
+ if (*(tmpptr+2) == ObjectEnd) {
+ dbglogfile << "End of Object definition." << endl;
+ }
+ }
+
+#if 0
+ hexify((unsigned char *)hexint, (unsigned char *)tmpptr, length+2, 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) {
+ memcpy(buffer, tmpptr, length);
+ el.name = 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;
+ return tmpptr;
+ }
+ }
+
+// dbglogfile << "AMF element name is: " << buffer << endl;
+ char type = *(astype_e *)tmpptr++;
+
+ if (type <= TypedObject) {
+ 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: " <<
(uint)buffer << endl;
+ tmpptr += 8;
+ break;
+ case Boolean:
+ case String:
+ length = ntohs(*(short *)tmpptr);
+ tmpptr += sizeof(short);
+ el.data = (unsigned char*)tmpptr;
+ dbglogfile << "Variable \"" << el.name.c_str() << "\" is: " <<
el.data << endl;
+ 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;
+ break;
+ }
+
+ return tmpptr;
+}
+
} // end of amf namespace
Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libamf/amf.h 2 Aug 2006 01:22:59 -0000 1.5
+++ libamf/amf.h 12 Aug 2006 15:11:53 -0000 1.6
@@ -43,6 +43,8 @@
#endif
#include <vector>
+#include <string>
+#include <map>
#include "amfutf8.h"
@@ -74,6 +76,13 @@
} amfsource_e;
const char AMF_VERSION = 0;
+const char AMF_HEADSIZE_MASK = 0xc0;
+const char AMF_INDEX_MASK = 0x03;
+const int AMF_VIDEO_PACKET_SIZE = 128;
+const int AMF_AUDIO_PACKET_SIZE = 64;
+
+// For terminating sequences, a byte with value 0x09 is used.
+const char TERMINATOR = 0x09;
// Each header consists of the following:
//
@@ -153,6 +162,13 @@
TypedObject=0x10
} astype_e;
typedef enum {
+ HEADER_12 = 0x0,
+ HEADER_8 = 0x40,
+ HEADER_4 = 0x80,
+ HEADER_1 = 0xc0
+ } amf_headersize_e;
+
+ typedef enum {
Byte,
Int,
MediumInt,
@@ -161,27 +177,69 @@
UTF8,
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 struct {
+ astype_e type;
+ short length;
+ std::string name;
+ unsigned char *data;
+ } amf_element_t;
+ AMF();
+ AMF(int size);
+ ~AMF();
+ size_t size() { return _total_size; };
// Swap the bytes for Little Endian machines
void *swapBytes(void *word, int size);
- int readElement(void *out, void *in);
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);
-
+ 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:
-private:
+ char *extractVariables(amf_element_t &el, const char *in);
+ bool parseAMF(char *in);
+ static int headerSize(char header);
+ int packetReadAMF(int bytes);
+
+ int parseHeader(char *in);
+ int parseBody(char *in, 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;
+ int _amf_index;
+ int _header_size;
+ int _total_size;
+ int _packet_size;
+ unsigned char *_amf_data;
+ unsigned char *_seekptr;
+ int _mystery_word;
+ int _src_dest;
};
-// For terminating sequences, a byte with value 0x09 is used.
-const char TERMINATOR = 0x09;
-
} // end of amf namespace
// end of _AMF_H_
Index: libamf/amftest.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amftest.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- libamf/amftest.cpp 24 Apr 2006 23:05:55 -0000 1.4
+++ libamf/amftest.cpp 12 Aug 2006 15:11:53 -0000 1.5
@@ -39,10 +39,11 @@
#include "config.h"
#endif
+#ifdef HAVE_DEJAGNU_H
+
#include <netinet/in.h>
#include <string>
-#ifdef HAVE_DEJAGNU_H
#include "dejagnu.h"
Index: libamf/rtmp.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/rtmp.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- libamf/rtmp.cpp 8 Aug 2006 11:20:19 -0000 1.3
+++ libamf/rtmp.cpp 12 Aug 2006 15:11:53 -0000 1.4
@@ -1,3 +1,4 @@
+
//
// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
//
@@ -33,13 +34,15 @@
// also makes it possible to release a modified version which carries
// forward this exception.
//
-//
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+// #ifdef HAVE_CONFIG_H
+// #include "config.h"
+// #endif
#include <iostream>
+#include <netinet/in.h>
+#include <new>
+#include "log.h"
#include "rtmp.h"
#include "log.h"
#include "new"
@@ -48,28 +51,37 @@
#include <netinet/in.h>
#endif
-using namespace gnash;
using namespace amf;
using namespace std;
-namespace rtmp
+namespace gnash
{
RTMPproto::RTMPproto()
- : _body(0)
{
-// GNASH_REPORT_FUNCTION;
-// _amf_data.reserve(MAX_AMF_INDEXES);
-// memset(_amf_data, 0, MAX_AMF_INDEXES);
- memset(_amf_size, 0, MAX_AMF_INDEXES);
+ GNASH_REPORT_FUNCTION;
+// _body = new unsigned char(RTMP_BODY_SIZE+1);
+ memset(_body, 0, RTMP_BODY_SIZE+1);
}
RTMPproto::~RTMPproto()
{
// GNASH_REPORT_FUNCTION;
- delete _body;
+ _variables.clear();
+// delete _body;
}
+void
+RTMPproto::addVariable(char *name, char *value)
+{
+ _variables[name] = value;
+}
+
+std::string
+RTMPproto::getVariable(char *name)
+{
+ return _variables[name];
+}
// The handshake is a byte with the value of 0x3, followed by 1536
// bytes of gibberish which we need to store for later.
@@ -78,8 +90,8 @@
{
GNASH_REPORT_FUNCTION;
- char buffer[RTMP_HEADERSIZE+1];
- memset(buffer, 0, RTMP_HEADERSIZE+1);
+ char buffer[RTMP_BODY_SIZE+16];
+ memset(buffer, 0, RTMP_BODY_SIZE+16);
if (readNet(buffer, 1) == 1) {
dbglogfile << "Read initial Handshake Request" << endl;
@@ -95,10 +107,10 @@
// return false;
}
- if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {
+ if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
dbglogfile << "Read Handshake Data" << endl;
- _body = new char(RTMP_HEADERSIZE+1);
- memcpy(_body, buffer, RTMP_HEADERSIZE);
+// _body = new char(RTMP_BODY_SIZE+1);
+ memcpy(_body, buffer, RTMP_BODY_SIZE);
} else {
dbglogfile << "Couldn't read Handshake Data" << endl;
dbglogfile << "Data read is: " << buffer << endl;
@@ -115,7 +127,7 @@
{
GNASH_REPORT_FUNCTION;
- char buffer[RTMP_HEADERSIZE+1];
+ char buffer[RTMP_BODY_SIZE+1];
char c = 0x3;
int i, ret;
@@ -128,11 +140,11 @@
// Since we don't know what the format is, create a pattern we can
// recognize if we stumble across it later on.
- for (i=0; i<RTMP_HEADERSIZE; i++) {
+ for (i=0; i<RTMP_BODY_SIZE; i++) {
buffer[i] = i^256;
}
- ret = writeNet(buffer, RTMP_HEADERSIZE);
+ ret = writeNet(buffer, RTMP_BODY_SIZE);
return true;
}
@@ -146,8 +158,8 @@
char c = 0x3;
writeNet(&c, 1);
- writeNet(_body, RTMP_HEADERSIZE);
- writeNet(_body, RTMP_HEADERSIZE);
+ writeNet(_body, RTMP_BODY_SIZE);
+ writeNet(_body, RTMP_BODY_SIZE);
return true;
}
@@ -159,27 +171,27 @@
{
GNASH_REPORT_FUNCTION;
- char buffer[RTMP_HEADERSIZE+1];
- memset(buffer, 0, RTMP_HEADERSIZE+1);
+ char buffer[RTMP_BODY_SIZE+1];
+ memset(buffer, 0, RTMP_BODY_SIZE+1);
- if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {
+ if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
dbglogfile << "Read first data block in handshake" << endl;
} else {
dbglogfile << "ERROR: Couldn't read first data block in handshake!"
<< endl;
return false;
}
- if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {
+ if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
dbglogfile << "Read second data block in handshake" << endl;
-// _body = new char(RTMP_HEADERSIZE+1);
-// memcpy(_body, buffer, RTMP_HEADERSIZE);
+// _body = new char(RTMP_BODY_SIZE+1);
+// memcpy(_body, buffer, RTMP_BODY_SIZE);
} else {
dbglogfile << "ERROR: Couldn't read second data block in handshake!"
<< endl;
return false;
}
- writeNet(buffer, RTMP_HEADERSIZE);
+ writeNet(buffer, RTMP_BODY_SIZE);
return true;
}
@@ -189,11 +201,11 @@
{
GNASH_REPORT_FUNCTION;
- int ret;
- char buffer[RTMP_HEADERSIZE+1];
- memset(buffer, 0, RTMP_HEADERSIZE+1);
+// int ret;
+ char buffer[RTMP_BODY_SIZE+1];
+ memset(buffer, 0, RTMP_BODY_SIZE+1);
- if (readNet(buffer, RTMP_HEADERSIZE) == RTMP_HEADERSIZE) {
+ if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
dbglogfile << "Read Handshake Finish Data" << endl;
} else {
dbglogfile << "ERROR: Couldn't read Handshake Finish Data!" << endl;
@@ -215,34 +227,6 @@
return true;
}
-int
-RTMPproto::headerSize(char header)
-{
- unsigned char hexint[2];
- switch (header & RTMP_HEADSIZE_MASK) {
- case HEADER_12:
- return(12);
- break;
- case HEADER_8:
- return(8);
- break;
- case HEADER_4:
- return(4);
- break;
- case HEADER_1:
- return(1);
- break;
- default:
- hexify((unsigned char *)hexint, (unsigned char *)&header, 1);
- dbglogfile << "ERROR: Header size bits out of range! was 0x"
- << hexint << endl;
- return -1;
- break;
- };
-
- return -1;
-}
-
bool
RTMPproto::packetRequest()
{
@@ -263,14 +247,19 @@
GNASH_REPORT_FUNCTION;
int ret;
- char buffer[AMFBODY_PACKET_SIZE+1];
- memset(buffer, 0, AMFBODY_PACKET_SIZE+1);
- unsigned char hexint[512];
- int blocksize;
+ char buffer[AMF_VIDEO_PACKET_SIZE+1];
+ memset(buffer, 0, AMF_VIDEO_PACKET_SIZE+1);
+ unsigned char hexint[1024];
+ int packetsize = 0;
char *tmpptr;
char *amfdata;
+ int amf_index, headersize;
+ AMF *amf;
+
+ tmpptr = buffer;
//
address@hidden@\000\000\000\000\000\000\003\000\003app\002\000#software/gnash/tests/1153948634.flv\000\bflashVer\002\000\fLNX
6,0,82,0\000\006swfUrl\002\000\035file:///file|address@hidden://localhost/software/gnash/tests/1153948634
+
if ((ret = readNet(buffer, 1)) > 0) {
dbglogfile << "Read first RTMP header byte"<< endl;
} else {
@@ -278,172 +267,34 @@
return false;
}
- _headersize = headerSize(*buffer);
- _amf_number = *buffer & RTMP_AMF_INDEX;
- dbglogfile << "The Header size is: " << _headersize << endl;
- dbglogfile << "The AMF index is: 0x" << _amf_number << endl;
-
+ amf_index = *tmpptr & AMF_INDEX_MASK;
+ headersize = AMF::headerSize(*tmpptr++);
+ dbglogfile << "The Header size is: " << headersize << endl;
+ dbglogfile << "The AMF index is: 0x" << amf_index << endl;
- if ((ret = readNet(buffer, _headersize-1)) > 0) {
- dbglogfile << "Read first RTMP packet body of " << ret
- << " bytes." << endl;
+ if (headersize > 1) {
+ if ((ret = readNet(tmpptr, headersize-1)) > 0) {
+ dbglogfile << "Read first RTMP packet header of " << ret
+ << " headersize." << endl;
} else {
- dbglogfile << "ERROR: Couldn't read first RTMP packet body!" << endl;
+ dbglogfile << "ERROR: Couldn't read first RTMP packet header!" <<
endl;
return false;
}
- tmpptr = buffer;
-
- if (_headersize >= 4) {
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
- _mystery_word = *tmpptr++;
- _mystery_word = (_mystery_word << 12) + *tmpptr++;
- _mystery_word = (_mystery_word << 8) + *tmpptr++;
- dbglogfile << "The mystery word is: " << _mystery_word
- << " Hex value is: 0x" << hexint << endl;
- }
-
- if (_headersize >= 8) {
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
- _bodysize = *tmpptr++;
- _bodysize = (_bodysize << 12) + *tmpptr++;
- _bodysize = (_bodysize << 8) + *tmpptr++;
- _bodysize = _bodysize & 0x0000ff;
- dbglogfile << "The body size is: " << _bodysize
- << " Hex value is: 0x" << hexint << endl;
- }
-// _amf_data[_amf_number] = new unsigned char(_bodysize);
- _amf_size[_amf_number] = 0;
-
- if (_headersize >= 8) {
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 1);
- _type = *(rtmp_types_e *)tmpptr;
- tmpptr++;
- dbglogfile << "The type is: " << _type
- << " Hex value is: 0x" << hexint << endl;
- }
-
- if (_headersize == 12) {
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 3);
- _src_dest = ntohl(*(unsigned int *)tmpptr);
- tmpptr += sizeof(unsigned int);
- dbglogfile << "The source/destination is: " << _src_dest
- << " Hex value is: 0x" << hexint << endl;
- }
-
-#if 0
- if ((ret = readNet(buffer, AMFBODY_PACKET_SIZE - _headersize)) > 0) {
- dbglogfile << "Read first RTMP packet body of " << ret
- << " bytes." << endl;
- } else {
- dbglogfile << "ERROR: Couldn't read first RTMP packet body!" << endl;
- return false;
}
- tmpptr = buffer;
-
-// hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 50);
-// dbglogfile << "The AMF header is: " << hexint << endl;
-
- if (_amf_number < MAX_AMF_INDEXES) {
- if (_amf_size[_amf_number] == 0) {
- dbglogfile << "New AMF object, index: " << _amf_number << endl;
-// amfdata = new char(AMFBODY_PACKET_SIZE+1);
-// memcpy(amfdata, tmpptr, _bodysize);
-// _amf_data[_amf_number] = amfdata;
- _amf_data[_amf_number] = (unsigned char *)tmpptr ;
- _amf_size[_amf_number] = _bodysize;
- } else {
- int amd_headersize = headerSize(*tmpptr);
- int amf_index = *tmpptr & RTMP_AMF_INDEX;
- dbglogfile << "The AMF Header size is: " << amd_headersize << endl;
- dbglogfile << "The AMF index is: 0x" << amf_index << endl;
-// amfdata = new unsigned char(
-// _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
-// memcpy(amfdata, _amf_data[amf_index],
-// _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
-// memcpy(amfdata+_amf_size[amf_index], tmpptr,
-// _amf_size[amf_index]+AMFBODY_PACKET_SIZE+1);
-// _amf_size[_amf_number] = _bodysize;
- }
-
- }
-#endif
-
- while ((ret = packetReadAMF(0)) > 0) {
- dbglogfile << "Reading AMF packetes till we're done..." << endl;
+ if (_amfs.size() < headersize) {
+ amf = new AMF;
}
-// _amf_data
- return true;
-}
+ packetsize = amf->parseHeader(buffer);
-int
-RTMPproto::packetReadAMF(int bytes)
-{
- GNASH_REPORT_FUNCTION;
+ tmpptr += headersize;
- int ret;
- char buffer[AMFBODY_PACKET_SIZE+1];
- unsigned char hexint[(AMFBODY_PACKET_SIZE*2)+1];
- char *tmpptr;
- unsigned char *amfdata;
- int amf_index;
-
- if (bytes == 0) {
- bytes = AMFBODY_PACKET_SIZE;
- }
-
- memset(buffer, 0, AMFBODY_PACKET_SIZE+1);
- if ((ret = readNet(buffer, bytes)) >= 0) {
- if (ret == 0) {
- dbglogfile << "Done reading AMF message" << endl;
- return ret;
+ while ((ret = readNet(buffer, packetsize)) > 0) {
+ amf->parseBody(buffer, ret);
+ dbglogfile << "Reading AMF packets till we're done..." << endl;
}
- dbglogfile << "Read AMF packet, " << ret
- << " bytes in size." << endl;
- } else {
- dbglogfile << "ERROR: Couldn't read AMF packet!" << endl;
- return -1;
- }
-
- tmpptr = buffer;
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 40);
- dbglogfile << "AMF packet: 0x" << hexint << endl;
-
- switch (*tmpptr & RTMP_HEADSIZE_MASK) {
- case 0x02:
- case 0x03:
- _headersize = 12;
- break;
- case 0x43:
- _headersize = 8;
- break;
- case 0x83:
- _headersize = 4;
- break;
- case 0xc3:
- _headersize = 1;
- break;
- default:
- hexify((unsigned char *)hexint, (unsigned char *)tmpptr, 1);
- dbglogfile << "ERROR: Header size bits out of range! was 0x"
- << hexint << endl;
- _headersize = 1;
- break;
- };
-
- amf_index = *tmpptr & RTMP_AMF_INDEX;
- tmpptr++;
- dbglogfile << "The Header size is: " << _headersize << endl;
- dbglogfile << "The AMF index is: 0x" << amf_index << endl;
- dbglogfile << "Read " << ret << " bytes" << endl;
-
-// memcpy(_amf_data[_amf_index]+_amf_size[amf_index],
-// AMFBODY_PACKET_SIZE);
- _amf_size[amf_index] += ret;
-
- return ret;
+ return true;
}
-
} // end of cygnal namespace
Index: libamf/rtmp.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/rtmp.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- libamf/rtmp.h 2 Aug 2006 01:22:59 -0000 1.2
+++ libamf/rtmp.h 12 Aug 2006 15:11:53 -0000 1.3
@@ -42,47 +42,23 @@
#include "config.h"
#endif
+#include <vector>
+
#include "amf.h"
#include "protocol.h"
-#include <vector>
+#include "log.h"
-namespace rtmp
+namespace gnash
{
#define RTMP_HANDSHAKE 0x3
-#define RTMP_HEADERSIZE 1536
-#define RTMP_HEADSIZE_MASK 0xc0
-#define RTMP_AMF_INDEX 0x3f
+#define RTMP_BODY_SIZE 1536
#define MAX_AMF_INDEXES 64
-#define AMFBODY_PACKET_SIZE 128
class RTMPproto : public Protocol
{
public:
typedef enum {
- HEADER_12 = 0x0,
- HEADER_8 = 0x1,
- HEADER_4 = 0x2,
- HEADER_1 = 0x3
- } rtmp_headersize_e;
-
- typedef enum {
- CHUNK_SIZE = 0x1,
-// UNKNOWN = 0x2,
- BYTES_READ = 0x3,
- PING = 0x4,
- SERVER = 0x5,
- CLIENT = 0x6,
-// UNKNOWN2 = 0x7,
- AUDIO_DATA = 0x8,
- VIDEO_DATA = 0x9,
-// UNKNOWN3 = 0xa,
- NOTIFY = 0x12,
- SHARED_OBJ = 0x13,
- INVOKE = 0x14
- } rtmp_types_e;
-
- typedef enum {
CONNECT = 0x1,
DISCONNECT = 0x2,
SET_ATTRIBUTE = 0x3,
@@ -102,24 +78,21 @@
virtual bool handShakeResponse();
virtual bool clientFinish();
virtual bool serverFinish();
+
virtual bool packetRequest();
virtual bool packetSend();
virtual bool packetRead();
- int headerSize(char header);
- int packetReadAMF(int bytes);
+
+ void addVariable(char *name, char *value);
+ std::string getVariable(char *name);
private:
- int _headersize;
- int _amf_number;
- char *_body;
- int _bodysize;
- rtmp_types_e _type;
- unsigned char *_amf_data[MAX_AMF_INDEXES];
- int _amf_size[MAX_AMF_INDEXES];
- int _mystery_word;
- int _src_dest;
+ std::map<char *, std::string> _variables;
+ unsigned char _body[RTMP_BODY_SIZE+1];
+ std::vector<amf::AMF *> _amfs;
+ // amf::AMF _amfs[MAX_AMF_INDEXES];
};
-} // end of rtmp namespace
+} // end of gnash namespace
// end of _RTMP_H_
#endif
Index: plugin/klash/klash.cpp
===================================================================
RCS file: /sources/gnash/gnash/plugin/klash/klash.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- plugin/klash/klash.cpp 26 Jul 2006 21:49:05 -0000 1.9
+++ plugin/klash/klash.cpp 12 Aug 2006 15:11:53 -0000 1.10
@@ -99,12 +99,12 @@
movie_state_e movie_menu_state;
-extern int mouse_x;
-extern int mouse_y;
-extern int mouse_buttons;
+int mouse_x;
+int mouse_y;
+int mouse_buttons;
-extern int width;
-extern int height;
+int width;
+int height;
extern int windowid;
class EmbedWidget : public QGLWidget
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash gui/Makefile.am libbase/network.cpp libba...,
Rob Savoye <=