Go to the documentation of this file.
   33     bytestream_put_byte(
dst, 
val);
 
   45     bytestream_put_be32(
dst, length);
 
   51     bytestream_put_be16(
dst, strlen(str));
 
   57     int len1 = 0, len2 = 0;
 
   63     bytestream_put_be16(
dst, len1 + len2);
 
   80     bytestream_put_be16(
dst, strlen(str));
 
   97     read = bytestream2_get_be64(bc);
 
  103                       int strsize, 
int *length)
 
  107     stringlen = bytestream2_get_be16(bc);
 
  108     if (stringlen + 1 > strsize)
 
  111     if (readsize != stringlen) {
 
  113                "Unable to read as many bytes as AMF string signaled\n");
 
  115     str[readsize] = 
'\0';
 
  116     *length = 
FFMIN(stringlen, readsize);
 
  121                        int strsize, 
int *length)
 
  150     memset(ptr + *nb_prev_pkt, 0, (nb_alloc - *nb_prev_pkt) * 
sizeof(*ptr));
 
  152     *nb_prev_pkt = nb_alloc;
 
  157                         int chunk_size, 
RTMPPacket **prev_pkt, 
int *nb_prev_pkt)
 
  170                                       int *nb_prev_pkt, uint8_t hdr)
 
  174     int channel_id, timestamp, 
