21 #ifndef AVFORMAT_RTSP_H
22 #define AVFORMAT_RTSP_H
74 #define RTSP_DEFAULT_PORT 554
75 #define RTSPS_DEFAULT_PORT 322
76 #define RTSP_MAX_TRANSPORTS 8
77 #define RTSP_TCP_MAX_PACKET_SIZE 1472
78 #define RTSP_DEFAULT_NB_AUDIO_CHANNELS 1
79 #define RTSP_DEFAULT_AUDIO_SAMPLERATE 44100
80 #define RTSP_RTP_PORT_MIN 5000
81 #define RTSP_RTP_PORT_MAX 65000
82 #define SDP_MAX_SIZE 16384
424 #define RTSP_FLAG_FILTER_SRC 0x1
427 #define RTSP_FLAG_LISTEN 0x2
428 #define RTSP_FLAG_CUSTOM_IO 0x4
429 #define RTSP_FLAG_RTCP_TO_SOURCE 0x8
431 #define RTSP_FLAG_PREFER_TCP 0x10
432 #define RTSP_FLAG_SATIP_RAW 0x20
498 const char *url,
const char *headers);
517 const char *method,
const char *url,
520 unsigned char **content_ptr,
521 const unsigned char *send_content,
522 int send_content_length);
530 const char *url,
const char *headers,
557 unsigned char **content_ptr,
558 int return_on_interleaved_data,
const char *method);
638 int lower_transport,
const char *real_challenge);
common internal API header
void ff_rtsp_skip_packet(AVFormatContext *s)
Skip a RTP/TCP interleaved packet.
int ff_sdp_parse(AVFormatContext *s, const char *content)
Parse an SDP description of streams by populating an RTSPState struct within the AVFormatContext; als...
RTSPServerType
Identify particular servers that require special handling, such as standards-incompliant "Transport:"...
@ RTSP_SERVER_SATIP
SAT>IP server.
@ RTSP_SERVER_WMS
Windows Media server.
@ RTSP_SERVER_RTP
Standards-compliant RTP-server.
@ RTSP_SERVER_REAL
Realmedia-style server.
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_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
Get the description of the stream and set up the RTSPStream child objects.
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 interleave...
int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port, int lower_transport, const char *real_challenge)
Do the SETUP requests for each stream for the chosen lower transport mode.
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_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
Open RTSP transport context.
int ff_rtsp_fetch_packet(AVFormatContext *s, AVPacket *pkt)
Receive one packet from the RTSPStreams set up in the AVFormatContext (which should contain a RTSPSta...
#define RTSP_MAX_TRANSPORTS
void ff_rtsp_parse_line(AVFormatContext *s, RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
RTSPLowerTransport
Network layer over which RTP/etc packet data will be transported.
@ RTSP_LOWER_TRANSPORT_TCP
TCP; interleaved in RTSP.
@ RTSP_LOWER_TRANSPORT_HTTP
HTTP tunneled - not a proper transport mode as such, only for use via AVOptions.
@ RTSP_LOWER_TRANSPORT_NB
@ RTSP_LOWER_TRANSPORT_UDP_MULTICAST
UDP/multicast.
@ RTSP_LOWER_TRANSPORT_CUSTOM
Custom IO - not a public option for lower_transport_mask, but set in the SDP demuxer based on a flag.
@ RTSP_LOWER_TRANSPORT_UDP
UDP/unicast.
@ RTSP_LOWER_TRANSPORT_HTTPS
HTTPS tunneled.
int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in listen mode.
RTSPControlTransport
Transport mode for the RTSP data.
@ RTSP_MODE_PLAIN
Normal RTSP.
@ RTSP_MODE_TUNNEL
RTSP over HTTP (tunneling)
void ff_rtsp_close_connections(AVFormatContext *s)
Close all connection handles within the RTSP (de)muxer.
RTSPClientState
Client state, i.e.
@ RTSP_STATE_SEEKING
initialized, requesting a seek
@ RTSP_STATE_STREAMING
initialized and sending/receiving data
@ RTSP_STATE_PAUSED
initialized, but not receiving data
@ RTSP_STATE_IDLE
not initialized
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.
const AVOption ff_rtsp_options[]
int ff_rtsp_tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
Send buffered packets over TCP.
void ff_rtsp_close_streams(AVFormatContext *s)
Close and free all streams within the RTSP (de)muxer.
int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, uint8_t *buf, int buf_size)
Receive one RTP packet from an TCP interleaved RTSP stream.
void ff_rtsp_undo_setup(AVFormatContext *s, int send_packets)
Undo the effect of ff_rtsp_make_setup_request, close the transport_priv and rtp_handle fields.
int ff_rtsp_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
RTSPTransport
Packet profile of the data that we will be receiving.
@ RTSP_TRANSPORT_RTP
Standards-compliant RTP.
@ RTSP_TRANSPORT_RAW
Raw data (over UDP)
@ RTSP_TRANSPORT_RDT
Realmedia Data Transport.
int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
Announce the stream to the server and set up the RTSPStream child objects for each media stream.
RTSPStatusCode
RTSP handling.
Describe the class of an AVClass context structure.
This structure stores compressed data.
HTTP Authentication state structure.
RTP/JPEG specific private data.
char addr[128]
Source-specific multicast include source IP address (from SDP content)
Private data for the RTSP demuxer.
char real_challenge[64]
the "RealChallenge1:" field from the server
int rtp_muxer_flags
Option flags for the chained RTP muxer.
int nb_rtsp_streams
number of items in the 'rtsp_streams' variable
enum RTSPTransport transport
the negotiated data/packet transport protocol; e.g.
AVFormatContext * asf_ctx
The following are used for RTP/ASF streams.
char last_subscription[1024]
the last value of the "SET_PARAMETER Subscribe:" RTSP command.
int timeout
copy of RTSPMessageHeader->timeout, i.e.
int accept_dynamic_rate
Whether the server accepts the x-Dynamic-Rate header.
HTTPAuthState auth_state
authentication state
int initial_timeout
Timeout to wait for incoming connections.
URLContext * rtsp_hd_out
Additional output handle, used when input and output are done separately, eg for HTTP tunneling.
int lower_transport_mask
A mask with all requested transport methods.
enum AVDiscard * real_setup
current stream setup.
enum RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
uint64_t asf_pb_pos
cache for position of the asf demuxer, since we load a new data packet in the bytecontext for each in...
int64_t last_cmd_time
timestamp of the last RTSP command that we sent to the RTSP server.
int need_subscription
The following are used for Real stream selection.
char session_id[512]
copy of RTSPMessageHeader->session_id, i.e.
int media_type_mask
Mask of all requested media types.
struct MpegTSContext * ts
The following are used for parsing raw mpegts in udp.
enum RTSPServerType server_type
brand of server that we're talking to; e.g.
uint8_t * recvbuf
Reusable buffer for receiving packets.
char * user_agent
User-Agent string.
int rtsp_flags
Various option flags for the RTSP muxer/demuxer.
int64_t seek_timestamp
the seek value requested when calling av_seek_frame().
char control_uri[MAX_URL_SIZE]
some MS RTSP streams contain a URL in the SDP that we need to use for all subsequent RTSP requests,...
enum RTSPControlTransport control_transport
RTSP transport mode, such as plain or tunneled.
void * cur_transport_priv
RTSPStream->transport_priv of the last stream that we read a packet from.
int reordering_queue_size
Size of RTP packet reordering queue.
char auth[128]
plaintext authorization line (username:password)
int rtp_port_min
Minimum and maximum local UDP ports.
uint64_t packets
The number of returned packets.
enum RTSPClientState state
indicator of whether we are currently receiving data from the server.
enum AVDiscard * real_setup_cache
stream setup during the last frame read.
int initial_pause
Do not begin to play the stream immediately.
int seq
RTSP command sequence number.
int stimeout
timeout of socket i/o operations.
struct RTSPStream ** rtsp_streams
streams in this session
struct pollfd * p
Polling array for udp.
int get_parameter_supported
Whether the server supports the GET_PARAMETER method.
char last_reply[2048]
The last reply of the server to a RTSP command.
Describe a single stream, as identified by a single m= line block in the SDP content.
struct RTSPSource ** exclude_source_addrs
Source-specific multicast exclude source IP addresses (from SDP content)
int sdp_ttl
IP Time-To-Live (from SDP content)
const RTPDynamicProtocolHandler * dynamic_handler
The following are used for dynamic protocols (rtpdec_*.c/rdt.c)
int sdp_port
The following are used only in SDP, not RTSP.
int nb_include_source_addrs
Number of source-specific multicast include source IP addresses (from SDP content)
int interleaved_min
interleave IDs; copies of RTSPTransportField->interleaved_min/max for the selected transport.
char control_url[MAX_URL_SIZE]
url for this stream (from SDP)
int sdp_payload_type
payload type
URLContext * rtp_handle
RTP stream handle (if UDP)
int stream_index
corresponding stream index, if any.
struct RTSPSource ** include_source_addrs
Source-specific multicast include source IP addresses (from SDP content)
int feedback
Enable sending RTCP feedback messages according to RFC 4585.
PayloadContext * dynamic_protocol_context
private data associated with the dynamic protocol
void * transport_priv
RTP/RDT parse context if input, RTP AVFormatContext if output.
uint32_t ssrc
SSRC for this stream, to allow identifying RTCP packets before the first RTP packet.
int nb_exclude_source_addrs
Number of source-specific multicast exclude source IP addresses (from SDP content)
struct sockaddr_storage sdp_ip
IP address (from SDP content)
This describes a single item in the "Transport:" line of one stream as negotiated by the SETUP RTSP c...
int server_port_min
UDP unicast server port range; the ports to which we should connect to receive unicast UDP RTP/RTCP d...
int client_port_min
UDP client ports; these should be the local ports of the UDP RTP (and RTCP) sockets over which we rec...
char source[INET6_ADDRSTRLEN+1]
source IP address
enum RTSPTransport transport
data/packet transport protocol; e.g.
int mode_record
transport set to record data
struct sockaddr_storage destination
destination IP address
int ttl
time-to-live value (required for multicast); the amount of HOPs that packets will be allowed to make ...
enum RTSPLowerTransport lower_transport
network layer transport protocol; e.g.
int port_min
UDP multicast port range; the ports to which we should connect to receive multicast UDP data.
int interleaved_min
interleave ids, if TCP transport; each TCP/RTSP data packet starts with a '$', stream length and stre...