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 au_headers_allocated;
00052 int nb_au_headers;
00053 int au_headers_length_bytes;
00054 int cur_au_index;
00055 } RTPPayloadData;
00056
00057 typedef struct PayloadContext PayloadContext;
00058 typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler;
00059
00060 #define RTP_MIN_PACKET_LENGTH 12
00061 #define RTP_MAX_PACKET_LENGTH 1500
00062
00063 typedef struct RTPDemuxContext RTPDemuxContext;
00064 RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, RTPPayloadData *rtp_payload_data);
00065 void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx,
00066 RTPDynamicProtocolHandler *handler);
00067 int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
00068 const uint8_t *buf, int len);
00069 void rtp_parse_close(RTPDemuxContext *s);
00070 #if (LIBAVFORMAT_VERSION_MAJOR <= 53)
00071 int rtp_get_local_port(URLContext *h);
00072 #endif
00073 int rtp_get_local_rtp_port(URLContext *h);
00074 int rtp_get_local_rtcp_port(URLContext *h);
00075
00076 int rtp_set_remote_url(URLContext *h, const char *uri);
00077 #if (LIBAVFORMAT_VERSION_MAJOR <= 52)
00078 void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
00079 #endif
00080
00092 void rtp_send_punch_packets(URLContext* rtp_handle);
00093
00099 int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
00100
00101
00102 typedef struct {
00103 uint16_t max_seq;
00104 uint32_t cycles;
00105 uint32_t base_seq;
00106 uint32_t bad_seq;
00107 int probation;
00108 int received;
00109 int expected_prior;
00110 int received_prior;
00111 uint32_t transit;
00112 uint32_t jitter;
00113 } RTPStatistics;
00114
00115 #define RTP_FLAG_KEY 0x1
00116 #define RTP_FLAG_MARKER 0x2
00117
00129 typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx,
00130 PayloadContext *s,
00131 AVStream *st,
00132 AVPacket * pkt,
00133 uint32_t *timestamp,
00134 const uint8_t * buf,
00135 int len, int flags);
00136
00137 struct RTPDynamicProtocolHandler_s {
00138
00139 const char enc_name[50];
00140 enum AVMediaType codec_type;
00141 enum CodecID codec_id;
00142
00143
00144 int (*parse_sdp_a_line) (AVFormatContext *s,
00145 int st_index,
00146 PayloadContext *priv_data,
00147 const char *line);
00148 PayloadContext *(*open) (void);
00149 void (*close)(PayloadContext *protocol_data);
00150 DynamicPayloadPacketHandlerProc parse_packet;
00151
00152 struct RTPDynamicProtocolHandler_s *next;
00153 };
00154
00155
00156 struct RTPDemuxContext {
00157 AVFormatContext *ic;
00158 AVStream *st;
00159 int payload_type;
00160 uint32_t ssrc;
00161 uint16_t seq;
00162 uint32_t timestamp;
00163 uint32_t base_timestamp;
00164 uint32_t cur_timestamp;
00165 int64_t range_start_offset;
00166 int max_payload_size;
00167 struct MpegTSContext *ts;
00168 int read_buf_index;
00169 int read_buf_size;
00170
00171 URLContext *rtp_ctx;
00172 char hostname[256];
00173
00174 RTPStatistics statistics;
00175
00176
00177 int64_t last_rtcp_ntp_time;
00178 int64_t first_rtcp_ntp_time;
00179 uint32_t last_rtcp_timestamp;
00180
00181
00182 unsigned int packet_count;
00183 unsigned int octet_count;
00184 unsigned int last_octet_count;
00185 int first_packet;
00186
00187 uint8_t buf[RTP_MAX_PACKET_LENGTH];
00188 uint8_t *buf_ptr;
00189
00190
00191 RTPPayloadData *rtp_payload_data;
00192
00193
00194 DynamicPayloadPacketHandlerProc parse_packet;
00195 PayloadContext *dynamic_protocol_context;
00196 int max_frames_per_packet;
00197 };
00198
00199 extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
00200 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
00201
00202 int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size);
00203
00204 void av_register_rtp_dynamic_payload_handlers(void);
00205
00206 #endif