size;
 
  183     channel_id = hdr & 0x3F;
 
  185     if (channel_id < 2) { 
 
  189         written += channel_id + 1;
 
  190         channel_id = 
AV_RL16(buf) + 64;
 
  195     prev_pkt = *prev_pkt_ptr;
 
  198     extra = prev_pkt[channel_id].
extra;
 
  202         ts_field = prev_pkt[channel_id].
ts_field;
 
  225     if (ts_field == 0xFFFFFF) {
 
  230         timestamp = ts_field;
 
  233         timestamp += prev_pkt[channel_id].
timestamp;
 
  235     if (prev_pkt[channel_id].
read && 
size != prev_pkt[channel_id].
size) {
 
  239         prev_pkt[channel_id].
read = 0;
 
  243     if (!prev_pkt[channel_id].
read) {
 
  249         prev_pkt[channel_id].
ts_field   = ts_field;
 
  250         prev_pkt[channel_id].
timestamp  = timestamp;
 
  270     prev_pkt[channel_id].
extra      = extra;
 
  291     prev_pkt[channel_id].
read = 0; 
 
  314     uint8_t pkt_hdr[16], *p = pkt_hdr;
 
  324                                          pkt->channel_id)) < 0)
 
  326     prev_pkt = *prev_pkt_ptr;
 
  333     timestamp = 
pkt->timestamp;
 
  337     if (timestamp >= 0xFFFFFF) {
 
  338         pkt->ts_field = 0xFFFFFF;
 
  340         pkt->ts_field = timestamp;
 
  344         if (
pkt->type == prev_pkt[
pkt->channel_id].
type &&
 
  354     if (
pkt->channel_id < 64) {
 
  355         bytestream_put_byte(&p, 
pkt->channel_id | (
mode << 6));
 
  356     } 
else if (
pkt->channel_id < 64 + 256) {
 
  357         bytestream_put_byte(&p, 0               | (
mode << 6));
 
  358         bytestream_put_byte(&p, 
pkt->channel_id - 64);
 
  360         bytestream_put_byte(&p, 1               | (
mode << 6));
 
  361         bytestream_put_le16(&p, 
pkt->channel_id - 64);
 
  364         bytestream_put_be24(&p, 
pkt->ts_field);
 
  366             bytestream_put_be24(&p, 
pkt->
size);
 
  367             bytestream_put_byte(&p, 
pkt->type);
 
  369                 bytestream_put_le32(&p, 
pkt->extra);
 
  372     if (
pkt->ts_field == 0xFFFFFF)
 
  373         bytestream_put_be32(&p, timestamp);
 
  390     written = p - pkt_hdr + 
pkt->
size;
 
  391     while (off < pkt->
size) {
 
  396         if (off < pkt->
size) {
 
  397             uint8_t marker = 0xC0 | 
pkt->channel_id;
 
  401             if (
pkt->ts_field == 0xFFFFFF) {
 
  402                 uint8_t ts_header[4];
 
  414                           int timestamp, 
int size)
 
  422     pkt->channel_id = channel_id;
 
  424     pkt->timestamp  = timestamp;
 
  447     type = bytestream2_get_byte(gb);
 
  450         bytestream2_get_be64(gb);
 
  453         bytestream2_get_byte(gb);
 
  468         nb = bytestream2_get_be32(gb);
 
  473                 int size = bytestream2_get_be16(gb);
 
  475                     bytestream2_get_byte(gb);
 
  497     if (
data >= data_end)
 
  510                            const uint8_t *
name, uint8_t *
dst, 
int dst_size)
 
  512     int namelen = strlen(
name);
 
  522     bytestream2_get_byte(gb);
 
  525         int size = bytestream2_get_be16(gb);
 
  532             switch (bytestream2_get_byte(gb)) {
 
  537                 snprintf(
dst, dst_size, 
"%s", bytestream2_get_byte(gb) ? 
"true" : 
"false");
 
  540                 len = bytestream2_get_be16(gb);
 
  543                 if (dst_size < 
len + 1)
 
  561                            const uint8_t *
name, uint8_t *
dst, 
int dst_size)
 
  565     if (
data >= data_end)
 
  574 static const char* rtmp_packet_type(
int type)
 
  591     default:                     
return "unknown";
 
  595 static void amf_tag_contents(
void *
ctx, 
const uint8_t *
data,
 
  596                              const uint8_t *data_end)
 
  598     unsigned int size, nb = -1;
 
  603     if (
data >= data_end)
 
  630         nb = bytestream_get_be32(&
data);
 
  650             amf_tag_contents(
ctx, 
data, data_end);
 
  652             if (t < 0 || t >= data_end - 
data)
 
  667     av_log(
ctx, 
AV_LOG_DEBUG, 
"RTMP packet type '%s'(%d) for channel %d, timestamp %d, extra field %d size %d\n",
 
  671         while (
src < src_end) {
 
  673             amf_tag_contents(
ctx, 
src, src_end);
 
  694     int len = strlen(str);
 
  707         if ((
size -= 4 + 1) < 0)
 
  709         amf_len = bytestream_get_be32(&
data);
 
  711         if ((
size -= 2 + 1) < 0)
 
  713         amf_len = bytestream_get_be16(&
data);
 
  722     return !memcmp(
data, str, 
len);
 
  
@ RTMP_PT_METADATA
FLV metadata.
 
@ RTMP_PT_FLEX_MESSAGE
Flex shared message.
 
@ AMF_DATA_TYPE_OBJECT_END
 
#define AV_LOG_WARNING
Something somehow does not look correct.
 
@ RTMP_PT_FLEX_OBJECT
Flex shared object.
 
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
 
@ RTMP_PT_SHARED_OBJ
shared object
 
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
 
@ RTMP_PT_BYTES_READ
number of bytes read
 
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
 
RTMPPacketType type
packet payload type
 
static av_always_inline int bytestream2_tell(const GetByteContext *g)
 
static av_always_inline double av_int2double(uint64_t i)
Reinterpret a 64-bit integer as a double.
 
@ RTMP_PT_NOTIFY
some notification
 
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
 
void ff_amf_write_field_name(uint8_t **dst, const char *str)
Write string used as field name in AMF object to buffer.
 
int ff_amf_match_string(const uint8_t *data, int size, const char *str)
Match AMF string with a NULL-terminated string.
 
@ RTMP_PT_WINDOW_ACK_SIZE
window acknowledgement size
 
uint32_t extra
probably an additional channel ID used during streaming data
 
int ff_rtmp_packet_read_internal(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket **prev_pkt, int *nb_prev_pkt, uint8_t hdr)
Read internal RTMP packet sent by the server.
 
void ff_amf_write_bool(uint8_t **dst, int val)
Write boolean value in AMF format to buffer.
 
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
 
int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket **prev_pkt, int *nb_prev_pkt)
Read RTMP packet sent by the server.
 
static double val(void *priv, double ch)
 
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
 
int ff_amf_get_string(GetByteContext *bc, uint8_t *str, int strsize, int *length)
Get AMF string value.
 
static int amf_get_field_value2(GetByteContext *gb, const uint8_t *name, uint8_t *dst, int dst_size)
 
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
 
void ff_amf_write_string(uint8_t **dst, const char *str)
Write string in AMF format to buffer.
 
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
 
int read
amount read, including headers
 
#define av_assert0(cond)
assert() equivalent, that is always enabled.
 
static int parse_key(DBEContext *s)
 
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
 
structure for holding RTMP packets
 
RTMPPacketType
known RTMP packet types
 
void ff_amf_write_object_end(uint8_t **dst)
Write marker for end of AMF object to buffer.
 
void ff_rtmp_packet_destroy(RTMPPacket *pkt)
Free RTMP packet.
 
static int amf_tag_skip(GetByteContext *gb)
 
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
 
@ RTMP_PT_USER_CONTROL
user control
 
int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, int chunk_size, RTMPPacket **prev_pkt_ptr, int *nb_prev_pkt)
Send RTMP packet to the server.
 
int size
packet payload size
 
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
 
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.
 
@ RTMP_PT_INVOKE
invoke some stream action
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
 
void ff_amf_write_null(uint8_t **dst)
Write AMF NULL value to buffer.
 
uint32_t ts_field
24-bit timestamp or increment to the previous one, in milliseconds (latter only for media packets)....
 
void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p)
Print information and contents of RTMP packet.
 
static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket **prev_pkt_ptr, int *nb_prev_pkt, uint8_t hdr)
 
int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size)
Create new RTMP packet with given attributes.
 
int ff_rtmp_check_alloc_array(RTMPPacket **prev_pkt, int *nb_prev_pkt, int channel)
Enlarge the prev_pkt array to fit the given channel.
 
static av_always_inline uint64_t av_double2int(double f)
Reinterpret a double as a 64-bit integer.
 
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
 
#define i(width, name, range_min, range_max)
 
uint32_t timestamp
packet full timestamp
 
@ RTMP_PT_SET_PEER_BW
peer bandwidth
 
@ AMF_DATA_TYPE_MIXEDARRAY
 
void ff_amf_write_string2(uint8_t **dst, const char *str1, const char *str2)
Write a string consisting of two parts in AMF format to a buffer.
 
int offset
amount of data read so far
 
int ff_amf_read_number(GetByteContext *bc, double *val)
Read AMF number value.
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
 
void ff_amf_write_number(uint8_t **dst, double val)
Write number in AMF format to buffer.
 
int channel_id
RTMP channel ID (nothing to do with audio/video channels though)
 
void ff_amf_write_array_start(uint8_t **dst, uint32_t length)
Write marker and length for AMF array to buffer.
 
@ RTMP_PS_EIGHTBYTES
packet has 8-byte header
 
uint8_t * data
packet payload
 
void ff_amf_write_object_start(uint8_t **dst)
Write marker for AMF object to buffer.
 
@ AMF_DATA_TYPE_LONG_STRING
 
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary.
 
@ RTMP_PS_ONEBYTE
packet is really a next chunk of a packet
 
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
 
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
 
@ RTMP_PT_AUDIO
audio packet
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
 
int ff_amf_read_null(GetByteContext *bc)
Read AMF NULL value.
 
@ RTMP_PS_TWELVEBYTES
packet has 12-byte header
 
@ RTMP_PT_VIDEO
video packet
 
@ RTMP_PS_FOURBYTES
packet has 4-byte header
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_RB64
 
@ RTMP_PT_FLEX_STREAM
Flex shared stream.
 
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
 
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.
 
void * av_realloc(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory.
 
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
 
@ RTMP_PT_CHUNK_SIZE
chunk size change
 
int ff_amf_read_string(GetByteContext *bc, uint8_t *str, int strsize, int *length)
Read AMF string value.