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 "libavcodec/bytestream.h"
26 #include "avformat.h"
27 #include "url.h"
28 
30 #define RTMP_CHANNELS 65599
31 
42 };
43 
47 typedef enum RTMPPacketType {
63 
72 };
73 
77 typedef struct RTMPPacket {
78  int channel_id;
80  uint32_t timestamp;
81  uint32_t ts_delta;
82  uint32_t extra;
84  int size;
85 } RTMPPacket;
86 
97 int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
98  int timestamp, int size);
99 
106 
118  int chunk_size, RTMPPacket *prev_pkt);
130 int ff_rtmp_packet_read_internal(URLContext *h, RTMPPacket *p, int chunk_size,
131  RTMPPacket *prev_pkt, uint8_t c);
132 
144  int chunk_size, RTMPPacket *prev_pkt);
145 
152 void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p);
153 
167 int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end);
168 
179 int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
180  const uint8_t *name, uint8_t *dst, int dst_size);
181 
188 void ff_amf_write_bool(uint8_t **dst, int val);
189 
196 void ff_amf_write_number(uint8_t **dst, double num);
197 
204 void ff_amf_write_string(uint8_t **dst, const char *str);
205 
213 void ff_amf_write_string2(uint8_t **dst, const char *str1, const char *str2);
214 
220 void ff_amf_write_null(uint8_t **dst);
221 
228 
235 void ff_amf_write_field_name(uint8_t **dst, const char *str);
236 
242 void ff_amf_write_object_end(uint8_t **dst);
243 
251 int ff_amf_read_bool(GetByteContext *gbc, int *val);
252 
260 int ff_amf_read_number(GetByteContext *gbc, double *val);
261 
275  int strsize, int *length);
276 
284 
291 int ff_amf_match_string(const uint8_t *data, int size, const char *str);
292  // AMF funcs
294 
295 #endif /* AVFORMAT_RTMPPKT_H */