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
00071 int rtp_get_local_port(URLContext *h);
00072 int rtp_set_remote_url(URLContext *h, const char *uri);
00073 #if (LIBAVFORMAT_VERSION_MAJOR <= 52)
00074 void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
00075 #endif
00076
00088 void rtp_send_punch_packets(URLContext* rtp_handle);
00089
00095 int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
00096
00097
00098 typedef struct {
00099 uint16_t max_seq;
00100 uint32_t cycles;
00101 uint32_t base_seq;
00102 uint32_t bad_seq;
00103 int probation;
00104 int received;
00105 int expected_prior;
00106 int received_prior;
00107 uint32_t transit;
00108 uint32_t jitter;
00109 } RTPStatistics;
00110
00111 #define RTP_FLAG_KEY 0x1
00112 #define RTP_FLAG_MARKER 0x2
00113
00125 typedef int (*DynamicPayloadPacketHandlerProc) (AVFormatContext *ctx,
00126 PayloadContext *s,
00127 AVStream *st,
00128 AVPacket * pkt,
00129 uint32_t *timestamp,
00130 const uint8_t * buf,
00131 int len, int flags);
00132
00133 struct RTPDynamicProtocolHandler_s {
00134
00135 const char enc_name[50];
00136 enum AVMediaType codec_type;
00137 enum CodecID codec_id;
00138
00139
00140 int (*parse_sdp_a_line) (AVFormatContext *s,
00141 int st_index,
00142 PayloadContext *priv_data,
00143 const char *line);
00144 PayloadContext *(*open) (void);
00145 void (*close)(PayloadContext *protocol_data);
00146 DynamicPayloadPacketHandlerProc parse_packet;
00147
00148 struct RTPDynamicProtocolHandler_s *next;
00149 };
00150
00151
00152 struct RTPDemuxContext {
00153 AVFormatContext *ic;
00154 AVStream *st;
00155 int payload_type;
00156 uint32_t ssrc;
00157 uint16_t seq;
00158 uint32_t timestamp;
00159 uint32_t base_timestamp;
00160 uint32_t cur_timestamp;
00161 int max_payload_size;
00162 struct MpegTSContext *ts;
00163 int read_buf_index;
00164 int read_buf_size;
00165
00166 URLContext *rtp_ctx;
00167 char hostname[256];
00168
00169 RTPStatistics statistics;
00170
00171
00172 int64_t last_rtcp_ntp_time;
00173 uint32_t last_rtcp_timestamp;
00174
00175
00176 unsigned int packet_count;
00177 unsigned int octet_count;
00178 unsigned int last_octet_count;
00179 int first_packet;
00180
00181 uint8_t buf[RTP_MAX_PACKET_LENGTH];
00182 uint8_t *buf_ptr;
00183
00184
00185 RTPPayloadData *rtp_payload_data;
00186
00187
00188 DynamicPayloadPacketHandlerProc parse_packet;
00189 PayloadContext *dynamic_protocol_context;
00190 int max_frames_per_packet;
00191 };
00192
00193 extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
00194 void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
00195
00196 int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size);
00197
00198 void av_register_rtp_dynamic_payload_handlers(void);
00199
00200 #endif