1 /*
2 * Apple HTTP Live Streaming segmenter
3 * Copyright (c) 2012, Luca Barbato
4 * Copyright (c) 2017 Akamai Technologies, Inc.
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config.h"
24 #include <stdint.h>
25
27
30
32 {
34 return;
37 }
38
40 const char *filename,
const char *
language,
41 int name_id, int is_default)
42 {
43 if (!
out || !agroup || !filename)
44 return;
45
46 avio_printf(
out,
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"", agroup);
47 avio_printf(
out,
",NAME=\"audio_%d\",DEFAULT=%s,", name_id, is_default ?
"YES" :
"NO");
50 }
52 }
53
55 const char *filename,
const char *
language,
56 int name_id, int is_default)
57 {
58 if (!
out || !filename)
59 return;
60
61 avio_printf(
out,
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup);
62 avio_printf(
out,
",NAME=\"subtitle_%d\",DEFAULT=%s,", name_id, is_default ?
"YES" :
"NO");
65 }
67 }
68
70 const char *filename, const char *agroup,
71 const char *
codecs,
const char *ccgroup,
72 const char *sgroup)
73 {
74 if (!
out || !filename)
75 return;
76
77 if (!bandwidth) {
79 "Bandwidth info not available, set audio and video bitrates\n");
80 return;
81 }
82
89 if (agroup && agroup[0])
91 if (ccgroup && ccgroup[0])
93 if (sgroup && sgroup[0])
96 }
97
99 int target_duration, int64_t sequence,
100 uint32_t playlist_type, int iframe_mode)
101 {
103 return;
105 if (allowcache == 0 || allowcache == 1) {
106 avio_printf(
out,
"#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ?
"NO" :
"YES");
107 }
111
116 }
117 if (iframe_mode) {
119 }
120 }
121
123 int byterange_mode, int64_t
size, int64_t
pos)
124 {
126 if (byterange_mode) {
128 }
130 }
131
133 int byterange_mode,
double duration,
134 int round_duration, int64_t
size,
135 int64_t
pos /* Used only if HLS_SINGLE_FILE flag is set */,
136 const char *baseurl /* Ignored if NULL */,
137 const char *filename, double *prog_date_time,
138 int64_t video_keyframe_size, int64_t video_keyframe_pos,
139 int iframe_mode)
140 {
141 if (!
out || !filename)
143
144 if (insert_discont) {
146 }
147 if (round_duration)
149 else
151 if (byterange_mode)
152 avio_printf(
out,
"#EXT-X-BYTERANGE:%"PRId64
"@%"PRId64
"\n", iframe_mode ? video_keyframe_size :
size,
153 iframe_mode ? video_keyframe_pos :
pos);
154
155 if (prog_date_time) {
156 time_t tt, wrongsecs;
157 int milli;
158 struct tm *tm, tmpbuf;
159 char buf0[128], buf1[128];
160 tt = (int64_t)*prog_date_time;
161 milli =
av_clip(
lrint(1000*(*prog_date_time - tt)), 0, 999);
163 if (!strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm)) {
166 }
167 if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') {
168 int tz_min, dst = tm->tm_isdst;
170 tm->tm_isdst = dst;
171 wrongsecs = mktime(tm);
172 tz_min = (
FFABS(wrongsecs - tt) + 30) / 60;
174 "%c%02d%02d",
175 wrongsecs <= tt ? '+' : '-',
176 tz_min / 60,
177 tz_min % 60);
178 }
179 avio_printf(
out,
"#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
181 }
182 if (baseurl)
185
186 return 0;
187 }
188
190 {
192 return;
194 }
195