rtmppkt.c File Reference
#include "libavcodec/bytestream.h"
#include "libavutil/avstring.h"
#include "libavutil/intfloat.h"
#include "avformat.h"
#include "rtmppkt.h"
#include "flv.h"
#include "url.h"

Go to the source code of this file.

Functions

void ff_amf_write_bool (uint8_t **dst, int val)
 Write boolean value in AMF format to buffer.
void ff_amf_write_number (uint8_t **dst, double val)
 Write number in AMF format to buffer.
void ff_amf_write_string (uint8_t **dst, const char *str)
 Write string in AMF format to buffer.
void ff_amf_write_null (uint8_t **dst)
 Write AMF NULL value to buffer.
void ff_amf_write_object_start (uint8_t **dst)
 Write marker for AMF object to buffer.
void ff_amf_write_field_name (uint8_t **dst, const char *str)
 Write string used as field name in AMF object to buffer.
void ff_amf_write_object_end (uint8_t **dst)
 Write marker for end of AMF object to buffer.
int ff_rtmp_packet_read (URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket *prev_pkt)
 Read RTMP packet sent by the server.
int ff_rtmp_packet_write (URLContext *h, RTMPPacket *pkt, int chunk_size, RTMPPacket *prev_pkt)
 Send RTMP packet to the server.
int ff_rtmp_packet_create (RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size)
 Create new RTMP packet with given attributes.
void ff_rtmp_packet_destroy (RTMPPacket *pkt)
 Free RTMP packet.
int ff_amf_tag_size (const uint8_t *data, const uint8_t *data_end)
 Calculate number of bytes taken by first AMF entry in data.
int ff_amf_get_field_value (const uint8_t *data, const uint8_t *data_end, const uint8_t *name, uint8_t *dst, int dst_size)
 Retrieve value of given AMF object field in string form.
static const char * rtmp_packet_type (int type)
static void ff_amf_tag_contents (void *ctx, const uint8_t *data, const uint8_t *data_end)
void ff_rtmp_packet_dump (void *ctx, RTMPPacket *p)
 Print information and contents of RTMP packet.
int ff_amf_match_string (const uint8_t *data, int size, const char *str)
 Match AMF string with a NULL-terminated string.

Function Documentation

int ff_amf_get_field_value ( const uint8_t *  data,
const uint8_t *  data_end,
const uint8_t *  name,
uint8_t *  dst,
int  dst_size 
)

Retrieve value of given AMF object field in string form.

Parameters
dataAMF object data
data_endinput buffer end
namename of field to retrieve
dstbuffer for storing result
dst_sizeoutput buffer size
Returns
0 if search and retrieval succeeded, negative value otherwise

Definition at line 296 of file rtmppkt.c.

Referenced by rtmp_parse_result().

int ff_amf_match_string ( const uint8_t *  data,
int  size,
const char *  str 
)

Match AMF string with a NULL-terminated string.

Returns
0 if the strings do not match.

Definition at line 452 of file rtmppkt.c.

Referenced by get_packet(), and rtmp_parse_result().

static void ff_amf_tag_contents ( void ctx,
const uint8_t *  data,
const uint8_t *  data_end 
)
static

Definition at line 364 of file rtmppkt.c.

Referenced by ff_rtmp_packet_dump().

int ff_amf_tag_size ( const uint8_t *  data,
const uint8_t *  data_end 
)

Calculate number of bytes taken by first AMF entry in data.

Parameters
datainput data
data_endinput buffer end
Returns
number of bytes used by first AMF entry

Definition at line 260 of file rtmppkt.c.

Referenced by ff_amf_get_field_value(), ff_amf_tag_contents(), ff_amf_tag_size(), ff_rtmp_packet_dump(), and rtmp_parse_result().

void ff_amf_write_bool ( uint8_t **  dst,
int  val 
)

Write boolean value in AMF format to buffer.

Parameters
dstpointer to the input buffer (will be modified)
valvalue to write

Definition at line 31 of file rtmppkt.c.

Referenced by gen_connect().

