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;
 
  130 #define OFFSET(x) offsetof(HTTPContext, x) 
  131 #define D AV_OPT_FLAG_DECODING_PARAM 
  132 #define E AV_OPT_FLAG_ENCODING_PARAM 
  133 #define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION) 
  136     { 
"seekable", 
"control seekability of connection", 
OFFSET(seekable), 
AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, 
D },
 
  137     { 
"chunked_post", 
"use chunked transfer-encoding for posts", 
OFFSET(chunked_post), 
AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, 
E },
 
  139     { 
"headers", 
"set custom HTTP headers, can override built in default headers", 
OFFSET(headers), 
AV_OPT_TYPE_STRING, { .str = 
NULL }, 0, 0, 
D | 
E },
 
  143 #if FF_API_HTTP_USER_AGENT 
  146     { 
"multiple_requests", 
"use persistent connections", 
OFFSET(multiple_requests), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
D | 
E },
 
  150     { 
"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 },
 
  156     { 
"none", 
"No auth method set, autodetect", 0, 
AV_OPT_TYPE_CONST, { .i64 = 
HTTP_AUTH_NONE }, 0, 0, 
D | 
E, 
"auth_type"},
 
  158     { 
"send_expect_100", 
"Force sending an Expect: 100-continue header for POST", 
OFFSET(send_expect_100), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
E },
 
  161     { 
"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 },
 
  162     { 
"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 },
 
  163     { 
"reconnect", 
"auto reconnect after disconnect before EOF", 
OFFSET(reconnect), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
D },
 
  164     { 
"reconnect_at_eof", 
"auto reconnect at EOF", 
OFFSET(reconnect_at_eof), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
D },
 
  165     { 
"reconnect_streamed", 
"auto reconnect streamed / non seekable streams", 
OFFSET(reconnect_streamed), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, 
D },
 
  166     { 
"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 },
 
  169     { 
"reply_code", 
"The http status code to return to a client", 
OFFSET(reply_code), 
AV_OPT_TYPE_INT, { .i64 = 200}, INT_MIN, 599, 
E},
 
  174                         const char *hoststr, 
const char *auth,
 
  175                         const char *proxyauth, 
int *new_location);
 
  191     const char *path, *proxy_path, *lower_proto = 
"tcp", *local_path;
 
  192     char hostname[1024], hoststr[1024], proto[10];
 
  193     char auth[1024], proxyauth[1024] = 
"";
 
  196     int port, use_proxy, err, location_changed = 0;
 
  200                  hostname, 
sizeof(hostname), &port,
 
  208     if (!strcmp(proto, 
"https")) {
 
  217     if (path1[0] == 
'\0')
 
  229                      hostname, 
sizeof(hostname), &port, 
NULL, 0, proxy_path);
 
  243                        auth, proxyauth, &location_changed);
 
  247     return location_changed;
 
  255     int location_changed, attempts = 0, redirects = 0;
 
  263     if (location_changed < 0)
 
  285         location_changed == 1) {
 
  294         location_changed = 0;
 
  302     if (location_changed < 0)
 
  303         return location_changed;
 
  312     char hostname1[1024], hostname2[1024], proto1[10], proto2[10];
 
  321                  hostname1, 
sizeof(hostname1), &port1,
 
  324                  hostname2, 
sizeof(hostname2), &port2,
 
  326     if (port1 != port2 || strncmp(hostname1, hostname2, 
sizeof(hostname2)) != 0) {
 
  327         av_log(h, 
AV_LOG_ERROR, 
"Cannot reuse HTTP connection for different host: %s:%d != %s:%d\n",
 
  360     switch (status_code) {
 
  367     if (status_code >= 400 && status_code <= 499)
 
  369     else if (status_code >= 500)
 
  372         return default_averror;
 
  377     int ret, 
body = 0, reply_code, message_len;
 
  378     const char *reply_text, *content_type;
 
  381     content_type = 
"text/plain";
 
  385     switch (status_code) {
 
  389         reply_text = 
"Bad Request";
 
  394         reply_text = 
"Forbidden";
 
  399         reply_text = 
"Not Found";
 
  409         reply_text = 
"Internal server error";
 
  416         message_len = 
snprintf(message, 
sizeof(message),
 
  417                  "HTTP/1.1 %03d %s\r\n" 
  418                  "Content-Type: %s\r\n" 
  426                  strlen(reply_text) + 6, 
 
  432         message_len = 
snprintf(message, 
sizeof(message),
 
  433                  "HTTP/1.1 %03d %s\r\n" 
  434                  "Content-Type: %s\r\n" 
  435                  "Transfer-Encoding: chunked\r\n" 
  457     int ret, err, new_location;
 
  495     char hostname[1024], proto[10];
 
  497     const char *lower_proto = 
"tcp";
 
  499     av_url_split(proto, 
sizeof(proto), 
NULL, 0, hostname, 
sizeof(hostname), &port,
 
  501     if (!strcmp(proto, 
"https"))
 
  503     ff_url_join(lower_url, 
sizeof(lower_url), lower_proto, 
NULL, hostname, port,
 
  542         if (len < 2 || strcmp(
"\r\n", s->
headers + len - 2)) {
 
  544                    "No trailing CRLF found in HTTP header.\n");
 
  574     cc = (*c)->priv_data;
 
  594         } 
else if (len == 0) {
 
  616             if (q > line && q[-1] == 
'\r')
 
  622             if ((q - line) < line_size - 1)
 
  633     if (http_code >= 400 && http_code < 600 &&
 
  648     new_loc = 
av_strdup(redirected_location);
 
  662     if (!strncmp(p, 
"bytes ", 6)) {
 
  664         s->
off = strtoull(p, 
NULL, 10);
 
  665         if ((slash = strchr(p, 
'/')) && strlen(slash) > 0)
 
  680         inflateEnd(&s->inflate_stream);
 
  681         if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) {
 
  683                    s->inflate_stream.msg);
 
  686         if (zlibCompileFlags() & (1 << 17)) {
 
  688                    "Your zlib was compiled without gzip support.\n");
 
  693                "Compressed (%s) content, need zlib with gzip support\n", p);
 
  708     int len = 4 + strlen(p) + strlen(tag);
 
  735     for (i = 0, j = 0; exp_str[i] != 
'\0' && j < exp_buf_len; i++) {
 
  736         if ((exp_str[i] >= 
'0' && exp_str[i] <= 
'9') ||
 
  737             (exp_str[i] >= 
'A' && exp_str[i] <= 
'Z') ||
 
  738             (exp_str[i] >= 
'a' && exp_str[i] <= 
'z')) {
 
  739             exp_buf[j] = exp_str[i];
 
  747     while ((*expiry < '0' || *expiry > 
'9') && *expiry != 
'\0')
 
  755     char *param, *next_param, *cstr, *back;
 
  764     back = &cstr[strlen(cstr)-1];
 
  773     while ((param = 
av_strtok(next_param, 
";", &next_param))) {
 
  776         if ((name = 
av_strtok(param, 
"=", &value))) {
 
  800     if (!cookie_entry || !cookie_entry->
value) {
 
  807         struct tm new_tm = {0};
 
  819             if (e2 && e2->
value) {
 
  823                     if (e2 && e2->
value) {
 
  824                         struct tm old_tm = {0};
 
  841     if (!(eql = strchr(p, 
'='))) 
return AVERROR(EINVAL);
 
  857         len += strlen(e->
key) + strlen(e->
value) + 1;
 
  861     if (*cookies) 
av_free(*cookies);
 
  863     if (!*cookies) 
return AVERROR(ENOMEM);
 
  882     if (line[0] == 
'\0') {
 
  888     if (line_count == 0) {
 
  898                     av_log(h, 
AV_LOG_ERROR, 
"Received and expected HTTP method do not match. (%s expected, %s received)\n",
 
  907                            "(%s autodetected %s received)\n", auto_method, method);
 
  940             while (*p != 
'/' && *p != 
'\0')
 
  958         while (*p != 
'\0' && *p != 
':')
 
  978                    !strncmp(p, 
"bytes", 5) &&
 
  992             if (!strcmp(p, 
"close"))
 
 1034     if (!set_cookies) 
return AVERROR(EINVAL);
 
 1040     while ((cookie = 
av_strtok(next, 
"\n", &next))) {
 
 1054         if (!cookie_entry || !cookie_entry->
value) {
 
 1061             struct tm tm_buf = {0};
 
 1073             int domain_offset = strlen(domain) - strlen(e->
value);
 
 1074             if (domain_offset < 0) {
 
 1100             char *
tmp = *cookies;
 
 1101             size_t str_size = strlen(cookie_entry->
key) + strlen(cookie_entry->
value) + strlen(*cookies) + 4;
 
 1102             if (!(*cookies = 
av_malloc(str_size))) {
 
 1107             snprintf(*cookies, str_size, 
"%s; %s=%s", tmp, cookie_entry->
key, cookie_entry->
value);
 
 1158                         const char *hoststr, 
const char *auth,
 
 1159                         const char *proxyauth, 
int *new_location)
 
 1164     char *authstr = 
NULL, *proxyauthstr = 
NULL;
 
 1165     uint64_t off = s->
off;
 
 1168     int send_expect_100 = 0;
 
 1184         method = post ? 
"POST" : 
"GET";
 
 1187                                                 local_path, method);
 
 1189                                                 local_path, method);
 
 1196         if (auth && *auth &&
 
 1199             send_expect_100 = 1;
 
 1202 #if FF_API_HTTP_USER_AGENT 
 1204         av_log(s, 
AV_LOG_WARNING, 
"the user-agent option is deprecated, please use user_agent option\n");
 
 1210         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1215             len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1216                                "Referer: %s\r\n", s->
referer);
 
 1219         len += 
av_strlcpy(headers + len, 
"Accept: */*\r\n",
 
 1220                           sizeof(headers) - len);
 
 1225         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1226                            "Range: bytes=%"PRIu64
"-", s->
off);
 
 1228             len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1231                           sizeof(headers) - len);
 
 1234         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1235                            "Expect: 100-continue\r\n");
 
 1239             len += 
av_strlcpy(headers + len, 
"Connection: keep-alive\r\n",
 
 1240                               sizeof(headers) - len);
 
 1242             len += 
av_strlcpy(headers + len, 
"Connection: close\r\n",
 
 1243                               sizeof(headers) - len);
 
 1247         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1248                            "Host: %s\r\n", hoststr);
 
 1250         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1254         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1257         char *cookies = 
NULL;
 
 1258         if (!
get_cookies(s, &cookies, path, hoststr) && cookies) {
 
 1259             len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1260                                "Cookie: %s\r\n", cookies);
 
 1265         len += 
av_strlcatf(headers + len, 
sizeof(headers) - len,
 
 1266                            "Icy-MetaData: %d\r\n", 1);
 
 1273              "%s %s HTTP/1.1\r\n" 
 1281              post && s->
chunked_post ? 
"Transfer-Encoding: chunked\r\n" : 
"",
 
 1283              authstr ? authstr : 
"",
 
 1284              proxyauthstr ? 
"Proxy-" : 
"", proxyauthstr ? proxyauthstr : 
"");
 
 1288     if (strlen(headers) + 1 == 
sizeof(headers) ||
 
 1289         ret >= 
sizeof(s->
buffer)) {
 
 1316     if (post && !s->
post_data && !send_expect_100) {
 
 1333     err = (off == s->
off) ? 0 : -1;
 
 1361                    "Chunked encoding data size: %"PRIu64
"\n",
 
 1397                    "Stream ends prematurely at %"PRIu64
", should be %"PRIu64
"\n",
 
 1414 #define DECOMPRESS_BUF_SIZE (256 * 1024) 
 1420     if (!s->inflate_buffer) {
 
 1421         s->inflate_buffer = 
av_malloc(DECOMPRESS_BUF_SIZE);
 
 1422         if (!s->inflate_buffer)
 
 1426     if (s->inflate_stream.avail_in == 0) {
 
 1427         int read = 
http_buf_read(h, s->inflate_buffer, DECOMPRESS_BUF_SIZE);
 
 1430         s->inflate_stream.next_in  = s->inflate_buffer;
 
 1431         s->inflate_stream.avail_in = read;
 
 1434     s->inflate_stream.avail_out = 
size;
 
 1435     s->inflate_stream.next_out  = 
buf;
 
 1437     ret = 
inflate(&s->inflate_stream, Z_SYNC_FLUSH);
 
 1438     if (ret != Z_OK && ret != Z_STREAM_END)
 
 1440                ret, s->inflate_stream.msg);
 
 1442     return size - s->inflate_stream.avail_out;
 
 1451     int err, new_location, read_ret;
 
 1453     int reconnect_delay = 0;
 
 1466         return http_buf_read_compressed(h, buf, size);
 
 1469     while (read_ret < 0) {
 
 1487         if (err != 
AVERROR(ETIMEDOUT))
 
 1489         reconnect_delay = 1 + 2*reconnect_delay;
 
 1491         if (seek_ret >= 0 && seek_ret != target) {
 
 1507     while (pos < size) {
 
 1525         val = strstr(key, 
"='");
 
 1528         end = strstr(val, 
"';");
 
 1562             char data[255 * 16 + 1];
 
 1569             if ((ret = 
av_opt_set(s, 
"icy_metadata_packet", data, 0)) < 0)
 
 1577     return FFMIN(size, remaining);
 
 1601     char crlf[] = 
"\r\n";
 
 1613         snprintf(temp, 
sizeof(temp), 
"%x\r\n", size);
 
 1626     char footer[] = 
"0\r\n\r\n";
 
 1633         ret = ret > 0 ? 0 : ret;
 
 1646     inflateEnd(&s->inflate_stream);
 
 1664     uint64_t old_off = s->
off;
 
 1666     int old_buf_size, ret;
 
 1671     else if (!force_reconnect &&
 
 1672              ((whence == SEEK_CUR && off == 0) ||
 
 1673               (whence == SEEK_SET && off == s->
off)))
 
 1675     else if ((s->
filesize == UINT64_MAX && whence == SEEK_END))
 
 1678     if (whence == SEEK_CUR)
 
 1680     else if (whence == SEEK_END)
 
 1682     else if (whence != SEEK_SET)
 
 1693     memcpy(old_buf, s->
buf_ptr, old_buf_size);
 
 1699         memcpy(s->
buffer, old_buf, old_buf_size);
 
 1728 #define HTTP_CLASS(flavor)                          \ 
 1729 static const AVClass flavor ## _context_class = {   \ 
 1730     .class_name = # flavor,                         \ 
 1731     .item_name  = av_default_item_name,             \ 
 1732     .option     = options,                          \ 
 1733     .version    = LIBAVUTIL_VERSION_INT,            \ 
 1736 #if CONFIG_HTTP_PROTOCOL 
 1752     .priv_data_class     = &http_context_class,
 
 1754     .default_whitelist   = 
"http,https,tls,rtp,tcp,udp,crypto,httpproxy" 
 1758 #if CONFIG_HTTPS_PROTOCOL 
 1772     .priv_data_class     = &https_context_class,
 
 1774     .default_whitelist   = 
"http,https,tls,rtp,tcp,udp,crypto,httpproxy" 
 1778 #if CONFIG_HTTPPROXY_PROTOCOL 
 1790     char hostname[1024], hoststr[1024];
 
 1791     char auth[1024], pathbuf[1024], *path;
 
 1792     char lower_url[100];
 
 1793     int port, ret = 0, attempts = 0;
 
 1803     av_url_split(
NULL, 0, auth, 
sizeof(auth), hostname, 
sizeof(hostname), &port,
 
 1804                  pathbuf, 
sizeof(pathbuf), uri);
 
 1810     ff_url_join(lower_url, 
sizeof(lower_url), 
"tcp", 
NULL, hostname, port,
 
 1822              "CONNECT %s HTTP/1.1\r\n" 
 1824              "Connection: close\r\n" 
 1829              authstr ? 
"Proxy-" : 
"", authstr ? authstr : 
"");
 
 1867     http_proxy_close(h);
 
 1878     .
name                = 
"httpproxy",
 
 1879     .url_open            = http_proxy_open,
 
 1881     .url_write           = http_proxy_write,
 
 1882     .url_close           = http_proxy_close,
 
static int http_get_line(HTTPContext *s, char *line, int line_size)
 
time_t av_timegm(struct tm *tm)
Convert the decomposed UTC time in tm to a time_t 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 void parse_content_range(URLContext *h, const char *p)
 
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)
 
const char const char void * val
 
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. 
 
#define AVERROR_INVALIDDATA
Invalid data found when processing input. 
 
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 URL_PROTOCOL_FLAG_NETWORK
 
ptrdiff_t const GLvoid * data
 
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller. 
 
HTTPAuthType
Authentication types, ordered from weakest to strongest. 
 
#define AV_LOG_WARNING
Something somehow does not look correct. 
 
static int http_close(URLContext *h)
 
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h. 
 
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle...
 
int is_streamed
true if streamed (no seek possible), default = false 
 
AVIOInterruptCB interrupt_callback
 
HTTPAuthState proxy_auth_state
 
#define AVIO_FLAG_READ
read-only 
 
char * icy_metadata_headers
 
static av_const int av_isspace(int c)
Locale-independent conversion of ASCII isspace. 
 
const URLProtocol ff_http_protocol
 
#define AVIO_FLAG_WRITE
write-only 
 
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare. 
 
#define AVERROR_HTTP_NOT_FOUND
 
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another. 
 
static int http_listen(URLContext *h, const char *uri, int flags, AVDictionary **options)
 
static int http_getc(HTTPContext *s)
 
HTTP Authentication state structure. 
 
int auth_type
The currently chosen auth type. 
 
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() or another memory allocation function...
 
static int parse_cookie(HTTPContext *s, const char *p, AVDictionary **cookies)
 
#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. 
 
static int http_get_file_handle(URLContext *h)
 
static int http_buf_read(URLContext *h, uint8_t *buf, int size)
 
int ff_http_averror(int status_code, int default_averror)
 
miscellaneous OS support macros and functions. 
 
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development. 
 
static int http_read_header(URLContext *h, int *new_location)
 
static av_cold int end(AVCodecContext *avctx)
 
#define HTTP_HEADERS_SIZE
 
static int http_open_cnx(URLContext *h, AVDictionary **options)
 
char * av_small_strptime(const char *p, const char *fmt, struct tm *dt)
Simplified version of strptime. 
 
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key. 
 
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
 
#define DEFAULT_USER_AGENT
 
#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. 
 
HTTP 1.0 Basic auth from RFC 1945 (also in RFC 2617) 
 
static const uint8_t header[24]
 
static int http_open_cnx_internal(URLContext *h, AVDictionary **options)
 
static void update_metadata(HTTPContext *s, char *data)
 
static void body(uint32_t ABCD[4], const uint8_t *src, int nblocks)
 
static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int force_reconnect)
 
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. 
 
const char * protocol_whitelist
 
static int http_write(URLContext *h, const uint8_t *buf, int size)
 
static const AVOption options[]
 
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers. 
 
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
 
static int http_handshake(URLContext *c)
 
simple assert() macros that are a bit more flexible than ISO C assert(). 
 
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. 
 
AVDictionary * chained_options
 
#define AVERROR_HTTP_SERVER_ERROR
 
char * av_asprintf(const char *fmt,...)
 
static int store_icy(URLContext *h, int size)
 
#define AVERROR_HTTP_UNAUTHORIZED
 
char * icy_metadata_packet
 
int ffurl_get_short_seek(URLContext *h)
Return the current short seek threshold value for this URL. 
 
static int http_get_short_seek(URLContext *h)
 
const URLProtocol ff_httpproxy_protocol
 
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare. 
 
GLsizei GLboolean const GLfloat * value
 
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
 
int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
Waits for up to 'timeout' microseconds. 
 
int ffurl_handshake(URLContext *c)
Perform one step of the protocol handshake to accept a new client. 
 
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
 
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL. 
 
int ffurl_accept(URLContext *s, URLContext **c)
Accept an URLContext c on an URLContext s. 
 
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted. 
 
AVDictionary * cookie_dict
 
static void error(const char *err)
 
int stale
Auth ok, but needs to be resent with a new nonce. 
 
offset must point to a pointer immediately followed by an int for the length 
 
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it. 
 
int64_t av_gettime(void)
Get the current time in microseconds. 
 
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
 
static int http_read(URLContext *h, uint8_t *buf, int size)
 
#define AV_LOG_INFO
Standard information. 
 
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer. 
 
char * av_strdup(const char *s)
Duplicate a string. 
 
const char * protocol_blacklist
 
HandshakeState handshake_step
 
int seekable
Control seekability, 0 = disable, 1 = enable, -1 = probe. 
 
#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. 
 
unsigned char buffer[BUFFER_SIZE]
 
Describe the class of an AVClass context structure. 
 
#define AVERROR_HTTP_OTHER_4XX
 
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
 
char * ff_http_auth_create_response(HTTPAuthState *state, const char *auth, const char *path, const char *method)
 
static int has_header(const char *str, const char *header)
 
#define AVERROR_HTTP_FORBIDDEN
 
int ffurl_close(URLContext *h)
 
static int process_line(URLContext *h, char *line, int line_count, int *new_location)
 
int ff_http_do_new_request(URLContext *h, const char *uri)
Send a new HTTP request, reusing the old connection. 
 
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 av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str. 
 
char * cookies
holds newline ( ) delimited Set-Cookie header field values (without the "Set-Cookie: " field name) ...
 
static int parse_content_encoding(URLContext *h, const char *p)
 
const struct URLProtocol * prot
 
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...
 
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...
 
char * filename
specified URL 
 
static int http_open(URLContext *h, const char *uri, int flags, AVDictionary **options)
 
#define AVSEEK_SIZE
ORing this as the "whence" parameter to a seek function causes it to return the filesize without seek...
 
void ff_http_auth_handle_header(HTTPAuthState *state, const char *key, const char *value)
 
static int cookie_string(AVDictionary *dict, char **cookies)
 
const URLProtocol ff_https_protocol
 
static int parse_location(HTTPContext *s, const char *p)
 
static int http_shutdown(URLContext *h, int flags)
 
static int http_write_reply(URLContext *h, int status_code)
 
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read. 
 
#define AVERROR_HTTP_BAD_REQUEST
 
static int parse_icy(HTTPContext *s, const char *tag, const char *p)
 
static int parse_set_cookie_expiry_time(const char *exp_str, struct tm *buf)
 
static int http_read_stream(URLContext *h, uint8_t *buf, int size)
 
static int http_read_stream_all(URLContext *h, uint8_t *buf, int size)
 
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string. 
 
unbuffered private I/O API 
 
static void handle_http_errors(URLContext *h, int error)
 
static int parse_set_cookie(const char *set_cookie, AVDictionary **dict)
 
static int64_t http_seek(URLContext *h, int64_t off, int whence)
 
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 
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...
 
char * av_strndup(const char *s, size_t len)
Duplicate a substring of a string. 
 
static int http_accept(URLContext *s, URLContext **c)
 
#define HTTP_CLASS(flavor)
 
No authentication specified. 
 
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_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);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
 
static int check_http_code(URLContext *h, int http_code, const char *end)