00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FFMPEG_RTSP_H
00022 #define FFMPEG_RTSP_H
00023
00024 #include <stdint.h>
00025 #include "avformat.h"
00026 #include "rtspcodes.h"
00027 #include "rtpdec.h"
00028 #include "network.h"
00029
00033 enum RTSPLowerTransport {
00034 RTSP_LOWER_TRANSPORT_UDP = 0,
00035 RTSP_LOWER_TRANSPORT_TCP = 1,
00036 RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2,
00037 RTSP_LOWER_TRANSPORT_NB
00038 };
00039
00045 enum RTSPTransport {
00046 RTSP_TRANSPORT_RTP,
00047 RTSP_TRANSPORT_RDT,
00048 RTSP_TRANSPORT_NB
00049 };
00050
00051 #define RTSP_DEFAULT_PORT 554
00052 #define RTSP_MAX_TRANSPORTS 8
00053 #define RTSP_TCP_MAX_PACKET_SIZE 1472
00054 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 2
00055 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
00056 #define RTSP_RTP_PORT_MIN 5000
00057 #define RTSP_RTP_PORT_MAX 10000
00058
00066 typedef struct RTSPTransportField {
00071 int interleaved_min, interleaved_max;
00072
00075 int port_min, port_max;
00076
00079 int client_port_min, client_port_max;
00080
00083 int server_port_min, server_port_max;
00084
00087 int ttl;
00088
00089 uint32_t destination;
00092 enum RTSPTransport transport;
00093
00095 enum RTSPLowerTransport lower_transport;
00096 } RTSPTransportField;
00097
00101 typedef struct RTSPMessageHeader {
00103 int content_length;
00104
00105 enum RTSPStatusCode status_code;
00108 int nb_transports;
00109
00112 int64_t range_start, range_end;
00113
00116 RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
00117
00118 int seq;
00122 char session_id[512];
00123
00125 char real_challenge[64];
00126
00134 char server[64];
00135 } RTSPMessageHeader;
00136
00142 enum RTSPClientState {
00143 RTSP_STATE_IDLE,
00144 RTSP_STATE_PLAYING,
00145 RTSP_STATE_PAUSED,
00146 };
00147
00152 enum RTSPServerType {
00153 RTSP_SERVER_RTP,
00154 RTSP_SERVER_REAL,
00155 RTSP_SERVER_WMS,
00156 RTSP_SERVER_NB
00157 };
00158
00162 typedef struct RTSPState {
00163 URLContext *rtsp_hd;
00164
00166 int nb_rtsp_streams;
00167
00168 struct RTSPStream **rtsp_streams;
00174 enum RTSPClientState state;
00175
00182 int64_t seek_timestamp;
00183
00184
00185
00186
00187 int seq;
00191 char session_id[512];
00192
00194 enum RTSPTransport transport;
00195
00198 enum RTSPLowerTransport lower_transport;
00199
00203 enum RTSPServerType server_type;
00204
00206 char last_reply[2048];
00207
00210 void *cur_transport_priv;
00211
00215 int need_subscription;
00216
00219 enum AVDiscard real_setup_cache[MAX_STREAMS];
00220
00224 char last_subscription[1024];
00226 } RTSPState;
00227
00234 typedef struct RTSPStream {
00235 URLContext *rtp_handle;
00236 void *transport_priv;
00239 int stream_index;
00240
00243 int interleaved_min, interleaved_max;
00244
00245 char control_url[1024];
00249 int sdp_port;
00250 struct in_addr sdp_ip;
00251 int sdp_ttl;
00252 int sdp_payload_type;
00254
00258 RTPPayloadData rtp_payload_data;
00259
00263 RTPDynamicProtocolHandler *dynamic_handler;
00264
00266 PayloadContext *dynamic_protocol_context;
00268 } RTSPStream;
00269
00270 int rtsp_init(void);
00271 void rtsp_parse_line(RTSPMessageHeader *reply, const char *buf);
00272
00273 #if LIBAVFORMAT_VERSION_INT < (53 << 16)
00274 extern int rtsp_default_protocols;
00275 #endif
00276 extern int rtsp_rtp_port_min;
00277 extern int rtsp_rtp_port_max;
00278
00279 int rtsp_pause(AVFormatContext *s);
00280 int rtsp_resume(AVFormatContext *s);
00281
00282 #endif