• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

libavformat/rtsp.h

Go to the documentation of this file.
00001 /*
00002  * RTSP definitions
00003  * Copyright (c) 2002 Fabrice Bellard
00004  *
00005  * This file is part of Libav.
00006  *
00007  * Libav is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * Libav is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with Libav; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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 
00031 #include "libavutil/log.h"
00032 #include "libavutil/opt.h"
00033 
00037 enum RTSPLowerTransport {
00038     RTSP_LOWER_TRANSPORT_UDP = 0,           
00039     RTSP_LOWER_TRANSPORT_TCP = 1,           
00040     RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2, 
00041     RTSP_LOWER_TRANSPORT_NB,
00042     RTSP_LOWER_TRANSPORT_HTTP = 8,          
00045 };
00046 
00052 enum RTSPTransport {
00053     RTSP_TRANSPORT_RTP, 
00054     RTSP_TRANSPORT_RDT, 
00055     RTSP_TRANSPORT_NB
00056 };
00057 
00062 enum RTSPControlTransport {
00063     RTSP_MODE_PLAIN,   
00064     RTSP_MODE_TUNNEL   
00065 };
00066 
00067 #define RTSP_DEFAULT_PORT   554
00068 #define RTSP_MAX_TRANSPORTS 8
00069 #define RTSP_TCP_MAX_PACKET_SIZE 1472
00070 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
00071 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
00072 #define RTSP_RTP_PORT_MIN 5000
00073 #define RTSP_RTP_PORT_MAX 10000
00074 
00082 typedef struct RTSPTransportField {
00087     int interleaved_min, interleaved_max;
00088 
00091     int port_min, port_max;
00092 
00095     int client_port_min, client_port_max;
00096 
00099     int server_port_min, server_port_max;
00100 
00103     int ttl;
00104 
00105     struct sockaddr_storage destination; 
00106     char source[INET6_ADDRSTRLEN + 1]; 
00109     enum RTSPTransport transport;
00110 
00112     enum RTSPLowerTransport lower_transport;
00113 } RTSPTransportField;
00114 
00118 typedef struct RTSPMessageHeader {
00120     int content_length;
00121 
00122     enum RTSPStatusCode status_code; 
00125     int nb_transports;
00126 
00129     int64_t range_start, range_end;
00130 
00133     RTSPTransportField transports[RTSP_MAX_TRANSPORTS];
00134 
00135     int seq;                         
00139     char session_id[512];
00140 
00143     char location[4096];
00144 
00146     char real_challenge[64];
00147 
00155     char server[64];
00156 
00163     int timeout;
00164 
00168     int notice;
00169 
00173     char reason[256];
00174 } RTSPMessageHeader;
00175 
00181 enum RTSPClientState {
00182     RTSP_STATE_IDLE,    
00183     RTSP_STATE_STREAMING, 
00184     RTSP_STATE_PAUSED,  
00185     RTSP_STATE_SEEKING, 
00186 };
00187 
00192 enum RTSPServerType {
00193     RTSP_SERVER_RTP,  
00194     RTSP_SERVER_REAL, 
00195     RTSP_SERVER_WMS,  
00196     RTSP_SERVER_NB
00197 };
00198 
00204 typedef struct RTSPState {
00205     const AVClass *class;             
00206     URLContext *rtsp_hd; /* RTSP TCP connection handle */
00207 
00209     int nb_rtsp_streams;
00210 
00211     struct RTSPStream **rtsp_streams; 
00217     enum RTSPClientState state;
00218 
00225     int64_t seek_timestamp;
00226 
00227     int seq;                          
00231     char session_id[512];
00232 
00236     int timeout;
00237 
00241     int64_t last_cmd_time;
00242 
00244     enum RTSPTransport transport;
00245 
00248     enum RTSPLowerTransport lower_transport;
00249 
00253     enum RTSPServerType server_type;
00254 
00256     char real_challenge[64];
00257 
00259     char auth[128];
00260 
00262     HTTPAuthState auth_state;
00263 
00265     char last_reply[2048]; /* XXX: allocate ? */
00266 
00269     void *cur_transport_priv;
00270 
00274     int need_subscription;
00275 
00278     enum AVDiscard *real_setup_cache;
00279 
00282     enum AVDiscard *real_setup;
00283 
00287     char last_subscription[1024];
00289 
00293     AVFormatContext *asf_ctx;
00294 
00297     uint64_t asf_pb_pos;
00299 
00303     char control_uri[1024];
00304 
00307     URLContext *rtsp_hd_out;
00308 
00310     enum RTSPControlTransport control_transport;
00311 
00312     /* Number of RTCP BYE packets the RTSP session has received.
00313      * An EOF is propagated back if nb_byes == nb_streams.
00314      * This is reset after a seek. */
00315     int nb_byes;
00316 
00318     uint8_t* recvbuf;
00319 
00323     int lower_transport_mask;
00324 
00328     uint64_t packets;
00329 
00333     struct pollfd *p;
00334 
00338     int get_parameter_supported;
00339 
00343     int initial_pause;
00344 
00348     int rtp_muxer_flags;
00349 
00351     int accept_dynamic_rate;
00352 
00356     int rtsp_flags;
00357 
00361     int media_type_mask;
00362 } RTSPState;
00363 
00364 #define RTSP_FLAG_FILTER_SRC  0x1    
00374 typedef struct RTSPStream {
00375     URLContext *rtp_handle;   
00376     void *transport_priv; 
00379     int stream_index;
00380 
00383     int interleaved_min, interleaved_max;
00384 
00385     char control_url[1024];   
00389     int sdp_port;             
00390     struct sockaddr_storage sdp_ip; 
00391     int sdp_ttl;              
00392     int sdp_payload_type;     
00394 
00398     RTPDynamicProtocolHandler *dynamic_handler;
00399 
00401     PayloadContext *dynamic_protocol_context;
00403 } RTSPStream;
00404 
00405 void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf,
00406                         RTSPState *rt, const char *method);
00407 
00413 int ff_rtsp_send_cmd_async(AVFormatContext *s, const char *method,
00414                            const char *url, const char *headers);
00415 
00432 int ff_rtsp_send_cmd_with_content(AVFormatContext *s,
00433                                   const char *method, const char *url,
00434                                   const char *headers,
00435                                   RTSPMessageHeader *reply,
00436                                   unsigned char **content_ptr,
00437                                   const unsigned char *send_content,
00438                                   int send_content_length);
00439 
00445 int ff_rtsp_send_cmd(AVFormatContext *s, const char *method,
00446                      const char *url, const char *headers,
00447                      RTSPMessageHeader *reply, unsigned char **content_ptr);
00448 
00472 int ff_rtsp_read_reply(AVFormatContext *s, RTSPMessageHeader *reply,
00473                        unsigned char **content_ptr,
00474                        int return_on_interleaved_data, const char *method);
00475 
00479 void ff_rtsp_skip_packet(AVFormatContext *s);
00480 
00490 int ff_rtsp_connect(AVFormatContext *s);
00491 
00497 void ff_rtsp_close_streams(AVFormatContext *s);
00498 
00504 void ff_rtsp_close_connections(AVFormatContext *s);
00505 
00510 int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply);
00511 
00516 int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr);
00517 
00523 int ff_sdp_parse(AVFormatContext *s, const char *content);
00524 
00528 int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
00529                             uint8_t *buf, int buf_size);
00530 
00535 int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt);
00536 
00542 int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
00543                                int lower_transport, const char *real_challenge);
00544 
00549 void ff_rtsp_undo_setup(AVFormatContext *s);
00550 
00551 extern const AVOption ff_rtsp_options[];
00552 
00553 #endif /* AVFORMAT_RTSP_H */
Generated on Sat Mar 17 2012 12:57:55 for Libav by doxygen 1.7.1