00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00222
00223 #endif