Lines Matching refs:pls

242 static void free_segment_list(struct playlist *pls)
244 free_segment_dynarray(pls->segments, pls->n_segments);
245 av_freep(&pls->segments);
246 pls->n_segments = 0;
249 static void free_init_section_list(struct playlist *pls)
252 for (i = 0; i < pls->n_init_sections; i++) {
253 av_freep(&pls->init_sections[i]->key);
254 av_freep(&pls->init_sections[i]->url);
255 av_freep(&pls->init_sections[i]);
257 av_freep(&pls->init_sections);
258 pls->n_init_sections = 0;
265 struct playlist *pls = c->playlists[i];
266 free_segment_list(pls);
267 free_init_section_list(pls);
268 av_freep(&pls->main_streams);
269 av_freep(&pls->renditions);
270 av_freep(&pls->id3_buf);
271 av_dict_free(&pls->id3_initial);
272 ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
273 av_freep(&pls->init_sec_buf);
274 av_packet_free(&pls->pkt);
275 av_freep(&pls->pb.pub.buffer);
276 ff_format_io_close(c->ctx, &pls->input);
277 pls->input_read_done = 0;
278 ff_format_io_close(c->ctx, &pls->input_next);
279 pls->input_next_requested = 0;
280 if (pls->ctx) {
281 pls->ctx->pb = NULL;
282 avformat_close_input(&pls->ctx);
284 av_free(pls);
314 struct playlist *pls = av_mallocz(sizeof(struct playlist));
315 if (!pls)
317 pls->pkt = av_packet_alloc();
318 if (!pls->pkt) {
319 av_free(pls);
322 ff_make_absolute_url(pls->url, sizeof(pls->url), base, url);
323 if (!pls->url[0]) {
324 av_packet_free(&pls->pkt);
325 av_free(pls);
328 pls->seek_timestamp = AV_NOPTS_VALUE;
330 pls->is_id3_timestamped = -1;
331 pls->id3_mpegts_timestamp = AV_NOPTS_VALUE;
333 dynarray_add(&c->playlists, &c->n_playlists, pls);
334 return pls;
349 struct playlist *pls;
351 pls = new_playlist(c, url, base);
352 if (!pls)
367 dynarray_add(&var->playlists, &var->n_playlists, pls);
415 static struct segment *new_init_section(struct playlist *pls,
454 dynarray_add(&pls->init_sections, &pls->n_init_sections, sec);
609 * *pls == NULL => Master Playlist or parentless Media Playlist
610 * *pls != NULL => parented Media Playlist, playlist+variant allocated */
611 static int ensure_playlist(HLSContext *c, struct playlist **pls, const char *url)
613 if (*pls)
617 *pls = c->playlists[c->n_playlists - 1];
727 struct playlist *pls, AVIOContext *in)
790 if (pls) {
791 prev_start_seq_no = pls->start_seq_no;
792 prev_segments = pls->segments;
793 prev_n_segments = pls->n_segments;
794 pls->segments = NULL;
795 pls->n_segments = 0;
797 pls->finished = 0;
798 pls->type = PLS_TYPE_UNSPECIFIED;
829 ret = ensure_playlist(c, &pls, url);
837 pls->target_duration = t * AV_TIME_BASE;
840 ret = ensure_playlist(c, &pls, url);
849 pls->start_seq_no = seq_no;
851 ret = ensure_playlist(c, &pls, url);
855 pls->type = PLS_TYPE_EVENT;
857 pls->type = PLS_TYPE_VOD;
860 ret = ensure_playlist(c, &pls, url);
865 cur_init_section = new_init_section(pls, &info, url);
874 int64_t seq = pls->start_seq_no + pls->n_segments;
898 ret = ensure_playlist(c, &pls, url);
904 pls->start_time_offset = offset * AV_TIME_BASE;
905 pls->time_offset_flag = 1;
912 if (pls)
913 pls->finished = 1;
935 ret = ensure_playlist(c, &pls, url);
946 uint64_t seq = pls->start_seq_no + (uint64_t)pls->n_segments;
991 dynarray_add(&pls->segments, &pls->n_segments, seg);
1009 if (pls->start_seq_no > prev_start_seq_no && c->first_timestamp != AV_NOPTS_VALUE) {
1012 int64_t diff = pls->start_seq_no - prev_start_seq_no;
1018 prev_start_seq_no, pls->start_seq_no,
1020 } else if (pls->start_seq_no < prev_start_seq_no) {
1022 prev_start_seq_no, pls->start_seq_no);
1027 if (pls)
1028 pls->last_load_time = av_gettime_relative();
1042 static struct segment *current_segment(struct playlist *pls)
1044 int64_t n = pls->cur_seq_no - pls->start_seq_no;
1045 if (n >= pls->n_segments)
1047 return pls->segments[n];
1050 static struct segment *next_segment(struct playlist *pls)
1052 int64_t n = pls->cur_seq_no - pls->start_seq_no + 1;
1053 if (n >= pls->n_segments)
1055 return pls->segments[n];
1058 static int read_from_url(struct playlist *pls, struct segment *seg,
1065 buf_size = FFMIN(buf_size, seg->size - pls->cur_seg_offset);
1067 ret = avio_read(pls->input, buf, buf_size);
1069 pls->cur_seg_offset += ret;
1104 static int id3_has_changed_values(struct playlist *pls, AVDictionary *metadata,
1111 oldentry = av_dict_get(pls->id3_initial, entry->key, NULL, AV_DICT_MATCH_CASE);
1117 if (apic && (pls->ctx->nb_streams != 2 || !pls->ctx->streams[1]->attached_pic.data))
1121 int size = pls->ctx->streams[1]->attached_pic.size;
1125 if (memcmp(apic->buf->data, pls->ctx->streams[1]->attached_pic.data, size) != 0)
1133 static void handle_id3(AVIOContext *pb, struct playlist *pls)
1140 parse_id3(pls->ctx, pb, &metadata, &timestamp, &pls->audio_setup_info, &apic, &extra_meta);
1143 pls->id3_mpegts_timestamp = timestamp;
1144 pls->id3_offset = 0;
1147 if (!pls->id3_found) {
1149 av_assert0(!pls->id3_deferred_extra);
1150 pls->id3_found = 1;
1153 if (pls->ctx->nb_streams)
1154 ff_id3v2_parse_apic(pls->ctx, extra_meta);
1157 pls->id3_deferred_extra = extra_meta;
1160 av_dict_copy(&pls->ctx->metadata, metadata, 0);
1161 pls->id3_initial = metadata;
1164 if (!pls->id3_changed && id3_has_changed_values(pls, metadata, apic)) {
1165 avpriv_report_missing_feature(pls->parent, "Changing ID3 metadata in HLS audio elementary stream");
1166 pls->id3_changed = 1;
1171 if (!pls->id3_deferred_extra)
1175 static void intercept_id3(struct playlist *pls, uint8_t *buf,
1183 struct segment *seg = current_segment(pls);
1189 bytes = read_from_url(pls, seg, buf + *len, ID3v2_HEADER_SIZE - *len);
1216 av_log(pls->parent, AV_LOG_ERROR, "Too large HLS ID3 tag (%d > %"PRId64" bytes)\n",
1228 pls->id3_buf = av_fast_realloc(pls->id3_buf, &pls->id3_buf_size, id3_buf_pos + taglen);
1229 if (!pls->id3_buf)
1231 memcpy(pls->id3_buf + id3_buf_pos, buf, tag_got_bytes);
1237 av_log(pls->parent, AV_LOG_DEBUG, "Stripped %d HLS ID3 bytes\n", tag_got_bytes);
1241 if (read_from_url(pls, seg, pls->id3_buf + id3_buf_pos, remaining) != remaining)
1244 av_log(pls->parent, AV_LOG_DEBUG, "Stripped additional %d HLS ID3 bytes\n", remaining);
1255 bytes = read_from_url(pls, seg, buf + *len, buf_size - *len);
1264 if (pls->id3_buf) {
1267 ffio_init_context(&id3ioctx, pls->id3_buf, id3_buf_pos, 0, NULL, NULL, NULL, NULL);
1268 handle_id3(&id3ioctx.pub, pls);
1271 if (pls->is_id3_timestamped == -1)
1272 pls->is_id3_timestamped = (pls->id3_mpegts_timestamp != AV_NOPTS_VALUE);
1275 static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, AVIOContext **in)
1291 av_log(pls->parent, AV_LOG_VERBOSE, "HLS request for url '%s', offset %"PRId64", playlist %d\n",
1292 seg->url, seg->url_offset, pls->index);
1295 if (strcmp(seg->key, pls->key_url)) {
1297 if (open_url(pls->parent, &pb, seg->key, &c->avio_opts, opts, NULL) == 0) {
1298 ret = avio_read(pb, pls->key, sizeof(pls->key));
1299 if (ret != sizeof(pls->key)) {
1300 av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n",
1303 ff_format_io_close(pls->parent, &pb);
1305 av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s\n",
1308 av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
1315 ff_data_to_hex(key, pls->key, sizeof(pls->key), 0);
1324 ret = open_url(pls->parent, in, url, &c->avio_opts, opts, &is_http);
1330 ret = open_url(pls->parent, in, seg->url, &c->avio_opts, opts, &is_http);
1346 av_log(pls->parent, AV_LOG_ERROR, "Unable to seek to offset %"PRId64" of HLS segment '%s'\n", seg->url_offset, seg->url);
1348 ff_format_io_close(pls->parent, in);
1354 pls->cur_seg_offset = 0;
1358 static int update_init_section(struct playlist *pls, struct segment *seg)
1361 HLSContext *c = pls->parent->priv_data;
1366 if (seg->init_section == pls->cur_init_section)
1369 pls->cur_init_section = NULL;
1374 ret = open_input(c, pls, seg->init_section, &pls->input);
1376 av_log(pls->parent, AV_LOG_WARNING,
1378 pls->index);
1384 else if ((urlsize = avio_size(pls->input)) >= 0)
1389 av_log(pls->parent, AV_LOG_DEBUG,
1395 av_fast_malloc(&pls->init_sec_buf, &pls->init_sec_buf_size, sec_size);
1397 ret = read_from_url(pls, seg->init_section, pls->init_sec_buf,
1398 pls->init_sec_buf_size);
1399 ff_format_io_close(pls->parent, &pls->input);
1404 pls->cur_init_section = seg->init_section;
1405 pls->init_sec_data_len = ret;
1406 pls->init_sec_buf_read_offset = 0;
1410 pls->is_id3_timestamped = 0;
1415 static int64_t default_reload_interval(struct playlist *pls)
1417 return pls->n_segments > 0 ?
1418 pls->segments[pls->n_segments - 1]->duration :
1419 pls->target_duration;
1422 static int playlist_needed(struct playlist *pls)
1424 AVFormatContext *s = pls->parent;
1430 if (!pls->ctx || !pls->n_main_streams)
1434 for (i = 0; i < pls->n_main_streams; i++) {
1435 if (pls->main_streams[i]->discard < AVDISCARD_ALL) {
1450 first_st = pls->main_streams[0]->index;
1652 static void add_metadata_from_renditions(AVFormatContext *s, struct playlist *pls,
1658 for (i = 0; i < pls->n_main_streams; i++) {
1659 AVStream *st = pls->main_streams[i];
1664 for (; rend_idx < pls->n_renditions; rend_idx++) {
1665 struct rendition *rend = pls->renditions[rend_idx];
1677 if (rend_idx >=pls->n_renditions)
1684 static int find_timestamp_in_playlist(HLSContext *c, struct playlist *pls,
1693 *seq_no = pls->start_seq_no;
1697 for (i = 0; i < pls->n_segments; i++) {
1698 int64_t diff = pos + pls->segments[i]->duration - timestamp;
1700 *seq_no = pls->start_seq_no + i;
1706 pos += pls->segments[i]->duration;
1709 *seq_no = pls->start_seq_no + pls->n_segments - 1;
1714 static int64_t select_cur_seq_no(HLSContext *c, struct playlist *pls)
1718 if (!pls->finished && !c->first_packet &&
1719 av_gettime_relative() - pls->last_load_time >= default_reload_interval(pls))
1721 parse_playlist(c, pls->url, pls, NULL);
1726 if (pls->finished && c->cur_timestamp != AV_NOPTS_VALUE) {
1727 find_timestamp_in_playlist(c, pls, c->cur_timestamp, &seq_no, NULL);
1731 if (!pls->finished) {
1733 c->cur_seq_no >= pls->start_seq_no &&
1734 c->cur_seq_no < pls->start_seq_no + pls->n_segments)
1744 seq_no = pls->start_seq_no + FFMAX(pls->n_segments +
1747 seq_no = pls->start_seq_no + FFMIN(c->live_start_index,
1748 pls->n_segments - 1);
1751 if (pls->time_offset_flag && c->prefer_x_start) {
1757 for (int i = 0; i < pls->n_segments; i++)
1758 playlist_duration += pls->segments[i]->duration;
1764 if (pls->start_time_offset >=0 &&
1765 pls->start_time_offset > playlist_duration)
1767 else if (pls->start_time_offset >= 0 &&
1768 pls->start_time_offset <= playlist_duration)
1769 start_timestamp = cur_timestamp + pls->start_time_offset;
1770 else if (pls->start_time_offset < 0 &&
1771 pls->start_time_offset < -playlist_duration)
1773 else if (pls->start_time_offset < 0 &&
1774 pls->start_time_offset > -playlist_duration)
1776 pls->start_time_offset;
1780 find_timestamp_in_playlist(c, pls, start_timestamp, &seq_no, NULL);
1786 return pls->start_seq_no;
1799 static void add_stream_to_programs(AVFormatContext *s, struct playlist *pls, AVStream *stream)
1809 if (v->playlists[j] != pls)
1825 static int set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
1833 if (pls->is_id3_timestamped) /* custom timestamps via id3 */
1858 static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *pls)
1862 while (pls->n_main_streams < pls->ctx->nb_streams) {
1863 int ist_idx = pls->n_main_streams;
1865 AVStream *ist = pls->ctx->streams[ist_idx];
1870 st->id = pls->index;
1871 dynarray_add(&pls->main_streams, &pls->n_main_streams, st);
1873 add_stream_to_programs(s, pls, st);
1875 err = set_stream_info_from_input_stream(st, pls, ist);
1890 struct playlist *pls = c->playlists[i];
1892 if (pls->has_noheader_flag) {
1953 struct playlist *pls = c->playlists[i];
1954 pls->m3u8_hold_counters = 0;
1955 if ((ret = parse_playlist(c, pls->url, pls, NULL)) < 0) {
1956 av_log(s, AV_LOG_WARNING, "parse_playlist error %s [%s]\n", av_err2str(ret), pls->url);
1957 pls->broken = 1;
2006 struct playlist *pls = c->playlists[i];
2008 if (pls->n_segments == 0)
2011 pls->cur_seq_no = select_cur_seq_no(c, pls);
2012 highest_cur_seq_no = FFMAX(highest_cur_seq_no, pls->cur_seq_no);
2017 struct playlist *pls = c->playlists[i];
2023 if (!(pls->ctx = avformat_alloc_context()))
2026 if (pls->n_segments == 0)
2029 pls->index = i;
2030 pls->needed = 1;
2031 pls->parent = s;
2040 if (!pls->finished && pls->cur_seq_no == highest_cur_seq_no - 1 &&
2041 highest_cur_seq_no < pls->start_seq_no + pls->n_segments) {
2042 pls->cur_seq_no = highest_cur_seq_no;
2045 pls->read_buffer = av_malloc(INITIAL_BUFFER_SIZE);
2046 if (!pls->read_buffer){
2047 avformat_free_context(pls->ctx);
2048 pls->ctx = NULL;
2052 ffio_init_context(&pls->pb, pls->read_buffer, INITIAL_BUFFER_SIZE, 0, pls,
2059 seg = current_segment(pls);
2060 if (seg && seg->key_type == KEY_SAMPLE_AES && pls->n_renditions > 0 &&
2061 pls->renditions[0]->type == AVMEDIA_TYPE_AUDIO) {
2063 if ((ret = avio_read(&pls->pb.pub, buf, HLS_MAX_ID3_TAGS_DATA_LEN)) < 0) {
2066 avformat_free_context(pls->ctx);
2067 pls->ctx = NULL;
2073 ff_format_io_close(pls->parent, &pls->input);
2074 pls->input = NULL;
2075 pls->input_read_done = 0;
2076 ff_format_io_close(pls->parent, &pls->input_next);
2077 pls->input_next = NULL;
2078 pls->input_next_requested = 0;
2079 pls->cur_seg_offset = 0;
2080 pls->cur_init_section = NULL;
2082 pls->pb.pub.eof_reached = 0;
2084 pls->pb.pub.buf_end = pls->pb.pub.buf_ptr = pls->pb.pub.buffer;
2086 pls->pb.pub.pos = 0;
2093 if (seg && seg->key_type == KEY_SAMPLE_AES && pls->is_id3_timestamped &&
2094 pls->audio_setup_info.codec_id != AV_CODEC_ID_NONE) {
2097 if (in_fmt->raw_codec_id == pls->audio_setup_info.codec_id)
2100 pls->ctx->probesize = s->probesize > 0 ? s->probesize : 1024 * 4;
2101 pls->ctx->max_analyze_duration = s->max_analyze_duration > 0 ? s->max_analyze_duration : 4 * AV_TIME_BASE;
2102 pls->ctx->interrupt_callback = s->interrupt_callback;
2103 url = av_strdup(pls->segments[0]->url);
2104 ret = av_probe_input_buffer(&pls->pb.pub, &in_fmt, url, NULL, 0, 0);
2111 avformat_free_context(pls->ctx);
2112 pls->ctx = NULL;
2122 ff_data_to_hex(key, pls->key, sizeof(pls->key), 0);
2127 avformat_free_context(pls->ctx);
2128 pls->ctx = NULL;
2134 pls->ctx->pb = &pls->pb.pub;
2135 pls->ctx->io_open = nested_io_open;
2136 pls->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO;
2138 if ((ret = ff_copy_whiteblacklists(pls->ctx, s)) < 0)
2143 ret = avformat_open_input(&pls->ctx, pls->segments[0]->url, in_fmt, &options);
2148 if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
2149 ff_id3v2_parse_apic(pls->ctx, pls->id3_deferred_extra);
2150 avformat_queue_attached_pictures(pls->ctx);
2151 ff_id3v2_parse_priv(pls->ctx, pls->id3_deferred_extra);
2152 ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
2155 if (pls->is_id3_timestamped == -1)
2164 if (pls->is_id3_timestamped || (pls->n_renditions > 0 && pls->renditions[0]->type == AVMEDIA_TYPE_AUDIO)) {
2165 if (seg && seg->key_type == KEY_SAMPLE_AES && pls->audio_setup_info.setup_data_length > 0 &&
2166 pls->ctx->nb_streams == 1)
2167 ret = ff_hls_senc_parse_audio_setup_info(pls->ctx->streams[0], &pls->audio_setup_info);
2169 ret = avformat_find_stream_info(pls->ctx, NULL);
2175 pls->has_noheader_flag = !!(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER);
2178 ret = update_streams_from_subdemuxer(s, pls);
2186 if (pls->n_main_streams)
2187 av_dict_copy(&pls->main_streams[0]->metadata, pls->ctx->metadata, 0);
2189 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO);
2190 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO);
2191 add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE);
2207 struct playlist *pls = c->playlists[i];
2211 if (pls->broken) {
2214 if (cur_needed && !pls->needed) {
2215 pls->needed = 1;
2217 pls->cur_seq_no = select_cur_seq_no(c, pls);
2218 pls->pb.pub.eof_reached = 0;
2221 pls->seek_timestamp = c->cur_timestamp;
2222 pls->seek_flags = AVSEEK_FLAG_ANY;
2223 pls->seek_stream_index = -1;
2225 av_log(s, AV_LOG_INFO, "Now receiving playlist %d, segment %"PRId64"\n", i, pls->cur_seq_no);
2226 } else if (first && !cur_needed && pls->needed) {
2227 ff_format_io_close(pls->parent, &pls->input);
2228 pls->input_read_done = 0;
2229 ff_format_io_close(pls->parent, &pls->input_next);
2230 pls->input_next_requested = 0;
2231 pls->needed = 0;
2239 static void fill_timing_for_id3_timestamped_stream(struct playlist *pls)
2241 if (pls->id3_offset >= 0) {
2242 pls->pkt->dts = pls->id3_mpegts_timestamp +
2243 av_rescale_q(pls->id3_offset,
2244 pls->ctx->streams[pls->pkt->stream_index]->time_base,
2246 if (pls->pkt->duration)
2247 pls->id3_offset += pls->pkt->duration;
2249 pls->id3_offset = -1;
2253 pls->pkt->dts = AV_NOPTS_VALUE;
2256 if (pls->pkt->duration)
2257 pls->pkt->duration = av_rescale_q(pls->pkt->duration,
2258 pls->ctx->streams[pls->pkt->stream_index]->time_base,
2261 pls->pkt->pts = AV_NOPTS_VALUE;
2264 static AVRational get_timebase(struct playlist *pls)
2266 if (pls->is_id3_timestamped)
2269 return pls->ctx->streams[pls->pkt->stream_index]->time_base;
2290 struct playlist *pls = c->playlists[i];
2293 if (pls->needed && !pls->pkt->data) {
2298 ret = av_read_frame(pls->ctx, pls->pkt);
2300 if (!avio_feof(&pls->pb.pub) && ret != AVERROR_EOF)
2305 if (pls->is_id3_timestamped && pls->pkt->stream_index == 0) {
2307 fill_timing_for_id3_timestamped_stream(pls);
2311 pls->pkt->dts != AV_NOPTS_VALUE)
2312 c->first_timestamp = av_rescale_q(pls->pkt->dts,
2313 get_timebase(pls), AV_TIME_BASE_Q);
2316 seg = current_segment(pls);
2317 if (seg && seg->key_type == KEY_SAMPLE_AES && !strstr(pls->ctx->iformat->name, "mov")) {
2318 enum AVCodecID codec_id = pls->ctx->streams[pls->pkt->stream_index]->codecpar->codec_id;
2320 memcpy(c->crypto_ctx.key, pls->key, sizeof(pls->key));
2321 ff_hls_senc_decrypt_frame(codec_id, &c->crypto_ctx, pls->pkt);
2324 if (pls->seek_timestamp == AV_NOPTS_VALUE)
2327 if (pls->seek_stream_index < 0 ||
2328 pls->seek_stream_index == pls->pkt->stream_index) {
2330 if (pls->pkt->dts == AV_NOPTS_VALUE) {
2331 pls->seek_timestamp = AV_NOPTS_VALUE;
2335 tb = get_timebase(pls);
2336 ts_diff = av_rescale_rnd(pls->pkt->dts, AV_TIME_BASE,
2338 pls->seek_timestamp;
2339 if (ts_diff >= 0 && (pls->seek_flags & AVSEEK_FLAG_ANY ||
2340 pls->pkt->flags & AV_PKT_FLAG_KEY)) {
2341 pls->seek_timestamp = AV_NOPTS_VALUE;
2345 av_packet_unref(pls->pkt);
2349 if (pls->pkt->data) {
2355 int64_t dts = pls->pkt->dts;
2359 (mindts != AV_NOPTS_VALUE && compare_ts_with_wrapdetect(dts, pls, mindts, minpls) < 0))
2367 struct playlist *pls = c->playlists[minplaylist];
2371 ret = update_streams_from_subdemuxer(s, pls);
2373 av_packet_unref(pls->pkt);
2379 if (pls->ctx->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
2380 if (pls->n_main_streams) {
2381 st = pls->main_streams[0];
2382 av_dict_copy(&st->metadata, pls->ctx->metadata, 0);
2385 pls->ctx->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
2389 if (pls->has_noheader_flag && !(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER)) {
2390 pls->has_noheader_flag = 0;
2394 if (pls->pkt->stream_index >= pls->n_main_streams) {
2396 pls->pkt->stream_index, pls->n_main_streams, pls->ctx->nb_streams);
2397 av_packet_unref(pls->pkt);
2401 ist = pls->ctx->streams[pls->pkt->stream_index];
2402 st = pls->main_streams[pls->pkt->stream_index];
2404 av_packet_move_ref(pkt, pls->pkt);
2415 ret = set_stream_info_from_input_stream(st, pls, ist);
2454 struct playlist *pls = c->playlists[i];
2455 for (j = 0; j < pls->n_main_streams; j++) {
2456 if (pls->main_streams[j] == s->streams[stream_index]) {
2457 seek_pls = pls;
2481 struct playlist *pls = c->playlists[i];
2482 AVIOContext *const pb = &pls->pb.pub;
2483 ff_format_io_close(pls->parent, &pls->input);
2484 pls->input_read_done = 0;
2485 ff_format_io_close(pls->parent, &pls->input_next);
2486 pls->input_next_requested = 0;
2487 av_packet_unref(pls->pkt);
2494 ff_read_frame_flush(pls->ctx);
2496 pls->seek_timestamp = seek_timestamp;
2497 pls->seek_flags = flags;
2499 if (pls != seek_pls) {
2501 find_timestamp_in_playlist(c, pls, seek_timestamp, &pls->cur_seq_no, NULL);
2505 pls->seek_stream_index = -1;
2506 pls->seek_flags |= AVSEEK_FLAG_ANY;