22#include "config_components.h"
62#define READ_PACKET_TIMEOUT_S 10
63#define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
64#define DEFAULT_REORDERING_DELAY 100000
66#define OFFSET(x) offsetof(RTSPState, x)
67#define DEC AV_OPT_FLAG_DECODING_PARAM
68#define ENC AV_OPT_FLAG_ENCODING_PARAM
70#define RTSP_FLAG_OPTS(name, longname) \
71 { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, DEC, .unit = "rtsp_flags" }, \
72 { "filter_src", "only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, .unit = "rtsp_flags" }
74#define RTSP_MEDIATYPE_OPTS(name, longname) \
75 { name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { .i64 = (1 << (AVMEDIA_TYPE_SUBTITLE+1)) - 1 }, INT_MIN, INT_MAX, DEC, .unit = "allowed_media_types" }, \
76 { "video", "Video", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_VIDEO}, 0, 0, DEC, .unit = "allowed_media_types" }, \
77 { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, .unit = "allowed_media_types" }, \
78 { "data", "Data", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, .unit = "allowed_media_types" }, \
79 { "subtitle", "Subtitle", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_SUBTITLE}, 0, 0, DEC, .unit = "allowed_media_types" }
81#define COMMON_OPTS() \
82 { "reorder_queue_size", "set number of packets to buffer for handling of reordered packets", OFFSET(reordering_queue_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC }, \
83 { "buffer_size", "Underlying protocol send/receive buffer size", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC|ENC }, \
84 { "pkt_size", "Underlying protocol send packet size", OFFSET(pkt_size), AV_OPT_TYPE_INT, { .i64 = 1472 }, -1, INT_MAX, ENC } \
88 {
"initial_pause",
"do not start playing the stream immediately",
OFFSET(initial_pause),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DEC },
90 {
"rtsp_transport",
"set RTSP transport protocols",
OFFSET(lower_transport_mask),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX,
DEC|
ENC, .unit =
"rtsp_transport" }, \
98 {
"prefer_tcp",
"try RTP via TCP first, if available", 0,
AV_OPT_TYPE_CONST, {.i64 =
RTSP_FLAG_PREFER_TCP}, 0, 0,
DEC|
ENC, .unit =
"rtsp_flags" },
103 {
"listen_timeout",
"set maximum timeout (in seconds) to wait for incoming connections (-1 is infinite, imply flag listen)",
OFFSET(initial_timeout),
AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX,
DEC },
104 {
"timeout",
"set timeout (in microseconds) of socket I/O operations",
OFFSET(stimeout),
AV_OPT_TYPE_INT64, {.i64 = 0}, INT_MIN, INT64_MAX,
DEC },
119 RTSP_MEDIATYPE_OPTS(
"allowed_media_types",
"set media types to accept from the server"),
128 RTSP_MEDIATYPE_OPTS(
"allowed_media_types",
"set media types to accept from the server"),
170 const char *sep,
const char **pp)
178 while (!strchr(sep, *p) && *p !=
'\0') {
179 if ((q - buf) < buf_size - 1)
191 if (**pp ==
'/') (*pp)++;
195static void get_word(
char *buf,
int buf_size,
const char **pp)
239 memcpy(sock, ai->ai_addr,
FFMIN(
sizeof(*sock), ai->ai_addrlen));
282#if CONFIG_RTSP_DEMUXER
307 finalize_rtp_handler_init(
s, rtsp_st,
NULL);
316 int payload_type,
const char *p)
338 init_rtp_handler(
handler, rtsp_st, st);
381 finalize_rtp_handler_init(
s, rtsp_st, st);
389 char *
value,
int value_size)
404typedef struct SDPParseState {
406 struct sockaddr_storage default_ip;
409 int nb_default_include_source_addrs;
410 struct RTSPSource **default_include_source_addrs;
411 int nb_default_exclude_source_addrs;
412 struct RTSPSource **default_exclude_source_addrs;
415 char delayed_fmtp[2048];
418static void copy_default_source_addrs(
struct RTSPSource **addrs,
int count,
423 for (
i = 0;
i < count;
i++) {
425 rtsp_src2 =
av_memdup(rtsp_src,
sizeof(*rtsp_src));
433 int payload_type,
const char *
line)
449 int letter,
const char *buf)
452 char buf1[64], st_type[64];
465 if (s1->skip_media && letter !=
'm')
470 if (strcmp(buf1,
"IN") != 0)
473 if (strcmp(buf1,
"IP4") && strcmp(buf1,
"IP6"))
484 if (
s->nb_streams == 0) {
485 s1->default_ip = sdp_ip;
486 s1->default_ttl = ttl;
497 if (
s->nb_streams == 0) {
508 get_word(st_type,
sizeof(st_type), &p);
509 if (!strcmp(st_type,
"audio")) {
511 }
else if (!strcmp(st_type,
"video")) {
513 }
else if (!strcmp(st_type,
"application")) {
515 }
else if (!strcmp(st_type,
"text")) {
531 rtsp_st->
sdp_ip = s1->default_ip;
532 rtsp_st->
sdp_ttl = s1->default_ttl;
534 copy_default_source_addrs(s1->default_include_source_addrs,
535 s1->nb_default_include_source_addrs,
538 copy_default_source_addrs(s1->default_exclude_source_addrs,
539 s1->nb_default_exclude_source_addrs,
547 if (!strcmp(buf1,
"udp"))
549 else if (strstr(buf1,
"/AVPF") || strstr(buf1,
"/SAVPF"))
559 if (CONFIG_RTPDEC && !rt->
ts)
566 finalize_rtp_handler_init(
s, rtsp_st,
NULL);
589 init_rtp_handler(
handler, rtsp_st, st);
590 finalize_rtp_handler_init(
s, rtsp_st, st);
602 if (!strncmp(p,
"rtsp://", 7))
613 if (proto[0] ==
'\0') {
625 }
else if (
av_strstart(p,
"rtpmap:", &p) &&
s->nb_streams > 0) {
628 payload_type = atoi(buf1);
632 sdp_parse_rtpmap(
s, st, rtsp_st, payload_type, p);
642 payload_type = atoi(buf1);
643 if (s1->seen_rtpmap) {
647 av_strlcpy(s1->delayed_fmtp, buf,
sizeof(s1->delayed_fmtp));
649 }
else if (
av_strstart(p,
"framerate:", &p) &&
s->nb_streams > 0) {
653 st =
s->streams[
s->nb_streams - 1];
656 }
else if (
av_strstart(p,
"ssrc:", &p) &&
s->nb_streams > 0) {
659 rtsp_st->
ssrc = strtoll(buf1,
NULL, 10);
665 s->start_time = start;
668 s->duration = end - start;
670 if (
s->nb_streams > 0) {
679 }
else if (
av_strstart(p,
"IsRealDataType:integer;",&p)) {
682 }
else if (
av_strstart(p,
"SampleRate:integer;", &p) &&
684 st =
s->streams[
s->nb_streams - 1];
686 }
else if (
av_strstart(p,
"crypto:", &p) &&
s->nb_streams > 0) {
697 if (strcmp(buf1,
"incl") && strcmp(buf1,
"excl"))
699 exclude = !strcmp(buf1,
"excl");
702 if (strcmp(buf1,
"IN") != 0)
705 if (strcmp(buf1,
"IP4") && strcmp(buf1,
"IP6") && strcmp(buf1,
"*"))
716 if (
s->nb_streams == 0) {
717 dynarray_add(&s1->default_exclude_source_addrs, &s1->nb_default_exclude_source_addrs, rtsp_src);
723 if (
s->nb_streams == 0) {
724 dynarray_add(&s1->default_include_source_addrs, &s1->nb_default_include_source_addrs, rtsp_src);
734 if (
s->nb_streams > 0) {
756 SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
772 while (*p !=
'\n' && *p !=
'\r' && *p !=
'\0') {
773 if ((q - buf) <
sizeof(buf) - 1)
778 sdp_parse_line(
s, s1, letter, buf);
780 while (*p !=
'\n' && *p !=
'\0')
786 for (
i = 0;
i < s1->nb_default_include_source_addrs;
i++)
787 av_freep(&s1->default_include_source_addrs[
i]);
788 av_freep(&s1->default_include_source_addrs);
789 for (
i = 0;
i < s1->nb_default_exclude_source_addrs;
i++)
790 av_freep(&s1->default_exclude_source_addrs[
i]);
791 av_freep(&s1->default_exclude_source_addrs);
815 if (CONFIG_RTSP_MUXER && rtpctx->
pb && send_packets)
863 if (CONFIG_RTPDEC && rt->
ts)
874 if (reordering_queue_size < 0) {
876 reordering_queue_size = 0;
887 if (CONFIG_RTSP_MUXER &&
s->oformat && st) {
903 else if (CONFIG_RTPDEC)
906 reordering_queue_size);
928#if CONFIG_RTSP_DEMUXER || CONFIG_RTSP_MUXER
929static void rtsp_parse_range(
int *min_ptr,
int *max_ptr,
const char **pp)
937 v = strtol(q, &p, 10);
941 v = strtol(p, &p, 10);
954 char transport_protocol[16];
956 char lower_transport[16];
970 get_word_sep(transport_protocol,
sizeof(transport_protocol),
974 lower_transport[0] =
'\0';
981 }
else if (!
av_strcasecmp (transport_protocol,
"x-pn-tng") ||
984 get_word_sep(lower_transport,
sizeof(lower_transport),
"/;,", &p);
989 lower_transport[0] =
'\0';
1007 while (*p !=
'\0' && *p !=
',') {
1009 if (!strcmp(parameter,
"port")) {
1014 }
else if (!strcmp(parameter,
"client_port")) {
1020 }
else if (!strcmp(parameter,
"server_port")) {
1026 }
else if (!strcmp(parameter,
"interleaved")) {
1032 }
else if (!strcmp(parameter,
"multicast")) {
1035 }
else if (!strcmp(parameter,
"ttl")) {
1039 th->
ttl = strtol(p, &end, 10);
1042 }
else if (!strcmp(parameter,
"destination")) {
1048 }
else if (!strcmp(parameter,
"source")) {
1054 }
else if (!strcmp(parameter,
"mode")) {
1064 while (*p !=
';' && *p !=
'\0' && *p !=
',')
1078static void handle_rtp_info(
RTSPState *rt,
const char *url,
1079 uint32_t seq, uint32_t rtptime)
1082 if (!rtptime || !url[0])
1098static void rtsp_parse_rtp_info(
RTSPState *rt,
const char *p)
1102 uint32_t seq = 0, rtptime = 0;
1114 if (!strcmp(
key,
"url"))
1116 else if (!strcmp(
key,
"seq"))
1118 else if (!strcmp(
key,
"rtptime"))
1121 handle_rtp_info(rt, url, seq, rtptime);
1130 handle_rtp_info(rt, url, seq, rtptime);
1145 (t = strtol(p,
NULL, 10)) > 0) {
1151 rtsp_parse_transport(
s, reply, p);
1153 reply->
seq = strtol(p,
NULL, 10);
1168 }
else if (
av_stristart(p,
"WWW-Authenticate:", &p) && rt) {
1171 }
else if (
av_stristart(p,
"Authentication-Info:", &p) && rt) {
1174 }
else if (
av_stristart(p,
"Content-Base:", &p) && rt) {
1176 if (method && !strcmp(method,
"DESCRIBE"))
1180 if (method && !strcmp(method,
"PLAY"))
1181 rtsp_parse_rtp_info(rt, p);
1183 if (strstr(p,
"GET_PARAMETER") &&
1184 method && !strcmp(method,
"OPTIONS"))
1186 }
else if (
av_stristart(p,
"x-Accept-Dynamic-Rate:", &p) && rt) {
1208 return ret < 0 ? ret :
AVERROR(EIO);
1216 if (len1 >
sizeof(buf))
1220 return ret < 0 ? ret :
AVERROR(EIO);
1229 unsigned char **content_ptr,
1230 int return_on_interleaved_data,
1237 int ret, content_length, line_count, request;
1238 unsigned char *content;
1244 memset(reply, 0,
sizeof(*reply));
1253 ret = (ret < 0) ? ret :
AVERROR(EIO);
1260 if (ch ==
'$' && q == buf) {
1261 if (return_on_interleaved_data) {
1269 }
else if (ch !=
'\r') {
1270 if ((q - buf) <
sizeof(buf) - 1)
1282 if (line_count == 0) {
1285 if (!strncmp(buf1,
"RTSP/", 5)) {
1307 if (content_length > 0) {
1309 content =
av_malloc(content_length + 1);
1314 return ret < 0 ? ret :
AVERROR(EIO);
1316 content[content_length] =
'\0';
1319 *content_ptr = content;
1326 const char* ptr = buf;
1328 if (!strcmp(reply->
reason,
"OPTIONS") ||
1329 !strcmp(reply->
reason,
"GET_PARAMETER")) {
1330 snprintf(buf,
sizeof(buf),
"RTSP/1.0 200 OK\r\n");
1337 snprintf(buf,
sizeof(buf),
"RTSP/1.0 501 Not Implemented\r\n");
1362 if (rt->
seq != reply->
seq) {
1368 if (reply->
notice == 2101 ||
1370 reply->
notice == 2306 ) {
1372 }
else if (reply->
notice >= 4400 && reply->
notice < 5500) {
1374 }
else if (reply->
notice == 2401 ||
1382 unsigned char **content_ptr,
1383 int return_on_interleaved_data,
const char *method)
1392 if (return_on_interleaved_data)
1403 ret = ff_rtsp_read_reply_internal(
s, &
header,
1427 return ff_rtsp_read_reply_internal(
s, reply, content_ptr,
1428 return_on_interleaved_data, method);
1445 const char *method,
const char *url,
1446 const char *headers,
1447 const unsigned char *send_content,
1448 int send_content_length)
1460 snprintf(buf,
sizeof(buf),
"%s %s RTSP/1.0\r\n", method, url);
1465 if (rt->
session_id[0] !=
'\0' && (!headers ||
1466 !strstr(headers,
"\nIf-Match:"))) {
1471 rt->
auth, url, method);
1476 if (send_content_length > 0 && send_content)
1477 av_strlcatf(buf,
sizeof(buf),
"Content-Length: %d\r\n", send_content_length);
1483 out_buf = base64buf;
1489 if (send_content_length > 0 && send_content) {
1502 const char *method,
const char *url,
1503 const char *headers,
1504 const unsigned char *send_content,
1505 int send_content_length)
1509 send_content, send_content_length);
1520 const char *url,
const char *headers)
1527 unsigned char **content_ptr)
1530 content_ptr,
NULL, 0);
1534 const char *method,
const char *url,
1537 unsigned char **content_ptr,
1538 const unsigned char *send_content,
1539 int send_content_length)
1543 int ret, attempts = 0;
1549 send_content_length)) < 0)
1573 unsigned char **content_ptr)
1600 int lower_transport,
const char *real_challenge)
1603 int rtx = 0, j,
i, err,
interleave = 0, port_off = 0;
1607 const char *trans_pref;
1609 memset(&reply1, 0,
sizeof(reply1));
1612 trans_pref =
"x-pn-tng";
1614 trans_pref =
"RAW/RAW";
1616 trans_pref =
"RTP/AVP";
1627 port_off -= port_off & 0x01;
1671 "?localrtpport=%d", j);
1675 &
s->interrupt_callback, &
opts,
s->protocol_whitelist,
s->protocol_blacklist,
NULL);
1689 av_strlcpy(transport, trans_pref,
sizeof(transport));
1694 av_strlcat(transport,
"unicast;",
sizeof(transport));
1696 "client_port=%d", port);
1699 av_strlcatf(transport,
sizeof(transport),
"-%d", port + 1);
1712 snprintf(transport,
sizeof(transport) - 1,
1713 "%s/TCP;", trans_pref);
1715 av_strlcat(transport,
"unicast;",
sizeof(transport));
1717 "interleaved=%d-%d",
1723 snprintf(transport,
sizeof(transport) - 1,
1724 "%s/UDP;multicast", trans_pref);
1731 av_strlcat(transport,
";mode=record",
sizeof(transport));
1734 av_strlcat(transport,
";mode=play",
sizeof(transport));
1736 "Transport: %s\r\n",
1739 av_strlcat(cmd,
"x-Dynamic-Rate: 0\r\n",
sizeof(cmd));
1741 char real_res[41], real_csum[9];
1746 "RealChallenge2: %s, sd=%s\r\n",
1760 char proto[128], host[128], path[512], auth[128];
1762 av_url_split(proto,
sizeof(proto), auth,
sizeof(auth), host,
sizeof(host),
1796 const char *peer = host;
1828 snprintf(optbuf,
sizeof(optbuf),
"?ttl=%d", ttl);
1829 getnameinfo((
struct sockaddr*) &addr,
sizeof(addr),
1832 port,
"%s", optbuf);
1834 &
s->interrupt_callback, &
opts,
s->protocol_whitelist,
s->protocol_blacklist,
NULL);
1871static int rtsp_url_same_origin(
const char *url1,
const char *url2)
1873 char proto1[128], proto2[128];
1874 char host1[1024], host2[1024];
1878 &port1,
NULL, 0, url1);
1880 &port2,
NULL, 0, url2);
1882 if (!proto1[0] || !proto2[0] || !host1[0] || !host2[0])
1900 char proto[128], host[1024], path[2048];
1902 const char *lower_rtsp_proto =
"tcp";
1903 int port, err, tcp_fd;
1905 int lower_transport_mask = 0;
1907 int https_tunnel = 0;
1908 char real_challenge[64] =
"";
1910 socklen_t peer_len =
sizeof(peer);
1923 if (
s->max_delay < 0)
1937 memset(&reply1, 0,
sizeof(reply1));
1940 host,
sizeof(host), &port, path,
sizeof(path),
s->url);
1942 if (!strcmp(proto,
"rtsps")) {
1943 lower_rtsp_proto =
"tls";
1946 }
else if (!strcmp(proto,
"satip")) {
1949 }
else if (strcmp(proto,
"rtsp"))
1956 port = default_port;
1960 if (!lower_transport_mask)
1969 "only UDP and TCP are supported for output.\n");
1979 host, port,
"%s", path);
1983 char httpname[1024];
1984 char sessioncookie[17];
1998 ff_url_join(httpname,
sizeof(httpname), https_tunnel ?
"https" :
"http", auth, host, port,
"%s", path);
1999 snprintf(sessioncookie,
sizeof(sessioncookie),
"%08x%08x",
2004 &
s->interrupt_callback) < 0) {
2012 "x-sessioncookie: %s\r\n"
2013 "Accept: application/x-rtsp-tunnelled\r\n"
2014 "Pragma: no-cache\r\n"
2015 "Cache-Control: no-cache\r\n",
2046 &
s->interrupt_callback) < 0 ) {
2054 "x-sessioncookie: %s\r\n"
2055 "Content-Type: application/x-rtsp-tunnelled\r\n"
2056 "Pragma: no-cache\r\n"
2057 "Cache-Control: no-cache\r\n"
2058 "Content-Length: 32767\r\n"
2059 "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
2094 if (strcmp(
"tls", lower_rtsp_proto) == 0) {
2107 &
s->interrupt_callback, &proto_opts,
s->protocol_whitelist,
s->protocol_blacklist,
NULL)) < 0) {
2122 if (!getpeername(tcp_fd, (
struct sockaddr*) &peer, &peer_len)) {
2123 getnameinfo((
struct sockaddr*) &peer, peer_len, host,
sizeof(host),
2144 "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
2145 "PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
2146 "CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
2147 "GUID: 00000000-0000-0000-0000-000000000000\r\n",
2166#if CONFIG_RTSP_DEMUXER
2169 err = init_satip_stream(
s);
2174 if (CONFIG_RTSP_MUXER)
2182 int lower_transport =
ff_log2_tab[lower_transport_mask &
2183 ~(lower_transport_mask - 1)];
2191 real_challenge :
NULL);
2194 lower_transport_mask &= ~(1 << lower_transport);
2195 if (lower_transport_mask == 0 && err == 1) {
2196 err =
AVERROR(EPROTONOSUPPORT);
2212 if (!rtsp_url_same_origin(
s->url, reply->
location)) {
2213 memset(rt->
auth, 0,
sizeof(rt->
auth));
2234#if CONFIG_RTSP_DEMUXER
2260 uint8_t *buf,
int buf_size,
int64_t wait_end)
2265 struct pollfd *
p = rt->
p;
2266 int *fds =
NULL, fdsnum, fdsidx;
2276 p[rt->
max_p++].events = POLLIN;
2288 "Number of fds %d not supported\n", fdsnum);
2292 for (fdsidx = 0; fdsidx < fdsnum; fdsidx++) {
2293 p[rt->
max_p].fd = fds[fdsidx];
2294 p[rt->
max_p++].events = POLLIN;
2312 if (p[j].revents & POLLIN || p[j+1].revents & POLLIN) {
2315 *prtsp_st = rtsp_st;
2322#if CONFIG_RTSP_DEMUXER
2323 if (rt->
rtsp_hd && p[0].revents & POLLIN) {
2324 if ((ret = parse_rtsp_message(
s)) < 0) {
2329 }
else if (n == 0 && rt->
stimeout > 0 && --runs <= 0) {
2331 }
else if (n < 0 && errno != EINTR)
2337 const uint8_t *buf,
int len)
2363 "Unable to pick stream for packet - SSRC not known for "
2389#if CONFIG_RTSP_DEMUXER
2434 }
else if (CONFIG_RTPDEC && rt->
ts) {
2445 }
else if (ret == 1) {
2461 if (queue_time && (queue_time - first_queue_time < 0 ||
2462 !first_queue_time)) {
2463 first_queue_time = queue_time;
2467 if (first_queue_time) {
2468 wait_end = first_queue_time +
s->max_delay;
2471 first_queue_st =
NULL;
2483 if (
len ==
AVERROR(EAGAIN) && first_queue_st &&
2486 "max delay reached. need to consume packet\n");
2487 rtsp_st = first_queue_st;
2522 if (rtpctx2 && st && st2 &&
2534 s->start_time_realtime -=
2549 }
else if (CONFIG_RTPDEC && rt->
ts) {
2575#if CONFIG_SDP_DEMUXER
2581 while (p < p_end && *p !=
'\0') {
2582 if (
sizeof(
"c=IN IP") - 1 < p_end - p &&
2586 while (p < p_end - 1 && *p !=
'\n')
p++;
2595static void append_source_addrs(
char *buf,
int size,
const char *
name,
2602 for (
i = 1;
i < count;
i++)
2617 if (
s->max_delay < 0)
2655 "?localrtpport=%d&ttl=%d&connect=%d&write_to_source=%d",
2660 p = strchr(
s->url,
'?');
2662 av_strlcatf(url,
sizeof(url),
"&localaddr=%s", buf);
2665 append_source_addrs(url,
sizeof(url),
"sources",
2668 append_source_addrs(url,
sizeof(url),
"block",
2672 &
s->interrupt_callback, &
opts,
s->protocol_whitelist,
s->protocol_blacklist,
NULL);
2698static const AVClass sdp_demuxer_class = {
2699 .class_name =
"SDP demuxer",
2708 .p.priv_class = &sdp_demuxer_class,
2717#if CONFIG_RTP_DEMUXER
2728 char host[500], filters_buf[1000];
2735 socklen_t addrlen =
sizeof(addr);
2746 &
s->interrupt_callback, &
opts,
s->protocol_whitelist,
s->protocol_blacklist,
NULL);
2752 ret =
ffurl_read(in, recvbuf,
sizeof(recvbuf));
2762 if ((recvbuf[0] & 0xc0) != 0x80) {
2771 payload_type = recvbuf[1] & 0x7f;
2785 "without an SDP file describing it\n",
2792 "properly you need an SDP file "
2801 addr.ss_family == AF_INET ? 4 : 6, host);
2803 p = strchr(
s->url,
'?');
2805 static const char filters[][2][8] = { {
"sources",
"incl" },
2806 {
"block",
"excl" } };
2812 while ((q = strchr(q,
',')) !=
NULL)
2814 av_bprintf(&sdp,
"a=source-filter:%s IN IP%d %s %s\r\n",
2816 addr.ss_family == AF_INET ? 4 : 6, host,
2825 port, payload_type);
2841 ret = sdp_read_header(
s);
2857static const AVClass rtp_demuxer_class = {
2858 .class_name =
"RTP demuxer",
2868 .p.priv_class = &rtp_demuxer_class,
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
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...
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
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.
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Return the file descriptors associated with this URL.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
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.
#define AVIO_FLAG_READ
read-only
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AVIO_FLAG_WRITE
write-only
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int av_sscanf(const char *string, const char *format,...)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
AVCodecParameters * avcodec_parameters_alloc(void)
void avcodec_parameters_free(AVCodecParameters **ppar)
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
@ AV_CODEC_ID_MPEG2TS
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
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 av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
#define AV_CHANNEL_LAYOUT_MONO
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
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 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.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
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,...
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
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.
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 av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
Initialize the authentication state based on another HTTP URLContext.
char * ff_http_auth_create_response(HTTPAuthState *state, const char *auth, const char *path, const char *method)
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value)
HTTPAuthType
Authentication types, ordered from weakest to strongest.
@ HTTP_AUTH_NONE
No authentication specified.
const uint8_t ff_log2_tab[256]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static av_cold int read_close(AVFormatContext *ctx)
static void handler(vbi_event *ev, void *user_data)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
void avpriv_mpegts_parse_close(MpegTSContext *ts)
MpegTSContext * avpriv_mpegts_parse_open(AVFormatContext *s)
int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int ff_network_init(void)
Initialize the network subsystem.
void ff_network_close(void)
miscellaneous OS support macros and functions.
int av_parse_time(int64_t *timeval, const char *timestr, int duration)
Parse timestr and return in *time a corresponding number of microseconds.
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
RDTDemuxContext * ff_rdt_parse_open(AVFormatContext *ic, int first_stream_of_set_idx, void *priv_data, const RTPDynamicProtocolHandler *handler)
Allocate and init the RDT parsing context.
int ff_rdt_parse_packet(RDTDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
Parse RDT-style packet data (header + media data).
void ff_rdt_parse_close(RDTDemuxContext *s)
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...
void ff_real_parse_sdp_a_line(AVFormatContext *s, int stream_index, const char *line)
Parse a server-related SDP line.
enum AVMediaType codec_type
int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type)
Initialize a codec context based on the payload type.
enum AVCodecID ff_rtp_codec_id(const char *buf, enum AVMediaType codec_type)
Return the codec id for the given encoding name and codec type.
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...
#define RTP_PT_IS_RTCP(x)
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
void ff_rtp_parse_close(RTPDemuxContext *s)
void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, const char *params)
const RTPDynamicProtocolHandler * ff_rtp_handler_find_by_id(int id, enum AVMediaType codec_type)
Find a registered rtp dynamic protocol handler with a matching codec ID.
int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd, AVIOContext *avio, int count)
some rtp servers assume client is dead if they don't hear from them... so we send a Receiver Report t...
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, const RTPDynamicProtocolHandler *handler)
int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd, AVIOContext *avio)
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.
int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s)
const RTPDynamicProtocolHandler * ff_rtp_handler_find_by_name(const char *name, enum AVMediaType codec_type)
Find a registered rtp dynamic protocol handler with the specified name.
#define RTP_REORDER_QUEUE_DEFAULT_SIZE
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
#define RTP_MAX_PACKET_LENGTH
int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
Parse a Windows Media Server-specific SDP line.
static int parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value)
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size, int idx)
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
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,...
static const AVOption sdp_options[]
static void get_word_until_chars(char *buf, int buf_size, const char *sep, const char **pp)
#define DEFAULT_REORDERING_DELAY
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
Open RTSP transport context.
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 AVDictionary * map_to_opts(RTSPState *rt)
static void get_word_sep(char *buf, int buf_size, const char *sep, const char **pp)
static const AVOption rtp_options[]
static int copy_tls_opts_dict(RTSPState *rt, AVDictionary **dict)
Add the TLS options of the given RTSPState to the dict.
static void get_word(char *buf, int buf_size, const char **pp)
static int get_sockaddr(AVFormatContext *s, const char *buf, struct sockaddr_storage *sock)
const AVOption ff_rtsp_options[]
void ff_rtsp_close_streams(AVFormatContext *s)
Close and free all streams within the RTSP (de)muxer.
#define READ_PACKET_TIMEOUT_S
#define RTSP_FLAG_OPTS(name, longname)
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 RTSP_MEDIATYPE_OPTS(name, longname)
int ff_sdp_parse(AVFormatContext *s, const char *content)
Parse an SDP description of streams by populating an RTSPState struct within the AVFormatContext; als...
#define RTSP_FLAG_LISTEN
Wait for incoming connections.
@ 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_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.
int ff_rtsp_setup_input_streams(AVFormatContext *s, RTSPMessageHeader *reply)
Get the description of the stream and set up the RTSPStream child objects.
#define RTSP_FLAG_SATIP_RAW
Export SAT>IP stream as raw MPEG-TS.
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.
#define RTSP_DEFAULT_AUDIO_SAMPLERATE
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_skip_packet(AVFormatContext *s)
Skip a RTP/TCP interleaved packet.
#define RTSP_FLAG_FILTER_SRC
Filter incoming UDP packets - receive packets only from the right source address and port.
#define RTSP_FLAG_CUSTOM_IO
Do all IO via the AVIOContext.
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)
#define RTSPS_DEFAULT_PORT
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.
@ 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.
#define RTSP_RTP_PORT_MIN
@ RTSP_MODE_PLAIN
Normal RTSP.
@ RTSP_MODE_TUNNEL
RTSP over HTTP (tunneling)
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.
void ff_rtsp_close_connections(AVFormatContext *s)
Close all connection handles within the RTSP (de)muxer.
@ RTSP_STATE_STREAMING
initialized and sending/receiving data
@ RTSP_STATE_IDLE
not initialized
#define RTSP_FLAG_PREFER_TCP
Try RTP via TCP first if possible.
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.
int ff_rtsp_tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
Send buffered packets over TCP.
#define RTSP_DEFAULT_PORT
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.
#define RTSP_RTP_PORT_MAX
int ff_rtsp_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
@ 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.
#define RTSP_FLAG_RTCP_TO_SOURCE
Send RTCP packets to the source address of received packets.
static int ff_rtsp_averror(enum RTSPStatusCode status_code, int default_averror)
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
An AVChannelLayout holds information about the channel layout of audio data.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
This struct describes the properties of a single codec described by an AVCodecID.
This struct describes the properties of an encoded stream.
AVChannelLayout ch_layout
The channel layout and number of channels.
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
AVIOContext * pb
I/O context.
This structure stores compressed data.
This structure contains the data a format has to probe a file.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
enum AVStreamParseType need_parsing
int stale
Auth ok, but needs to be resent with a new nonce.
int auth_type
The currently chosen auth type.
uint64_t first_rtcp_ntp_time
int(* parse_sdp_a_line)(AVFormatContext *s, int st_index, PayloadContext *priv_data, const char *line)
Parse the a= line from the sdp field.
void(* close)(PayloadContext *protocol_data)
Free any data needed by the rtp parsing for this dynamic data.
int(* init)(AVFormatContext *s, int st_index, PayloadContext *priv_data)
Initialize dynamic protocol handler, called after the full rtpmap line is parsed, may be null.
char addr[128]
Source-specific multicast include source IP address (from SDP content)
Private data for the RTSP demuxer.
RTSPMessageHeader * header
Last stored reply message from the RTSP server.
char real_challenge[64]
the "RealChallenge1:" field from the server
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.
int timeout
copy of RTSPMessageHeader->timeout, i.e.
struct RTSPState::@252032344213367267171314033051017303322026071151 tls_opts
Options used for TLS based RTSP streams.
int accept_dynamic_rate
Whether the server accepts the x-Dynamic-Rate header.
HTTPAuthState auth_state
authentication state
int64_t stimeout
timeout of socket i/o operations.
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 RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
struct RTSPState::@211246031337226306262152230103102050134060150124 stored_msg
Stored message context This is used to store the last reply marked to be stored with ff_rtsp_send_cmd...
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.
int pending_packet
Indicates if a packet is pending to be read (useful for interleaved reads)
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.
unsigned char * body
Last stored reply message body from the RTSP server.
int rtsp_flags
Various option flags for the RTSP muxer/demuxer.
int expected_seq
Sequence number of the reply to be stored -1 if we are not waiting to store any message.
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.
enum RTSPClientState state
indicator of whether we are currently receiving data from the server.
int seq
RTSP command sequence number.
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...
const char * protocol_whitelist
const char * protocol_blacklist
#define av_malloc_array(a, b)
static AVDictionary * opts
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
#define FF_TLS_CLIENT_OPTIONS(pstruct, options_field)
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
unbuffered private I/O API
static int ffurl_write(URLContext *h, const uint8_t *buf, int size)
Write size bytes from buf to the resource accessed by h.
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)