| 492 | } |
| 493 | |
| 494 | static int hds_write_packet(AVFormatContext *s, AVPacket *pkt) |
| 495 | { |
| 496 | HDSContext *c = s->priv_data; |
| 497 | AVStream *st = s->streams[pkt->stream_index]; |
| 498 | FFStream *const sti = ffstream(st); |
| 499 | OutputStream *os = &c->streams[s->streams[pkt->stream_index]->id]; |
| 500 | int64_t end_dts = os->fragment_index * (int64_t)c->min_frag_duration; |
| 501 | int ret; |
| 502 | |
| 503 | if (sti->first_dts == AV_NOPTS_VALUE) |
| 504 | sti->first_dts = pkt->dts; |
| 505 | |
| 506 | if ((!os->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && |
| 507 | av_compare_ts(pkt->dts - sti->first_dts, st->time_base, |
| 508 | end_dts, AV_TIME_BASE_Q) >= 0 && |
| 509 | pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) { |
| 510 | |
| 511 | if ((ret = hds_flush(s, os, 0, pkt->dts)) < 0) |
| 512 | return ret; |
| 513 | } |
| 514 | |
| 515 | // Note, these fragment start timestamps, that represent a whole |
| 516 | // OutputStream, assume all streams in it have the same time base. |
| 517 | if (!os->packets_written) |
| 518 | os->frag_start_ts = pkt->dts; |
| 519 | os->last_ts = pkt->dts; |
| 520 | |
| 521 | os->packets_written++; |
| 522 | return ff_write_chained(os->ctx, pkt->stream_index - os->first_stream, pkt, s, 0); |
| 523 | } |
| 524 | |
| 525 | static int hds_write_trailer(AVFormatContext *s) |
| 526 | { |
nothing calls this directly
no test coverage detected