| 1809 | } |
| 1810 | |
| 1811 | static int read_data(void *opaque, uint8_t *buf, int buf_size) |
| 1812 | { |
| 1813 | int ret = 0; |
| 1814 | struct representation *v = opaque; |
| 1815 | DASHContext *c = v->parent->priv_data; |
| 1816 | |
| 1817 | restart: |
| 1818 | if (!v->input) { |
| 1819 | free_fragment(&v->cur_seg); |
| 1820 | v->cur_seg = get_current_fragment(v); |
| 1821 | if (!v->cur_seg) { |
| 1822 | ret = AVERROR_EOF; |
| 1823 | goto end; |
| 1824 | } |
| 1825 | |
| 1826 | /* load/update Media Initialization Section, if any */ |
| 1827 | ret = update_init_section(v); |
| 1828 | if (ret) |
| 1829 | goto end; |
| 1830 | |
| 1831 | ret = open_input(c, v, v->cur_seg); |
| 1832 | if (ret < 0) { |
| 1833 | if (ff_check_interrupt(c->interrupt_callback)) { |
| 1834 | ret = AVERROR_EXIT; |
| 1835 | goto end; |
| 1836 | } |
| 1837 | av_log(v->parent, AV_LOG_WARNING, "Failed to open fragment of playlist\n"); |
| 1838 | if (++v->n_open_failures > c->max_reload) { |
| 1839 | av_log(v->parent, AV_LOG_ERROR, |
| 1840 | "Reached max consecutive fragment open failures (%d), giving up\n", |
| 1841 | c->max_reload); |
| 1842 | ret = AVERROR_EOF; |
| 1843 | goto end; |
| 1844 | } |
| 1845 | v->cur_seq_no++; |
| 1846 | goto restart; |
| 1847 | } |
| 1848 | v->n_open_failures = 0; |
| 1849 | } |
| 1850 | |
| 1851 | if (v->init_sec_buf_read_offset < v->init_sec_data_len) { |
| 1852 | /* Push init section out first before first actual fragment */ |
| 1853 | int copy_size = FFMIN(v->init_sec_data_len - v->init_sec_buf_read_offset, buf_size); |
| 1854 | memcpy(buf, v->init_sec_buf, copy_size); |
| 1855 | v->init_sec_buf_read_offset += copy_size; |
| 1856 | ret = copy_size; |
| 1857 | goto end; |
| 1858 | } |
| 1859 | |
| 1860 | /* check the v->cur_seg, if it is null, get current and double check if the new v->cur_seg*/ |
| 1861 | if (!v->cur_seg) { |
| 1862 | v->cur_seg = get_current_fragment(v); |
| 1863 | } |
| 1864 | if (!v->cur_seg) { |
| 1865 | ret = AVERROR_EOF; |
| 1866 | goto end; |
| 1867 | } |
| 1868 | ret = read_from_url(v, v->cur_seg, buf, buf_size); |
nothing calls this directly
no test coverage detected