97 if (whence != SEEK_SET)
118 if (offset >= frag->
start_pos && offset < frag->start_pos + frag->
size) {
157 for (i = 0; i <
size; i++)
191 int removed = 0, i, start = 0;
202 if (!
final || removed)
214 int ret, i, video_chunks = 0, audio_chunks = 0, video_streams = 0, audio_streams = 0;
223 avio_printf(out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
240 video_chunks = audio_chunks = 0;
246 avio_printf(out,
"<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" Duration=\"%"PRIu64
"\"", duration);
251 int last = -1,
index = 0;
252 avio_printf(out,
"<StreamIndex Type=\"video\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", video_streams, video_chunks);
265 int last = -1,
index = 0;
266 avio_printf(out,
"<StreamIndex Type=\"audio\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", audio_streams, audio_chunks);
321 if (mkdir(os->
dirname, 0777) < 0) {
411 if (*moof_size < 8 || *moof_size > size)
416 if (len > *moof_size)
428 if (len < 8 || len >= *moof_size)
430 if (tag ==
MKTAG(
'u',
'u',
'i',
'd')) {
432 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
433 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
437 if (!memcmp(uuid, tfxd, 16) && len >= 8 + 16 + 4 + 16) {
488 int n =
FFMIN(size,
sizeof(buf));
510 char filename[1024], target_filename[1024], header_filename[1024];
512 int64_t start_ts,
duration, moof_size;
534 copy_moof(s, filename, header_filename, moof_size);
535 rename(filename, target_filename);
536 add_fragment(os, target_filename, header_filename, start_ts, duration, start_pos,
size);
547 for (j = 0; j <
remove; j++) {
606 #define OFFSET(x) offsetof(SmoothStreamingContext, x)
607 #define E AV_OPT_FLAG_ENCODING_PARAM
609 {
"window_size",
"number of fragments kept in the manifest",
OFFSET(window_size),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
E },
610 {
"extra_window_size",
"number of fragments kept outside of the manifest before removing from disk",
OFFSET(extra_window_size),
AV_OPT_TYPE_INT, { .i64 = 5 }, 0, INT_MAX,
E },
611 {
"lookahead_count",
"number of lookahead fragments",
OFFSET(lookahead_count),
AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX,
E },
612 {
"min_frag_duration",
"minimum fragment duration (in microseconds)",
OFFSET(min_frag_duration),
AV_OPT_TYPE_INT64, { .i64 = 5000000 }, 0, INT_MAX,
E },
613 {
"remove_at_exit",
"remove all fragments when finished",
OFFSET(remove_at_exit),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
E },
626 .
name =
"smoothstreaming",