| 1753 | } |
| 1754 | |
| 1755 | static int update_init_section(struct representation *pls) |
| 1756 | { |
| 1757 | static const int max_init_section_size = 1024 * 1024; |
| 1758 | DASHContext *c = pls->parent->priv_data; |
| 1759 | int64_t sec_size; |
| 1760 | int64_t urlsize; |
| 1761 | int ret; |
| 1762 | |
| 1763 | if (!pls->init_section || pls->init_sec_buf) |
| 1764 | return 0; |
| 1765 | |
| 1766 | ret = open_input(c, pls, pls->init_section); |
| 1767 | if (ret < 0) { |
| 1768 | av_log(pls->parent, AV_LOG_WARNING, |
| 1769 | "Failed to open an initialization section\n"); |
| 1770 | return ret; |
| 1771 | } |
| 1772 | |
| 1773 | if (pls->init_section->size >= 0) |
| 1774 | sec_size = pls->init_section->size; |
| 1775 | else if ((urlsize = avio_size(pls->input)) >= 0) |
| 1776 | sec_size = urlsize; |
| 1777 | else |
| 1778 | sec_size = max_init_section_size; |
| 1779 | |
| 1780 | av_log(pls->parent, AV_LOG_DEBUG, |
| 1781 | "Downloading an initialization section of size %"PRId64"\n", |
| 1782 | sec_size); |
| 1783 | |
| 1784 | sec_size = FFMIN(sec_size, max_init_section_size); |
| 1785 | |
| 1786 | av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size); |
| 1787 | |
| 1788 | ret = read_from_url(pls, pls->init_section, pls->init_sec_buf, |
| 1789 | pls->init_sec_buf_size); |
| 1790 | ff_format_io_close(pls->parent, &pls->input); |
| 1791 | |
| 1792 | if (ret < 0) |
| 1793 | return ret; |
| 1794 | |
| 1795 | pls->init_sec_data_len = ret; |
| 1796 | pls->init_sec_buf_read_offset = 0; |
| 1797 | |
| 1798 | return 0; |
| 1799 | } |
| 1800 | |
| 1801 | static int64_t seek_data(void *opaque, int64_t offset, int whence) |
| 1802 | { |
no test coverage detected