Gnash
0.8.11dev
|
Classes | |
struct | RTMP |
This class is for handling the RTMP protocol. More... | |
struct | RTMPHeader |
The RTMPHeader contains all the fields for the packet header. More... | |
struct | RTMPPacket |
An RTMPPacket class contains a full description of an RTMP packet. More... | |
Functions | |
bool | sendServerBW (RTMP &r) |
Send the server bandwidth. More... | |
bool | sendCtrl (RTMP &r, ControlType, unsigned int nObject, unsigned int nTime) |
Send a control packet. More... | |
std::ostream & | operator<< (std::ostream &o, PacketType p) |
Logging assistance for PacketType. More... | |
std::ostream & | operator<< (std::ostream &o, ControlType t) |
Logging assistance for ControlType. More... | |
bool | hasPayload (const RTMPPacket &p) |
Check whether an RTMPPacket has a payload. More... | |
void | clearPayload (RTMPPacket &p) |
Clear the message body and the bytes read of an RTMPPacket. More... | |
size_t | payloadSize (const RTMPPacket &p) |
The current size of the space allocated for the message payload. More... | |
std::uint8_t * | payloadData (RTMPPacket &p) |
Access the payload data section of the buffer. More... | |
const std::uint8_t * | payloadData (const RTMPPacket &p) |
Access the payload data section of the buffer. More... | |
const std::uint8_t * | payloadEnd (const RTMPPacket &p) |
Get the end of the allocated payload data section of the buffer. More... | |
bool | isReady (const RTMPPacket &p) |
Check if a packet is ready for processing. More... | |
The known channels.
CHANNEL_CONTROL1 is for internal controls: sendCtrl send server BW send bytes received. These contain no AMF data. CHANNEL_CONTROL2 is for ActionScript controls _checkbw: AS _result: connect: Maybe from ASNative(2100, 0) (connect) createStream: AS deleteStream: Maybe ASNative(2100, 1) (close) FCSubscribe: Don't know. These all contain AMF data.
Enumerator | |
---|---|
CHANNEL_CONTROL1 | |
CHANNEL_CONTROL2 | |
CHANNEL_VIDEO |
Known control / ping codes.
See http://jira.red5.org/confluence/display/docs/Ping (may not exist). 0x00: Clear the stream. No third and fourth parameters. The second parameter could be 0. After the connection is established, a Ping 0,0 will be sent from server to client. The message will also be sent to client on the start of Play and in response of a Seek or Pause/Resume request. This Ping tells client to re-calibrate the clock with the timestamp of the next packet server sends. 0x01: Tell the stream to clear the playing buffer. 0x02: Stream dry (not sure what this means!) 0x03: Buffer time of the client. The third parameter is the buffer time in milliseconds. 0x04: Reset a stream. Used together with type 0 in the case of VOD. Often sent before type 0. 0x06: Ping the client from server. The second parameter is the current time. 0x07: Pong reply from client. The second parameter is the time the server sent with his ping request. 0x1a: SWFVerification request 0x1b: SWFVerification response 0x1f: Not sure, maybe buffer empty. 0x20: Buffer ready.
The PacketSize specifies the number of fields contained in the header.
Enumerator | |
---|---|
RTMP_PACKET_SIZE_LARGE | |
RTMP_PACKET_SIZE_MEDIUM | |
RTMP_PACKET_SIZE_SMALL | |
RTMP_PACKET_SIZE_MINIMUM |
The known packet types.
|
inline |
Clear the message body and the bytes read of an RTMPPacket.
This is to be used to free used information from packets in a channel. The header information must be preserved for future packets, but the payload is no longer needed once read.
References gnash::rtmp::RTMPPacket::buffer, and gnash::rtmp::RTMPPacket::bytesRead.
Referenced by sendServerBW(), and gnash::rtmp::RTMP::update().
|
inline |
Check whether an RTMPPacket has a payload.
Only stored packets may not have a payload. A packet without a payload has already been processed and is only used for its header information.
References gnash::rtmp::RTMPPacket::buffer.
Referenced by payloadData(), payloadEnd(), payloadSize(), sendServerBW(), and gnash::rtmp::RTMP::update().
|
inline |
Check if a packet is ready for processing.
A packet is ready for processing if its payload size matches the data size in its header. It may take several successive packets to form a complete packet.
References gnash::rtmp::RTMPPacket::bytesRead, gnash::rtmp::RTMPHeader::dataSize, and gnash::rtmp::RTMPPacket::header.
Referenced by gnash::rtmp::RTMP::update().
std::ostream & gnash::rtmp::operator<< | ( | std::ostream & | o, |
PacketType | p | ||
) |
Logging assistance for PacketType.
References PACKET_TYPE_AUDIO, PACKET_TYPE_BYTES_READ, PACKET_TYPE_CHUNK_SIZE, PACKET_TYPE_CLIENTBW, PACKET_TYPE_CONTROL, PACKET_TYPE_FLEX_MESSAGE, PACKET_TYPE_FLEX_SHARED_OBJECT, PACKET_TYPE_FLEX_STREAM_SEND, PACKET_TYPE_FLV, PACKET_TYPE_INVOKE, PACKET_TYPE_METADATA, PACKET_TYPE_SERVERBW, PACKET_TYPE_SHARED_OBJECT, and PACKET_TYPE_VIDEO.
std::ostream & gnash::rtmp::operator<< | ( | std::ostream & | o, |
ControlType | t | ||
) |
Logging assistance for ControlType.
References CONTROL_BUFFER_EMPTY, CONTROL_BUFFER_READY, CONTROL_BUFFER_TIME, CONTROL_CLEAR_BUFFER, CONTROL_CLEAR_STREAM, CONTROL_PING, CONTROL_PONG, CONTROL_REQUEST_VERIFY, CONTROL_RESET_STREAM, CONTROL_RESPOND_VERIFY, and CONTROL_STREAM_DRY.
|
inline |
Access the payload data section of the buffer.
References gnash::rtmp::RTMPPacket::buffer, gnash::SimpleBuffer::data(), hasPayload(), and gnash::rtmp::RTMPHeader::headerSize.
Referenced by gnash::rtmp::RTMP::handlePacket(), sendCtrl(), gnash::rtmp::RTMP::sendPacket(), and sendServerBW().
|
inline |
Access the payload data section of the buffer.
References gnash::rtmp::RTMPPacket::buffer, gnash::SimpleBuffer::data(), hasPayload(), and gnash::rtmp::RTMPHeader::headerSize.
|
inline |
Get the end of the allocated payload data section of the buffer.
Note that this is only valid for packets we create, and for packets we have fully read. Stored packets that have not yet received all data have allocated space that has not yet been written.
References gnash::rtmp::RTMPPacket::buffer, gnash::SimpleBuffer::data(), hasPayload(), and gnash::SimpleBuffer::size().
Referenced by gnash::rtmp::RTMP::sendPacket().
|
inline |
The current size of the space allocated for the message payload.
For messages we create, this matches the exact size of the payload. For messages we read, this is the expected size of the data.
References gnash::rtmp::RTMPPacket::buffer, hasPayload(), gnash::rtmp::RTMPHeader::headerSize, and gnash::SimpleBuffer::size().
Referenced by gnash::rtmp::RTMP::handlePacket(), sendCtrl(), and gnash::rtmp::RTMP::sendPacket().
bool gnash::rtmp::sendCtrl | ( | RTMP & | r, |
ControlType | t, | ||
unsigned int | nObject, | ||
unsigned int | nTime | ||
) |
Send a control packet.
The type of Ping packet is 0x4 and contains two mandatory parameters and two optional parameters. The first parameter is the type of Ping and in short integer. The second parameter is the target of the ping. As Ping is always sent in Channel 2 (control channel) and the target object in RTMP header is always 0 whicj means the Connection object, it's necessary to put an extra parameter to indicate the exact target object the Ping is sent to. The second parameter takes this responsibility. The value has the same meaning as the target object field in RTMP header. (The second value could also be used as other purposes, like RTT Ping/Pong. It is used as the timestamp.) The third and fourth parameters are optional and could be looked upon as the parameter of the Ping packet.
References _, gnash::rtmp::RTMP::_bytesIn, gnash::rtmp::RTMP::_bytesInSent, gnash::rtmp::RTMP::_inChunkSize, gnash::SimpleBuffer::appendNetworkLong(), gnash::SimpleBuffer::appendNetworkShort(), gnash::rtmp::RTMP::bandwidth(), gnash::rtmp::RTMPPacket::buffer, gnash::key::c, gnash::rtmp::RTMPHeader::channel, CHANNEL_CONTROL1, CHANNEL_CONTROL2, CONTROL_BUFFER_EMPTY, CONTROL_BUFFER_READY, CONTROL_BUFFER_TIME, CONTROL_CLEAR_BUFFER, CONTROL_CLEAR_STREAM, CONTROL_PING, CONTROL_PONG, CONTROL_RESET_STREAM, CONTROL_RESPOND_VERIFY, CONTROL_STREAM_DRY, gnash::rtmp::RTMPPacket::header, gnash::rtmp::RTMPHeader::headerType, gnash::log_debug(), gnash::log_error(), gnash::rtmp::RTMP::m_nClientBW2, PACKET_TYPE_BYTES_READ, PACKET_TYPE_CONTROL, PACKET_TYPE_INVOKE, gnash::rtmp::RTMPHeader::packetType, payloadData(), payloadSize(), gnash::key::r, gnash::amf::readNetworkLong(), gnash::amf::readNetworkShort(), RTMP_PACKET_SIZE_LARGE, gnash::rtmp::RTMP::sendPacket(), gnash::rtmp::RTMP::setBandwidth(), and gnash::rtmp::RTMP::setServerBandwidth().
Referenced by gnash::rtmp::RTMP::setBufferTime().
Send the server bandwidth.
Send a bandwidth ping to the server.
Why would we want to send this?
References _, __FUNCTION__, gnash::rtmp::RTMP::_inChunkSize, gnash::rtmp::RTMPHeader::_streamID, gnash::rtmp::RTMPHeader::_timestamp, gnash::SimpleBuffer::appendNetworkLong(), gnash::rtmp::RTMPPacket::buffer, gnash::rtmp::RTMPPacket::bytesRead, gnash::rtmp::RTMPHeader::channel, CHANNEL_CONTROL1, clearPayload(), gnash::rtmp::RTMPHeader::dataSize, hasPayload(), gnash::rtmp::RTMPPacket::header, gnash::rtmp::RTMPHeader::headerSize, gnash::rtmp::RTMPHeader::headerType, gnash::log_debug(), gnash::log_error(), PACKET_TYPE_SERVERBW, gnash::rtmp::RTMPHeader::packetType, payloadData(), gnash::amf::readNetworkLong(), gnash::rtmp::RTMP::readSocket(), RTMP_PACKET_SIZE_LARGE, gnash::rtmp::RTMP::sendPacket(), and gnash::rtmp::RTMP::serverBandwidth().