Go to the documentation of this file.
22 #include "config_components.h"
89 if (rbuf[idx] ==
'\r') {
91 }
else if (rbuf[idx] ==
'\n') {
97 }
while (idx < rbufsize);
103 const char *extracontent, uint16_t seq)
134 if (!session_id[0]) {
138 if (strcmp(session_id, request->
session_id)) {
162 }
while (rbuflen > 0);
163 if (request->
seq != rt->
seq + 1) {
168 if (rt->
session_id[0] && strcmp(method,
"OPTIONS")) {
203 "Unable to get complete SDP Description in ANNOUNCE\n");
218 "Content-Length header value exceeds sdp allocated buffer (4KB)\n");
220 "Content-Length exceeds buffer size", request.
seq);
237 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, RECORD\r\n",
251 int transportidx = 0;
270 " protocol not supported (yet)\n");
276 "using first of all\n");
308 snprintf(responseheaders,
sizeof(responseheaders),
"Transport: "
309 "RTP/AVP/TCP;unicast;mode=record;interleaved=%d-%d"
319 &
s->interrupt_callback, &
opts,
320 s->protocol_whitelist,
s->protocol_blacklist,
NULL);
338 snprintf(responseheaders,
sizeof(responseheaders),
"Transport: "
339 "RTP/AVP/UDP;unicast;mode=record;source=%s;"
340 "client_port=%d-%d;server_port=%d-%d\r\n",
352 av_strlcatf(responseheaders,
sizeof(responseheaders),
"Session: %s\r\n",
375 snprintf(responseheaders,
sizeof(responseheaders),
"Session: %s\r\n",
384 int linelen,
char *uri,
int urisize,
385 char *method,
int methodsize,
389 const char *linept, *searchlinept;
390 linept = strchr(
line,
' ');
397 if (linept -
line > methodsize - 1) {
401 memcpy(method,
line, linept -
line);
402 method[linept -
line] =
'\0';
404 if (!strcmp(method,
"ANNOUNCE"))
406 else if (!strcmp(method,
"OPTIONS"))
408 else if (!strcmp(method,
"RECORD"))
410 else if (!strcmp(method,
"SETUP"))
412 else if (!strcmp(method,
"PAUSE"))
414 else if (!strcmp(method,
"TEARDOWN"))
427 && (*methodcode !=
SETUP)) {
444 searchlinept = strchr(linept,
' ');
449 if (searchlinept - linept > urisize - 1) {
453 memcpy(uri, linept, searchlinept - linept);
454 uri[searchlinept - linept] =
'\0';
456 char host[128], path[512], auth[128];
458 char ctl_host[128], ctl_path[512], ctl_auth[128];
461 path,
sizeof(path), uri);
463 sizeof(ctl_host), &ctl_port, ctl_path,
sizeof(ctl_path),
465 if (strcmp(host, ctl_host))
468 if (strcmp(path, ctl_path) && *methodcode !=
SETUP)
470 " %s\n", path, ctl_path);
473 "Updating control URI to %s\n", uri);
478 linept = searchlinept + 1;
490 unsigned char method[10];
502 sizeof(method), &methodcode);
512 if (methodcode ==
PAUSE) {
516 }
else if (methodcode ==
OPTIONS) {
518 "Public: ANNOUNCE, PAUSE, SETUP, TEARDOWN, "
519 "RECORD\r\n", request.
seq);
520 }
else if (methodcode ==
TEARDOWN) {
569 "Range: npt=%"PRId64
".%03"PRId64
"-\r\n",
719 unsigned char *content =
NULL;
724 "Accept: application/sdp\r\n");
731 "Require: com.real.retain-entity-for-setup\r\n",
755 char proto[128], host[128], path[512], auth[128];
760 const char *lower_proto =
"tcp";
762 unsigned char method[10];
771 av_url_split(proto,
sizeof(proto), auth,
sizeof(auth), host,
sizeof(host),
772 &port, path,
sizeof(path),
s->url);
778 if (!strcmp(proto,
"rtsps")) {
791 &
s->interrupt_callback,
NULL,
792 s->protocol_whitelist,
s->protocol_blacklist,
NULL)) {
804 sizeof(method), &methodcode);
813 }
else if (methodcode ==
OPTIONS) {
815 }
else if (methodcode ==
RECORD) {
819 }
else if (methodcode ==
SETUP)
836 #
if CONFIG_TLS_PROTOCOL
887 uint8_t *buf,
int buf_size)
914 if (
len > buf_size ||
len < 8)
928 id <= rtsp_st->interleaved_max)
961 for (
i = 0;
i <
s->nb_streams;
i++)
968 "Unsubscribe: %s\r\n",
979 int r, rule_nr,
first = 1;
989 for (
r = 0;
r <
s->nb_streams;
r++) {
990 if (
s->streams[
r]->id ==
i) {
1072 s->streams[stream_index]->time_base,
int initial_timeout
Timeout to wait for incoming connections.
@ RTSP_STATE_PAUSED
initialized, but not receiving data
void ff_rdt_subscribe_rule(char *cmd, int size, int stream_nr, int rule_nr)
Add subscription information to Subscribe parameter string.
int initial_pause
Do not begin to play the stream immediately.
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...
int64_t last_cmd_time
timestamp of the last RTSP command that we sent to the RTSP server.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
void ff_rtsp_close_streams(AVFormatContext *s)
Close and free all streams within the RTSP (de)muxer.
uint64_t ntp_timestamp
NTP time when the report was sent.
static int rtsp_read_request(AVFormatContext *s, RTSPMessageHeader *request, const char *method)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
void * transport_priv
RTP/RDT parse context if input, RTP AVFormatContext if output.
URLContext * rtp_handle
RTP stream handle (if UDP)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
@ RTSP_STATE_SEEKING
initialized, requesting a seek
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.
static int resetup_tcp(AVFormatContext *s)
#define AVERROR_EOF
End of file.
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
static int rtsp_read_options(AVFormatContext *s)
@ RTSP_TRANSPORT_RTP
Standards-compliant RTP.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
int get_parameter_supported
Whether the server supports the GET_PARAMETER method.
static int ff_rtsp_averror(enum RTSPStatusCode status_code, int default_averror)
int interleaved_min
interleave IDs; copies of RTSPTransportField->interleaved_min/max for the selected transport.
int ff_rtsp_read_reply_async_stored(AVFormatContext *s, RTSPMessageHeader **reply, unsigned char **content_ptr)
Retrieve a previously stored RTSP reply message from the server.
static int rtsp_read_setup(AVFormatContext *s, char *host, char *controlurl)
static int rtsp_read_close(AVFormatContext *s)
static int rtsp_send_reply(AVFormatContext *s, enum RTSPStatusCode code, const char *extracontent, uint16_t seq)
int64_t range_start_offset
enum RTSPLowerTransport lower_transport
network layer transport protocol; e.g.
int rtp_port_min
Minimum and maximum local UDP ports.
size_t body_len
Body payload size.
int interleaved_min
interleave ids, if TCP transport; each TCP/RTSP data packet starts with a '$', stream length and stre...
Describe a single stream, as identified by a single m= line block in the SDP content.
#define AV_LOG_VERBOSE
Detailed information.
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.
char real_challenge[64]
the "RealChallenge1:" field from the server
void ff_network_close(void)
@ RTSP_SERVER_REAL
Realmedia-style server.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int64_t seek_timestamp
the seek value requested when calling av_seek_frame().
AVFormatCommandID
Command IDs that can be sent to the demuxer.
int ff_network_init(void)
int ff_sdp_parse(AVFormatContext *s, const char *content)
Parse an SDP description of streams by populating an RTSPState struct within the AVFormatContext; als...
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
void ff_rtp_send_punch_packets(URLContext *rtp_handle)
Send a dummy packet on both port pairs to set up the connection state in potential NAT routers,...
static int check_sessionid(AVFormatContext *s, RTSPMessageHeader *request)
FFInputFormatCommandOption
Command handling options Different options influencing the behaviour of the FFInputFormat::handle_com...
int ff_rtsp_send_cmd_with_content_async_stored(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, storing the reply on future reads.
static int rtsp_submit_command(struct AVFormatContext *s, enum AVFormatCommandID id, void *data)
size_t body_len
Body payload size.
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
char * reason
Reason phrase from the server, describing the status in a human-readable way.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int nb_rtsp_streams
number of items in the 'rtsp_streams' variable
static int read_line(AVFormatContext *s, char *rbuf, const int rbufsize, int *rbuflen)
static int rtsp_read_header(AVFormatContext *s)
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt)
static av_cold int read_close(AVFormatContext *ctx)
#define AVERROR_OPTION_NOT_FOUND
Option not found.
int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
Get the description of the stream and set up the RTSPStream child objects.
@ RTSP_TRANSPORT_RDT
Realmedia Data Transport.
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.
@ RTSP_STATE_STREAMING
initialized and sending/receiving data
int lower_transport_mask
A mask with all requested transport methods.
static int rtsp_handle_command(struct AVFormatContext *s, enum FFInputFormatCommandOption opt, enum AVFormatCommandID id, void *data)
int stream_index
corresponding stream index, if any.
void ff_rdt_parse_close(RDTDemuxContext *s)
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
URLContext * rtsp_hd_out
Additional output handle, used when input and output are done separately, eg for HTTP tunneling.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define RTSP_FLAG_LISTEN
Wait for incoming connections.
int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in listen mode.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
FFInputFormatStreamState
Input format stream state The stream states to be used for FFInputFormat::read_set_state.
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,...
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
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.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
Open RTSP transport context.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
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...
static int parse_command_line(AVFormatContext *s, const char *line, int linelen, char *uri, int urisize, char *method, int methodsize, enum RTSPMethod *methodcode)
static int rtsp_read_set_state(AVFormatContext *s, enum FFInputFormatStreamState state)
unsigned char * body
Body payload.
@ AVDISCARD_ALL
discard all
static AVDictionary * opts
char session_id[512]
copy of RTSPMessageHeader->session_id, i.e.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
int ff_rdt_parse_header(const uint8_t *buf, int len, int *pset_id, int *pseq_no, int *pstream_id, int *pis_keyframe, uint32_t *ptimestamp)
Actual data handling.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVDictionary * headers
Headers sent in the request to the server.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
const char * av_default_item_name(void *ptr)
Return the context name.
static int rtsp_probe(const AVProbeData *p)
@ FF_INFMT_COMMAND_GET_REPLY
enum AVDiscard * real_setup
current stream setup.
This structure contains the data a format has to probe a file.
static int rtsp_read_play(AVFormatContext *s)
enum RTSPClientState state
indicator of whether we are currently receiving data from the server.
static int rtsp_read_record(AVFormatContext *s)
void ff_rtp_parse_close(RTPDemuxContext *s)
static int rtsp_read_command_reply(AVFormatContext *s, enum AVFormatCommandID id, void **data_out)
static int rtsp_listen(AVFormatContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int rtsp_flags
Various option flags for the RTSP muxer/demuxer.
const AVOption ff_rtsp_options[]
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void ff_rtsp_close_connections(AVFormatContext *s)
Close all connection handles within the RTSP (de)muxer.
Private data for the RTSP demuxer.
enum RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
uint64_t first_rtcp_ntp_time
struct RTSPStream ** rtsp_streams
streams in this session
#define AV_NOPTS_VALUE
Undefined timestamp value.
int seq
RTSP command sequence number.
static const uint8_t header[24]
HTTPAuthState auth_state
authentication state
int64_t unwrapped_timestamp
void ff_rtsp_parse_line(AVFormatContext *s, RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static int read_header(FFV1Context *f, RangeCoder *c)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
char last_subscription[1024]
the last value of the "SET_PARAMETER Subscribe:" RTSP command.
int timeout
copy of RTSPMessageHeader->timeout, i.e.
#define AV_LOG_INFO
Standard information.
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
#define AV_TIME_BASE
Internal time base represented as integer.
int need_subscription
The following are used for Real stream selection.
static int rtsp_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
@ RTSP_LOWER_TRANSPORT_TCP
TCP; interleaved in RTSP.
static const struct RTSPStatusMessage status_messages[]
void * av_calloc(size_t nmemb, size_t size)
int client_port_min
UDP client ports; these should be the local ports of the UDP RTP (and RTCP) sockets over which we rec...
static const AVClass rtsp_demuxer_class
static int rtsp_read_announce(AVFormatContext *s)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
int status_code
Response status code from server.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
AVRTCPSenderReport last_sr
Last RTCP SR data.
void * av_malloc(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int stale
Auth ok, but needs to be resent with a new nonce.
#define RTSP_DEFAULT_PORT
enum RTSPTransport transport
the negotiated data/packet transport protocol; e.g.
char control_url[MAX_URL_SIZE]
url for this stream (from SDP)
#define AVERROR_STREAM_NOT_FOUND
Stream not found.
RTSPStatusCode
RTSP handling.
@ RTSP_SERVER_WMS
Windows Media server.
const FFInputFormat ff_rtsp_demuxer
static char * dict_to_headers(AVDictionary *headers)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
@ AVFORMAT_COMMAND_RTSP_SET_PARAMETER
Send a RTSP SET_PARAMETER request to the server.
@ FF_INFMT_COMMAND_SUBMIT
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
enum AVDiscard * real_setup_cache
stream setup during the last frame read.
char * av_strdup(const char *s)
Duplicate a string.
@ RTSP_STATE_IDLE
not initialized
static int read_probe(const AVProbeData *p)
@ RTSP_STATUS_ONLY_AGGREGATE
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
Read as many bytes as possible (up to size), calling the read function multiple times if necessary.
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets fate list failing List the fate tests that failed the last time they were executed fate clear reports Remove the test reports from previous test libraries and programs examples Build all examples located in doc examples checkheaders Check headers dependencies alltools Build all tools in tools directory config Reconfigure the project with the current configuration tools target_dec_< decoder > _fuzzer Build fuzzer to fuzz the specified decoder tools target_bsf_< filter > _fuzzer Build fuzzer to fuzz the specified bitstream filter Useful standard make this is useful to reduce unneeded rebuilding when changing headers
This structure stores compressed data.
enum RTSPServerType server_type
brand of server that we're talking to; e.g.
void ff_rtp_reset_packet_queue(RTPDemuxContext *s)
uint64_t packets
The number of returned packets.
int mode_record
transport set to record data
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
int pending_packet
Indicates if a packet is pending to be read (useful for interleaved reads)
static int rtsp_read_pause(AVFormatContext *s)
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
#define RTSPS_DEFAULT_PORT
@ RTSP_LOWER_TRANSPORT_UDP
UDP/unicast.
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16