MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / http_read_stream

Function http_read_stream

libavformat/http.c:1825–1901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1823static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int force_reconnect);
1824
1825static int http_read_stream(URLContext *h, uint8_t *buf, int size)
1826{
1827 HTTPContext *s = h->priv_data;
1828 int err, read_ret;
1829 int64_t seek_ret;
1830 int reconnect_delay = 0;
1831 int reconnect_delay_total = 0;
1832 int conn_attempts = 1;
1833
1834 if (!s->hd)
1835 return AVERROR_EOF;
1836
1837 if (s->end_chunked_post && !s->end_header) {
1838 err = http_read_header(h);
1839 if (err < 0)
1840 return err;
1841 }
1842
1843#if CONFIG_ZLIB
1844 if (s->compressed)
1845 return http_buf_read_compressed(h, buf, size);
1846#endif /* CONFIG_ZLIB */
1847
1848retry:
1849 read_ret = http_buf_read(h, buf, size);
1850 while (read_ret < 0) {
1851 uint64_t target = h->is_streamed ? 0 : s->off;
1852 bool is_premature = s->filesize > 0 && s->off < s->filesize;
1853
1854 if (read_ret == AVERROR_EXIT)
1855 break;
1856 else if (read_ret == AVERROR(EAGAIN)) {
1857 /* send new request for more data on existing connection */
1858 AVDictionary *options = NULL;
1859 if (s->willclose)
1860 ffurl_closep(&s->hd);
1861 s->initial_requests = 0; /* continue streaming uninterrupted from now on */
1862 read_ret = http_open_cnx(h, &options);
1863 av_dict_free(&options);
1864 if (read_ret == 0)
1865 goto retry;
1866 }
1867
1868 if (h->is_streamed && !s->reconnect_streamed)
1869 break;
1870
1871 if (!(s->reconnect && is_premature) &&
1872 !(s->reconnect_at_eof && read_ret == AVERROR_EOF)) {
1873 if (is_premature)
1874 return AVERROR(EIO);
1875 else
1876 break;
1877 }
1878
1879 if (reconnect_delay > s->reconnect_delay_max || (s->reconnect_max_retries >= 0 && conn_attempts > s->reconnect_max_retries) ||
1880 reconnect_delay_total > s->reconnect_delay_total_max)
1881 return AVERROR(EIO);
1882

Callers 2

http_read_stream_allFunction · 0.85
http_readFunction · 0.85

Calls 9

http_read_headerFunction · 0.85
http_buf_read_compressedFunction · 0.85
http_buf_readFunction · 0.85
ffurl_closepFunction · 0.85
http_open_cnxFunction · 0.85
av_dict_freeFunction · 0.85
av_logFunction · 0.85
http_seek_internalFunction · 0.85

Tested by

no test coverage detected