void ff_amf_write_field_name ( uint8_t **  dst,
const char *  str 
)

Write string used as field name in AMF object to buffer.

Parameters
dstpointer to the input buffer (will be modified)
strstring to write

Definition at line 60 of file rtmppkt.c.

Referenced by gen_connect().

void ff_amf_write_null ( uint8_t **  dst)

Write AMF NULL value to buffer.

Parameters
dstpointer to the input buffer (will be modified)

Definition at line 50 of file rtmppkt.c.

Referenced by gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcunpublish_stream(), gen_play(), gen_publish(), and gen_release_stream().

void ff_amf_write_number ( uint8_t **  dst,
double  num 
)

Write number in AMF format to buffer.

Parameters
dstpointer to the input buffer (will be modified)
numvalue to write

Definition at line 37 of file rtmppkt.c.

Referenced by gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcunpublish_stream(), gen_play(), gen_publish(), and gen_release_stream().

void ff_amf_write_object_end ( uint8_t **  dst)

Write marker for end of AMF object to buffer.

Parameters
dstpointer to the input buffer (will be modified)

Definition at line 66 of file rtmppkt.c.

Referenced by gen_connect().

void ff_amf_write_object_start ( uint8_t **  dst)

Write marker for AMF object to buffer.

Parameters
dstpointer to the input buffer (will be modified)

Definition at line 55 of file rtmppkt.c.

Referenced by gen_connect().

void ff_amf_write_string ( uint8_t **  dst,
const char *  str 
)

Write string in AMF format to buffer.

Parameters
dstpointer to the input buffer (will be modified)
strstring to write

Definition at line 43 of file rtmppkt.c.

Referenced by gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcunpublish_stream(), gen_play(), gen_publish(), gen_release_stream(), and rtmp_write().

int ff_rtmp_packet_create ( RTMPPacket pkt,
int  channel_id,
RTMPPacketType  type,
int  timestamp,
int  size 
)

Create new RTMP packet with given attributes.

Parameters
pktpacket
channel_idpacket channel ID
typepacket type
timestamppacket timestamp
sizepacket size
Returns
zero on success, negative value otherwise

Definition at line 234 of file rtmppkt.c.

Referenced by ff_rtmp_packet_read(), gen_bytes_read(), gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcunpublish_stream(), gen_play(), gen_pong(), gen_publish(), gen_release_stream(), and rtmp_write().

void ff_rtmp_packet_dump ( void ctx,
RTMPPacket p 
)

Print information and contents of RTMP packet.

Parameters
ctxoutput context
ppacket to dump

Definition at line 426 of file rtmppkt.c.

Referenced by rtmp_parse_result().

int ff_rtmp_packet_read ( URLContext h,
RTMPPacket p,
int  chunk_size,
RTMPPacket prev_pkt 
)

Read RTMP packet sent by the server.

Parameters
hreader context
ppacket
chunk_sizecurrent chunk size
prev_pktpreviously read packet headers for all channels (may be needed for restoring incomplete packet header)
Returns
number of bytes read on success, negative value otherwise

Definition at line 74 of file rtmppkt.c.

Referenced by get_packet().

int ff_rtmp_packet_write ( URLContext h,
RTMPPacket p,
int  chunk_size,
RTMPPacket prev_pkt 
)

Send RTMP packet to the server.

Parameters
hreader context
ppacket to send
chunk_sizecurrent chunk size
prev_pktpreviously sent packet headers for all channels (may be used for packet header compressing)
Returns
number of bytes written on success, negative value otherwise

Definition at line 161 of file rtmppkt.c.

Referenced by gen_bytes_read(), gen_connect(), gen_create_stream(), gen_delete_stream(), gen_fcpublish_stream(), gen_fcunpublish_stream(), gen_play(), gen_pong(), gen_publish(), gen_release_stream(), rtmp_parse_result(), and rtmp_write().

static const char* rtmp_packet_type ( int  type)
static

Definition at line 343 of file rtmppkt.c.

Referenced by ff_rtmp_packet_dump().