98 if (whence != SEEK_SET)
119 if (offset >= frag->
start_pos && offset < frag->start_pos + frag->
size) {
160 for (i = 0; i <
size; i++)
195 int removed = 0, i,
start = 0;
206 if (!
final || removed)
217 char filename[1024], temp_filename[1024];
218 int ret, i, video_chunks = 0, audio_chunks = 0, video_streams = 0, audio_streams = 0;
222 snprintf(temp_filename,
sizeof(temp_filename),
"%s/Manifest.tmp", s->
filename);
228 avio_printf(out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
245 video_chunks = audio_chunks = 0;
251 avio_printf(out,
"<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" Duration=\"%"PRIu64
"\"", duration);
256 int last = -1,
index = 0;
257 avio_printf(out,
"<StreamIndex Type=\"video\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n", video_streams, video_chunks);
270 int last = -1,
index = 0;
271 avio_printf(out,
"<StreamIndex Type=\"audio\" QualityLevels=\"%d\" Chunks=\"%d\" Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n", audio_streams, audio_chunks);
286 return ff_rename(temp_filename, filename, s);
295 if (mkdir(s->
filename, 0777) == -1 && errno != EEXIST) {
325 if (mkdir(os->
dirname, 0777) == -1 && errno != EEXIST) {
416 if (*moof_size < 8 || *moof_size > size)
421 if (len > *moof_size)
433 if (len < 8 || len >= *moof_size)
435 if (tag ==
MKTAG(
'u',
'u',
'i',
'd')) {
436 static const uint8_t tfxd[] = {
437 0x6d, 0x1d, 0x9b, 0x05, 0x42, 0xd5, 0x44, 0xe6,
438 0x80, 0xe2, 0x14, 0x1d, 0xaf, 0xf7, 0x57, 0xb2
442 if (!memcmp(uuid, tfxd, 16) && len >= 8 + 16 + 4 + 16) {
497 int n =
FFMIN(size,
sizeof(buf));
519 char filename[1024], target_filename[1024], header_filename[1024];
521 int64_t start_ts,
duration, moof_size;
539 if ((ret =
parse_fragment(s, filename, &start_ts, &duration, &moof_size, size)) < 0)
543 copy_moof(s, filename, header_filename, moof_size);
544 ret =
ff_rename(filename, target_filename, s);
547 add_fragment(os, target_filename, header_filename, start_ts, duration,
559 for (j = 0; j <
remove; j++) {
618 #define OFFSET(x) offsetof(SmoothStreamingContext, x)
619 #define E AV_OPT_FLAG_ENCODING_PARAM
621 {
"window_size",
"number of fragments kept in the manifest",
OFFSET(window_size),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX,
E },
622 {
"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 },
623 {
"lookahead_count",
"number of lookahead fragments",
OFFSET(lookahead_count),
AV_OPT_TYPE_INT, { .i64 = 2 }, 0, INT_MAX,
E },
624 {
"min_frag_duration",
"minimum fragment duration (in microseconds)",
OFFSET(min_frag_duration),
AV_OPT_TYPE_INT64, { .i64 = 5000000 }, 0, INT_MAX,
E },
625 {
"remove_at_exit",
"remove all fragments when finished",
OFFSET(remove_at_exit),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
E },
638 .
name =
"smoothstreaming",