libavformat/rtsp.c File Reference

#include "libavutil/base64.h"
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/random_seed.h"
#include "avformat.h"
#include <sys/time.h>
#include <sys/select.h>
#include <strings.h>
#include "internal.h"
#include "network.h"
#include "os_support.h"
#include "http.h"
#include "rtsp.h"
#include "rtpdec.h"
#include "rdt.h"
#include "rtpdec_formats.h"
#include "rtpenc_chain.h"

Go to the source code of this file.

Defines

#define SELECT_TIMEOUT_MS   100
#define READ_PACKET_TIMEOUT_S   10
#define MAX_TIMEOUTS   READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS
#define SDP_MAX_SIZE   16384
#define RECVBUF_SIZE   10 * RTP_MAX_PACKET_LENGTH

Functions

static void get_word_until_chars (char *buf, int buf_size, const char *sep, const char **pp)
static void get_word_sep (char *buf, int buf_size, const char *sep, const char **pp)
static void get_word (char *buf, int buf_size, const char **pp)
static void rtsp_parse_range_npt (const char *p, int64_t *start, int64_t *end)
 Parse a string p in the form of Range:npt=xx-xx, and determine the start and end time.
static int get_sockaddr (const char *buf, struct sockaddr_storage *sock)
void ff_rtsp_close_streams (AVFormatContext *s)
 Close and free all streams within the RTSP (de)muxer.
