55 #define POLL_TIMEOUT_MS 100
56 #define READ_PACKET_TIMEOUT_S 10
57 #define MAX_TIMEOUTS READ_PACKET_TIMEOUT_S * 1000 / POLL_TIMEOUT_MS
58 #define SDP_MAX_SIZE 16384
59 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
60 #define DEFAULT_REORDERING_DELAY 100000
62 #define OFFSET(x) offsetof(RTSPState, x)
63 #define DEC AV_OPT_FLAG_DECODING_PARAM
64 #define ENC AV_OPT_FLAG_ENCODING_PARAM
66 #define RTSP_FLAG_OPTS(name, longname) \
67 { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \
68 { "filter_src", "only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {.i64 = RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" }
70 #define RTSP_MEDIATYPE_OPTS(name, longname) \
71 { name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { .i64 = (1 << (AVMEDIA_TYPE_SUBTITLE+1)) - 1 }, INT_MIN, INT_MAX, DEC, "allowed_media_types" }, \
72 { "video", "Video", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_VIDEO}, 0, 0, DEC, "allowed_media_types" }, \
73 { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, "allowed_media_types" }, \
74 { "data", "Data", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, "allowed_media_types" }, \
75 { "subtitle", "Subtitle", 0, AV_OPT_TYPE_CONST, {.i64 = 1 << AVMEDIA_TYPE_SUBTITLE}, 0, 0, DEC, "allowed_media_types" }
77 #define COMMON_OPTS() \
78 { "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 }, \
79 { "buffer_size", "Underlying protocol send/receive buffer size", OFFSET(buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, DEC|ENC } \
83 {
"initial_pause",
"do not start playing the stream immediately",
OFFSET(initial_pause),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
DEC },
85 {
"rtsp_transport",
"set RTSP transport protocols",
OFFSET(lower_transport_mask),
AV_OPT_TYPE_FLAGS, {.i64 = 0}, INT_MIN, INT_MAX,
DEC|
ENC,
"rtsp_transport" }, \
92 {
"prefer_tcp",
"try RTP via TCP first, if available", 0,
AV_OPT_TYPE_CONST, {.i64 =
RTSP_FLAG_PREFER_TCP}, 0, 0,
DEC|
ENC,
"rtsp_flags" },
96 {
"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 },
97 {
"stimeout",
"set timeout (in microseconds) of socket TCP I/O operations",
OFFSET(stimeout),
AV_OPT_TYPE_INT, {.i64 = 0}, INT_MIN, INT_MAX,
DEC },
131 const char *sep,
const char **pp)
139 while (!strchr(sep, *p) && *p !=
'\0') {
140 if ((q - buf) < buf_size - 1)
152 if (**pp ==
'/') (*pp)++;
200 memcpy(sock, ai->ai_addr,
FFMIN(
sizeof(*sock), ai->ai_addrlen));
246 int payload_type,
const char *p)
268 init_rtp_handler(handler, rtsp_st, st);
278 if (desc && desc->
name)
311 finalize_rtp_handler_init(s, rtsp_st, st);
319 char *
value,
int value_size)
334 typedef struct SDPParseState {
339 int nb_default_include_source_addrs;
340 struct RTSPSource **default_include_source_addrs;
341 int nb_default_exclude_source_addrs;
342 struct RTSPSource **default_exclude_source_addrs;
345 char delayed_fmtp[2048];
348 static void copy_default_source_addrs(
struct RTSPSource **addrs,
int count,
353 for (i = 0; i <
count; i++) {
355 rtsp_src2 =
av_malloc(
sizeof(*rtsp_src2));
358 memcpy(rtsp_src2, rtsp_src,
sizeof(*rtsp_src));
364 int payload_type,
const char *
line)
380 int letter,
const char *buf)
383 char buf1[64], st_type[64];
396 if (s1->skip_media && letter !=
'm')
401 if (strcmp(buf1,
"IN") != 0)
404 if (strcmp(buf1,
"IP4") && strcmp(buf1,
"IP6"))
416 s1->default_ip = sdp_ip;
417 s1->default_ttl = ttl;
439 get_word(st_type,
sizeof(st_type), &p);
440 if (!strcmp(st_type,
"audio")) {
442 }
else if (!strcmp(st_type,
"video")) {
444 }
else if (!strcmp(st_type,
"application")) {
446 }
else if (!strcmp(st_type,
"text")) {
459 rtsp_st->
sdp_ip = s1->default_ip;
460 rtsp_st->
sdp_ttl = s1->default_ttl;
462 copy_default_source_addrs(s1->default_include_source_addrs,
463 s1->nb_default_include_source_addrs,
466 copy_default_source_addrs(s1->default_exclude_source_addrs,
467 s1->nb_default_exclude_source_addrs,
475 if (!strcmp(buf1,
"udp"))
477 else if (strstr(buf1,
"/AVPF") || strstr(buf1,
"/SAVPF"))
487 if (CONFIG_RTPDEC && !rt->
ts)
493 init_rtp_handler(handler, rtsp_st,
NULL);
494 finalize_rtp_handler_init(s, rtsp_st,
NULL);
517 init_rtp_handler(handler, rtsp_st, st);
518 finalize_rtp_handler_init(s, rtsp_st, st);
530 if (!strncmp(p,
"rtsp://", 7))
541 if (proto[0] ==
'\0') {
555 payload_type = atoi(buf1);
559 sdp_parse_rtpmap(s, st, rtsp_st, payload_type, p);
563 parse_fmtp(s, rt, payload_type, s1->delayed_fmtp);
569 payload_type = atoi(buf1);
570 if (s1->seen_rtpmap) {
574 av_strlcpy(s1->delayed_fmtp, buf,
sizeof(s1->delayed_fmtp));
579 rtsp_st->
ssrc = strtoll(buf1,
NULL, 10);
599 }
else if (
av_strstart(p,
"IsRealDataType:integer;",&p)) {
602 }
else if (
av_strstart(p,
"SampleRate:integer;", &p) &&
617 if (strcmp(buf1,
"incl") && strcmp(buf1,
"excl"))
619 exclude = !strcmp(buf1,
"excl");
622 if (strcmp(buf1,
"IN") != 0)
625 if (strcmp(buf1,
"IP4") && strcmp(buf1,
"IP6") && strcmp(buf1,
"*"))
637 dynarray_add(&s1->default_exclude_source_addrs, &s1->nb_default_exclude_source_addrs, rtsp_src);
644 dynarray_add(&s1->default_include_source_addrs, &s1->nb_default_include_source_addrs, rtsp_src);
685 SDPParseState sdp_parse_state = { { 0 } }, *s1 = &sdp_parse_state;
699 while (*p !=
'\n' && *p !=
'\r' && *p !=
'\0') {
700 if ((q - buf) <
sizeof(buf) - 1)
705 sdp_parse_line(s, s1, letter, buf);
707 while (*p !=
'\n' && *p !=
'\0')
713 for (i = 0; i < s1->nb_default_include_source_addrs; i++)
714 av_freep(&s1->default_include_source_addrs[i]);
715 av_freep(&s1->default_include_source_addrs);
716 for (i = 0; i < s1->nb_default_exclude_source_addrs; i++)
717 av_freep(&s1->default_exclude_source_addrs[i]);
718 av_freep(&s1->default_exclude_source_addrs);
740 if (CONFIG_RTSP_MUXER && rtpctx->
pb && send_packets)
790 if (CONFIG_RTPDEC && rt->
ts)
801 if (reordering_queue_size < 0) {
803 reordering_queue_size = 0;
814 if (CONFIG_RTSP_MUXER && s->
oformat && st) {
830 else if (CONFIG_RTPDEC)
833 reordering_queue_size);
855 #if CONFIG_RTSP_DEMUXER || CONFIG_RTSP_MUXER
856 static void rtsp_parse_range(
int *min_ptr,
int *max_ptr,
const char **pp)
864 v = strtol(q, &p, 10);
868 v = strtol(p, &p, 10);
881 char transport_protocol[16];
883 char lower_transport[16];
897 get_word_sep(transport_protocol,
sizeof(transport_protocol),
901 lower_transport[0] =
'\0';
908 }
else if (!
av_strcasecmp (transport_protocol,
"x-pn-tng") ||
911 get_word_sep(lower_transport,
sizeof(lower_transport),
"/;,", &p);
916 lower_transport[0] =
'\0';
932 while (*p !=
'\0' && *p !=
',') {
934 if (!strcmp(parameter,
"port")) {
939 }
else if (!strcmp(parameter,
"client_port")) {
945 }
else if (!strcmp(parameter,
"server_port")) {
951 }
else if (!strcmp(parameter,
"interleaved")) {
957 }
else if (!strcmp(parameter,
"multicast")) {
960 }
else if (!strcmp(parameter,
"ttl")) {
964 th->
ttl = strtol(p, &end, 10);
967 }
else if (!strcmp(parameter,
"destination")) {
973 }
else if (!strcmp(parameter,
"source")) {
979 }
else if (!strcmp(parameter,
"mode")) {
983 if (!strcmp(buf,
"record") ||
984 !strcmp(buf,
"receive"))
989 while (*p !=
';' && *p !=
'\0' && *p !=
',')
1003 static void handle_rtp_info(
RTSPState *rt,
const char *url,
1004 uint32_t seq, uint32_t rtptime)
1007 if (!rtptime || !url[0])
1023 static void rtsp_parse_rtp_info(
RTSPState *rt,
const char *p)
1026 char key[20], value[1024], url[1024] =
"";
1027 uint32_t seq = 0, rtptime = 0;
1039 if (!strcmp(key,
"url"))
1041 else if (!strcmp(key,
"seq"))
1042 seq = strtoul(value,
NULL, 10);
1043 else if (!strcmp(key,
"rtptime"))
1044 rtptime = strtoul(value,
NULL, 10);
1046 handle_rtp_info(rt, url, seq, rtptime);
1055 handle_rtp_info(rt, url, seq, rtptime);
1070 (t = strtol(p,
NULL, 10)) > 0) {
1076 rtsp_parse_transport(s, reply, p);
1078 reply->
seq = strtol(p,
NULL, 10);
1093 }
else if (
av_stristart(p,
"WWW-Authenticate:", &p) && rt) {
1096 }
else if (
av_stristart(p,
"Authentication-Info:", &p) && rt) {
1099 }
else if (
av_stristart(p,
"Content-Base:", &p) && rt) {
1101 if (method && !strcmp(method,
"DESCRIBE"))
1105 if (method && !strcmp(method,
"PLAY"))
1106 rtsp_parse_rtp_info(rt, p);
1108 if (strstr(p,
"GET_PARAMETER") &&
1109 method && !strcmp(method,
"OPTIONS"))
1111 }
else if (
av_stristart(p,
"x-Accept-Dynamic-Rate:", &p) && rt) {
1137 if (len1 >
sizeof(buf))
1147 unsigned char **content_ptr,
1148 int return_on_interleaved_data,
const char *method)
1151 char buf[4096], buf1[1024], *q;
1154 int ret, content_length, line_count = 0, request = 0;
1155 unsigned char *content =
NULL;
1161 memset(reply, 0,
sizeof(*reply));
1174 if (ch ==
'$' && q == buf) {
1175 if (return_on_interleaved_data) {
1179 }
else if (ch !=
'\r') {
1180 if ((q - buf) <
sizeof(buf) - 1)
1192 if (line_count == 0) {
1195 if (!strncmp(buf1,
"RTSP/", 5)) {
1216 if (content_length > 0) {
1218 content =
av_malloc(content_length + 1);
1222 content[content_length] =
'\0';
1225 *content_ptr = content;
1232 const char* ptr =
buf;
1234 if (!strcmp(reply->
reason,
"OPTIONS")) {
1235 snprintf(buf,
sizeof(buf),
"RTSP/1.0 200 OK\r\n");
1242 snprintf(buf,
sizeof(buf),
"RTSP/1.0 501 Not Implemented\r\n");
1267 if (rt->
seq != reply->
seq) {
1273 if (reply->
notice == 2101 ||
1275 reply->
notice == 2306 ) {
1277 }
else if (reply->
notice >= 4400 && reply->
notice < 5500) {
1279 }
else if (reply->
notice == 2401 ||
1300 const char *method,
const char *url,
1301 const char *headers,
1302 const unsigned char *send_content,
1303 int send_content_length)
1306 char buf[4096], *out_buf;
1312 snprintf(buf,
sizeof(buf),
"%s %s RTSP/1.0\r\n", method, url);
1317 if (rt->
session_id[0] !=
'\0' && (!headers ||
1318 !strstr(headers,
"\nIf-Match:"))) {
1323 rt->
auth, url, method);
1328 if (send_content_length > 0 && send_content)
1329 av_strlcatf(buf,
sizeof(buf),
"Content-Length: %d\r\n", send_content_length);
1335 out_buf = base64buf;
1341 if (send_content_length > 0 && send_content) {
1354 const char *url,
const char *headers)
1356 return rtsp_send_cmd_with_content_async(s, method, url, headers,
NULL, 0);
1361 unsigned char **content_ptr)
1364 content_ptr,
NULL, 0);
1368 const char *method,
const char *url,
1371 unsigned char **content_ptr,
1372 const unsigned char *send_content,
1373 int send_content_length)
1377 int ret, attempts = 0;
1381 if ((ret = rtsp_send_cmd_with_content_async(s, method, url, header,
1383 send_content_length)))
1407 int lower_transport,
const char *real_challenge)
1410 int rtx = 0, j, i, err,
interleave = 0, port_off;
1414 const char *trans_pref;
1417 trans_pref =
"x-pn-tng";
1419 trans_pref =
"RAW/RAW";
1421 trans_pref =
"RTP/AVP";
1431 port_off -= port_off & 0x01;
1433 for (j = rt->
rtp_port_min + port_off, i = 0; i < rt->nb_rtsp_streams; ++i) {
1434 char transport[2048];
1470 while (j <= rt->rtp_port_max) {
1474 "?localport=%d", j);
1492 snprintf(transport,
sizeof(transport) - 1,
1493 "%s/UDP;", trans_pref);
1495 av_strlcat(transport,
"unicast;",
sizeof(transport));
1497 "client_port=%d", port);
1500 av_strlcatf(transport,
sizeof(transport),
"-%d", port + 1);
1513 snprintf(transport,
sizeof(transport) - 1,
1514 "%s/TCP;", trans_pref);
1516 av_strlcat(transport,
"unicast;",
sizeof(transport));
1518 "interleaved=%d-%d",
1519 interleave, interleave + 1);
1524 snprintf(transport,
sizeof(transport) - 1,
1525 "%s/UDP;multicast", trans_pref);
1528 av_strlcat(transport,
";mode=record",
sizeof(transport));
1531 av_strlcat(transport,
";mode=play",
sizeof(transport));
1533 "Transport: %s\r\n",
1536 av_strlcat(cmd,
"x-Dynamic-Rate: 0\r\n",
sizeof(cmd));
1538 char real_res[41], real_csum[9];
1543 "RealChallenge2: %s, sd=%s\r\n",
1583 char url[1024],
options[30] =
"";
1584 const char *peer = host;
1587 av_strlcpy(options,
"?connect=1",
sizeof(options));
1601 char url[1024], namebuf[50], optbuf[20] =
"";
1615 snprintf(optbuf,
sizeof(optbuf),
"?ttl=%d", ttl);
1616 getnameinfo((
struct sockaddr*) &addr,
sizeof(addr),
1619 port,
"%s", optbuf);
1657 char proto[128], host[1024], path[1024];
1658 char tcpname[1024], cmd[2048], auth[128];
1659 const char *lower_rtsp_proto =
"tcp";
1660 int port, err, tcp_fd;
1662 int lower_transport_mask = 0;
1664 char real_challenge[64] =
"";
1666 socklen_t peer_len =
sizeof(peer);
1692 host,
sizeof(host), &port, path,
sizeof(path), s->
filename);
1694 if (!strcmp(proto,
"rtsps")) {
1695 lower_rtsp_proto =
"tls";
1704 port = default_port;
1708 if (!lower_transport_mask)
1717 "only UDP and TCP are supported for output.\n");
1727 host, port,
"%s", path);
1731 char httpname[1024];
1732 char sessioncookie[17];
1735 ff_url_join(httpname,
sizeof(httpname),
"http", auth, host, port,
"%s", path);
1736 snprintf(sessioncookie,
sizeof(sessioncookie),
"%08x%08x",
1748 "x-sessioncookie: %s\r\n"
1749 "Accept: application/x-rtsp-tunnelled\r\n"
1750 "Pragma: no-cache\r\n"
1751 "Cache-Control: no-cache\r\n",
1778 "x-sessioncookie: %s\r\n"
1779 "Content-Type: application/x-rtsp-tunnelled\r\n"
1780 "Pragma: no-cache\r\n"
1781 "Cache-Control: no-cache\r\n"
1782 "Content-Length: 32767\r\n"
1783 "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n",
1831 if (!getpeername(tcp_fd, (
struct sockaddr*) &peer, &peer_len)) {
1832 getnameinfo((
struct sockaddr*) &peer, peer_len, host,
sizeof(host),
1851 "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7\r\n"
1852 "PlayerStarttime: [28/03/2003:22:50:23 00:00]\r\n"
1853 "CompanyID: KnKV4M4I/B2FjJ1TToLycw==\r\n"
1854 "GUID: 00000000-0000-0000-0000-000000000000\r\n",
1873 if (CONFIG_RTSP_DEMUXER && s->
iformat)
1875 else if (CONFIG_RTSP_MUXER)
1883 int lower_transport =
ff_log2_tab[lower_transport_mask &
1884 ~(lower_transport_mask - 1)];
1892 real_challenge :
NULL);
1895 lower_transport_mask &= ~(1 << lower_transport);
1896 if (lower_transport_mask == 0 && err == 1) {
1897 err =
AVERROR(EPROTONOSUPPORT);
1925 uint8_t *buf,
int buf_size, int64_t wait_end)
1929 int n, i, ret, tcp_fd, timeout_cnt = 0;
1931 struct pollfd *p = rt->
p;
1932 int *fds =
NULL, fdsnum, fdsidx;
1942 p[max_p].fd = tcp_fd;
1943 p[max_p++].events = POLLIN;
1957 "Number of fds %d not supported\n", fdsnum);
1960 for (fdsidx = 0; fdsidx < fdsnum; fdsidx++) {
1961 p[max_p].fd = fds[fdsidx];
1962 p[max_p++].events = POLLIN;
1969 int j = 1 - (tcp_fd == -1);
1974 if (p[j].revents & POLLIN || p[j+1].revents & POLLIN) {
1977 *prtsp_st = rtsp_st;
1984 #if CONFIG_RTSP_DEMUXER
1985 if (tcp_fd != -1 && p[0].revents & POLLIN) {
1992 "Unable to answer to TEARDOWN\n");
2008 }
else if (n < 0 && errno != EINTR)
2040 "Unable to pick stream for packet - SSRC not known for "
2062 int64_t wait_end = 0;
2073 }
else if (CONFIG_RTPDEC && rt->
ts) {
2084 }
else if (ret == 1) {
2093 int64_t first_queue_time = 0;
2100 if (queue_time && (queue_time - first_queue_time < 0 ||
2101 !first_queue_time)) {
2102 first_queue_time = queue_time;
2106 if (first_queue_time) {
2107 wait_end = first_queue_time + s->
max_delay;
2110 first_queue_st =
NULL;
2123 #if CONFIG_RTSP_DEMUXER
2140 len = pick_stream(s, &rtsp_st, rt->
recvbuf, len);
2145 if (len ==
AVERROR(EAGAIN) && first_queue_st &&
2148 "max delay reached. need to consume packet\n");
2149 rtsp_st = first_queue_st;
2185 if (rtpctx2 && st && st2 &&
2214 }
else if (CONFIG_RTPDEC && rt->
ts) {
2240 #if CONFIG_SDP_DEMUXER
2246 while (p < p_end && *p !=
'\0') {
2247 if (
sizeof(
"c=IN IP") - 1 < p_end - p &&
2251 while (p < p_end - 1 && *p !=
'\n') p++;
2260 static void append_source_addrs(
char *buf,
int size,
const char *
name,
2266 av_strlcatf(buf, size,
"&%s=%s", name, addrs[0]->addr);
2267 for (i = 1; i <
count; i++)
2297 content[
size] =
'\0';
2322 "?localport=%d&ttl=%d&connect=%d&write_to_source=%d",
2327 append_source_addrs(url,
sizeof(url),
"sources",
2330 append_source_addrs(url,
sizeof(url),
"block",
2360 static const AVClass sdp_demuxer_class = {
2375 .priv_class = &sdp_demuxer_class,
2379 #if CONFIG_RTP_DEMUXER
2390 char host[500], sdp[500];
2397 socklen_t addrlen =
sizeof(addr);
2409 ret =
ffurl_read(in, recvbuf,
sizeof(recvbuf));
2419 if ((recvbuf[0] & 0xc0) != 0x80) {
2428 payload_type = recvbuf[1] & 0x7f;
2443 "without an SDP file describing it\n",
2449 "properly you need an SDP file "
2457 "v=0\r\nc=IN IP%d %s\r\nm=%s %d RTP/AVP %d\r\n",
2458 addr.ss_family == AF_INET ? 4 : 6, host,
2461 port, payload_type);
2473 ret = sdp_read_header(s);
2485 static const AVClass rtp_demuxer_class = {
2501 .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.
int rtp_port_min
Minimum and maximum local UDP ports.
int ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
Parse a Windows Media Server-specific SDP line.
void ff_rtp_parse_set_crypto(RTPDemuxContext *s, const char *suite, const char *params)
Realmedia Data Transport.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int ff_rtp_get_local_rtp_port(URLContext *h)
Return the local rtp port used by the RTP connection.
int64_t start_time_realtime
Start time of the stream in real world time, in microseconds since the Unix epoch (00:00 1st January ...
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. ...
#define RTP_MAX_PACKET_LENGTH
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
char source[INET6_ADDRSTRLEN+1]
source IP address
HTTPAuthType
Authentication types, ordered from weakest to strongest.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
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
struct pollfd * p
Polling array for udp.
int ff_rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
Open RTSP transport context.
MpegTSContext * avpriv_mpegts_parse_open(AVFormatContext *s)
int ffurl_connect(URLContext *uc, AVDictionary **options)
Connect an URLContext that has been allocated by ffurl_alloc.
static int parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
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
char * user_agent
User-Agent string.
#define AVIO_FLAG_WRITE
write-only
int mode_record
transport set to record data
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
#define RTSP_FLAG_RTCP_TO_SOURCE
Send RTCP packets to the source address of received packets.
#define RTSP_RTP_PORT_MAX
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int nb_include_source_addrs
Number of source-specific multicast include source IP addresses (from SDP content) ...
int ctx_flags
Flags signalling stream properties.
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
#define RTSP_FLAG_LISTEN
Wait for incoming connections.
char session_id[512]
copy of RTSPMessageHeader->session_id, i.e.
int auth_type
The currently chosen auth type.
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...
This struct describes the properties of an encoded stream.
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.
RTPDemuxContext * ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_type, int queue_size)
open a new RTP parse context for stream 'st'.
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.
int ff_rtsp_connect(AVFormatContext *s)
Connect to the RTSP server and set up the individual media streams.
Standards-compliant RTP-server.
int reordering_queue_size
Size of RTP packet reordering queue.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define RTSP_FLAG_PREFER_TCP
Try RTP via TCP first if possible.
uint64_t first_rtcp_ntp_time
#define av_assert0(cond)
assert() equivalent, that is always enabled.
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.
#define RTSP_MAX_TRANSPORTS
Opaque data information usually continuous.
int ttl
time-to-live value (required for multicast); the amount of HOPs that packets will be allowed to make ...
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...
static int get_sockaddr(AVFormatContext *s, const char *buf, struct sockaddr_storage *sock)
int ff_network_init(void)
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
miscellaneous OS support macros and functions.
int feedback
Enable sending RTCP feedback messages according to RFC 4585.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
static av_cold int end(AVCodecContext *avctx)
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
#define DEFAULT_REORDERING_DELAY
static void handler(vbi_event *ev, void *user_data)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int ff_rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size)
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_RB32
AVStream ** streams
A list of all streams in the file.
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...
int ff_rtp_get_codec_info(AVCodecParameters *par, int payload_type)
Initialize a codec context based on the payload type.
Describe a single stream, as identified by a single m= line block in the SDP content.
Custom IO - not a public option for lower_transport_mask, but set in the SDP demuxer based on a flag...
char * protocol_whitelist
',' separated list of allowed protocols.
void(* close)(PayloadContext *protocol_data)
Free any data needed by the rtp parsing for this dynamic data.
#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.
#define AV_LOG_VERBOSE
Detailed information.
static av_cold int read_close(AVFormatContext *ctx)
static const uint8_t header[24]
int ff_rtsp_parse_streaming_commands(AVFormatContext *s)
Parse RTSP commands (OPTIONS, PAUSE and TEARDOWN) during streaming in listen mode.
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.
const OptionDef options[]
static int ff_rtsp_averror(enum RTSPStatusCode status_code, int default_averror)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void ff_rtsp_parse_line(AVFormatContext *s, RTSPMessageHeader *reply, const char *buf, RTSPState *rt, const char *method)
struct AVOutputFormat * oformat
The output container format.
#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...
struct RTSPSource ** exclude_source_addrs
Source-specific multicast exclude source IP addresses (from SDP content)
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...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
Return the file descriptors associated with this URL.
int timeout
copy of RTSPMessageHeader->timeout, i.e.
const char * protocol_whitelist
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
const AVOption ff_rtsp_options[]
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
enum AVMediaType codec_type
General type of the encoded data.
simple assert() macros that are a bit more flexible than ISO C assert().
enum RTSPControlTransport control_transport
RTSP transport mode, such as plain or tunneled.
struct RTSPSource ** include_source_addrs
Source-specific multicast include source IP addresses (from SDP content)
int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
char * av_base64_encode(char *out, int out_size, const uint8_t *in, int in_size)
Encode data to base64 and null-terminate.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
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
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int stream_index
corresponding stream index, if any.
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
Number of elements in AVFormatContext.streams.
#define RTSP_FLAG_CUSTOM_IO
Do all IO via the AVIOContext.
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 av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_BASE64_SIZE(x)
Calculate the output size needed to base64-encode x bytes to a null-terminated string.
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)
Locale-independent case-insensitive compare.
GLsizei GLboolean const GLfloat * value
#define RTSP_TCP_MAX_PACKET_SIZE
enum AVStreamParseType need_parsing
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)
int ff_rtsp_tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st)
Send buffered packets over TCP.
static void get_word(char *buf, int buf_size, const char **pp)
Usually treated as AVMEDIA_TYPE_DATA.
int(* parse_sdp_a_line)(AVFormatContext *s, int st_index, PayloadContext *priv_data, const char *line)
Parse the a= line from the sdp field.
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.
struct MpegTSContext * ts
The following are used for parsing raw mpegts in udp.
int stale
Auth ok, but needs to be resent with a new nonce.
const uint8_t ff_log2_tab[256]
int sdp_payload_type
payload type
void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, RTPDynamicProtocolHandler *handler)
int nb_exclude_source_addrs
Number of source-specific multicast exclude source IP addresses (from SDP content) ...
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static int read_header(FFV1Context *f)
int ff_rtp_send_rtcp_feedback(RTPDemuxContext *s, URLContext *fd, AVIOContext *avio)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
enum RTSPLowerTransport lower_transport
the negotiated network layer transport protocol; e.g.
char addr[128]
Source-specific multicast include source IP address (from SDP content)
#define AV_LOG_INFO
Standard information.
struct sockaddr_storage sdp_ip
IP address (from SDP content)
char * av_strdup(const char *s)
Duplicate a string.
void ff_rtsp_undo_setup(AVFormatContext *s, int send_packets)
Undo the effect of ff_rtsp_make_setup_request, close the transport_priv and rtp_handle fields...
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
AVIOContext * pb
I/O context.
int media_type_mask
Mask of all requested media types.
#define FF_RTP_FLAG_OPTS(ctx, fieldname)
#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.
uint32_t ssrc
SSRC for this stream, to allow identifying RTCP packets before the first RTP packet.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
#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.
#define RTSPS_DEFAULT_PORT
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 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.
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.
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.
int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
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.
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...
const char * name
Name of the codec described by this descriptor.
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)
static void interleave(short *output, short **input, int channels, int samples)
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...
#define RTP_PT_IS_RTCP(x)
This struct describes the properties of a single codec described by an AVCodecID. ...
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
enum RTSPServerType server_type
brand of server that we're talking to; e.g.
int ffurl_close(URLContext *h)
int64_t start_time
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 sample_rate
Audio only.
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[]
int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size, int idx)
static AVDictionary * map_to_opts(RTSPState *rt)
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 need_subscription
The following are used for Real stream selection.
RTPDynamicProtocolHandler * dynamic_handler
The following are used for dynamic protocols (rtpdec_*.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...
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_YASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
struct AVInputFormat * iformat
The input container format.
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...
int stimeout
timeout of socket i/o operations.
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
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.
char * protocol_blacklist
',' separated list of disallowed protocols.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int lower_transport_mask
A mask with all requested transport methods.
unbuffered private I/O API
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
AVCodecParameters * codecpar
#define av_malloc_array(a, b)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
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
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...
void avpriv_mpegts_parse_close(MpegTSContext *ts)
#define RTP_REORDER_QUEUE_DEFAULT_SIZE
int interleaved_min
interleave IDs; copies of RTSPTransportField->interleaved_min/max for the selected transport...
This structure stores compressed data.
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 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...