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

Function hls_window

libavformat/hlsenc.c:1516–1658  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1514}
1515
1516static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
1517{
1518 HLSContext *hls = s->priv_data;
1519 HLSSegment *en;
1520 int target_duration = 0;
1521 int ret = 0;
1522 char temp_filename[MAX_URL_SIZE];
1523 char temp_vtt_filename[MAX_URL_SIZE];
1524 int64_t sequence = FFMAX(hls->start_sequence, vs->sequence - vs->nb_entries);
1525 const char *proto = avio_find_protocol_name(vs->m3u8_name);
1526 int is_file_proto = proto && !strcmp(proto, "file");
1527 int use_temp_file = is_file_proto && ((hls->flags & HLS_TEMP_FILE) || !(hls->pl_type == PLAYLIST_TYPE_VOD));
1528 static unsigned warned_non_file;
1529 char *key_uri = NULL;
1530 char *iv_string = NULL;
1531 AVDictionary *options = NULL;
1532 double prog_date_time = vs->initial_prog_date_time;
1533 double *prog_date_time_p = (hls->flags & HLS_PROGRAM_DATE_TIME) ? &prog_date_time : NULL;
1534 int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
1535
1536 hls->version = 2;
1537 if (!(hls->flags & HLS_ROUND_DURATIONS)) {
1538 hls->version = 3;
1539 }
1540
1541 if (byterange_mode) {
1542 hls->version = 4;
1543 sequence = 0;
1544 }
1545
1546 if (hls->flags & HLS_I_FRAMES_ONLY) {
1547 hls->version = 4;
1548 }
1549
1550 if (hls->flags & HLS_INDEPENDENT_SEGMENTS) {
1551 hls->version = 6;
1552 }
1553
1554 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
1555 hls->version = 7;
1556 }
1557
1558 if (!is_file_proto && (hls->flags & HLS_TEMP_FILE) && !warned_non_file++)
1559 av_log(s, AV_LOG_ERROR, "Cannot use rename on non file protocol, this may lead to races and temporary partial files\n");
1560
1561 set_http_options(s, &options, hls);
1562 snprintf(temp_filename, sizeof(temp_filename), use_temp_file ? "%s.tmp" : "%s", vs->m3u8_name);
1563 ret = hlsenc_io_open(s, byterange_mode ? &hls->m3u8_out : &vs->out, temp_filename, &options);
1564 av_dict_free(&options);
1565 if (ret < 0) {
1566 goto fail;
1567 }
1568
1569 for (en = vs->segments; en; en = en->next) {
1570 if (target_duration <= en->duration)
1571 target_duration = lrint(en->duration);
1572 }
1573

Callers 2

hls_write_packetFunction · 0.85
hls_write_trailerFunction · 0.85

Calls 15

avio_find_protocol_nameFunction · 0.85
av_logFunction · 0.85
hlsenc_io_openFunction · 0.85
av_dict_freeFunction · 0.85
lrintFunction · 0.85
avio_printfFunction · 0.85
av_strcasecmpFunction · 0.85
ff_hls_write_init_fileFunction · 0.85
ff_hls_write_file_entryFunction · 0.85
ff_hls_write_end_listFunction · 0.85
hlsenc_io_closeFunction · 0.85

Tested by

no test coverage detected