#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 MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS |
| #define SDP_MAX_SIZE 16384 |
Definition at line 52 of file rtsp.c.
Referenced by ff_rtsp_setup_output_streams(), and sdp_read_header().
| void ff_rtsp_close_connections | ( | AVFormatContext * | rt | ) |
Close all connection handles within the RTSP (de)muxer.
| 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.
| 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.
| s | RTSP (de)muxer context |
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.
| 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.
| 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. |
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.
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.
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.
| 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 |
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.
| 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 |
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] |
| static void get_word | ( | char * | buf, | |
| int | buf_size, | |||
| const char ** | pp | |||
| ) | [static] |
| static void get_word_sep | ( | char * | buf, | |
| int | buf_size, | |||
| const char * | sep, | |||
| const char ** | pp | |||
| ) | [static] |
Definition at line 74 of file rtsp.c.
Referenced by ff_rtsp_parse_line(), rtsp_parse_range_npt(), rtsp_parse_rtp_info(), and rtsp_parse_transport().
| static void get_word_until_chars | ( | char * | buf, | |
| int | buf_size, | |||
| const char * | sep, | |||
| const char ** | pp | |||
| ) | [static] |
| static void handle_rtp_info | ( | RTSPState * | rt, | |
| const char * | url, | |||
| uint32_t | seq, | |||
| uint32_t | rtptime | |||
| ) | [static] |
| static int make_setup_request | ( | AVFormatContext * | s, | |
| const char * | host, | |||
| int | port, | |||
| int | lower_transport, | |||
| const char * | real_challenge | |||
| ) | [static] |
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] |
| static void rtsp_parse_range | ( | int * | min_ptr, | |
| int * | max_ptr, | |||
| const char ** | pp | |||
| ) | [static] |
| 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] |
| static void rtsp_parse_transport | ( | RTSPMessageHeader * | reply, | |
| const char * | p | |||
| ) | [static] |
| static int sdp_probe | ( | AVProbeData * | p1 | ) | [static] |
| static int sdp_read_close | ( | AVFormatContext * | s | ) | [static] |
| static int sdp_read_header | ( | AVFormatContext * | s, | |
| AVFormatParameters * | ap | |||
| ) | [static] |
Initial value:
{
"sdp",
NULL_IF_CONFIG_SMALL("SDP"),
sizeof(RTSPState),
sdp_probe,
sdp_read_header,
ff_rtsp_fetch_packet,
sdp_read_close,
}
1.5.6