| 2393 | return ret; |
| 2394 | } |
| 2395 | static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 2396 | { |
| 2397 | HLSContext *hls = s->priv_data; |
| 2398 | AVFormatContext *oc = NULL; |
| 2399 | AVStream *st = s->streams[pkt->stream_index]; |
| 2400 | int64_t end_pts = 0; |
| 2401 | int is_ref_pkt = 1; |
| 2402 | int ret = 0, can_split = 1, i, j; |
| 2403 | int stream_index = 0; |
| 2404 | int range_length = 0; |
| 2405 | const char *proto = NULL; |
| 2406 | int use_temp_file = 0; |
| 2407 | VariantStream *vs = NULL; |
| 2408 | char *old_filename = NULL; |
| 2409 | |
| 2410 | for (i = 0; i < hls->nb_varstreams; i++) { |
| 2411 | int subtitle_streams = 0; |
| 2412 | vs = &hls->var_streams[i]; |
| 2413 | for (j = 0; j < vs->nb_streams; j++) { |
| 2414 | if (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
| 2415 | subtitle_streams++; |
| 2416 | } |
| 2417 | if (vs->streams[j] == st) { |
| 2418 | if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { |
| 2419 | oc = vs->vtt_avf; |
| 2420 | stream_index = 0; |
| 2421 | } else { |
| 2422 | oc = vs->avf; |
| 2423 | stream_index = j - subtitle_streams; |
| 2424 | } |
| 2425 | break; |
| 2426 | } |
| 2427 | } |
| 2428 | |
| 2429 | if (oc) |
| 2430 | break; |
| 2431 | } |
| 2432 | |
| 2433 | if (!oc) { |
| 2434 | av_log(s, AV_LOG_ERROR, "Unable to find mapping variant stream\n"); |
| 2435 | return AVERROR(ENOMEM); |
| 2436 | } |
| 2437 | |
| 2438 | end_pts = hls->recording_time * vs->number; |
| 2439 | |
| 2440 | if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time > 0) { |
| 2441 | /* reset end_pts, hls->recording_time at end of the init hls list */ |
| 2442 | int64_t init_list_dur = hls->init_time * vs->nb_entries; |
| 2443 | int64_t after_init_list_dur = (vs->sequence - hls->start_sequence - vs->nb_entries) * hls->time; |
| 2444 | hls->recording_time = hls->time; |
| 2445 | end_pts = init_list_dur + after_init_list_dur ; |
| 2446 | } |
| 2447 | |
| 2448 | if (vs->start_pts == AV_NOPTS_VALUE) { |
| 2449 | vs->start_pts = pkt->pts; |
| 2450 | if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) |
| 2451 | vs->start_pts_from_audio = 1; |
| 2452 | } |
nothing calls this directly
no test coverage detected