00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef AVFORMAT_RTPDEC_H
00023 #define AVFORMAT_RTPDEC_H
00024
00025 #include "libavcodec/avcodec.h"
00026 #include "avformat.h"
00027 #include "rtp.h"
00028
00030 typedef struct rtp_payload_data
00031 {
00032 int sizelength;
00033 int indexlength;
00034 int indexdeltalength;
00035 int profile_level_id;
00036 int streamtype;
00037 int objecttype;
00038 char *mode;
00039
00041 struct AUHeaders {
00042 int size;
00043 int index;
00044 int cts_flag;
00045 int cts;
00046 int dts_flag;
00047 int dts;
00048 int rap_flag;
00049 int streamstate;
00050 } *au_headers;
00051 int nb_au_headers;
00052 int au_headers_length_bytes;
00053 int cur_au_index;
00054 } RTPPayloadData;
00055
00056 typedef struct PayloadContext PayloadContext;
00057 typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler;
00058
00059 #define RTP_MIN_PACKET_LENGTH 12
00060 #define RTP_MAX_PACKET_LENGTH 1500
00061
00062 typedef struct RTPDemuxContext RTPDemuxContext;
00063 RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data);
00064 void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
00065 RTPDynamicProtocolHandler *handler);
00066 int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
00067 const uint8_t *buf, int len);
00068 void rtp_parse_close(RTPDemuxContext *s);
00069
00070 int rtp_get_local_port(URLContext *h);
00071 int rtp_set_remote_url(URLContext *h, const char *uri);
00072 void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
00073
00079 int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
00080
00081
00082 typedef struct {
00083 uint16_t max_seq;
00084 uint32_t cycles;
00085 uint32_t base_seq;
00086 uint32_t bad_seq;
00087 int probation;
00088 int received;
00089 int expected_prior;
00090 int received_prior;
00091 uint32_t transit;
00092 uint32_t jitter;
00093 } RTPStatistics;
00094
00095 #define RTP_FLAG_KEY 0x1
00096 #define RTP_FLAG_MARKER 0x2
00097
00109 typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx,
00110 PayloadContext *s,
00111 AVStream *st,
00112 AVPacket * pkt,
00113 uint32_t *timestamp,
00114 const uint8_t * buf,
00115 int len, int flags);
00116
00117 struct RTPDynamicProtocolHandler_s {
00118
00119 const char enc_name[50];
00120 enum CodecType codec_type;
00121 enum CodecID codec_id;
00122
00123
00124 int (*parse_sdp_a_line) (AVFormatContext *s,
00125 int st_index,
00126 PayloadContext *priv_data,
00127 const char *line);
00128 PayloadContext *(*open) ();
00129 void (*close)(PayloadContext *protocol_data);
00130 DynamicPayloadPacketHandlerProc parse_packet;
00131
00132 struct RTPDynamicProtocolHandler_s *next;
00133 };
00134
00135
00136 struct RTPDemuxContext {
00137 AVFormatContext *ic;
00138 AVStream *st;
00139 int payload_type;
00140 uint32_t ssrc;
00141 uint16_t seq;
00142 uint32_t timestamp;
00143 uint32_t base_timestamp;
00144 uint32_t cur_timestamp;
00145 int max_payload_size;
00146 struct MpegTSContext *ts;
00147 int read_buf_index;
00148 int read_buf_size;
00149
00150 URLContext *rtp_ctx;
00151 char hostname[256];
00152
00153 RTPStatistics statistics;
00154
00155
00156 int64_t last_rtcp_ntp_time;
00157 int64_t first_rtcp_ntp_time;
00158 uint32_t last_rtcp_timestamp;
00159
00160
00161 unsigned int packet_count;
00162 unsigned int octet_count;
00163 unsigned int last_octet_count;
00164 int first_packet;
00165
00166 uint8_t buf[RTP_MAX_PACKET_LENGTH];
00167 uint8_t *buf_ptr;
00168
00169
00170 RTPPayloadData *rtp_payload_data;
00171
00172
00173 DynamicPayloadPacketHandlerProc parse_packet;
00174 PayloadContext *dynamic_protocol_context;
00175 int max_frames_per_packet;
00176 };
00177
00178 extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
00179 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
00180
00181 int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size);
00182
00183 void av_register_rtp_dynamic_payload_handlers(void);
00184
00185 #endif