| 1462 | } |
| 1463 | |
| 1464 | static int update_init_section(struct playlist *pls, struct segment *seg) |
| 1465 | { |
| 1466 | static const int max_init_section_size = 1024*1024; |
| 1467 | HLSContext *c = pls->parent->priv_data; |
| 1468 | int64_t sec_size; |
| 1469 | int64_t urlsize; |
| 1470 | int ret; |
| 1471 | |
| 1472 | if (seg->init_section == pls->cur_init_section) |
| 1473 | return 0; |
| 1474 | |
| 1475 | pls->cur_init_section = NULL; |
| 1476 | |
| 1477 | if (!seg->init_section) |
| 1478 | return 0; |
| 1479 | |
| 1480 | ret = open_input(c, pls, seg->init_section, &pls->input); |
| 1481 | if (ret < 0) { |
| 1482 | av_log(pls->parent, AV_LOG_WARNING, |
| 1483 | "Failed to open an initialization section in playlist %d\n", |
| 1484 | pls->index); |
| 1485 | return ret; |
| 1486 | } |
| 1487 | |
| 1488 | if (seg->init_section->size >= 0) |
| 1489 | sec_size = seg->init_section->size; |
| 1490 | else if ((urlsize = avio_size(pls->input)) >= 0) |
| 1491 | sec_size = urlsize; |
| 1492 | else |
| 1493 | sec_size = max_init_section_size; |
| 1494 | |
| 1495 | av_log(pls->parent, AV_LOG_DEBUG, |
| 1496 | "Downloading an initialization section of size %"PRId64"\n", |
| 1497 | sec_size); |
| 1498 | |
| 1499 | sec_size = FFMIN(sec_size, max_init_section_size); |
| 1500 | |
| 1501 | av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size); |
| 1502 | |
| 1503 | ret = read_from_url(pls, seg->init_section, pls->init_sec_buf, |
| 1504 | pls->init_sec_buf_size); |
| 1505 | ff_format_io_close(pls->parent, &pls->input); |
| 1506 | |
| 1507 | if (ret < 0) |
| 1508 | return ret; |
| 1509 | |
| 1510 | pls->cur_init_section = seg->init_section; |
| 1511 | pls->init_sec_data_len = ret; |
| 1512 | pls->init_sec_buf_read_offset = 0; |
| 1513 | |
| 1514 | /* spec says audio elementary streams do not have media initialization |
| 1515 | * sections, so there should be no ID3 timestamps */ |
| 1516 | pls->is_id3_timestamped = 0; |
| 1517 | |
| 1518 | return 0; |
| 1519 | } |
| 1520 | |
| 1521 | static int64_t default_reload_interval(struct playlist *pls) |
no test coverage detected