Gnash
0.8.11dev
|
Functions and classes for handling AMF. More...
Classes | |
class | AMFException |
Exception for handling malformed buffers. More... | |
class | Reader |
Deserialize an AMF buffer to as_values. More... | |
class | Writer |
A class to compose AMF buffers. More... | |
Enumerations | |
enum | Type { NOTYPE = -1, NUMBER_AMF0 = 0x00, BOOLEAN_AMF0 = 0x01, STRING_AMF0 = 0x02, OBJECT_AMF0 = 0x03, MOVIECLIP_AMF0 = 0x04, NULL_AMF0 = 0x05, UNDEFINED_AMF0 = 0x06, REFERENCE_AMF0 = 0x07, ECMA_ARRAY_AMF0 = 0x08, OBJECT_END_AMF0 = 0x09, STRICT_ARRAY_AMF0 = 0x0a, DATE_AMF0 = 0x0b, LONG_STRING_AMF0 = 0x0c, UNSUPPORTED_AMF0 = 0x0d, RECORD_SET_AMF0 = 0x0e, XML_OBJECT_AMF0 = 0x0f, TYPED_OBJECT_AMF0 = 0x10 } |
Functions | |
bool | readBoolean (const std::uint8_t *&pos, const std::uint8_t *end) |
Read a boolean value from the buffer. More... | |
double | readNumber (const std::uint8_t *&pos, const std::uint8_t *end) |
Read a number from an AMF buffer. More... | |
std::string | readString (const std::uint8_t *&pos, const std::uint8_t *end) |
Read a string value from the buffer. More... | |
std::string | readLongString (const std::uint8_t *&pos, const std::uint8_t *end) |
Read a long string value from the buffer. More... | |
void | writePlainString (SimpleBuffer &buf, const std::string &str, Type t) |
Encode a plain short string to an AMF buffer. More... | |
void | writePlainNumber (SimpleBuffer &buf, double d) |
Write a number to an AMF buffer. More... | |
void | write (SimpleBuffer &buf, const std::string &str) |
Write a string to an AMF buffer. More... | |
void | write (SimpleBuffer &buf, double d) |
Write a number to an AMF buffer. More... | |
void | write (SimpleBuffer &buf, bool b) |
Write a boolean value to an AMF buffer. More... | |
std::uint16_t | readNetworkShort (const std::uint8_t *buf) |
Read an unsigned 16-bit value in network byte order. More... | |
std::uint32_t | readNetworkLong (const std::uint8_t *buf) |
Read an unsigned 32-bit value in network byte order. More... | |
void | write (SimpleBuffer &buf, const char *str) |
Write a C string to an AMF buffer. More... | |
template<typename T > | |
void | writeProperty (SimpleBuffer &buf, const std::string &name, const T &t) |
Encode a string-value pair. More... | |
Functions and classes for handling AMF.
AMF is a simple serialization format for ActionScript objects and values, allowing them to be stored and transmitted. The AMF namespace provides both low-level and high-level conversion to and from AMF buffers.
AMF is a simple serialization format for ActionScript objects and values, allowing them to be stored and transmitted. These classes convert between AMF buffers and the objects they contain.
enum gnash::amf::Type |
DSOEXPORT bool gnash::amf::readBoolean | ( | const std::uint8_t *& | pos, |
const std::uint8_t * | end | ||
) |
Read a boolean value from the buffer.
This does not read a type byte; use AMF::Reader when the type should be determined from the buffer. This function will throw an AMFException if it encounters ill-formed AMF.
References gnash::log_debug().
Referenced by gnash::amf::AMFException::AMFException(), and gnash::amf::Reader::operator()().
DSOEXPORT std::string gnash::amf::readLongString | ( | const std::uint8_t *& | pos, |
const std::uint8_t * | end | ||
) |
Read a long string value from the buffer.
This does not read a type byte; use AMF::Reader when the type should be determined from the buffer. This function will throw an AMFException if it encounters ill-formed AMF.
References gnash::log_debug(), and readNetworkLong().
Referenced by gnash::amf::AMFException::AMFException(), and gnash::amf::Reader::operator()().
|
inline |
Read an unsigned 32-bit value in network byte order.
You must ensure that the buffer contains at least 4 bytes!
References DSOEXPORT, gnash::key::s, and write().
Referenced by gnash::amf::Reader::operator()(), readLongString(), gnash::rtmp::sendCtrl(), and gnash::rtmp::sendServerBW().
|
inline |
Read an unsigned 16-bit value in network byte order.
You must ensure that the buffer contains at least 2 bytes!
References gnash::key::s.
Referenced by gnash::amf::Reader::operator()(), readString(), gnash::rtmp::sendCtrl(), and gnash::NetConnection_as::update().
DSOEXPORT double gnash::amf::readNumber | ( | const std::uint8_t *& | pos, |
const std::uint8_t * | end | ||
) |
Read a number from an AMF buffer.
This does not read a type byte; use AMF::Reader when the type should be determined from the buffer. This function will throw an AMFException if it encounters ill-formed AMF.
References gnash::key::d, and gnash::log_debug().
Referenced by gnash::amf::AMFException::AMFException(), handleInvoke(), and gnash::amf::Reader::operator()().
DSOEXPORT std::string gnash::amf::readString | ( | const std::uint8_t *& | pos, |
const std::uint8_t * | end | ||
) |
Read a string value from the buffer.
This does not read a type byte; use AMF::Reader when the type should be determined from the buffer. This function will throw an AMFException if it encounters ill-formed AMF.
References _, gnash::log_debug(), and readNetworkShort().
Referenced by gnash::amf::AMFException::AMFException(), handleInvoke(), gnash::amf::Reader::operator()(), and gnash::rtmp::RTMP::sendPacket().
|
inline |
Write a C string to an AMF buffer.
The overload is necessary to prevent const char* being resolved to the boolean overload.
References gnash::key::b, gnash::key::d, DSOEXPORT, gnash::key::t, write(), writePlainNumber(), and writePlainString().
DSOEXPORT void gnash::amf::write | ( | SimpleBuffer & | buf, |
const std::string & | str | ||
) |
Write a string to an AMF buffer.
This function writes the type byte and the string value. It also handles both long and short strings automatically. This is overloaded for automatic type deduction to allow the use of a template for more complex operations. You must be careful when using it!
References gnash::SimpleBuffer::appendByte(), LONG_STRING_AMF0, STRING_AMF0, gnash::key::t, and writePlainString().
Referenced by gnash::MouseDevice::command(), gnash::renderer::rawfb::RawFBDevice::dump(), dump_shm(), gnash::UinputDevice::init(), gnash::UinputDevice::moveTo(), gnash::movie_root::processInvoke(), readNetworkLong(), gnash::IOChannel::readNonBlocking(), replyBWCheck(), gnash::Player::run(), sendCheckBW(), sendConnectPacket(), sendCreateStream(), sendDeleteStream(), sendFCSubscribe(), sendPausePacket(), sendPlayPacket(), gnash::nsPluginInstance::Write(), write(), gnash::amf::Writer::writeBoolean(), gnash::ExternalInterface::writeBrowser(), gnash::amf::Writer::writeNumber(), gnash::GnashPluginScriptObject::writePlayer(), writeProperty(), and gnash::amf::Writer::writeString().
DSOEXPORT void gnash::amf::write | ( | SimpleBuffer & | buf, |
double | d | ||
) |
Write a number to an AMF buffer.
This function writes the type byte and the double value. This is overloaded for automatic type deduction to allow the use of a template for more complex operations. You must be careful when using it!
References gnash::SimpleBuffer::appendByte(), NUMBER_AMF0, and writePlainNumber().
DSOEXPORT void gnash::amf::write | ( | SimpleBuffer & | buf, |
bool | b | ||
) |
Write a boolean value to an AMF buffer.
This function writes the type byte and the boolean value. This is overloaded for automatic type deduction to allow the use of a template for more complex operations. You must be careful when using it!
References gnash::SimpleBuffer::appendByte(), BOOLEAN_AMF0, gnash::key::c, gnash::key::s, gnash::key::u, and x.
DSOEXPORT void gnash::amf::writePlainNumber | ( | SimpleBuffer & | buf, |
double | d | ||
) |
Write a number to an AMF buffer.
This function writes the double value without a type byte.
References gnash::SimpleBuffer::append().
Referenced by write().
DSOEXPORT void gnash::amf::writePlainString | ( | SimpleBuffer & | buf, |
const std::string & | str, | ||
Type | t | ||
) |
Encode a plain short string to an AMF buffer.
This does not encode a type byte; it is used for cases where a string is required, such as for the name of an object property, and therefore does not use a type byte.
References _, gnash::SimpleBuffer::append(), gnash::SimpleBuffer::appendNetworkLong(), gnash::SimpleBuffer::appendNetworkShort(), gnash::log_error(), LONG_STRING_AMF0, and STRING_AMF0.
Referenced by write(), writeProperty(), and gnash::amf::Writer::writePropertyName().
void gnash::amf::writeProperty | ( | SimpleBuffer & | buf, |
const std::string & | name, | ||
const T & | t | ||
) |
Encode a string-value pair.
This is used for object properties; the string is always encoded with a 2-byte length.
References STRING_AMF0, write(), and writePlainString().
Referenced by sendConnectPacket().