rtmppkt.h
Go to the documentation of this file.
1 /*
2  * RTMP packet utilities
3  * Copyright (c) 2009 Kostya Shishkov
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef AVFORMAT_RTMPPKT_H
23 #define AVFORMAT_RTMPPKT_H
24 
25 #include "avformat.h"
26 #include "url.h"
27 
29 #define RTMP_CHANNELS 65599
30 
41 };
42 
46 typedef enum RTMPPacketType {
62 
71 };
72 
76 typedef struct RTMPPacket {
77  int channel_id;
79  uint32_t timestamp;
80  uint32_t ts_delta;
81  uint32_t extra;
82  uint8_t *data;
83  int size;
84 } RTMPPacket;
85 
96 int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
97  int timestamp, int size);
98 
105 
117  int chunk_size, RTMPPacket *prev_pkt);
118 
130  int chunk_size, RTMPPacket *prev_pkt);
131 
138 void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p);
139 
153 int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end);
154 
165 int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
166  const uint8_t *name, uint8_t *dst, int dst_size);
167 
174 void ff_amf_write_bool(uint8_t **dst, int val);
175 
182 void ff_amf_write_number(uint8_t **dst, double num);
183 
190 void ff_amf_write_string(uint8_t **dst, const char *str);
191 
197 void ff_amf_write_null(uint8_t **dst);
198 
204 void ff_amf_write_object_start(uint8_t **dst);
205 
212 void ff_amf_write_field_name(uint8_t **dst, const char *str);
213 
219 void ff_amf_write_object_end(uint8_t **dst);
220 
226 int ff_amf_match_string(const uint8_t *data, int size, const char *str);
227  // AMF funcs
229 
230 #endif /* AVFORMAT_RTMPPKT_H */
void ff_rtmp_packet_destroy(RTMPPacket *pkt)
Free RTMP packet.
Definition: rtmppkt.c:252
video packet
Definition: rtmppkt.h:53
int size
int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size)
Create new RTMP packet with given attributes.
Definition: rtmppkt.c:234
client bandwidth
Definition: rtmppkt.h:51
int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket *prev_pkt)
Read RTMP packet sent by the server.
Definition: rtmppkt.c:74
RTMPChannel
channels used to for RTMP packets with different purposes (i.e.
Definition: rtmppkt.h:35
struct RTMPPacket RTMPPacket
structure for holding RTMP packets
void ff_amf_write_number(uint8_t **dst, double num)
Write number in AMF format to buffer.
Definition: rtmppkt.c:37
RTMPPacketType type
packet payload type
Definition: rtmppkt.h:78
channel for sending a/v to server
Definition: rtmppkt.h:38
ping
Definition: rtmppkt.h:49
void ff_amf_write_bool(uint8_t **dst, int val)
Write boolean value in AMF format to buffer.
Definition: rtmppkt.c:31
int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p, int chunk_size, RTMPPacket *prev_pkt)
Send RTMP packet to the server.
Definition: rtmppkt.c:161
uint32_t extra
probably an additional channel ID used during streaming data
Definition: rtmppkt.h:81
void ff_amf_write_null(uint8_t **dst)
Write AMF NULL value to buffer.
Definition: rtmppkt.c:50
uint32_t ts_delta
timestamp increment to the previous one in milliseconds (latter only for media packets) ...
Definition: rtmppkt.h:80
const char data[16]
Definition: mxf.c:60
int size
packet payload size
Definition: rtmppkt.h:83
number of bytes read
Definition: rtmppkt.h:48
packet has 4-byte header
Definition: rtmppkt.h:69
void ff_amf_write_string(uint8_t **dst, const char *str)
Write string in AMF format to buffer.
Definition: rtmppkt.c:43
audio packet
Definition: rtmppkt.h:52
void ff_amf_write_field_name(uint8_t **dst, const char *str)
Write string used as field name in AMF object to buffer.
Definition: rtmppkt.c:60
packet has 12-byte header
Definition: rtmppkt.h:67
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.
Definition: rtmppkt.c:260
RTMPPacketSize
possible RTMP packet header sizes
Definition: rtmppkt.h:66
server bandwidth
Definition: rtmppkt.h:50
RTMPPacketType
known RTMP packet types
Definition: rtmppkt.h:46
shared object
Definition: rtmppkt.h:58
Flex shared message.
Definition: rtmppkt.h:56
int ff_amf_match_string(const uint8_t *data, int size, const char *str)
Match AMF string with a NULL-terminated string.
Definition: rtmppkt.c:452
chunk size change
Definition: rtmppkt.h:47
Definition: url.h:42
channel for sending server control messages
Definition: rtmppkt.h:37
void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p)
Print information and contents of RTMP packet.
Definition: rtmppkt.c:426
int channel_id
RTMP channel ID (nothing to do with audio/video channels though)
Definition: rtmppkt.h:77
packet has 8-byte header
Definition: rtmppkt.h:68
void ff_amf_write_object_start(uint8_t **dst)
Write marker for AMF object to buffer.
Definition: rtmppkt.c:55
channel for audio data
Definition: rtmppkt.h:40
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.
Definition: rtmppkt.c:296
some notification
Definition: rtmppkt.h:57
channel for network-related messages (bandwidth report, ping, etc)
Definition: rtmppkt.h:36
const char * name
Definition: audioconvert.c:61
uint32_t timestamp
packet full timestamp
Definition: rtmppkt.h:79
uint8_t * data
packet payload
Definition: rtmppkt.h:82
Main libavformat public API header.
Flex shared stream.
Definition: rtmppkt.h:54
channel for video data
Definition: rtmppkt.h:39
packet is really a next chunk of a packet
Definition: rtmppkt.h:70
Flex shared object.
Definition: rtmppkt.h:55
structure for holding RTMP packets
Definition: rtmppkt.h:76
unbuffered private I/O API
invoke some stream action
Definition: rtmppkt.h:59
void ff_amf_write_object_end(uint8_t **dst)
Write marker for end of AMF object to buffer.
Definition: rtmppkt.c:66
FLV metadata.
Definition: rtmppkt.h:60