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>
26
28
31
33 {
35 return;
38 }
39
41 const char *filename,
const char *
language,
42 int name_id, int is_default, int nb_channels)
43 {
44 if (!
out || !agroup || !filename)
45 return;
46
47 avio_printf(
out,
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"", agroup);
48 avio_printf(
out,
",NAME=\"audio_%d\",DEFAULT=%s,", name_id, is_default ?
"YES" :
"NO");
51 }
52 if (nb_channels) {
54 }
56 }
57
59 const char *filename,
const char *
language,
60 const char *sname, int name_id, int is_default)
61 {
62 if (!
out || !filename)
63 return;
64
65 avio_printf(
out,
"#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID=\"%s\"", sgroup);
66 if (sname) {
68 } else {
70 }
74 }
76 }
77
79 int avg_bandwidth,
80 const char *filename, const char *agroup,
81 const char *
codecs,
const char *ccgroup,
82 const char *sgroup)
83 {
84 if (!
out || !filename)
85 return;
86
87 if (!bandwidth) {
89 "Bandwidth info not available, set audio and video bitrates\n");
90 return;
91 }
92
94 if (avg_bandwidth)
101 if (agroup && agroup[0])
103 if (ccgroup && ccgroup[0])
105 if (sgroup && sgroup[0])
108 }
109
111 int target_duration,
int64_t sequence,
112 uint32_t playlist_type, int iframe_mode)
113 {
115 return;
117 if (allowcache == 0 || allowcache == 1) {
118 avio_printf(
out,
"#EXT-X-ALLOW-CACHE:%s\n", allowcache == 0 ?
"NO" :
"YES");
119 }
123
128 }
129 if (iframe_mode) {
131 }
132 }
133
136 {
138 if (byterange_mode) {
140 }
142 }
143
145 int byterange_mode,
double duration,
147 int64_t pos /* Used only if HLS_SINGLE_FILE flag is set */,
148 const char *baseurl /* Ignored if NULL */,
149 const char *filename, double *prog_date_time,
151 int iframe_mode)
152 {
153 if (!
out || !filename)
155
156 if (insert_discont) {
158 }
159 if (round_duration)
161 else
163 if (byterange_mode)
164 avio_printf(
out,
"#EXT-X-BYTERANGE:%"PRId64
"@%"PRId64
"\n", iframe_mode ? video_keyframe_size :
size,
165 iframe_mode ? video_keyframe_pos :
pos);
166
167 if (prog_date_time) {
168 time_t tt, wrongsecs;
169 int milli;
170 struct tm *tm, tmpbuf;
171 char buf0[128], buf1[128];
173 milli =
av_clip(
lrint(1000*(*prog_date_time - tt)), 0, 999);
175 if (!strftime(buf0, sizeof(buf0), "%Y-%m-%dT%H:%M:%S", tm)) {
178 }
179 if (!strftime(buf1, sizeof(buf1), "%z", tm) || buf1[1]<'0' ||buf1[1]>'2') {
180 int tz_min,
dst = tm->tm_isdst;
183 wrongsecs = mktime(tm);
184 tz_min = (
FFABS(wrongsecs - tt) + 30) / 60;
186 "%c%02d%02d",
187 wrongsecs <= tt ? '+' : '-',
188 tz_min / 60,
189 tz_min % 60);
190 }
191 avio_printf(
out,
"#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
193 }
194 if (baseurl)
197
198 return 0;
199 }
200
202 {
204 return;
206 }