00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVFORMAT_RTSP_H
00022 #define AVFORMAT_RTSP_H
00023
00024 #include <stdint.h>
00025 #include "avformat.h"
00026 #include "rtspcodes.h"
00027 #include "rtpdec.h"
00028 #include "network.h"
00029 #include "httpauth.h"
00030
00034 enum RTSPLowerTransport {
00035 RTSP_LOWER_TRANSPORT_UDP = 0,
00036 RTSP_LOWER_TRANSPORT_TCP = 1,
00037 RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2,
00038 RTSP_LOWER_TRANSPORT_NB
00039 };
00040
00046 enum RTSPTransport {
00047 RTSP_TRANSPORT_RTP,
00048 RTSP_TRANSPORT_RDT,
00049 RTSP_TRANSPORT_NB
00050 };
00051
00056 enum RTSPControlTransport {
00057 RTSP_MODE_PLAIN,
00058 RTSP_MODE_TUNNEL
00059 };
00060
00061 #define RTSP_DEFAULT_PORT 554
00062 #define RTSP_MAX_TRANSPORTS 8
00063 #define RTSP_TCP_MAX_PACKET_SIZE 1472
00064 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
00065 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
00066 #define RTSP_RTP_PORT_MIN 5000
00067 #define RTSP_RTP_PORT_MAX 10000
00068
00076 typedef struct RTSPTransportField {
00081 int interleaved_min, interleaved_max;
00082
00085 int port_min, port_max;
00086
00089 int client_port_min, client_port_max;
00090
00093 int server_port_min, server_port_max;
00094
00097 int ttl;
00098
00099 struct sockaddr_storage destination;
00100 char source[INET6_ADDRSTRLEN + 1];
00103 enum RTSPTransport transport;
00104
00106 enum RTSPLowerTransport lower_transport;
00107 } RTSPTransportField;
00108
00112 typedef struct RTSPMessageHeader {
00114 int content_length;
00115
00116 enum RTSPStatusCode status_code;
00119 int nb_transports;
00120
00123 int64_t range_start, range_end;
00124
00127 RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
00128
00129 int seq;
00133 char session_id[512];
00134
00137 char location[4096];
00138
00140 char real_challenge[64];
00141
00149 char server[64];
00150
00157 int timeout;
00158
00162 int notice;
00163
00167 char reason[256];
00168 } RTSPMessageHeader;
00169
00175 enum RTSPClientState {
00176 RTSP_STATE_IDLE,
00177 RTSP_STATE_STREAMING,
00178 RTSP_STATE_PAUSED,
00179 RTSP_STATE_SEEKING,
00180 };
00181
00186 enum RTSPServerType {
00187 RTSP_SERVER_RTP,
00188 RTSP_SERVER_REAL,
00189 RTSP_SERVER_WMS,
00190 RTSP_SERVER_NB
00191 };
00192
00198 typedef struct RTSPState {
00199 URLContext *rtsp_hd;
00200
00202 int nb_rtsp_streams;
00203
00204 struct RTSPStream **rtsp_streams;
00210 enum RTSPClientState state;
00211
00218 int64_t seek_timestamp;
00219
00220
00221
00222
00223 int seq;
00227 char session_id[512];
00228
00232 int timeout;
00233
00237 int64_t last_cmd_time;
00238
00240 enum RTSPTransport transport;
00241
00244 enum RTSPLowerTransport lower_transport;
00245
00249 enum RTSPServerType server_type;
00250
00252 char real_challenge[64];
00253
00255 char auth[128];
00256
00258 HTTPAuthState auth_state;
00259
00261 char last_reply[2048];
00262
00265 void *cur_transport_priv;
00266
00270 int need_subscription;
00271
00274 enum AVDiscard *real_setup_cache;
00275
00278 enum AVDiscard *real_setup;
00279
00283 char last_subscription[1024];
00285
00289 AVFormatContext *asf_ctx;
00290
00293 uint64_t asf_pb_pos;
00295
00299 char control_uri[1024];
00300
00303 URLContext *rtsp_hd_out;
00304
00306 enum RTSPControlTransport control_transport;
00307
00308
00309
00310
00311 int nb_byes;
00312
00314 uint8_t* recvbuf;
00315
00318 int filter_source;
00319
00323 int lower_transport_mask;
00324
00328 uint64_t packets;
00329
00333 struct pollfd *p;
00334 } RTSPState;
00335
00342 typedef struct RTSPStream {
00343 URLContext *rtp_handle;
00344 void *transport_priv;
00347 int stream_index;
00348
00351 int interleaved_min, interleaved_max;
00352
00353 char control_url[1024];
00357 int sdp_port;
00358 struct sockaddr_storage sdp_ip;
00359 int sdp_ttl;
00360 int sdp_payload_type;
00362
00366 RTPDynamicProtocolHandler *dynamic_handler;
00367
00369 PayloadContext *dynamic_protocol_context;
00371 } RTSPStream;
00372
00373 void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf,
00374 RTSPState *rt, const char *method);
00375
00376 extern int rtsp_rtp_port_min;
00377 extern int rtsp_rtp_port_max;
00378
00384 int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
00385 const char *url, const char *headers);
00386
00403 int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
00404 const char *method, const char *url,
00405 const char *headers,
00406 RTSPMessageHeader *reply,
00407 unsigned char **content_ptr,
00408 const unsigned char *send_content,
00409 int send_content_length);
00410
00416 int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
00417 const char *url, const char *headers,
00418 RTSPMessageHeader *reply, unsigned char **content_ptr);
00419
00443 int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
00444 unsigned char **content_ptr,
00445 int return_on_interleaved_data, const char *method);
00446
00450 void ff_rtsp_skip_packet(AVFormatContext *s);
00451
00461 int ff_rtsp_connect(AVFormatContext *s);
00462
00468 void ff_rtsp_close_streams(AVFormatContext *s);
00469
00475 void ff_rtsp_close_connections(AVFormatContext *rt);
00476
00481 int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply);
00482
00487 int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr);
00488
00493 int ff_sdp_parse(AVFormatContext *s, const char *content);
00494
00498 int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
00499 uint8_t *buf, int buf_size);
00500
00505 int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt);
00506
00511 int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
00512 int lower_transport, const char *real_challenge);
00513
00518 void ff_rtsp_undo_setup(AVFormatContext *s);
00519
00520 #endif