[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h lib...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h lib... |
Date: |
Sun, 30 Mar 2008 22:08:54 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 08/03/30 22:08:54
Modified files:
. : ChangeLog
libamf : amf.cpp amf.h element.cpp element.h lcshm.cpp
lcshm.h sol.cpp sol.h
Removed files:
libamf : rtmp.cpp rtmp.h
Log message:
* libamf/sol.{h,cpp}, lcshm.{h,cpp}: Use Network::byte_t instead
of boost::uint8_t top stay consistant. Move all RTMP methods to
libnet/rtmp.h.
* libamf/amf.cpp: Move all RTMP methods to libnet/rtmp.h.
* libamf/element.{h,cpp}: Add more overloaded make* methods, get
ready to depreciated the init methods to use this instead.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.6102&r2=1.6103
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.cpp?cvsroot=gnash&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/amf.h?cvsroot=gnash&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/element.cpp?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/element.h?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/lcshm.cpp?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/lcshm.h?cvsroot=gnash&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.cpp?cvsroot=gnash&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/sol.h?cvsroot=gnash&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.cpp?cvsroot=gnash&r1=1.21&r2=0
http://cvs.savannah.gnu.org/viewcvs/gnash/libamf/rtmp.h?cvsroot=gnash&r1=1.13&r2=0
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.6102
retrieving revision 1.6103
diff -u -b -r1.6102 -r1.6103
--- ChangeLog 30 Mar 2008 20:56:15 -0000 1.6102
+++ ChangeLog 30 Mar 2008 22:08:53 -0000 1.6103
@@ -1,5 +1,12 @@
2008-03-30 Rob Savoye <address@hidden>
+ * libamf/sol.{h,cpp}, lcshm.{h,cpp}: Use Network::byte_t instead
+ of boost::uint8_t top stay consistant. Move all RTMP methods to
+ libnet/rtmp.h.
+ * libamf/amf.cpp: Move all RTMP methods to libnet/rtmp.h.
+ * libamf/element.{h,cpp}: Add more overloaded make* methods, get
+ ready to depreciated the init methods to use this instead.
+
* plugin/mozilla-sdk/include/npupp.h: Don't use NPPluginFuncs.
* gui/klash.moc.in: Drop the extraneous gnash-head path from the
include for kdesup.h.
Index: libamf/amf.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.cpp,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- libamf/amf.cpp 29 Mar 2008 19:35:53 -0000 1.62
+++ libamf/amf.cpp 30 Mar 2008 22:08:53 -0000 1.63
@@ -739,177 +739,6 @@
return vec;
}
-
-#if 0
-/// \brief \ Each RTMP header consists of the following:
-///
-/// * Index & header size - The header size and amf channel index.
-/// * Total size - The total size of the message
-/// * Type - The type of the message
-/// * Routing - The source/destination of the message
-void *
-AMF::encodeRTMPHeader(int amf_index, amf_headersize_e head_size,
- int total_size, content_types_e type,
- amfsource_e routing)
-{
-// GNASH_REPORT_FUNCTION;
- void *out = new char[total_size + 12 + 4];
- memset(out, 0, total_size + 12 + 4);
- char *tmpptr = reinterpret_cast<char *>(out);
- // Make the index & header size byte
- *tmpptr = head_size & AMF_HEADSIZE_MASK;
- *tmpptr += amf_index & AMF_INDEX_MASK;
- tmpptr++;
-
- // Add the unknown bytes. These seem to be used by video and
- // audio, and only when the header size is 4 or more.
- if (head_size <= HEADER_4) {
- memset(tmpptr, 0, 3);
- tmpptr += 3;
- }
-
- // Add the size of the message if the header size is 8 or more.
- if (head_size <= HEADER_8) {
- int length = total_size;
- swapBytes(&length, 4);
- memcpy(tmpptr, ((char *)&length +1), 3);
- tmpptr += 3;
- }
-
- // Add the type of the objectif the header size is 8 or more.
- if (head_size <= HEADER_8) {
- *tmpptr = type;
- tmpptr++;
- }
-
- // Add the routing of the message if the header size is 12 or more.
- if (head_size == HEADER_12) {
- memcpy(tmpptr, &routing, 4);
- tmpptr += 4;
- }
-
- return out;
-}
-
-/// \brief 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)
-amfhead_t *
-AMF::encodeHeader(amfutf8_t *name, bool required, int nbytes, void *data)
-{
-// GNASH_REPORT_FUNCTION;
-
- AMF_Int_t length = sizeof(amfhead_t) + nbytes + name->length + 1;
- char *buf = new char[length];
- memset(buf, 0, length);
- char *ptr = buf;
-
- // The first two bytes are the byte count for the UTF8 string,
- // which is in big-endian format.
- length = name->length;
- swapBytes(&length, sizeof(AMF_Int_t));
- memcpy(ptr, &length, sizeof(AMF_Int_t));
- ptr += sizeof(AMF_Int_t);
-
- // Now the data part of the UTF8 string
- memcpy(ptr, name->data, name->length);
- ptr += name->length;
-
- // Then the "required" flag, whatever this does...
- memcpy(ptr, &required, 1);
- ptr++;
-
- // Then the byte count of the data, which is an ActionScript
- // object
- length = nbytes;
- swapBytes(&length, 2);
- memcpy(ptr, &length, 2);
- ptr += 2;
-
- // And finally all the data
- memcpy(ptr, data, nbytes);
-
- return (amfhead_t *)buf;
-}
-
-/// \brief Each body consists of the following:
-///
-/// * UTF String - Target
-/// * UTF String - Response
-/// * Long - Body length in bytes
-/// * Variable - Actual data (including a type code)
-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;
- memcpy(&body->target, target, sizeof(amfutf8_t));
- memcpy(&body->response, response, sizeof(amfutf8_t));
- body->length = nbytes;
- memcpy(body->data, data, nbytes);
-
- return body;
-}
-
-/// \brief Each packet consists of the following:
-///
-/// The first byte of the AMF file/stream is believed to be a version
-/// indicator. So far the only valid value for this field that has been
-/// found is 0Ã00. If it is anything other than 0Ã00 (zero), your
-/// system should consider the AMF file/stream to be
-/// 'cmalformed'd. This can happen in the IDE if AMF calls are put
-/// on the stack but never executed and the user exits the movie from the
-/// IDE; the two top bytes will be random and the number of headers will
-/// be unreliable.
-
-/// The second byte of the AMF file/stream is appears to be 0Ã00 if the
-/// client is the Flash Player and 0Ã01 if the client is the FlashCom
-/// server.
-
-/// The third and fourth bytes form an integer value that specifies the
-/// number of headers.
-amfpacket_t *
-AMF::encodePacket(std::vector<amfpacket_t *> messages)
-{
-// GNASH_REPORT_FUNCTION;
-
- int total = 0;
- amfpacket_t pkt;
- pkt.version = AMF_VERSION;
- pkt.source = CLIENT;
- pkt.count = (AMF_Int_t)messages.size();
-
- // figure out how big the output buffer has to be
- for (unsigned int i=0; i<messages.size(); i++ ) {
- total += messages[i]->name.length + // the UTF8 string length
- messages[i]->length // the data length
- + sizeof(amfhead_t); // the header length
- }
-
- amfpacket_t *out = (amfpacket_t *)new char[total];
- char *ptr = (char *)out;
- memset(ptr, 0, total);
-
- // Copy the header
- memcpy(ptr, &pkt, sizeof(amfpacket_t));
- ptr += sizeof(amfpacket_t);
-
- // Add the messages
- for (unsigned int i=0; i<messages.size(); i++ ) {
- memcpy(ptr, messages[i], messages[i]->length + sizeof(amfhead_t));
- ptr += messages[i]->length + sizeof(amfhead_t);
- }
-
- return out;
-}
-#endif
-
#if 0
AMF::astype_e
AMF::extractElementHeader(void *in)
@@ -1179,10 +1008,10 @@
#endif
uint8_t *
-AMF::encodeVariable(amf::Element *el, size_t& outsize)
+AMF::encodeVariable(amf::Element *el)
{
GNASH_REPORT_FUNCTION;
- outsize = el->getName().size() + el->getLength() + 5; // why +5 here ?
+ size_t outsize = el->getName().size() + el->getLength() + 5; // why +5
here ?
Network::byte_t *out = new Network::byte_t[outsize + 4]; // why +4 here ?
Network::byte_t *end = out + outsize+4; // why +4 ?
@@ -1463,7 +1292,7 @@
{
// GNASH_REPORT_FUNCTION;
- Network::byte_t buffer[AMF_PACKET_SIZE];
+ char *buffer[AMF_PACKET_SIZE];
Network::byte_t *tmpptr = in;
boost::int16_t length;
@@ -1501,7 +1330,7 @@
// log_debug(_("AMF element length is: %d"), length);
memcpy(buffer, tmpptr, length);
- el->setName(buffer);
+ el->setName(tmpptr, length);
tmpptr += length;
}
Index: libamf/amf.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/amf.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- libamf/amf.h 29 Mar 2008 19:35:53 -0000 1.34
+++ libamf/amf.h 30 Mar 2008 22:08:53 -0000 1.35
@@ -248,7 +248,7 @@
/// in form of a newly allocated byte array.
/// to be deleted by caller using delete [] operator, or NULL
///
- gnash::Network::byte_t *encodeVariable(amf::Element *el, size_t& outsize);
+ gnash::Network::byte_t *encodeVariable(amf::Element *el);
#if 0
/// Encode an element
Index: libamf/element.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/element.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libamf/element.cpp 29 Mar 2008 19:35:53 -0000 1.11
+++ libamf/element.cpp 30 Mar 2008 22:08:53 -0000 1.12
@@ -81,7 +81,7 @@
}
}
-Element::Element(boost::uint8_t *indata)
+Element::Element(Network::byte_t *indata)
{
GNASH_REPORT_FUNCTION;
init(indata);
@@ -177,7 +177,7 @@
_name = name;
}
_length = AMF_NUMBER_SIZE;
- _data = reinterpret_cast<boost::uint8_t *>(new char[sizeof(double)]);
+ _data = reinterpret_cast<Network::byte_t *>(new char[sizeof(double)]);
memcpy(_data, &indata, _length);
return *this;
}
@@ -192,14 +192,14 @@
Element &
Element::init(const string &name, const string &indata)
{
-// GNASH_REPORT_FUNCTION;
+ GNASH_REPORT_FUNCTION;
_type = Element::STRING;
if (name.size()) {
_name = name;
}
_length = indata.size();
// add a byte for a NULL string terminator byte.
- _data = new boost::uint8_t[indata.size() + 1];
+ _data = new Network::byte_t[indata.size() + 1];
memset(_data, 0, indata.size() + 1);
memcpy(_data, indata.c_str(), indata.size());
return *this;
@@ -221,7 +221,7 @@
_name = name;
}
_length = 1;
- _data = new boost::uint8_t[1];
+ _data = new Network::byte_t[1];
*_data = indata;
return *this;
}
@@ -282,7 +282,7 @@
if (el.getName().size()) {
_name = el.getName();
}
- _data = new boost::uint8_t[_length + 1];
+ _data = new Network::byte_t[_length + 1];
memcpy(_data, el.getData(), _length);
return *this;
@@ -295,18 +295,18 @@
/// normal ASCII. It may be that these need to be converted to wide
/// characters, but for now we just leave them as standard multibyte
/// characters.
-boost::uint8_t *
-Element::init(boost::uint8_t *indata)
+Network::byte_t *
+Element::init(Network::byte_t *indata)
{
// GNASH_REPORT_FUNCTION;
- boost::uint8_t *ptr = indata;
+ Network::byte_t *ptr = indata;
// Extract the type
_type = (Element::astype_e)((*ptr++) & 0xff);
// For doubles, the length value is never set, but we might as
// well put in a legit value anyway.
_length = AMF_NUMBER_SIZE;
- _data = new boost::uint8_t[AMF_NUMBER_SIZE + 1];
+ _data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
memset(_data, 0, AMF_NUMBER_SIZE + 1);
memcpy(_data, &indata, AMF_NUMBER_SIZE);
@@ -314,51 +314,97 @@
}
Element &
-Element::makeString(boost::uint8_t *data, int size)
+Element::makeString(Network::byte_t *data, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::STRING;
_length = size;
- _data = new boost::uint8_t[size+1];
+ _data = new Network::byte_t[size+1];
memset(_data, 0, size+1);
memcpy(_data, data, size);
return *this;
}
Element &
-Element::makeNumber(boost::uint8_t *data)
+Element::makeString(const string &name, const string &indata)
+{
+ GNASH_REPORT_FUNCTION;
+ _type = Element::STRING;
+ if (name.size()) {
+ _name = name;
+ }
+ _length = indata.size();
+ // add a byte for a NULL string terminator byte.
+ _data = new Network::byte_t[indata.size() + 1];
+ memcpy(_data, indata.c_str(),_length);
+ *(_data + _length) = 0; // terminate the string for printing
+ return *this;
+}
+
+Element &
+Element::makeNumber(Network::byte_t *data)
{
// GNASH_REPORT_FUNCTION;
_type = Element::NUMBER;
_length = amf::AMF_NUMBER_SIZE;
- _data = new boost::uint8_t[amf::AMF_NUMBER_SIZE];
+ _data = new Network::byte_t[amf::AMF_NUMBER_SIZE];
memcpy(_data, data, amf::AMF_NUMBER_SIZE);
return *this;
}
Element &
-Element::makeBoolean(bool &data)
+Element::makeNumber(const string &name, double data)
+{
+// GNASH_REPORT_FUNCTION;
+ if (name.size()) {
+ _name = name;
+ }
+ _type = Element::NUMBER;
+ _length = amf::AMF_NUMBER_SIZE;
+ _data = new Network::byte_t[amf::AMF_NUMBER_SIZE];
+ memcpy(_data, &data, amf::AMF_NUMBER_SIZE);
+// std::copy(&data, &data + amf::AMF_NUMBER_SIZE, _data);
+ return *this;
+}
+
+Element &
+Element::makeBoolean(bool data)
{
// GNASH_REPORT_FUNCTION;
_type = Element::BOOLEAN;
_length = 1;
- _data = new boost::uint8_t[2];
+ _data = new Network::byte_t[2];
+ memset(_data, 0, 2);
+ _data[1]= data;
+ return *this;
+}
+
+Element &
+Element::makeBoolean(const string &name, bool data)
+{
+// GNASH_REPORT_FUNCTION;
+ if (name.size()) {
+ _name = name;
+ }
+ _type = Element::BOOLEAN;
+ _length = 1;
+ _data = new Network::byte_t[2];
memset(_data, 0, 2);
_data[1]= data;
return *this;
}
Element &
-Element::makeBoolean(boost::uint8_t *data)
+Element::makeBoolean(Network::byte_t *data)
{
// GNASH_REPORT_FUNCTION;
_type = Element::BOOLEAN;
_length = 1;
- _data = new boost::uint8_t[2];
+ _data = new Network::byte_t[2];
memset(_data, 0, 2);
memcpy(_data, data+1, 1);
return *this;
@@ -406,13 +452,13 @@
}
Element &
-Element::makeObject(boost::uint8_t *indata, int size)
+Element::makeObject(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::OBJECT;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
@@ -430,75 +476,75 @@
}
Element &
-Element::makeXMLObject(boost::uint8_t *indata, int size)
+Element::makeXMLObject(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::XML_OBJECT;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
}
Element &
-Element::makeTypedObject(boost::uint8_t *indata, int size)
+Element::makeTypedObject(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::TYPED_OBJECT;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
}
Element &
-Element::makeReference(boost::uint8_t *indata, int size)
+Element::makeReference(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::TYPED_OBJECT;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
}
Element &
-Element::makeMovieClip(boost::uint8_t *indata, int size)
+Element::makeMovieClip(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::MOVIECLIP;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
}
Element &
-Element::makeECMAArray(boost::uint8_t *indata, int size)
+Element::makeECMAArray(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::ECMA_ARRAY;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
return *this;
}
Element &
-Element::makeLongString(boost::uint8_t *indata, int size)
+Element::makeLongString(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::LONG_STRING;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
@@ -506,13 +552,13 @@
}
Element &
-Element::makeRecordSet(boost::uint8_t *indata, int size)
+Element::makeRecordSet(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::RECORD_SET;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
@@ -520,13 +566,13 @@
}
Element &
-Element::makeDate(boost::uint8_t *indata)
+Element::makeDate(Network::byte_t *indata)
{
// GNASH_REPORT_FUNCTION;
_type = Element::DATE;
_length = AMF_NUMBER_SIZE;
- _data = new boost::uint8_t[AMF_NUMBER_SIZE + 1];
+ _data = new Network::byte_t[AMF_NUMBER_SIZE + 1];
memset(_data, 0, AMF_NUMBER_SIZE + 1);
memcpy(_data, indata, AMF_NUMBER_SIZE);
@@ -534,13 +580,13 @@
}
Element &
-Element::makeStrictArray(boost::uint8_t *indata, int size)
+Element::makeStrictArray(Network::byte_t *indata, int size)
{
// GNASH_REPORT_FUNCTION;
_type = Element::STRICT_ARRAY;
_length = size;
- _data = new boost::uint8_t[size + 1];
+ _data = new Network::byte_t[size + 1];
memset(_data, 0, size + 1);
memcpy(_data, indata, size);
@@ -548,12 +594,23 @@
}
void
+Element::setName(Network::byte_t *name, int x)
+{
+// GNASH_REPORT_FUNCTION;
+
+ char *buf = new char[x+1];
+ *(buf+x) = 0; // terminate the string, we don't need
to memcpy the whole thing
+ std::copy(name, name+x, buf);
+ _name = buf;
+}
+
+void
Element::dump()
{
// GNASH_REPORT_FUNCTION;
if (_name.size()) {
- cerr << "AMF object name: " << _name << endl;
+ cerr << "AMF object name: " << _name << ", length is " << _length <<
endl;
}
cerr << astype_str[_type] << ": ";
Index: libamf/element.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/element.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libamf/element.h 28 Mar 2008 16:23:07 -0000 1.10
+++ libamf/element.h 30 Mar 2008 22:08:53 -0000 1.11
@@ -26,9 +26,11 @@
#include <string>
#include <cstring>
-#include "amfutf8.h"
#include <boost/cstdint.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
+
+#include "network.h"
+#include "amfutf8.h"
#include "amf.h"
#include "dsodefs.h" // DSOEXPORT
@@ -62,7 +64,7 @@
FUNCTION=0x12
} astype_e;
Element();
- Element(boost::uint8_t *data);
+ Element(gnash::Network::byte_t *data);
Element(double data);
Element(std::vector<double> &data);
Element(const std::string &data);
@@ -73,7 +75,7 @@
Element(bool, double, double, const std::string &str);
~Element();
void clear();
- boost::uint8_t *init(boost::uint8_t *data);
+ gnash::Network::byte_t *init(gnash::Network::byte_t *data);
Element &init(const std::string &name, double data);
Element &init(double data);
Element &init(std::vector<double> &data);
@@ -85,25 +87,32 @@
Element &init(bool, double, double, const std::string &str);
// These create the other "special" AMF types.
- Element &makeString(boost::uint8_t *data, int size);
- Element &makeNumber(boost::uint8_t *data);
- Element &makeBoolean(boost::uint8_t *data);
- Element &makeBoolean(bool &data);
+ Element &makeString(gnash::Network::byte_t *data, int size);
+ Element &makeString(const std::string &data);
+ Element &makeString(const std::string &name, const std::string &data);
+
+ Element &makeNumber(gnash::Network::byte_t *data);
+ Element &makeNumber(const std::string &name, double);
+
+ Element &makeBoolean(gnash::Network::byte_t *data);
+ Element &makeBoolean(bool data);
+ Element &makeBoolean(const std::string &name, bool data);
+
Element &makeUndefined();
Element &makeUndefined(const std::string &name);
Element &makeNull();
Element &makeNull(const std::string &name);
Element &makeObjectEnd();
- Element &makeObject(boost::uint8_t *data, int size);
- Element &makeXMLObject(boost::uint8_t *data, int size);
- Element &makeTypedObject(boost::uint8_t *data, int size);
- Element &makeReference(boost::uint8_t *data, int size);
- Element &makeMovieClip(boost::uint8_t *data, int size);
- Element &makeECMAArray(boost::uint8_t *data, int size);
- Element &makeLongString(boost::uint8_t *data, int size);
- Element &makeRecordSet(boost::uint8_t *data, int size);
- Element &makeDate(boost::uint8_t *data);
- Element &makeStrictArray(boost::uint8_t *data, int size);
+ Element &makeObject(gnash::Network::byte_t *data, int size);
+ Element &makeXMLObject(gnash::Network::byte_t *data, int size);
+ Element &makeTypedObject(gnash::Network::byte_t *data, int size);
+ Element &makeReference(gnash::Network::byte_t *data, int size);
+ Element &makeMovieClip(gnash::Network::byte_t *data, int size);
+ Element &makeECMAArray(gnash::Network::byte_t *data, int size);
+ Element &makeLongString(gnash::Network::byte_t *data, int size);
+ Element &makeRecordSet(gnash::Network::byte_t *data, int size);
+ Element &makeDate(gnash::Network::byte_t *data);
+ Element &makeStrictArray(gnash::Network::byte_t *data, int size);
// Element &makeArray();
Element &operator=(Element &);
@@ -114,8 +123,8 @@
// These are all accessors for the various output formats
astype_e getType() { return _type; };
void setType(astype_e x) { _type = x; };
- boost::uint8_t *getData() { return _data; };
- void setData(boost::uint8_t *x) { _data = x; };
+ gnash::Network::byte_t *getData() { return _data; };
+ void setData(gnash::Network::byte_t *x) { _data = x; };
// These accessors convert the raw data to a standard data type we can use.
double to_number();
@@ -127,7 +136,7 @@
void setLength(boost::uint16_t x) { _length = x; };
const std::string &getName() const { return _name; };
void setName(const std::string &name) { _name = name; };
- void setName(boost::uint8_t *name) { _name = reinterpret_cast<const char
*>(name); };
+ void setName(gnash::Network::byte_t *name, int x);
// boost::posix_time::ptime to_date();
void dump();
@@ -135,7 +144,7 @@
astype_e _type;
boost::int16_t _length;
std::string _name;
- boost::uint8_t *_data;
+ gnash::Network::byte_t *_data;
std::vector<Element *> _children;
}; // end of class definition
Index: libamf/lcshm.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/lcshm.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libamf/lcshm.cpp 23 Mar 2008 00:48:28 -0000 1.9
+++ libamf/lcshm.cpp 30 Mar 2008 22:08:53 -0000 1.10
@@ -28,6 +28,7 @@
#include <boost/cstdint.hpp>
#include "log.h"
+#include "network.h"
#include "amf.h"
#include "shm.h"
#include "element.h"
@@ -67,7 +68,7 @@
// GNASH_REPORT_FUNCTION;
}
-LcShm::LcShm(boost::uint8_t *addr)
+LcShm::LcShm(Network::byte_t *addr)
{
// GNASH_REPORT_FUNCTION;
_baseaddr = addr;
@@ -99,7 +100,7 @@
// GNASH_REPORT_FUNCTION;
}
-Listener::Listener(boost::uint8_t *x)
+Listener::Listener(Network::byte_t *x)
{
// GNASH_REPORT_FUNCTION;
_baseaddr = x;
@@ -116,7 +117,7 @@
{
// GNASH_REPORT_FUNCTION;
- boost::uint8_t *addr = _baseaddr + LC_LISTENERS_START;
+ Network::byte_t *addr = _baseaddr + LC_LISTENERS_START;
char *item = reinterpret_cast<char *>(addr);
// Walk through the list to the end
while (*item != 0) {
@@ -134,7 +135,7 @@
{
GNASH_REPORT_FUNCTION;
- boost::uint8_t *addr = _baseaddr + LC_LISTENERS_START;
+ Network::byte_t *addr = _baseaddr + LC_LISTENERS_START;
char *item = reinterpret_cast<char *>(addr);
// Walk to the end of the list
while ((item[0] != 0) && (item[1] != 0)) {
@@ -175,7 +176,7 @@
{
GNASH_REPORT_FUNCTION;
- boost::uint8_t *addr = _baseaddr + LC_LISTENERS_START;
+ Network::byte_t *addr = _baseaddr + LC_LISTENERS_START;
int len = 0;
char *item = reinterpret_cast<char *>(addr);
@@ -203,7 +204,7 @@
// GNASH_REPORT_FUNCTION;
auto_ptr< vector<string> > listeners ( new vector<string> );
if (_baseaddr != 0) {
- boost::uint8_t *addr = _baseaddr + LC_LISTENERS_START;
+ Network::byte_t *addr = _baseaddr + LC_LISTENERS_START;
const char *item = reinterpret_cast<const char *>(addr);
while (*item != 0) {
@@ -226,11 +227,11 @@
}
#if 0
-boost::uint8_t *
-LcShm::parseElement(amf::Element *el, boost::uint8_t *data)
+Network::byte_t *
+LcShm::parseElement(amf::Element *el, Network::byte_t *data)
{
GNASH_REPORT_FUNCTION;
- boost::uint8_t *ptr = reinterpret_cast<uint8_t *>(data);
+ Network::byte_t *ptr = reinterpret_cast<uint8_t *>(data);
Element::astype_e type = (Element::astype_e)*ptr;
switch (type) {
case AMF::NUMBER:
@@ -247,10 +248,10 @@
#endif
vector<amf::Element *>
-LcShm::parseBody(boost::uint8_t *data)
+LcShm::parseBody(Network::byte_t *data)
{
// GNASH_REPORT_FUNCTION;
- boost::uint8_t *ptr = reinterpret_cast<uint8_t *>(data);
+ Network::byte_t *ptr = reinterpret_cast<uint8_t *>(data);
AMF amf;
while (ptr) {
@@ -286,11 +287,11 @@
// added to the LocalConnection. This can be up to 40k long. While
// other web sites have claimed there is a length field in the initial
// shared memory segment header, I've never seen one in my tests.
-boost::uint8_t *
-LcShm::parseHeader(boost::uint8_t *data)
+Network::byte_t *
+LcShm::parseHeader(Network::byte_t *data)
{
// GNASH_REPORT_FUNCTION;
- boost::uint8_t *ptr = data;
+ Network::byte_t *ptr = data;
memcpy(&_header, ptr, LC_HEADER_SIZE);
// memcpy(&_object, data + LC_HEADER_SIZE, _header.length);
@@ -345,15 +346,15 @@
return ptr;
}
-boost::uint8_t *
+Network::byte_t *
LcShm::formatHeader(const std::string &con, const std::string &host, bool /*
domain */ )
{
GNASH_REPORT_FUNCTION;
-// boost::uint8_t *ptr = data + LC_HEADER_SIZE;
+// Network::byte_t *ptr = data + LC_HEADER_SIZE;
int size = con.size() + host.size() + 9;
- boost::uint8_t *header = new boost::uint8_t[size + 1];
- boost::uint8_t *ptr = header;
+ Network::byte_t *header = new Network::byte_t[size + 1];
+ Network::byte_t *ptr = header;
// This is the initial 16 bytes of the header
memset(ptr, 0, size + 1);
@@ -363,7 +364,7 @@
ptr = header + LC_HEADER_SIZE;
// Which is then always followed by 3 AMF objects.
- boost::uint8_t *tmp = AMF::encodeElement(con.c_str());
+ Network::byte_t *tmp = AMF::encodeElement(con.c_str());
memcpy(ptr, tmp, con.size());
ptr += con.size();
delete[] tmp;
@@ -452,12 +453,12 @@
// formatHeader(name, domainname, _object.domain);
// Update the connection name
- boost::uint8_t *ptr = Listener::getBaseAddress();
- if (ptr == reinterpret_cast<boost::uint8_t *>(0)) {
+ Network::byte_t *ptr = Listener::getBaseAddress();
+ if (ptr == reinterpret_cast<Network::byte_t *>(0)) {
log_error("base address not set!");
}
-// boost::uint8_t *tmp = AMF::encodeElement(name.c_str());
+// Network::byte_t *tmp = AMF::encodeElement(name.c_str());
// memcpy(ptr, tmp, name.size());
// ptr += name.size() + AMF_HEADER_SIZE;
// delete[] tmp;
@@ -467,7 +468,7 @@
// ptr += domainname.size() + AMF_HEADER_SIZE;
// ptr += LC_HEADER_SIZE;
- boost::uint8_t *x = ptr; // just for debugging from gdb. temporary
+ Network::byte_t *x = ptr; // just for debugging from gdb. temporary
// This is the initial 16 bytes of the header
memset(ptr, 0, LC_HEADER_SIZE + 200);
@@ -478,7 +479,7 @@
// Which is then always followed by 3 AMF objects.
- boost::uint8_t *tmp = AMF::encodeElement(name.c_str());
+ Network::byte_t *tmp = AMF::encodeElement(name.c_str());
memcpy(ptr, tmp, name.size() + AMF_HEADER_SIZE);
delete[] tmp;
@@ -499,8 +500,8 @@
// ptr += AMF_BOOLEAN_SIZE;
- vector<boost::uint8_t> *vec = AMF::encodeElement(data);
- vector<boost::uint8_t>::iterator vit;
+ vector<Network::byte_t> *vec = AMF::encodeElement(data);
+ vector<Network::byte_t>::iterator vit;
// Can't do a memcpy with a std::vector
// log_debug("Number of bytes in the vector: %x", vec->size());
for (vit = vec->begin(); vit != vec->end(); vit++) {
Index: libamf/lcshm.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/lcshm.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- libamf/lcshm.h 28 Mar 2008 12:22:44 -0000 1.9
+++ libamf/lcshm.h 30 Mar 2008 22:08:54 -0000 1.10
@@ -39,17 +39,17 @@
class DSOEXPORT Listener {
public:
Listener();
- Listener(boost::uint8_t *baseaddr);
+ Listener(gnash::Network::byte_t *baseaddr);
~Listener();
bool addListener(const std::string &name);
bool findListener(const std::string &name);
bool removeListener(const std::string &name);
std::auto_ptr< std::vector<std::string> > listListeners();
- void setBaseAddress(boost::uint8_t *addr) { _baseaddr = addr; };
- boost::uint8_t *getBaseAddress() { return _baseaddr; };
+ void setBaseAddress(gnash::Network::byte_t *addr) { _baseaddr = addr; };
+ gnash::Network::byte_t *getBaseAddress() { return _baseaddr; };
protected:
std::string _name;
- boost::uint8_t *_baseaddr;
+ gnash::Network::byte_t *_baseaddr;
// std::vector<std::string> _listeners;
};
@@ -76,7 +76,7 @@
double unknown_num2;
} lc_object_t;
LcShm();
- LcShm(boost::uint8_t *baseaddr);
+ LcShm(gnash::Network::byte_t *baseaddr);
LcShm(key_t key);
~LcShm();
bool connect(const std::string &name);
@@ -85,19 +85,19 @@
void send(const std::string &name, const std::string &dataname,
std::vector<amf::Element *> &data);
void recv(std::string &name, std::string &dataname, amf::Element *data);
- std::vector<amf::Element *> parseBody(boost::uint8_t *data);
- boost::uint8_t *parseHeader(boost::uint8_t *data);
- boost::uint8_t *formatHeader(const std::string &con, const std::string
&host, bool domain);
+ std::vector<amf::Element *> parseBody(gnash::Network::byte_t *data);
+ gnash::Network::byte_t *parseHeader(gnash::Network::byte_t *data);
+ gnash::Network::byte_t *formatHeader(const std::string &con, const
std::string &host, bool domain);
void addConnectionName(std::string &name);
void addHostname(std::string &name);
void addObject(amf::Element *el) { _amfobjs.push_back(el); };
size_t size() { return _amfobjs.size(); };
std::vector<amf::Element *> getElements() { return _amfobjs; };
- void setBaseAddr(boost::uint8_t *x) { _baseaddr = x; };
+ void setBaseAddr(gnash::Network::byte_t *x) { _baseaddr = x; };
void dump();
private:
- boost::uint8_t *_baseaddr;
+ gnash::Network::byte_t *_baseaddr;
lc_header_t _header;
lc_object_t _object;
std::vector<amf::Element *> _amfobjs;
Index: libamf/sol.cpp
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- libamf/sol.cpp 29 Mar 2008 19:35:53 -0000 1.25
+++ libamf/sol.cpp 30 Mar 2008 22:08:54 -0000 1.26
@@ -27,6 +27,8 @@
#include <vector>
#include <iostream>
#include <fstream>
+
+#include "network.h"
#include "amf.h"
#include "sol.h"
#include "log.h"
@@ -129,7 +131,7 @@
// so we swap it first.
boost::uint16_t swapped = SOL_MAGIC;
swapped = htons(swapped);
- boost::uint8_t *ptr = reinterpret_cast<boost::uint8_t *>(&swapped);
+ Network::byte_t *ptr = reinterpret_cast<Network::byte_t *>(&swapped);
for (i=0; i<sizeof(boost::uint16_t); i++) {
_header.push_back(ptr[i]);
}
@@ -140,7 +142,7 @@
filesize += name.size() + 16;
boost::uint32_t len = filesize;
len = htonl(len);
- ptr = reinterpret_cast<boost::uint8_t *>(&len);
+ ptr = reinterpret_cast<Network::byte_t *>(&len);
for (i=0; i<sizeof(boost::uint32_t); i++) {
_header.push_back(ptr[i]);
}
@@ -156,7 +158,7 @@
// then the 0x0004 bytes, also a mystery
swapped = SOL_BLOCK_MARK;
swapped = htons(swapped);
- ptr = reinterpret_cast<boost::uint8_t *>(&swapped);
+ ptr = reinterpret_cast<Network::byte_t *>(&swapped);
for (i=0; i<sizeof(boost::uint16_t); i++) {
_header.push_back(ptr[i]);
}
@@ -170,12 +172,12 @@
// First the length in two bytes
swapped = name.size();
swapped = htons(swapped);
- ptr = reinterpret_cast<boost::uint8_t *>(&swapped);
+ ptr = reinterpret_cast<Network::byte_t *>(&swapped);
for (i=0; i<sizeof(boost::uint16_t); i++) {
_header.push_back(ptr[i]);
}
// then the string itself
- ptr = (boost::uint8_t *)name.c_str();
+ ptr = (Network::byte_t *)name.c_str();
for (i=0; i<name.size(); i++) {
_header.push_back(ptr[i]);
}
@@ -204,13 +206,12 @@
{
// GNASH_REPORT_FUNCTION;
ofstream ofs(filespec.c_str(), ios::binary);
- if ( ! ofs )
- {
+ if ( ! ofs ) {
log_error("Failed opening file '%s' in binary mode", filespec.c_str());
return false;
}
- vector<boost::uint8_t>::iterator it;
+ vector<Network::byte_t>::iterator it;
vector<amf::Element *>::iterator ita;
AMF amf_obj;
char *ptr;
@@ -233,32 +234,33 @@
for (ita = _amfobjs.begin(); ita != _amfobjs.end(); ita++) {
amf::Element *el = (*(ita));
- size_t outsize;
- boost::uint8_t *foo = amf_obj.encodeVariable(el, outsize);
- if ( ! foo )
- {
+ size_t outsize = 0;
+ Network::byte_t *var = amf_obj.encodeVariable(el);
+// Network::byte_t *var = amf_obj.encodeVariable(el, outsize);
+ if (!var) {
continue;
}
assert(outsize);
switch (el->getType()) {
case Element::BOOLEAN:
- //outsize = el->getName().size() + 5;
+ outsize = el->getName().size() + 5;
assert(ptr+outsize < endPtr);
- memcpy(ptr, foo, outsize);
+ memcpy(ptr, var, outsize);
ptr += outsize;
break;
case Element::OBJECT:
- //outsize = el->getName().size() + 5;
+ outsize = el->getName().size() + 5;
assert(ptr+outsize < endPtr);
- memcpy(ptr, foo, outsize);
+ outsize = el->getName().size() + 5;
+ memcpy(ptr, var, outsize);
ptr += outsize;
*ptr++ = Element::OBJECT_END;
*ptr++ = 0; // objects are terminated too!
break;
case Element::NUMBER:
- //outsize = el->getName().size() + AMF_NUMBER_SIZE + 2;
+ outsize = el->getName().size() + AMF_NUMBER_SIZE + 2;
assert(ptr+outsize < endPtr);
- memcpy(ptr, foo, outsize);
+ memcpy(ptr, var, outsize);
ptr += outsize;
*ptr++ = 0; // doubles are terminated too!
*ptr++ = 0; // doubles are terminated too!
@@ -266,21 +268,21 @@
case Element::STRING:
if (el->getLength() == 0) {
assert(ptr+outsize+1 < endPtr);
- memcpy(ptr, foo, outsize+1);
+ memcpy(ptr, var, outsize+1);
ptr += outsize+1;
} else { // null terminate the string
assert(ptr+outsize < endPtr);
- memcpy(ptr, foo, outsize);
+ memcpy(ptr, var, outsize);
ptr += outsize;
*ptr++ = 0;
}
break;
default:
assert(ptr+outsize < endPtr);
- memcpy(ptr, foo, outsize);
+ memcpy(ptr, var, outsize);
ptr += outsize;
}
- delete[] foo;
+ delete[] var;
}
_filesize = ptr - body.get();
@@ -317,8 +319,8 @@
// GNASH_REPORT_FUNCTION;
struct stat st;
boost::uint16_t size;
- boost::scoped_array<boost::uint8_t> buf;
- boost::uint8_t *ptr;
+ boost::scoped_array<Network::byte_t> buf;
+ Network::byte_t *ptr;
int bodysize;
// Make sure it's an SOL file
@@ -327,7 +329,7 @@
_filesize = st.st_size;
bodysize = st.st_size - 6;
_filespec = filespec;
- buf.reset( new boost::uint8_t[_filesize+1] );
+ buf.reset( new Network::byte_t[_filesize+1] );
ptr = buf.get();
ifs.read(reinterpret_cast<char *>(buf.get()), _filesize);
Index: libamf/sol.h
===================================================================
RCS file: /sources/gnash/gnash/libamf/sol.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libamf/sol.h 28 Mar 2008 16:23:07 -0000 1.11
+++ libamf/sol.h 30 Mar 2008 22:08:54 -0000 1.12
@@ -22,10 +22,12 @@
#include "gnashconfig.h"
#endif
-#include "dsodefs.h" //DSOEXPORT
#include <boost/cstdint.hpp>
#include <string>
#include <vector>
+
+#include "dsodefs.h" //DSOEXPORT
+#include "network.h"
#include "element.h"
#include "amf.h"
@@ -49,11 +51,11 @@
size_t size() { return _amfobjs.size(); };
// extract the header
- bool extractHeader(const std::vector<boost::uint8_t> &data);
+ bool extractHeader(const std::vector<gnash::Network::byte_t> &data);
bool extractHeader(const std::string &filespec);
// Create the header
- bool formatHeader(const std::vector<boost::uint8_t> &data);
+ bool formatHeader(const std::vector<gnash::Network::byte_t> &data);
bool formatHeader(const std::string &name);
bool formatHeader(const std::string &name, int filesize);
@@ -64,7 +66,7 @@
// read the .sol file from disk
bool readFile(std::string &filespec);
- std::vector<boost::uint8_t> getHeader() { return _header; };
+ std::vector<gnash::Network::byte_t> getHeader() { return _header; };
/// Add the AMF objects that are the data of the file
//
@@ -102,8 +104,8 @@
std::string &getObjectName() { return _objname; };
private:
- std::vector<boost::uint8_t> _header;
- std::vector<boost::uint8_t> _data;
+ std::vector<gnash::Network::byte_t> _header;
+ std::vector<gnash::Network::byte_t> _data;
std::string _objname;
std::string _filespec;
Index: libamf/rtmp.cpp
===================================================================
RCS file: libamf/rtmp.cpp
diff -N libamf/rtmp.cpp
--- libamf/rtmp.cpp 19 Feb 2008 19:20:50 -0000 1.21
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,320 +0,0 @@
-// rtmp.cpp: Adobe/Macromedia Real Time Message Protocol handler, for Gnash.
-//
-// Copyright (C) 2005, 2006, 2007, 2008 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 3 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 "gnashconfig.h"
-#endif
-
-#include <iostream>
-
-#if ! (defined(_WIN32) || defined(WIN32))
-# include <netinet/in.h>
-#endif
-
-#include <new>
-#include "log.h"
-#include "rtmp.h"
-
-using namespace amf;
-using namespace std;
-
-namespace gnash
-{
-
-// These are the textual responses
-const char *response_str[] = {
- "/onStatus",
- "/onResult",
- "/onDebugEvents"
-};
-
-RTMPproto::RTMPproto()
-{
-// GNASH_REPORT_FUNCTION;
- _inbytes = 0;
- _outbytes = 0;
-
-// _body = new unsigned char(RTMP_BODY_SIZE+1);
- memset(_body, 0, RTMP_BODY_SIZE+1);
-}
-
-RTMPproto::~RTMPproto()
-{
-// GNASH_REPORT_FUNCTION;
- _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.
-bool
-RTMPproto::handShakeWait()
-{
- GNASH_REPORT_FUNCTION;
-
- char buffer[RTMP_BODY_SIZE+16];
- memset(buffer, 0, RTMP_BODY_SIZE+16);
-
- if (readNet(buffer, 1) == 1) {
- log_debug (_("Read initial Handshake Request"));
- } else {
- log_error (_("Couldn't read initial Handshake Request"));
- return false;
- }
- _inbytes += 1;
-
- if (*buffer == 0x3) {
- log_debug (_("Handshake is correct"));
- } else {
- log_error (_("Handshake isn't correct; "
- "Data read is: 0x%x"), *buffer);
- return false;
- }
-
- if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
- _inbytes += RTMP_BODY_SIZE;
- log_debug (_("Read Handshake Data"));
-// _body = new char(RTMP_BODY_SIZE+1);
- memcpy(_body, buffer, RTMP_BODY_SIZE);
- } else {
- log_error (_("Couldn't read Handshake Data"
- "Data read is: %s"), buffer);
- return false;
- }
-
- return true;
-}
-
-// A request for a handshake is initiated by sending a byte with a
-// value of 0x3, followed by a message body of unknown format.
-bool
-RTMPproto::handShakeRequest()
-{
- GNASH_REPORT_FUNCTION;
-
- char buffer[RTMP_BODY_SIZE+1];
- char c = 0x3;
- int i, ret;
-
- ret = writeNet(&c, 1);
- _outbytes += 1;
- // something went wrong, chances are the other end of the network
- // connection is down, or never initialized.
- if (ret <= 0) {
- return false;
- }
-
- // Since we don't know what the format is, create a pattern we can
- // recognize if we stumble across it later on.
- for (i=0; i<RTMP_BODY_SIZE; i++) {
- buffer[i] = i^256;
- }
-
- _outbytes += RTMP_BODY_SIZE;
- ret = writeNet(buffer, RTMP_BODY_SIZE);
-
- return true;
-}
-
-// The response is the giobberish sent back twice, preceeded by a byte
-// with the value of 0x3.
-bool
-RTMPproto::handShakeResponse()
-{
- GNASH_REPORT_FUNCTION;
-
- char c = 0x3;
- writeNet(&c, 1);
- _outbytes += 1;
- writeNet(_body, RTMP_BODY_SIZE);
- _outbytes += RTMP_BODY_SIZE;
- writeNet(_body, RTMP_BODY_SIZE);
- _outbytes += RTMP_BODY_SIZE;
-
- return true;
-}
-
-// The client finished the handshake process by sending the second
-// data block we get from the server as the response
-bool
-RTMPproto::clientFinish()
-{
- GNASH_REPORT_FUNCTION;
-
- char buffer[RTMP_BODY_SIZE+1];
- memset(buffer, 0, RTMP_BODY_SIZE+1);
-
- if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
- log_debug (_("Read first data block in handshake"));
- } else {
- log_error (_("Couldn't read first data block in handshake"));
- return false;
- }
- _inbytes += RTMP_BODY_SIZE;
- if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
- log_debug (_("Read second data block in handshake"));
-// _body = new char(RTMP_BODY_SIZE+1);
-// memcpy(_body, buffer, RTMP_BODY_SIZE);
- } else {
- log_error (_("Couldn't read second data block in handshake"));
- return false;
- }
- _inbytes += RTMP_BODY_SIZE;
-
- writeNet(buffer, RTMP_BODY_SIZE);
- _outbytes += RTMP_BODY_SIZE;
-
- return true;
-}
-
-bool
-RTMPproto::serverFinish()
-{
- GNASH_REPORT_FUNCTION;
-
-// int ret;
- char buffer[RTMP_BODY_SIZE+1];
- memset(buffer, 0, RTMP_BODY_SIZE+1);
-
- if (readNet(buffer, RTMP_BODY_SIZE) == RTMP_BODY_SIZE) {
- log_debug (_("Read Handshake Finish Data"));
- } else {
- log_error (_("Couldn't read Handshake Finish Data"));
- return false;
- }
-
- _inbytes += RTMP_BODY_SIZE;
-// FIXME: These should match, and appear to in GDB, but this triggers
-// an error of some kind.
-// if (memcmp(buffer, _body, 10) == 0) {
-// log_debug (_("Handshake Finish Data matches"));
-// } else {
-// log_error (_("Handshake Finish Data doesn't match"));
-// return false;
-// }
-
-
- packetRead();
-
- return true;
-}
-
-bool
-RTMPproto::packetRequest()
-{
- GNASH_REPORT_FUNCTION;
- return false;
-}
-
-bool
-RTMPproto::packetSend()
-{
- GNASH_REPORT_FUNCTION;
- return false;
-}
-
-bool
-RTMPproto::packetRead()
-{
- GNASH_REPORT_FUNCTION;
-
- int ret;
- unsigned char buffer[AMF_VIDEO_PACKET_SIZE+1];
- memset(buffer, 0, AMF_VIDEO_PACKET_SIZE+1);
- //unsigned char hexint[1024];
- int packetsize = 0;
- unsigned char *tmpptr;
- //char *amfdata;
- unsigned int amf_index, headersize;
- AMF *amf=NULL;
-#if 1
- unsigned char hexint[512];
-#endif
-
- 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(reinterpret_cast<char *>(buffer), 1)) > 0) {
- log_debug (_("Read first RTMP header byte"));
- } else {
- log_error (_("Couldn't read first RTMP header byte"));
- return false;
- }
-
- amf_index = *tmpptr & AMF_INDEX_MASK;
- headersize = AMF::headerSize(*tmpptr++);
- log_debug (_("The Header size is: %d"), headersize);
- log_debug (_("The AMF index is: 0x%x"), amf_index);
-
- if (headersize > 1) {
- if ((ret = readNet(reinterpret_cast<char *>(tmpptr), headersize-1)) >
0) {
- log_debug (_("Read first RTMP packet header of header size %d"),
- ret);
- _inbytes += ret;
- } else {
- log_error (_("Couldn't read first RTMP packet header"));
- return false;
- }
- }
- if (_amfs.size() < headersize) {
- amf = new AMF;
- }
-
- packetsize = amf->parseHeader(buffer);
- tmpptr += headersize;
- tmpptr = buffer;
-
- while ((ret = readNet(reinterpret_cast<char *>(buffer), packetsize, 1)) >
0) {
- log_debug (_("Reading AMF packets till we're done..."));
- amf->addPacketData(tmpptr, ret);
- tmpptr = buffer + ret;
- _inbytes += ret;
-#if 1
- hexify(hexint, buffer, packetsize, true);
- log_debug (_("The packet data is: 0x%s"), (char *)hexint);
- hexify(hexint, buffer, packetsize, false);
- log_debug (_("The packet data is: 0x%s"), (char *)hexint);
-#endif
- }
-
- log_debug (_("Done reading packet"));
- amf->parseBody();
-
- return true;
-}
-
-} // end of cygnal namespace
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
Index: libamf/rtmp.h
===================================================================
RCS file: libamf/rtmp.h
diff -N libamf/rtmp.h
--- libamf/rtmp.h 29 Mar 2008 10:23:05 -0000 1.13
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,134 +0,0 @@
-//
-// Copyright (C) 2005, 2006, 2007, 2008 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 3 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
-
-#ifndef _RTMP_H_
-#define _RTMP_H_
-
-#ifdef HAVE_CONFIG_H
-#include "gnashconfig.h"
-#endif
-
-#include "dsodefs.h"
-
-#include <boost/cstdint.hpp>
-#include <vector>
-
-#include "amf.h"
-#include "protocol.h"
-
-namespace gnash
-{
-
-#define RTMP_HANDSHAKE 0x3
-#define RTMP_BODY_SIZE 1536
-#define MAX_AMF_INDEXES 64
-
-class DSOEXPORT RTMPproto : public Protocol
-{
-public:
- typedef enum {
- CONNECT = 0x1,
- DISCONNECT = 0x2,
- SET_ATTRIBUTE = 0x3,
- UPDATE_DATA = 0x4,
- UPDATE_ATTRIBUTE = 0x5,
- SEND_MESSAGE = 0x6,
- STATUS = 0x7,
- CLEAR_DATA = 0x8,
- DELETE_DATA = 0x9,
- DELETE_ATTRIBUTE = 0xa,
- INITIAL_DATA = 0xb
- } sharedobj_types_e;
- typedef enum {
- RTMP_STATE_HANDSHAKE_SEND,
- RTMP_STATE_HANDSHAKE_RECV,
- 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;
- boost::uint8_t required;
- boost::uint32_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;
- boost::uint32_t length;
- void *data;
- } rtmp_body_t;
-
- RTMPproto();
- virtual ~RTMPproto();
- virtual bool handShakeWait();
- virtual bool handShakeRequest();
- virtual bool handShakeResponse();
- virtual bool clientFinish();
- virtual bool serverFinish();
-
- virtual bool packetRequest();
- virtual bool packetSend();
- virtual bool packetRead();
-
- void addVariable(char *name, char *value);
- std::string getVariable(char *name);
-private:
- std::map<char *, std::string> _variables;
- unsigned char _body[RTMP_BODY_SIZE+1];
- std::vector<amf::AMF *> _amfs;
-};
-
-} // end of gnash namespace
-
-// end of _RTMP_H_
-#endif
-
-// local Variables:
-// mode: C++
-// indent-tabs-mode: t
-// End:
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog libamf/amf.cpp libamf/amf.h lib...,
Rob Savoye <=