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 "libavcodec/bytestream.h"
00026 #include "avformat.h"
00027 #include "url.h"
00028
00030 #define RTMP_CHANNELS 65599
00031
00036 enum RTMPChannel {
00037 RTMP_NETWORK_CHANNEL = 2,
00038 RTMP_SYSTEM_CHANNEL,
00039 RTMP_SOURCE_CHANNEL,
00040 RTMP_VIDEO_CHANNEL = 8,
00041 RTMP_AUDIO_CHANNEL,
00042 };
00043
00047 typedef enum RTMPPacketType {
00048 RTMP_PT_CHUNK_SIZE = 1,
00049 RTMP_PT_BYTES_READ = 3,
00050 RTMP_PT_PING,
00051 RTMP_PT_SERVER_BW,
00052 RTMP_PT_CLIENT_BW,
00053 RTMP_PT_AUDIO = 8,
00054 RTMP_PT_VIDEO,
00055 RTMP_PT_FLEX_STREAM = 15,
00056 RTMP_PT_FLEX_OBJECT,
00057 RTMP_PT_FLEX_MESSAGE,
00058 RTMP_PT_NOTIFY,
00059 RTMP_PT_SHARED_OBJ,
00060 RTMP_PT_INVOKE,
00061 RTMP_PT_METADATA = 22,
00062 } RTMPPacketType;
00063
00067 enum RTMPPacketSize {
00068 RTMP_PS_TWELVEBYTES = 0,
00069 RTMP_PS_EIGHTBYTES,
00070 RTMP_PS_FOURBYTES,
00071 RTMP_PS_ONEBYTE
00072 };
00073
00077 typedef struct RTMPPacket {
00078 int channel_id;
00079 RTMPPacketType type;
00080 uint32_t timestamp;
00081 uint32_t ts_delta;
00082 uint32_t extra;
00083 uint8_t *data;
00084 int data_size;
00085 } RTMPPacket;
00086
00097 int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
00098 int timestamp, int size);
00099
00105 void ff_rtmp_packet_destroy(RTMPPacket *pkt);
00106
00117 int ff_rtmp_packet_read(URLContext *h, RTMPPacket *p,
00118 int chunk_size, RTMPPacket *prev_pkt);
00130 int ff_rtmp_packet_read_internal(URLContext *h, RTMPPacket *p, int chunk_size,
00131 RTMPPacket *prev_pkt, uint8_t c);
00132
00143 int ff_rtmp_packet_write(URLContext *h, RTMPPacket *p,
00144 int chunk_size, RTMPPacket *prev_pkt);
00145
00152 void ff_rtmp_packet_dump(void *ctx, RTMPPacket *p);
00153
00167 int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end);
00168
00179 int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end,
00180 const uint8_t *name, uint8_t *dst, int dst_size);
00181
00188 void ff_amf_write_bool(uint8_t **dst, int val);
00189
00196 void ff_amf_write_number(uint8_t **dst, double num);
00197
00204 void ff_amf_write_string(uint8_t **dst, const char *str);
00205
00211 void ff_amf_write_null(uint8_t **dst);
00212
00218 void ff_amf_write_object_start(uint8_t **dst);
00219
00226 void ff_amf_write_field_name(uint8_t **dst, const char *str);
00227
00233 void ff_amf_write_object_end(uint8_t **dst);
00234
00242 int ff_amf_read_bool(GetByteContext *gbc, int *val);
00243
00251 int ff_amf_read_number(GetByteContext *gbc, double *val);
00252
00265 int ff_amf_read_string(GetByteContext *gbc, uint8_t *str,
00266 int strsize, int *length);
00267
00274 int ff_amf_read_null(GetByteContext *gbc);
00275
00276
00278
00279 #endif