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)
213 char filename[1024], temp_filename[1024];
214 int ret, i, video_chunks = 0, audio_chunks = 0, video_streams = 0, audio_streams = 0;
218 snprintf(temp_filename,
sizeof(temp_filename),
"%s/Manifest.tmp", s->
filename);
224 avio_printf(out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
241 video_chunks = audio_chunks = 0;
247 avio_printf(out,
"<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" Duration=\"%"PRIu64
"\"", duration);
252 int last = -1,
index = 0;
253 avio_printf(out,
"<StreamIndex Type=\"video\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", video_streams, video_chunks);
266 int last = -1,
index = 0;
267 avio_printf(out,
"<StreamIndex Type=\"audio\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", audio_streams, audio_chunks);
282 rename(temp_filename, filename);
323 if (mkdir(os->
dirname, 0777) < 0) {
413 if (*moof_size < 8 || *moof_size > size)
418 if (len > *moof_size)
430 if (len < 8 || len >= *moof_size)
432 if (tag ==
MKTAG(
'u',
'u',
'i',
'd')) {
433 static const uint8_t tfxd[] = {
434 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
435 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
439 if (!memcmp(uuid, tfxd, 16) && len >= 8 + 16 + 4 + 16) {
494 int n =
FFMIN(size,
sizeof(buf));
516 char filename[1024], target_filename[1024], header_filename[1024];
518 int64_t start_ts,
duration, moof_size;
540 copy_moof(s, filename, header_filename, moof_size);
541 rename(filename, target_filename);
542 add_fragment(os, target_filename, header_filename, start_ts, duration, start_pos,
size);
553 for (j = 0; j <
remove; j++) {
612 #define OFFSET(x) offsetof(SmoothStreamingContext, x)
613 #define E AV_OPT_FLAG_ENCODING_PARAM
615 {
"window_size",
"number of fragments kept in the manifest",
OFFSET(window_size),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
E },
616 {
"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 },
617 {
"lookahead_count",
"number of lookahead fragments",
OFFSET(lookahead_count),
AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX,
E },
618 {
"min_frag_duration",
"minimum fragment duration (in microseconds)",
OFFSET(min_frag_duration),
AV_OPT_TYPE_INT64, { .i64 = 5000000 }, 0, INT_MAX,
E },
619 {
"remove_at_exit",
"remove all fragments when finished",
OFFSET(remove_at_exit),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
E },
632 .
name =
"smoothstreaming",