54 #define POLL_TIMEOUT_MS 100
55 #define READ_PACKET_TIMEOUT_S 10
56 #define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / POLL_TIMEOUT_MS
57 #define SDP_MAX_SIZE 16384
58 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
60 #define OFFSET(x) offsetof(RTSPState, x)
61 #define DEC AV_OPT_FLAG_DECODING_PARAM
62 #define ENC AV_OPT_FLAG_ENCODING_PARAM
64 #define RTSP_FLAG_OPTS(name, longname) \
65 { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
66 { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }
68 #define RTSP_MEDIATYPE_OPTS(name, longname) \
69 { name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { (1 << (AVMEDIA_TYPE_DATA+1)) - 1 }, INT_MIN, INT_MAX, DEC, "allowed_media_types" }, \
70 { "video", "Video", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_VIDEO}, 0, 0, DEC, "allowed_media_types" }, \
71 { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, "allowed_media_types" }, \
72 { "data", "Data", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, "allowed_media_types" }
75 {
"initial_pause",
"Don't start playing the stream immediately",
OFFSET(initial_pause),
AV_OPT_TYPE_INT, {0}, 0, 1,
DEC },
77 {
"rtsp_transport",
"RTSP transport protocols",
OFFSET(lower_transport_mask),
AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX,
DEC|
ENC,
"rtsp_transport" }, \
99 const char *sep,
const char **pp)
107 while (!strchr(sep, *p) && *p !=
'\0') {
108 if ((q - buf) < buf_size - 1)
120 if (**pp ==
'/') (*pp)++;
124 static void get_word(
char *buf,
int buf_size,
const char **pp)
158 memset(&hints, 0,
sizeof(hints));
175 if (handler->
alloc) {
185 int payload_type,
const char *p)
202 init_rtp_handler(handler, rtsp_st, codec);
264 char *value,
int value_size)
279 typedef struct SDPParseState {
287 int letter,
const char *buf)
290 char buf1[64], st_type[64];
299 av_dlog(s,
"sdp: %c='%s'\n", letter, buf);
302 if (s1->skip_media && letter !=
'm')
307 if (strcmp(buf1,
"IN") != 0)
310 if (strcmp(buf1,
"IP4") && strcmp(buf1,
"IP6"))
322 s1->default_ip = sdp_ip;
323 s1->default_ttl = ttl;
343 get_word(st_type,
sizeof(st_type), &p);
344 if (!strcmp(st_type,
"audio")) {
346 }
else if (!strcmp(st_type,
"video")) {
348 }
else if (!strcmp(st_type,
"application")) {
361 rtsp_st->
sdp_ip = s1->default_ip;
362 rtsp_st->
sdp_ttl = s1->default_ttl;
392 init_rtp_handler(handler, rtsp_st, st->
codec);
393 if (handler && handler->
init)
405 if (!strncmp(p,
"rtsp://", 7))
416 if (proto[0] ==
'\0') {
430 payload_type = atoi(buf1);
433 sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
439 payload_type = atoi(buf1);
457 }
else if (
av_strstart(p,
"IsRealDataType:integer;",&p)) {
460 }
else if (
av_strstart(p,
"SampleRate:integer;", &p) &&
497 SDPParseState sdp_parse_state, *s1 = &sdp_parse_state;
499 memset(s1, 0,
sizeof(SDPParseState));
512 while (*p !=
'\n' && *p !=
'\r' && *p !=
'\0') {
513 if ((q - buf) <
sizeof(buf) - 1)
518 sdp_parse_line(s, s1, letter, buf);
520 while (*p !=
'\n' && *p !=
'\0')
629 #if CONFIG_RTSP_DEMUXER || CONFIG_RTSP_MUXER
630 static void rtsp_parse_range(
int *min_ptr,
int *max_ptr,
const char **pp)
637 v = strtol(p, (
char **)&p, 10);
641 v = strtol(p, (
char **)&p, 10);
653 char transport_protocol[16];
655 char lower_transport[16];
669 get_word_sep(transport_protocol,
sizeof(transport_protocol),
673 lower_transport[0] =
'\0';
680 }
else if (!
av_strcasecmp (transport_protocol,
"x-pn-tng") ||
683 get_word_sep(lower_transport,
sizeof(lower_transport),
"/;,", &p);
695 while (*p !=
'\0' && *p !=
',') {
697 if (!strcmp(parameter,
"port")) {
702 }
else if (!strcmp(parameter,
"client_port")) {
708 }
else if (!strcmp(parameter,
"server_port")) {
714 }
else if (!strcmp(parameter,
"interleaved")) {
720 }
else if (!strcmp(parameter,
"multicast")) {
723 }
else if (!strcmp(parameter,
"ttl")) {
726 th->
ttl = strtol(p, (
char **)&p, 10);
728 }
else if (!strcmp(parameter,
"destination")) {
734 }
else if (!strcmp(parameter,
"source")) {
742 while (*p !=
';' && *p !=
'\0' && *p !=
',')
754 static void handle_rtp_info(
RTSPState *rt,
const char *url,
755 uint32_t seq, uint32_t rtptime)
758 if (!rtptime || !url[0])
774 static void rtsp_parse_rtp_info(
RTSPState *rt,
const char *p)
777 char key[20], value[1024], url[1024] =
"";
778 uint32_t seq = 0, rtptime = 0;
790 if (!strcmp(key,
"url"))
792 else if (!strcmp(key,
"seq"))
793 seq = strtoul(value,
NULL, 10);
794 else if (!strcmp(key,
"rtptime"))
795 rtptime = strtoul(value,
NULL, 10);
797 handle_rtp_info(rt, url, seq, rtptime);
806 handle_rtp_info(rt, url, seq, rtptime);
820 (t = strtol(p,
NULL, 10)) > 0) {
826 rtsp_parse_transport(reply, p);
828 reply->
seq = strtol(p,
NULL, 10);
843 }
else if (
av_stristart(p,
"WWW-Authenticate:", &p) && rt) {
846 }
else if (
av_stristart(p,
"Authentication-Info:", &p) && rt) {
849 }
else if (
av_stristart(p,
"Content-Base:", &p) && rt) {
851 if (method && !strcmp(method,
"DESCRIBE"))
855 if (method && !strcmp(method,
"PLAY"))
856 rtsp_parse_rtp_info(rt, p);
858 if (strstr(p,
"GET_PARAMETER") &&
859 method && !strcmp(method,
"OPTIONS"))
861 }
else if (
av_stristart(p,
"x-Accept-Dynamic-Rate:", &p) && rt) {
879 av_dlog(s,
"skipping RTP packet len=%d\n", len);
884 if (len1 >
sizeof(buf))
894 unsigned char **content_ptr,
895 int return_on_interleaved_data,
const char *method)
898 char buf[4096], buf1[1024], *q;
901 int ret, content_length, line_count = 0;
902 unsigned char *content =
NULL;
904 memset(reply, 0,
sizeof(*reply));
912 av_dlog(s,
"ret=%d c=%02x [%c]\n", ret, ch, ch);
919 if (return_on_interleaved_data) {
923 }
else if (ch !=
'\r') {
924 if ((q - buf) <
sizeof(buf) - 1)
930 av_dlog(s,
"line='%s'\n", buf);
936 if (line_count == 0) {
954 if (content_length > 0) {
958 content[content_length] =
'\0';
961 *content_ptr = content;
965 if (rt->
seq != reply->
seq) {
971 if (reply->
notice == 2101 ||
975 }
else if (reply->
notice >= 4400 && reply->
notice < 5500) {
977 }
else if (reply->
notice == 2401 ||
998 const char *method,
const char *url,
1000 const unsigned char *send_content,
1001 int send_content_length)
1004 char buf[4096], *out_buf;
1010 snprintf(buf,
sizeof(buf),
"%s %s RTSP/1.0\r\n", method, url);
1014 if (rt->
session_id[0] !=
'\0' && (!headers ||
1015 !strstr(headers,
"\nIf-Match:"))) {
1020 rt->
auth, url, method);
1025 if (send_content_length > 0 && send_content)
1026 av_strlcatf(buf,
sizeof(buf),
"Content-Length: %d\r\n", send_content_length);
1032 out_buf = base64buf;
1035 av_dlog(s,
"Sending:\n%s--\n", buf);
1038 if (send_content_length > 0 && send_content) {
1041 "with content data not supported\n");
1052 const char *url,
const char *headers)
1054 return ff_rtsp_send_cmd_with_content_async(s, method, url, headers,
NULL, 0);
1059 unsigned char **content_ptr)
1062 content_ptr,
NULL, 0);
1066 const char *method,
const char *url,
1069 unsigned char **content_ptr,
1070 const unsigned char *send_content,
1071 int send_content_length)
1079 if ((ret = ff_rtsp_send_cmd_with_content_async(s, method, url, header,
1081 send_content_length)))
1103 int lower_transport,
const char *real_challenge)
1110 const char *trans_pref;
1113 trans_pref =
"x-pn-tng";
1115 trans_pref =
"RTP/AVP";
1125 char transport[2048];
1164 "?localport=%d", j);
1180 snprintf(transport,
sizeof(transport) - 1,
1181 "%s/UDP;", trans_pref);
1183 av_strlcat(transport,
"unicast;",
sizeof(transport));
1185 "client_port=%d", port);
1188 av_strlcatf(transport,
sizeof(transport),
"-%d", port + 1);
1200 snprintf(transport,
sizeof(transport) - 1,
1201 "%s/TCP;", trans_pref);
1203 av_strlcat(transport,
"unicast;",
sizeof(transport));
1205 "interleaved=%d-%d",
1206 interleave, interleave + 1);
1211 snprintf(transport,
sizeof(transport) - 1,
1212 "%s/UDP;multicast", trans_pref);
1215 av_strlcat(transport,
";mode=receive",
sizeof(transport));
1218 av_strlcat(transport,
";mode=play",
sizeof(transport));
1219 snprintf(cmd,
sizeof(cmd),
1220 "Transport: %s\r\n",
1223 av_strlcat(cmd,
"x-Dynamic-Rate: 0\r\n",
sizeof(cmd));
1225 char real_res[41], real_csum[9];
1230 "RealChallenge2: %s, sd=%s\r\n",
1270 char url[1024],
options[30] =
"";
1273 av_strlcpy(options,
"?connect=1",
sizeof(options));
1298 char url[1024], namebuf[50];
1311 getnameinfo((
struct sockaddr*) &addr,
sizeof(addr),
1314 port,
"?ttl=%d", ttl);
1352 char host[1024], path[1024], tcpname[1024], cmd[2048], auth[128];
1353 char *option_list, *
option, *filename;
1354 int port, err, tcp_fd;
1356 int lower_transport_mask = 0;
1357 char real_challenge[64] =
"";
1359 socklen_t peer_len =
sizeof(peer);
1376 host,
sizeof(host), &port, path,
sizeof(path), s->
filename);
1383 #if FF_API_RTSP_URL_OPTIONS
1385 option_list = strrchr(path,
'?');
1389 filename = option_list;
1390 while (option_list) {
1393 option = ++option_list;
1394 option_list = strchr(option_list,
'&');
1399 if (!strcmp(option,
"udp")) {
1401 }
else if (!strcmp(option,
"multicast")) {
1403 }
else if (!strcmp(option,
"tcp")) {
1405 }
else if(!strcmp(option,
"http")) {
1408 }
else if (!strcmp(option,
"filter_src")) {
1413 int len = strlen(option);
1414 memmove(++filename, option, len);
1416 if (option_list) *filename =
'&';
1421 "deprecated, use -rtsp_transport "
1422 "and -rtsp_flags instead.\n");
1428 if (!lower_transport_mask)
1437 "only UDP and TCP are supported for output.\n");
1447 host, port,
"%s", path);
1451 char httpname[1024];
1452 char sessioncookie[17];
1455 ff_url_join(httpname,
sizeof(httpname),
"http", auth, host, port,
"%s", path);
1456 snprintf(sessioncookie,
sizeof(sessioncookie),
"%08x%08x",
1467 snprintf(headers,
sizeof(headers),
1468 "x-sessioncookie: %s\r\n"
1469 "Accept: application/x-rtsp-tunnelled\r\n"
1470 "Pragma: no-cache\r\n"
1471 "Cache-Control: no-cache\r\n",
1489 snprintf(headers,
sizeof(headers),
1490 "x-sessioncookie: %s\r\n"
1491 "Content-Type: application/x-rtsp-tunnelled\r\n"
1492 "Pragma: no-cache\r\n"
1493 "Cache-Control: no-cache\r\n"
1494 "Content-Length: 32767\r\n"
1495 "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
1536 if (!getpeername(tcp_fd, (
struct sockaddr*) &peer, &peer_len)) {
1537 getnameinfo((
struct sockaddr*) &peer, peer_len, host,
sizeof(host),
1556 "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
1557 "PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
1558 "CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
1559 "GUID: 00000000-0000-0000-0000-000000000000\r\n",
1586 int lower_transport =
ff_log2_tab[lower_transport_mask &
1587 ~(lower_transport_mask - 1)];
1591 real_challenge :
NULL);
1594 lower_transport_mask &= ~(1 << lower_transport);
1595 if (lower_transport_mask == 0 && err == 1) {
1596 err =
AVERROR(EPROTONOSUPPORT);
1623 uint8_t *buf,
int buf_size, int64_t wait_end)
1627 int n, i, ret, tcp_fd, timeout_cnt = 0;
1629 struct pollfd *p = rt->
p;
1639 p[max_p].fd = tcp_fd;
1640 p[max_p++].events = POLLIN;
1648 p[max_p++].events = POLLIN;
1650 p[max_p++].events = POLLIN;
1655 int j = 1 - (tcp_fd == -1);
1660 if (p[j].revents & POLLIN || p[j+1].revents & POLLIN) {
1663 *prtsp_st = rtsp_st;
1670 #if CONFIG_RTSP_DEMUXER
1671 if (tcp_fd != -1 && p[0].revents & POLLIN) {
1684 }
else if (n < 0 && errno != EINTR)
1694 int64_t wait_end = 0;
1708 }
else if (ret == 1) {
1717 int64_t first_queue_time = 0;
1724 if (queue_time && (queue_time - first_queue_time < 0 ||
1725 !first_queue_time)) {
1726 first_queue_time = queue_time;
1730 if (first_queue_time) {
1731 wait_end = first_queue_time + s->
max_delay;
1734 first_queue_st =
NULL;
1747 #if CONFIG_RTSP_DEMUXER
1759 if (len ==
AVERROR(EAGAIN) && first_queue_st &&
1761 rtsp_st = first_queue_st;
1791 if (rtpctx2 && st && st2 &&
1822 #if CONFIG_SDP_DEMUXER
1828 while (p < p_end && *p !=
'\0') {
1829 if (p +
sizeof(
"c=IN IP") - 1 < p_end &&
1833 while (p < p_end - 1 && *p !=
'\n') p++;
1861 content[
size] =
'\0';
1876 "?localport=%d&ttl=%d&connect=%d", rtsp_st->
sdp_port,
1901 static const AVClass sdp_demuxer_class = {
1916 .priv_class = &sdp_demuxer_class
1920 #if CONFIG_RTP_DEMUXER
1931 uint8_t recvbuf[1500];
1932 char host[500], sdp[500];
1939 socklen_t addrlen =
sizeof(addr);
1951 ret =
ffurl_read(in, recvbuf,
sizeof(recvbuf));
1961 if ((recvbuf[0] & 0xc0) != 0x80) {
1967 payload_type = recvbuf[1] & 0x7f;
1974 memset(&codec, 0,
sizeof(codec));
1977 "without an SDP file describing it\n",
1983 "properly you need an SDP file "
1990 snprintf(sdp,
sizeof(sdp),
1991 "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
1992 addr.ss_family == AF_INET ? 4 : 6, host,
1995 port, payload_type);
2006 ret = sdp_read_header(s, ap);
2017 static const AVClass rtp_demuxer_class = {
2033 .priv_class = &rtp_demuxer_class
char auth[128]
plaintext authorization line (username:password)
int interleaved_min
interleave ids, if TCP transport; each TCP/RTSP data packet starts with a '$', stream length and stre...
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.
void ff_rtsp_skip_packet(AVFormatContext *s)
Skip a RTP/TCP interleaved packet.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
Parse a Windows Media Server-specific SDP line.
Realmedia Data Transport.
int(* parse_sdp_a_line)(AVFormatContext *s, int st_index, PayloadContext *priv_data, const char *line)
Parse the a= line from the sdp field.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void(* free)(PayloadContext *protocol_data)
free any data needed by the rtp parsing for this dynamic data.
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
void ff_rtsp_undo_setup(AVFormatContext *s)
Undo the effect of ff_rtsp_make_setup_request, close the transport_priv and rtp_handle fields...
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...
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
char source[INET6_ADDRSTRLEN+1]
source IP address
HTTPAuthType
Authentication types, ordered from weakest to strongest.
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.
char control_uri[1024]
some MS RTSP streams contain a URL in the SDP that we need to use for all subsequent RTSP requests...
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
#define RTSP_DEFAULT_PORT
static void interleave(short *output, short **input, int channels, int samples)
struct pollfd * p
Polling array for udp.
#define AV_LOG_WARNING
Something somehow does not look correct.
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
int ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
Parse RDT-style packet data (header + media data).
int index
stream index in AVFormatContext
#define AVIO_FLAG_READ
read-only
#define AVIO_FLAG_WRITE
write-only
AVCodec * avcodec_find_decoder(enum CodecID id)
Find a registered decoder with a matching codec ID.
enum AVMediaType codec_type
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
void ff_network_close(void)
initialized and sending/receiving data
char real_challenge[64]
the "RealChallenge1:" field from the server
PayloadContext *(* alloc)(void)
allocate any data needed by the rtp parsing for this dynamic data.
const uint8_t ff_log2_tab[256]
#define RTSP_RTP_PORT_MAX
int ctx_flags
Format-specific flags, see AVFMTCTX_xx.
char session_id[512]
copy of RTSPMessageHeader->session_id, i.e.
int64_t seek_timestamp
the seek value requested when calling av_seek_frame().
const char * ff_rtp_enc_name(int payload_type)
Return the encoding name (as defined in http://www.iana.org/assignments/rtp-parameters) for a given p...
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.
enum RTSPLowerTransport lower_transport
network layer transport protocol; e.g.
int ff_rtsp_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
Standards-compliant RTP-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...
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
int get_parameter_supported
Whether the server supports the GET_PARAMETER method.
Opaque data information usually continuous.
static int rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
int ttl
time-to-live value (required for multicast); the amount of HOPs that packets will be allowed to make ...
int ff_network_init(void)
miscellaneous OS support macros and functions.
int id
format-specific stream ID
int ff_rtp_get_rtcp_file_handle(URLContext *h)
Get the file handle for the RTCP socket.
void ff_rtsp_parse_line(RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
from rtsp.c, but used by rtp dynamic protocol handlers.
int accept_dynamic_rate
Whether the server accepts the x-Dynamic-Rate header.
URLContext * rtsp_hd_out
Additional output handle, used when input and output are done separately, eg for HTTP tunneling...
static int read_header(FFV1Context *f)
Describe a single stream, as identified by a single m= line block in the SDP content.
#define AVERROR_EOF
End of file.
void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
Initialize the authentication state based on another HTTP URLContext.
static av_cold int read_close(AVFormatContext *ctx)
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 avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
struct AVOutputFormat * oformat
#define RTSP_DEFAULT_AUDIO_SAMPLERATE
void ff_rdt_parse_close(RDTDemuxContext *s)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int ff_sdp_parse(AVFormatContext *s, const char *content)
Parse an SDP description of streams by populating an RTSPState struct within the AVFormatContext; als...
Private data for the RTSP demuxer.
int64_t last_cmd_time
timestamp of the last RTSP command that we sent to the RTSP server.
int ffurl_alloc(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb)
Create a URLContext for accessing to the resource indicated by url, but do not initiate the connectio...
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int timeout
copy of RTSPMessageHeader->timeout, i.e.
int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count)
some rtp servers assume client is dead if they don't hear from them...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
const AVOption ff_rtsp_options[]
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
const char * name
Name of the codec implementation.
enum RTSPControlTransport control_transport
RTSP transport mode, such as plain or tunneled.
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
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.
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
struct RTSPStream ** rtsp_streams
streams in this session
int ff_rtp_get_codec_info(AVCodecContext *codec, int payload_type)
Initialize a codec context based on the payload type.
int stream_index
corresponding stream index, if any.
int(* init)(AVFormatContext *s, int st_index, PayloadContext *priv_data)
Initialize dynamic protocol handler, called after the full rtpmap line is parsed. ...
AVCodecContext * codec
codec context
int buf_size
Size of buf except extra allocated bytes.
int seq
RTSP command sequence number.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
uint8_t * recvbuf
Reusable buffer for receiving packets.
unsigned int nb_streams
A list of all streams in the file.
AVFormatContext * asf_ctx
The following are used for RTP/ASF streams.
char filename[1024]
input or output filename
int nb_rtsp_streams
number of items in the 'rtsp_streams' variable
int64_t first_rtcp_ntp_time
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes.
void * cur_transport_priv
RTSPStream->transport_priv of the last stream that we read a packet from.
int av_strcasecmp(const char *a, const char *b)
#define RTSP_TCP_MAX_PACKET_SIZE
static int read_probe(AVProbeData *p)
HTTP tunneled - not a proper transport mode as such, only for use via AVOptions.
This describes a single item in the "Transport:" line of one stream as negotiated by the SETUP RTSP c...
RTSP over HTTP (tunneling)
static void get_word_until_chars(char *buf, int buf_size, const char *sep, const char **pp)
static void get_word(char *buf, int buf_size, const char **pp)
Usually treated as AVMEDIA_TYPE_DATA.
enum CodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type)
Return the codec id for the given encoding name and codec type.
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int sdp_port
The following are used only in SDP, not RTSP.
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
int sdp_payload_type
payload type
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
static int get_sockaddr(const char *buf, struct sockaddr_storage *sock)
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
enum RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
struct sockaddr_storage sdp_ip
IP address (from SDP content)
enum AVMediaType codec_type
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrup a blocking function associated with cb.
int sample_rate
samples per second
int media_type_mask
Mask of all requested media types.
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
static const OptionDef options[]
main external API structure.
#define RTSP_FLAG_OPTS(name, longname)
RDTDemuxContext * ff_rdt_parse_open(AVFormatContext *ic, int first_stream_of_set_idx, void *priv_data, RTPDynamicProtocolHandler *handler)
Allocate and init the RDT parsing context.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define RTSP_FLAG_FILTER_SRC
Filter incoming UDP packets - receive packets only from the right source address and port...
enum RTSPTransport transport
the negotiated data/packet transport protocol; e.g.
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...
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int rtsp_flags
Various option flags for the RTSP muxer/demuxer.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Describe the class of an AVClass context structure.
void ff_real_parse_sdp_a_line(AVFormatContext *s, int stream_index, const char *line)
Parse a server-related SDP line.
struct RTSPState RTSPState
Private data for the RTSP demuxer.
PayloadContext * dynamic_protocol_context
private data associated with the dynamic protocol
char last_reply[2048]
The last reply of the server to a RTSP command.
enum RTSPTransport transport
data/packet transport protocol; e.g.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
#define RTSP_MEDIATYPE_OPTS(name, longname)
int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s)
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_close_streams(AVFormatContext *s)
Close and free all streams within the RTSP (de)muxer.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
This structure contains the data a format has to probe a file.
#define RTSP_DEFAULT_NB_AUDIO_CHANNELS
char * ff_http_auth_create_response(HTTPAuthState *state, const char *auth, const char *path, const char *method)
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...
enum RTSPServerType server_type
brand of server that we're talking to; e.g.
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
int64_t start_time
Decoding: position of the first frame of the component, in AV_TIME_BASE fractional seconds...
enum RTSPClientState state
indicator of whether we are currently receiving data from the server.
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...
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
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.
static const AVOption sdp_options[]
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
int need_subscription
The following are used for Real stream selection.
RTPDynamicProtocolHandler * dynamic_handler
The following are used for dynamic protocols (rtp_*.c/rdt.c)
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...
void ff_rdt_calc_response_and_checksum(char response[41], char chksum[9], const char *challenge)
Calculate the response (RealChallenge2 in the RTSP header) to the challenge (RealChallenge1 in the RT...
struct AVInputFormat * iformat
Can only be iformat or oformat, not both at the same time.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value)
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...
AVFormatContext * ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size)
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.
static void get_word_sep(char *buf, int buf_size, const char *sep, const char **pp)
TCP; interleaved in RTSP.
HTTPAuthState auth_state
authentication state
#define RTSP_RTP_PORT_MIN
int channels
number of audio channels
char control_url[1024]
url for this stream (from SDP)
void * priv_data
Format private data.
int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
Get the description of the stream and set up the RTSPStream child objects.
void ff_rtp_parse_close(RTPDemuxContext *s)
int sdp_ttl
IP Time-To-Live (from SDP content)
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
HTTPAuthType auth_type
The currently chosen auth type.
int lower_transport_mask
A mask with all requested transport methods.
unbuffered private I/O API
uint32_t av_get_random_seed(void)
Get random data.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int ff_rtp_set_remote_url(URLContext *h, const char *uri)
If no filename is given to av_open_input_file because you want to get the local port first...
int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
Parse an RTP or RTCP packet directly sent as a buffer.
struct sockaddr_storage destination
destination IP address
struct sockaddr * ai_addr
#define RTP_REORDER_QUEUE_DEFAULT_SIZE
int interleaved_min
interleave IDs; copies of RTSPTransportField->interleaved_min/max for the selected transport...
int server_port_min
UDP unicast server port range; the ports to which we should connect to receive unicast UDP RTP/RTCP d...
void ff_rtsp_close_connections(AVFormatContext *s)
Close all connection handles within the RTSP (de)muxer.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static const AVOption rtp_options[]
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf...
URLContext * rtp_handle
RTP stream handle (if UDP)
#define AV_NOPTS_VALUE
Undefined timestamp value.
int port_min
UDP multicast port range; the ports to which we should connect to receive multicast UDP data...
void * transport_priv
RTP/RDT parse context if input, RTP AVFormatContext if output.
No authentication specified.
int client_port_min
UDP client ports; these should be the local ports of the UDP RTP (and RTCP) sockets over which we rec...
int64_t av_gettime(void)
Get the current time in microseconds.