Libav 0.7.1
|
00001 /* 00002 * RTMP packet utilities 00003 * Copyright (c) 2009 Kostya Shishkov 00004 * 00005 * This file is part of Libav. 00006 * 00007 * Libav is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * Libav is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with Libav; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef AVFORMAT_RTMPPKT_H 00023 #define AVFORMAT_RTMPPKT_H 00024 00025 #include "avformat.h" 00026 #include "url.h" 00027 00029 #define RTMP_CHANNELS 65599 00030 00035 enum RTMPChannel { 00036 RTMP_NETWORK_CHANNEL = 2, 00037 RTMP_SYSTEM_CHANNEL, 00038 RTMP_SOURCE_CHANNEL, 00039 RTMP_VIDEO_CHANNEL = 8, 00040 RTMP_AUDIO_CHANNEL, 00041 }; 00042 00046 typedef enum RTMPPacketType { 00047 RTMP_PT_CHUNK_SIZE = 1, 00048 RTMP_PT_BYTES_READ = 3, 00049 RTMP_PT_PING, 00050 RTMP_PT_SERVER_BW, 00051 RTMP_PT_CLIENT_BW, 00052 RTMP_PT_AUDIO = 8, 00053 RTMP_PT_VIDEO, 00054 RTMP_PT_FLEX_STREAM = 15, 00055 RTMP_PT_FLEX_OBJECT, 00056 RTMP_PT_FLEX_MESSAGE, 00057 RTMP_PT_NOTIFY, 00058 RTMP_PT_SHARED_OBJ, 00059 RTMP_PT_INVOKE, 00060 RTMP_PT_METADATA = 22, 00061 } RTMPPacketType; 00062 00066 enum RTMPPacketSize { 00067 RTMP_PS_TWELVEBYTES = 0, 00068 RTMP_PS_EIGHTBYTES, 00069 RTMP_PS_FOURBYTES, 00070 RTMP_PS_ONEBYTE 00071 }; 00072 00076 typedef struct RTMPPacket { 00077 int channel_id; 00078 RTMPPacketType type; 00079 uint32_t timestamp; 00080 uint32_t ts_delta; 00081 uint32_t extra; 00082 uint8_t *data; 00083 int data_size; 00084 } RTMPPacket; 00085 00096 int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, 00097 int timestamp, int size); 00098 00104 void ff_rtmp_packet_destroy(RTMPPacket *pkt); 00105 00116 int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p, 00117 int chunk_size, RTMPPacket *prev_pkt); 00118 00129 int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p, 00130 int chunk_size, RTMPPacket *prev_pkt); 00131 00138 void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p); 00139 00153 int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end); 00154 00165 int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, 00166 const uint8_t *name, uint8_t *dst, int dst_size); 00167 00174 void ff_amf_write_bool(uint8_t **dst, int val); 00175 00182 void ff_amf_write_number(uint8_t **dst, double num); 00183 00190 void ff_amf_write_string(uint8_t **dst, const char *str); 00191 00197 void ff_amf_write_null(uint8_t **dst); 00198 00204 void ff_amf_write_object_start(uint8_t **dst); 00205 00212 void ff_amf_write_field_name(uint8_t **dst, const char *str); 00213 00219 void ff_amf_write_object_end(uint8_t **dst); 00220 // AMF funcs 00222 00223 #endif /* AVFORMAT_RTMPPKT_H */