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

Function store_icy

libavformat/http.c:1945–1981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1943}
1944
1945static int store_icy(URLContext *h, int size)
1946{
1947 HTTPContext *s = h->priv_data;
1948 /* until next metadata packet */
1949 uint64_t remaining;
1950
1951 if (s->icy_metaint < s->icy_data_read)
1952 return AVERROR_INVALIDDATA;
1953 remaining = s->icy_metaint - s->icy_data_read;
1954
1955 if (!remaining) {
1956 /* The metadata packet is variable sized. It has a 1 byte header
1957 * which sets the length of the packet (divided by 16). If it's 0,
1958 * the metadata doesn't change. After the packet, icy_metaint bytes
1959 * of normal data follows. */
1960 uint8_t ch;
1961 int len = http_read_stream_all(h, &ch, 1);
1962 if (len < 0)
1963 return len;
1964 if (ch > 0) {
1965 char data[255 * 16 + 1];
1966 int ret;
1967 len = ch * 16;
1968 ret = http_read_stream_all(h, data, len);
1969 if (ret < 0)
1970 return ret;
1971 data[len] = 0;
1972 if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0)
1973 return ret;
1974 update_metadata(h, data);
1975 }
1976 s->icy_data_read = 0;
1977 remaining = s->icy_metaint;
1978 }
1979
1980 return FFMIN(size, remaining);
1981}
1982
1983static int http_read(URLContext *h, uint8_t *buf, int size)
1984{

Callers 1

http_readFunction · 0.85

Calls 3

http_read_stream_allFunction · 0.85
av_opt_setFunction · 0.85
update_metadataFunction · 0.85

Tested by

no test coverage detected