static int rtsp_open_transport_ctx (AVFormatContext *s, RTSPStream *rtsp_st)
static void rtsp_parse_range (int *min_ptr, int *max_ptr, const char **pp)
static void rtsp_parse_transport (RTSPMessageHeader *reply, const char *p)
static void handle_rtp_info (RTSPState *rt, const char *url, uint32_t seq, uint32_t rtptime)
static void rtsp_parse_rtp_info (RTSPState *rt, const char *p)
void ff_rtsp_parse_line (RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
void ff_rtsp_skip_packet (AVFormatContext *s)
 Skip a RTP/TCP interleaved packet.
int ff_rtsp_read_reply (AVFormatContext *s, RTSPMessageHeader *reply, unsigned char **content_ptr, int return_on_interleaved_data, const char *method)
 Read a RTSP message from the server, or prepare to read data packets if we're reading data interleaved over the TCP/RTSP connection as well.
int ff_rtsp_send_cmd_with_content_async (AVFormatContext *s, const char *method, const char *url, const char *headers, const unsigned char *send_content, int send_content_length)
 Send a command to the RTSP server without waiting for the reply.
int ff_rtsp_send_cmd_async (AVFormatContext *s, const char *method, const char *url, const char *headers)
 Send a command to the RTSP server without waiting for the reply.
int ff_rtsp_send_cmd (AVFormatContext *s, const char *method, const char *url, const char *headers, RTSPMessageHeader *reply, unsigned char **content_ptr)
 Send a command to the RTSP server and wait for the reply.
int ff_rtsp_send_cmd_with_content (AVFormatContext *s, const char *method, const char *url, const char *header, RTSPMessageHeader *reply, unsigned char **content_ptr, const unsigned char *send_content, int send_content_length)
 Send a command to the RTSP server and wait for the reply.
static int make_setup_request (AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge)
void ff_rtsp_close_connections (AVFormatContext *s)
 Close all connection handles within the RTSP (de)muxer.
int ff_rtsp_connect (AVFormatContext *s)
 Connect to the RTSP server and set up the individual media streams.
static int sdp_probe (AVProbeData *p1)
static int sdp_read_header (AVFormatContext *s, AVFormatParameters *ap)
static int sdp_read_close (AVFormatContext *s)

Variables

AVInputFormat sdp_demuxer


Define Documentation

#define MAX_TIMEOUTS   READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS

Definition at line 51 of file rtsp.c.

#define READ_PACKET_TIMEOUT_S   10

Definition at line 50 of file rtsp.c.

#define RECVBUF_SIZE   10 * RTP_MAX_PACKET_LENGTH

Definition at line 53 of file rtsp.c.

#define SDP_MAX_SIZE   16384

Definition at line 52 of file rtsp.c.

Referenced by ff_rtsp_setup_output_streams(), and sdp_read_header().

#define SELECT_TIMEOUT_MS   100

Definition at line 49 of file rtsp.c.


Function Documentation

void ff_rtsp_close_connections ( AVFormatContext rt  ) 

Close all connection handles within the RTSP (de)muxer.

Parameters:
rt RTSP (de)muxer context

Definition at line 1268 of file rtsp.c.

Referenced by ff_rtsp_connect(), rtsp_read_close(), rtsp_read_header(), rtsp_write_close(), and rtsp_write_header().

void ff_rtsp_close_streams ( AVFormatContext s  ) 

Close and free all streams within the RTSP (de)muxer.

Parameters:
s RTSP (de)muxer context

Definition at line 478 of file rtsp.c.

Referenced by ff_rtsp_connect(), rtsp_read_close(), rtsp_read_header(), rtsp_write_close(), rtsp_write_header(), sdp_read_close(), and sdp_read_header().

int ff_rtsp_connect ( AVFormatContext s  ) 

Connect to the RTSP server and set up the individual media streams.

This can be used for both muxers and demuxers.

Parameters:
s RTSP (de)muxer context
Returns:
0 on success, < 0 on error. Cleans up all allocations done within the function on error.

The following entries are required for proper streaming from a Realmedia server. They are interdependent in some way although we currently don't quite understand how. Values were copied from mplayer SVN r23589.

Parameters:
CompanyID is a 16-byte ID in base64
ClientChallenge is a 16-byte ID in hex

Definition at line 1276 of file rtsp.c.

Referenced by rtsp_read_header(), and rtsp_write_header().

void ff_rtsp_parse_line ( RTSPMessageHeader reply,
const char *  buf,
RTSPState rt,
const char *  method 
)

Definition at line 742 of file rtsp.c.

Referenced by ff_rtsp_read_reply(), and rtsp_parse_request().

int ff_rtsp_read_reply ( AVFormatContext s,
RTSPMessageHeader reply,
unsigned char **  content_ptr,
int  return_on_interleaved_data,
const char *  method 
)

Read a RTSP message from the server, or prepare to read data packets if we're reading data interleaved over the TCP/RTSP connection as well.

Parameters:
s RTSP (de)muxer context
reply pointer where the RTSP message header will be stored
content_ptr pointer where the RTSP message body, if any, will be stored (length is in reply)
return_on_interleaved_data whether the function may return if we encounter a data marker ('$'), which precedes data packets over interleaved TCP/RTSP connections. If this is set, this function will return 1 after encountering a '$'. If it is not set, the function will skip any data packets (if they are encountered), until a reply has been fully parsed. If no more data is available without parsing a reply, it will return an error.
method the RTSP method this is a reply to. This affects how some response headers are acted upon. May be NULL.
Returns:
1 if a data packets is ready to be received, -1 on error, and 0 on success.

Definition at line 819 of file rtsp.c.

Referenced by ff_rtsp_send_cmd_with_content(), ff_rtsp_tcp_read_packet(), and rtsp_write_packet().

int ff_rtsp_send_cmd ( AVFormatContext s,
const char *  method,
const char *  url,
const char *  headers,
RTSPMessageHeader reply,
unsigned char **  content_ptr 
)

Send a command to the RTSP server and wait for the reply.

See also:
rtsp_send_cmd_with_content

Definition at line 972 of file rtsp.c.

Referenced by ff_rtsp_connect(), ff_rtsp_setup_input_streams(), make_setup_request(), rtsp_read_packet(), rtsp_read_pause(), rtsp_read_play(), and rtsp_write_record().

int ff_rtsp_send_cmd_async ( AVFormatContext s,
const char *  method,
const char *  url,
const char *  headers 
)

Send a command to the RTSP server without waiting for the reply.

See also:
rtsp_send_cmd_with_content_async

Definition at line 966 of file rtsp.c.

Referenced by rtsp_read_close(), rtsp_read_packet(), and rtsp_write_close().

int ff_rtsp_send_cmd_with_content ( AVFormatContext s,
const char *  method,
const char *  url,
const char *  headers,
RTSPMessageHeader reply,
unsigned char **  content_ptr,
const unsigned char *  send_content,
int  send_content_length 
)

Send a command to the RTSP server and wait for the reply.

Parameters:
s RTSP (de)muxer context
method the method for the request
url the target url for the request
headers extra header lines to include in the request
reply pointer where the RTSP message header will be stored
content_ptr pointer where the RTSP message body, if any, will be stored (length is in reply)
send_content if non-null, the data to send as request body content
send_content_length the length of the send_content data, or 0 if send_content is null
Returns:
zero if success, nonzero otherwise

Definition at line 980 of file rtsp.c.

Referenced by ff_rtsp_send_cmd(), and ff_rtsp_setup_output_streams().

int ff_rtsp_send_cmd_with_content_async ( AVFormatContext s,
const char *  method,
const char *  url,
const char *  headers,
const unsigned char *  send_content,
int  send_content_length 
)

Send a command to the RTSP server without waiting for the reply.

Parameters:
s RTSP (de)muxer context
method the method for the request
url the target url for the request
headers extra header lines to include in the request
send_content if non-null, the data to send as request body content
send_content_length the length of the send_content data, or 0 if send_content is null
Returns:
zero if success, nonzero otherwise

Definition at line 912 of file rtsp.c.

Referenced by ff_rtsp_send_cmd_async(), and ff_rtsp_send_cmd_with_content().

void ff_rtsp_skip_packet ( AVFormatContext s  ) 

Skip a RTP/TCP interleaved packet.

Definition at line 794 of file rtsp.c.

Referenced by ff_rtsp_read_reply(), and rtsp_write_packet().

static int get_sockaddr ( const char *  buf,
struct sockaddr_storage sock 
) [static]

Definition at line 112 of file rtsp.c.

Referenced by rtsp_parse_transport().

static void get_word ( char *  buf,
int  buf_size,
const char **  pp 
) [static]

Definition at line 81 of file rtsp.c.

static void get_word_sep ( char *  buf,
int  buf_size,
const char *  sep,
const char **  pp 
) [static]

static void get_word_until_chars ( char *  buf,
int  buf_size,
const char *  sep,
const char **  pp 
) [static]

Definition at line 55 of file rtsp.c.

Referenced by get_word(), and get_word_sep().

static void handle_rtp_info ( RTSPState rt,
const char *  url,
uint32_t  seq,
uint32_t  rtptime 
) [static]

Definition at line 687 of file rtsp.c.

Referenced by rtsp_parse_rtp_info().

static int make_setup_request ( AVFormatContext s,
const char *  host,
int  port,
int  lower_transport,
const char *  real_challenge 
) [static]

Returns:
0 on success, <0 on error, 1 if protocol is unavailable.

WMS serves all UDP data over a single connection, the RTX, which isn't necessarily the first in the SDP but has to be the first to be set up, else the second/third SETUP will fail with a 461.

For WMS streams, the application streams are only used for UDP. When trying to set it up for TCP streams, the server will return an error. Therefore, we skip those streams.

Definition at line 1020 of file rtsp.c.

Referenced by ff_rtsp_connect().

static int rtsp_open_transport_ctx ( AVFormatContext s,
RTSPStream rtsp_st 
) [static]

Definition at line 522 of file rtsp.c.

Referenced by make_setup_request(), and sdp_read_header().

static void rtsp_parse_range ( int *  min_ptr,
int *  max_ptr,
const char **  pp 
) [static]

Definition at line 563 of file rtsp.c.

Referenced by rtsp_parse_transport().

static void rtsp_parse_range_npt ( const char *  p,
int64_t *  start,
int64_t *  end 
) [static]

Parse a string p in the form of Range:npt=xx-xx, and determine the start and end time.

Used for seeking in the rtp stream.

Definition at line 90 of file rtsp.c.

Referenced by ff_rtsp_parse_line().

static void rtsp_parse_rtp_info ( RTSPState rt,
const char *  p 
) [static]

Definition at line 707 of file rtsp.c.

Referenced by ff_rtsp_parse_line().

static void rtsp_parse_transport ( RTSPMessageHeader reply,
const char *  p 
) [static]

Definition at line 584 of file rtsp.c.

Referenced by ff_rtsp_parse_line().

static int sdp_probe ( AVProbeData p1  )  [static]

Definition at line 1728 of file rtsp.c.

static int sdp_read_close ( AVFormatContext s  )  [static]

Definition at line 1796 of file rtsp.c.

static int sdp_read_header ( AVFormatContext s,
AVFormatParameters ap 
) [static]

Definition at line 1747 of file rtsp.c.


Variable Documentation

Initial value:

Definition at line 1803 of file rtsp.c.


Generated on Wed Jan 19 23:49:51 2011 for FFmpeg by  doxygen 1.5.6