Go to the documentation of this file.
48 #define BUFFER_SIZE MAX_URL_SIZE
49 #define MAX_REDIRECTS 8
53 #define WHITESPACES " \n\t\r"
80 #if FF_API_HTTP_USER_AGENT
81 char *user_agent_deprecated;
112 z_stream inflate_stream;
131 #define OFFSET(x) offsetof(HTTPContext, x)
132 #define D AV_OPT_FLAG_DECODING_PARAM
133 #define E AV_OPT_FLAG_ENCODING_PARAM
134 #define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
137 {
"seekable",
"control seekability of connection",
OFFSET(seekable),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
D },
138 {
"chunked_post",
"use chunked transfer-encoding for posts",
OFFSET(chunked_post),
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1,
E },
144 #if FF_API_HTTP_USER_AGENT
147 {
"multiple_requests",
"use persistent connections",
OFFSET(multiple_requests),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
D |
E },
151 {
"cookies",
"set cookies to be sent in applicable future requests, use newline delimited Set-Cookie HTTP field value syntax",
OFFSET(cookies),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, 0,
D },
157 {
"none",
"No auth method set, autodetect", 0,
AV_OPT_TYPE_CONST, { .i64 =
HTTP_AUTH_NONE }, 0, 0,
D |
E,
"auth_type"},
159 {
"send_expect_100",
"Force sending an Expect: 100-continue header for POST",
OFFSET(send_expect_100),
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1,
E },
162 {
"end_offset",
"try to limit the request to bytes preceding this offset",
OFFSET(end_off),
AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX,
D },
163 {
"method",
"Override the HTTP method or set the expected HTTP method from a client",
OFFSET(method),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, 0,
D |
E },
164 {
"reconnect",
"auto reconnect after disconnect before EOF",
OFFSET(reconnect),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
D },
165 {
"reconnect_at_eof",
"auto reconnect at EOF",
OFFSET(reconnect_at_eof),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
D },
166 {
"reconnect_streamed",
"auto reconnect streamed / non seekable streams",
OFFSET(reconnect_streamed),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
D },
167 {
"reconnect_delay_max",
"max reconnect delay in seconds after which to give up",
OFFSET(reconnect_delay_max),
AV_OPT_TYPE_INT, { .i64 = 120 }, 0, UINT_MAX/1000/1000,
D },
170 {
"reply_code",
"The http status code to return to a client",
OFFSET(reply_code),
AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599,
E},
175 const char *hoststr,
const char *auth,
176 const char *proxyauth,
int *new_location);
192 const char *path, *proxy_path, *lower_proto =
"tcp", *local_path;
193 char hostname[1024], hoststr[1024], proto[10];
194 char auth[1024], proxyauth[1024] =
"";
197 int port, use_proxy, err, location_changed = 0;
201 hostname,
sizeof(hostname), &port,
202 path1,
sizeof(path1),
s->location);
205 proxy_path =
s->http_proxy ?
s->http_proxy : getenv(
"http_proxy");
209 if (!strcmp(proto,
"https")) {
218 if (path1[0] ==
'\0')
230 hostname,
sizeof(hostname), &port,
NULL, 0, proxy_path);
238 h->protocol_whitelist,
h->protocol_blacklist,
h);
244 auth, proxyauth, &location_changed);
248 return location_changed;
256 int location_changed, attempts = 0, redirects = 0;
260 cur_auth_type =
s->auth_state.auth_type;
261 cur_proxy_auth_type =
s->auth_state.auth_type;
264 if (location_changed < 0)
268 if (
s->http_code == 401) {
276 if (
s->http_code == 407) {
277 if ((cur_proxy_auth_type ==
HTTP_AUTH_NONE ||
s->proxy_auth_state.stale) &&
284 if ((
s->http_code == 301 ||
s->http_code == 302 ||
285 s->http_code == 303 ||
s->http_code == 307) &&
286 location_changed == 1) {
293 memset(&
s->auth_state, 0,
sizeof(
s->auth_state));
295 location_changed = 0;
303 if (location_changed < 0)
304 return location_changed;
313 char hostname1[1024], hostname2[1024], proto1[10], proto2[10];
317 !(!strcmp(
h->prot->name,
"http") ||
318 !strcmp(
h->prot->name,
"https")))
322 hostname1,
sizeof(hostname1), &port1,
323 NULL, 0,
s->location);
325 hostname2,
sizeof(hostname2), &port2,
327 if (port1 != port2 || strncmp(hostname1, hostname2,
sizeof(hostname2)) != 0) {
328 av_log(
h,
AV_LOG_ERROR,
"Cannot reuse HTTP connection for different host: %s:%d != %s:%d\n",
335 if (!
s->end_chunked_post) {
344 s->end_chunked_post = 0;
347 s->icy_data_read = 0;
361 switch (status_code) {
368 if (status_code >= 400 && status_code <= 499)
370 else if (status_code >= 500)
373 return default_averror;
378 int ret,
body = 0, reply_code, message_len;
379 const char *reply_text, *content_type;
382 content_type =
"text/plain";
386 switch (status_code) {
390 reply_text =
"Bad Request";
395 reply_text =
"Forbidden";
400 reply_text =
"Not Found";
405 content_type =
s->content_type ?
s->content_type :
"application/octet-stream";
410 reply_text =
"Internal server error";
418 "HTTP/1.1 %03d %s\r\n"
419 "Content-Type: %s\r\n"
427 strlen(reply_text) + 6,
428 s->headers ?
s->headers :
"",
434 "HTTP/1.1 %03d %s\r\n"
435 "Content-Type: %s\r\n"
436 "Transfer-Encoding: chunked\r\n"
442 s->headers ?
s->headers :
"");
458 int ret, err, new_location;
461 switch (
ch->handshake_step) {
469 ch->is_connected_server = 1;
496 char hostname[1024], proto[10];
498 const char *lower_proto =
"tcp";
500 av_url_split(proto,
sizeof(proto),
NULL, 0, hostname,
sizeof(hostname), &port,
502 if (!strcmp(proto,
"https"))
504 ff_url_join(lower_url,
sizeof(lower_url), lower_proto,
NULL, hostname, port,
510 h->protocol_whitelist,
h->protocol_blacklist,
h
529 if(
s->seekable == 1 )
534 s->filesize = UINT64_MAX;
542 int len = strlen(
s->headers);
543 if (
len < 2 || strcmp(
"\r\n",
s->headers +
len - 2)) {
545 "No trailing CRLF found in HTTP header. Adding it.\n");
549 s->headers[
len] =
'\r';
550 s->headers[
len + 1] =
'\n';
551 s->headers[
len + 2] =
'\0';
575 cc = (*c)->priv_data;
591 if (
s->buf_ptr >=
s->buf_end) {
595 }
else if (
len == 0) {
598 s->buf_ptr =
s->buffer;
599 s->buf_end =
s->buffer +
len;
602 return *
s->buf_ptr++;
617 if (q >
line && q[-1] ==
'\r')
623 if ((q -
line) < line_size - 1)
634 if (http_code >= 400 && http_code < 600 &&
636 (http_code != 407 ||
s->proxy_auth_state.auth_type !=
HTTP_AUTH_NONE)) {
649 new_loc =
av_strdup(redirected_location);
653 s->location = new_loc;
663 if (!strncmp(p,
"bytes ", 6)) {
665 s->off = strtoull(p,
NULL, 10);
666 if ((slash = strchr(p,
'/')) && strlen(slash) > 0)
667 s->filesize = strtoull(slash + 1,
NULL, 10);
669 if (
s->seekable == -1 && (!
s->is_akamai ||
s->filesize != 2147483647))
681 inflateEnd(&
s->inflate_stream);
682 if (inflateInit2(&
s->inflate_stream, 32 + 15) != Z_OK) {
684 s->inflate_stream.msg);
687 if (zlibCompileFlags() & (1 << 17)) {
689 "Your zlib was compiled without gzip support.\n");
694 "Compressed (%s) content, need zlib with gzip support\n", p);
709 int len = 4 + strlen(p) + strlen(
tag);
710 int is_first = !
s->icy_metadata_headers;
715 if (
s->icy_metadata_headers)
716 len += strlen(
s->icy_metadata_headers);
722 *
s->icy_metadata_headers =
'\0';
736 for (
i = 0, j = 0; exp_str[
i] !=
'\0' && j < exp_buf_len;
i++) {
737 if ((exp_str[
i] >=
'0' && exp_str[
i] <=
'9') ||
738 (exp_str[
i] >=
'A' && exp_str[
i] <=
'Z') ||
739 (exp_str[
i] >=
'a' && exp_str[
i] <=
'z')) {
740 exp_buf[j] = exp_str[
i];
748 while ((*expiry < '0' || *expiry >
'9') && *expiry !=
'\0')
756 char *param, *next_param, *cstr, *back;
765 back = &cstr[strlen(cstr)-1];
774 while ((param =
av_strtok(next_param,
";", &next_param))) {
801 if (!cookie_entry || !cookie_entry->
value) {
808 struct tm new_tm = {0};
820 if (e2 && e2->
value) {
824 if (e2 && e2->
value) {
825 struct tm old_tm = {0};
842 if (!(eql = strchr(p,
'=')))
return AVERROR(EINVAL);
862 if (*cookies)
av_free(*cookies);
864 if (!*cookies)
return AVERROR(ENOMEM);
883 if (
line[0] ==
'\0') {
889 if (line_count == 0) {
890 if (
s->is_connected_server) {
899 av_log(
h,
AV_LOG_ERROR,
"Received and expected HTTP method do not match. (%s expected, %s received)\n",
908 "(%s autodetected %s received)\n", auto_method, method);
941 while (*p !=
'/' && *p !=
'\0')
951 s->http_code = strtol(p, &
end, 10);
959 while (*p !=
'\0' && *p !=
':')
974 s->filesize == UINT64_MAX) {
975 s->filesize = strtoull(p,
NULL, 10);
979 !strncmp(p,
"bytes", 5) &&
984 s->filesize = UINT64_MAX;
993 if (!strcmp(p,
"close"))
999 s->is_mediagateway = 1;
1008 s->icy_metaint = strtoull(p,
NULL, 10);
1034 char *cookie, *set_cookies, *next;
1047 while ((cookie =
av_strtok(next,
"\n", &next)) && !
ret) {
1061 if (!cookie_entry || !cookie_entry->
value)
1066 struct tm tm_buf = {0};
1076 int domain_offset = strlen(domain) - strlen(e->
value);
1077 if (domain_offset < 0)
1094 char *
tmp = *cookies;
1124 s->chunksize = UINT64_MAX;
1140 if (
s->seekable == -1 &&
s->is_mediagateway &&
s->filesize == 2000000000)
1151 const char *hoststr,
const char *auth,
1152 const char *proxyauth,
int *new_location)
1157 char *authstr =
NULL, *proxyauthstr =
NULL;
1158 uint64_t off =
s->off;
1161 int send_expect_100 = 0;
1171 s->chunked_post = 0;
1177 method = post ?
"POST" :
"GET";
1180 local_path, method);
1182 local_path, method);
1184 if (post && !
s->post_data) {
1185 if (
s->send_expect_100 != -1) {
1186 send_expect_100 =
s->send_expect_100;
1188 send_expect_100 = 0;
1193 if (auth && *auth &&
1195 s->http_code != 401)
1196 send_expect_100 = 1;
1200 #if FF_API_HTTP_USER_AGENT
1202 s->user_agent =
av_strdup(
s->user_agent_deprecated);
1208 "User-Agent: %s\r\n",
s->user_agent);
1213 "Referer: %s\r\n",
s->referer);
1221 if (!
has_header(
s->headers,
"\r\nRange: ") && !post && (
s->off > 0 ||
s->end_off ||
s->seekable == -1)) {
1223 "Range: bytes=%"PRIu64
"-",
s->off);
1226 "%"PRId64,
s->end_off - 1);
1230 if (send_expect_100 && !
has_header(
s->headers,
"\r\nExpect: "))
1232 "Expect: 100-continue\r\n");
1234 if (!
has_header(
s->headers,
"\r\nConnection: ")) {
1235 if (
s->multiple_requests)
1245 "Host: %s\r\n", hoststr);
1246 if (!
has_header(
s->headers,
"\r\nContent-Length: ") &&
s->post_data)
1248 "Content-Length: %d\r\n",
s->post_datalen);
1250 if (!
has_header(
s->headers,
"\r\nContent-Type: ") &&
s->content_type)
1252 "Content-Type: %s\r\n",
s->content_type);
1253 if (!
has_header(
s->headers,
"\r\nCookie: ") &&
s->cookies) {
1254 char *cookies =
NULL;
1255 if (!
get_cookies(
s, &cookies, path, hoststr) && cookies) {
1257 "Cookie: %s\r\n", cookies);
1261 if (!
has_header(
s->headers,
"\r\nIcy-MetaData: ") &&
s->icy)
1263 "Icy-MetaData: %d\r\n", 1);
1270 "%s %s HTTP/1.1\r\n"
1278 post &&
s->chunked_post ?
"Transfer-Encoding: chunked\r\n" :
"",
1280 authstr ? authstr :
"",
1281 proxyauthstr ?
"Proxy-" :
"", proxyauthstr ? proxyauthstr :
"");
1286 ret >=
sizeof(
s->buffer)) {
1293 if ((err =
ffurl_write(
s->hd,
s->buffer, strlen(
s->buffer))) < 0)
1297 if ((err =
ffurl_write(
s->hd,
s->post_data,
s->post_datalen)) < 0)
1301 s->buf_ptr =
s->buffer;
1302 s->buf_end =
s->buffer;
1305 s->icy_data_read = 0;
1306 s->filesize = UINT64_MAX;
1308 s->end_chunked_post = 0;
1313 if (post && !
s->post_data && !send_expect_100) {
1330 err = (off ==
s->off) ? 0 : -1;
1342 if (
s->chunksize != UINT64_MAX) {
1346 if (!
s->chunksize) {
1355 s->chunksize = strtoull(
line,
NULL, 16);
1358 "Chunked encoding data size: %"PRIu64
"\n",
1361 if (!
s->chunksize &&
s->multiple_requests) {
1366 else if (!
s->chunksize) {
1371 else if (
s->chunksize == UINT64_MAX) {
1381 len =
s->buf_end -
s->buf_ptr;
1388 uint64_t target_end =
s->end_off ?
s->end_off :
s->filesize;
1389 if ((!
s->willclose ||
s->chunksize == UINT64_MAX) &&
s->off >= target_end)
1392 if (!
len && (!
s->willclose ||
s->chunksize == UINT64_MAX) &&
s->off < target_end) {
1394 "Stream ends prematurely at %"PRIu64
", should be %"PRIu64
"\n",
1402 if (
s->chunksize > 0 &&
s->chunksize != UINT64_MAX) {
1404 s->chunksize -=
len;
1411 #define DECOMPRESS_BUF_SIZE (256 * 1024)
1417 if (!
s->inflate_buffer) {
1418 s->inflate_buffer =
av_malloc(DECOMPRESS_BUF_SIZE);
1419 if (!
s->inflate_buffer)
1423 if (
s->inflate_stream.avail_in == 0) {
1427 s->inflate_stream.next_in =
s->inflate_buffer;
1428 s->inflate_stream.avail_in = read;
1431 s->inflate_stream.avail_out =
size;
1432 s->inflate_stream.next_out =
buf;
1435 if (
ret != Z_OK &&
ret != Z_STREAM_END)
1437 ret,
s->inflate_stream.msg);
1439 return size -
s->inflate_stream.avail_out;
1448 int err, new_location, read_ret;
1450 int reconnect_delay = 0;
1455 if (
s->end_chunked_post && !
s->end_header) {
1463 return http_buf_read_compressed(
h,
buf,
size);
1466 while (read_ret < 0) {
1467 uint64_t target =
h->is_streamed ? 0 :
s->off;
1472 if (
h->is_streamed && !
s->reconnect_streamed)
1475 if (!(
s->reconnect &&
s->filesize > 0 &&
s->off <
s->filesize) &&
1479 if (reconnect_delay >
s->reconnect_delay_max)
1484 if (err !=
AVERROR(ETIMEDOUT))
1486 reconnect_delay = 1 + 2*reconnect_delay;
1488 if (seek_ret >= 0 && seek_ret != target) {
1504 while (pos <
size) {
1547 if (
s->icy_metaint <
s->icy_data_read)
1549 remaining =
s->icy_metaint -
s->icy_data_read;
1561 char data[255 * 16 + 1];
1572 s->icy_data_read = 0;
1573 remaining =
s->icy_metaint;
1583 if (
s->icy_metaint > 0) {
1591 s->icy_data_read +=
size;
1600 char crlf[] =
"\r\n";
1603 if (!
s->chunked_post) {
1625 char footer[] =
"0\r\n\r\n";
1640 if (read_ret < 0 && read_ret !=
AVERROR(EAGAIN)) {
1645 s->end_chunked_post = 1;
1657 inflateEnd(&
s->inflate_stream);
1661 if (
s->hd && !
s->end_chunked_post)
1675 uint64_t old_off =
s->off;
1677 int old_buf_size,
ret;
1682 else if (!force_reconnect &&
1683 ((whence == SEEK_CUR && off == 0) ||
1684 (whence == SEEK_SET && off ==
s->off)))
1686 else if ((
s->filesize == UINT64_MAX && whence == SEEK_END))
1689 if (whence == SEEK_CUR)
1691 else if (whence == SEEK_END)
1693 else if (whence != SEEK_SET)
1699 if (
s->off &&
h->is_streamed)
1703 if (
s->end_off ||
s->filesize != UINT64_MAX) {
1704 uint64_t end_pos =
s->end_off ?
s->end_off :
s->filesize;
1705 if (
s->off >= end_pos)
1710 old_buf_size =
s->buf_end -
s->buf_ptr;
1711 memcpy(old_buf,
s->buf_ptr, old_buf_size);
1717 memcpy(
s->buffer, old_buf, old_buf_size);
1718 s->buf_ptr =
s->buffer;
1719 s->buf_end =
s->buffer + old_buf_size;
1746 #define HTTP_CLASS(flavor) \
1747 static const AVClass flavor ## _context_class = { \
1748 .class_name = # flavor, \
1749 .item_name = av_default_item_name, \
1750 .option = options, \
1751 .version = LIBAVUTIL_VERSION_INT, \
1754 #if CONFIG_HTTP_PROTOCOL
1770 .priv_data_class = &http_context_class,
1772 .default_whitelist =
"http,https,tls,rtp,tcp,udp,crypto,httpproxy"
1776 #if CONFIG_HTTPS_PROTOCOL
1790 .priv_data_class = &https_context_class,
1792 .default_whitelist =
"http,https,tls,rtp,tcp,udp,crypto,httpproxy"
1796 #if CONFIG_HTTPPROXY_PROTOCOL
1808 char hostname[1024], hoststr[1024];
1809 char auth[1024], pathbuf[1024], *path;
1810 char lower_url[100];
1811 int port,
ret = 0, attempts = 0;
1816 if(
s->seekable == 1 )
1821 av_url_split(
NULL, 0, auth,
sizeof(auth), hostname,
sizeof(hostname), &port,
1822 pathbuf,
sizeof(pathbuf), uri);
1828 ff_url_join(lower_url,
sizeof(lower_url),
"tcp",
NULL, hostname, port,
1832 &
h->interrupt_callback,
NULL,
1833 h->protocol_whitelist,
h->protocol_blacklist,
h);
1840 "CONNECT %s HTTP/1.1\r\n"
1842 "Connection: close\r\n"
1847 authstr ?
"Proxy-" :
"", authstr ? authstr :
"");
1853 s->buf_ptr =
s->buffer;
1854 s->buf_end =
s->buffer;
1856 s->filesize = UINT64_MAX;
1857 cur_auth_type =
s->proxy_auth_state.auth_type;
1873 if (
s->http_code == 407 &&
1880 if (
s->http_code < 400)
1885 http_proxy_close(
h);
1896 .
name =
"httpproxy",
1897 .url_open = http_proxy_open,
1899 .url_write = http_proxy_write,
1900 .url_close = http_proxy_close,
@ HTTP_AUTH_BASIC
HTTP 1.0 Basic auth from RFC 1945 (also in RFC 2617)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int http_open_cnx(URLContext *h, AVDictionary **options)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read.
static int http_write_reply(URLContext *h, int status_code)
#define URL_PROTOCOL_FLAG_NETWORK
#define AVERROR_HTTP_OTHER_4XX
static int parse_icy(HTTPContext *s, const char *tag, const char *p)
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
#define AVERROR_EOF
End of file.
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
static int http_listen(URLContext *h, const char *uri, int flags, AVDictionary **options)
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_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), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { 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) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;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)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&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);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=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) { int planes=out->planar ? out->ch_count :1;unsigned m=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){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
char * av_asprintf(const char *fmt,...)
int seekable
Control seekability, 0 = disable, 1 = enable, -1 = probe.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace.
static av_cold int end(AVCodecContext *avctx)
static int http_read(URLContext *h, uint8_t *buf, int size)
static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int force_reconnect)
#define AVERROR_HTTP_SERVER_ERROR
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#define AV_LOG_VERBOSE
Detailed information.
static int http_get_line(HTTPContext *s, char *line, int line_size)
int ffurl_close(URLContext *h)
AVDictionary * chained_options
static int parse_location(HTTPContext *s, const char *p)
static int http_read_stream(URLContext *h, uint8_t *buf, int size)
char * ff_http_auth_create_response(HTTPAuthState *state, const char *auth, const char *path, const char *method)
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
const URLProtocol ff_httpproxy_protocol
#define AVERROR_HTTP_UNAUTHORIZED
static int get_cookies(HTTPContext *s, char **cookies, const char *path, const char *domain)
Create a string containing cookie values for use as a HTTP cookie header field value for a particular...
@ AV_OPT_TYPE_BINARY
offset must point to a pointer immediately followed by an int for the length
static int check_http_code(URLContext *h, int http_code, const char *end)
#define DEFAULT_USER_AGENT
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord, int maxc)
static int cookie_string(AVDictionary *dict, char **cookies)
static int has_header(const char *str, const char *header)
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t value.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static int process_line(URLContext *h, char *line, int line_count, int *new_location)
static int http_connect(URLContext *h, const char *path, const char *local_path, const char *hoststr, const char *auth, const char *proxyauth, int *new_location)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AVERROR_HTTP_NOT_FOUND
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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.
char * cookies
holds newline ( ) delimited Set-Cookie header field values (without the "Set-Cookie: " field name)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AVIO_FLAG_WRITE
write-only
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
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.
static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
static int http_read_header(URLContext *h, int *new_location)
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value)
static int parse_content_encoding(URLContext *h, const char *p)
static void handle_http_errors(URLContext *h, int error)
unsigned char buffer[BUFFER_SIZE]
int ff_http_do_new_request(URLContext *h, const char *uri)
Send a new HTTP request, reusing the old connection.
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s.
static int http_read_stream_all(URLContext *h, uint8_t *buf, int size)
Describe the class of an AVClass context structure.
static int http_get_short_seek(URLContext *h)
void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
Initialize the authentication state based on another HTTP URLContext.
HTTPAuthState proxy_auth_state
static int http_buf_read(URLContext *h, uint8_t *buf, int size)
static int http_shutdown(URLContext *h, int flags)
static void parse_content_range(URLContext *h, const char *p)
#define AVERROR_HTTP_BAD_REQUEST
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static void error(const char *err)
HTTP Authentication state structure.
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i http
int ff_http_averror(int status_code, int default_averror)
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
static int http_write(URLContext *h, const uint8_t *buf, int size)
const char const char void * val
static const uint8_t header[24]
#define HTTP_HEADERS_SIZE
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
char * icy_metadata_packet
const URLProtocol ff_http_protocol
static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
#define AV_LOG_INFO
Standard information.
static void update_metadata(URLContext *h, char *data)
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL.
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...
static int http_handshake(URLContext *c)
@ HTTP_AUTH_NONE
No authentication specified.
static int http_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
#define i(width, name, range_min, range_max)
int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
Waits for up to 'timeout' microseconds.
static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
static int64_t http_seek(URLContext *h, int64_t off, int whence)
static const AVOption options[]
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
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.
static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
FFmpeg currently uses a custom build this text attempts to document some of its obscure features and options Makefile the full command issued by make and its output will be shown on the screen DBG Preprocess x86 external assembler files to a dbg asm file in the object which then gets compiled Helps in developing those assembler files DESTDIR Destination directory for the install useful to prepare packages or install FFmpeg in cross environments GEN Set to ‘1’ to generate the missing or mismatched references Makefile builds all the libraries and the executables fate Run the fate test note that you must have installed it fate list List all fate regression test targets install Install headers
static int http_close(URLContext *h)
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
HandshakeState handshake_step
const URLProtocol ff_https_protocol
AVIOInterruptCB interrupt_callback
void ff_make_absolute_url(char *buf, int size, const char *base, const char *rel)
Convert a relative url into an absolute url, given a base url.
AVDictionary * cookie_dict
char * av_small_strptime(const char *p, const char *fmt, struct tm *dt)
Simplified version of strptime.
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
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.
#define AVERROR_HTTP_FORBIDDEN
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
#define HTTP_CLASS(flavor)
static int http_get_file_handle(URLContext *h)
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the and we are assuming vf_foobar is as well We are also assuming vf_foobar is not an edge detector so you can update the boilerplate with your credits Doxy Next chunk is the Doxygen about the file See https
int64_t av_gettime(void)
Get the current time in microseconds.
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.
HTTPAuthType
Authentication types, ordered from weakest to strongest.
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client.
#define AVIO_FLAG_NONBLOCK
Use non-blocking mode.
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_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static int http_getc(HTTPContext *s)
static int http_accept(URLContext *s, URLContext **c)
#define flags(name, subs,...)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
char * icy_metadata_headers
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string.
static int store_icy(URLContext *h, int size)
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function.
#define AV_OPT_FLAG_DEPRECATED
set if option is deprecated, users should refer to AVOption.help text for more information