1 /*
2 * Apple HTTP Live Streaming segmenter
3 * Copyright (c) 2012, Luca Barbato
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <float.h>
23
29
32
38
40 const AVClass *
class;
// Class for private options.
45 float time;
// Set by a private option.
46 int size;
// Set by a private option.
47 int wrap;
// Set by a private option.
52 int64_t
duration;
///< last segment duration computed so far, in seconds
59
61 {
64 int i;
65
67 if (!oc)
69
72
79 }
80
81 return 0;
82 }
83
85 {
87
88 if (!en)
90
92
95
98 else
100
102
107 } else
109
111
112 return 0;
113 }
114
116 {
118
119 while(p) {
120 en = p;
123 }
124 }
125
127 {
130 int target_duration = 0;
131 int ret = 0;
132
135 goto fail;
136
137 for (en = hls->
list; en; en = en->
next) {
140 }
141
144 avio_printf(hls->
pb,
"#EXT-X-TARGETDURATION:%d\n", target_duration);
147
148 for (en = hls->
list; en; en = en->
next) {
151 }
152
153 if (last)
155
156 fail:
158 return ret;
159 }
160
162 {
165 int err = 0;
166
169
174 }
175
178 return err;
179
182
183 return 0;
184 }
185
187 {
189 int ret, i;
190 char *p;
191 const char *pattern = "%d.ts";
192 int basename_size = strlen(s->
filename) + strlen(pattern) + 1;
193
195
198
202
205 "More than a single video stream present, "
206 "expect issues decoding it.\n");
207
209
212 goto fail;
213 }
214
216
219 goto fail;
220 }
221
223
225
226 if (p)
227 *p = '0円';
228
230
232 goto fail;
233
235 goto fail;
236
238 return ret;
239
240
241 fail:
242 if (ret) {
246 }
247 return ret;
248 }
249
251 {
256 int ret, is_ref_pkt = 0;
257
261 }
262
265 is_ref_pkt = 1;
268 }
269
270 if (is_ref_pkt &&
274
276 if (ret)
277 return ret;
278
281
284
286
287 if (ret)
288 return ret;
289
291
293 return ret;
294 }
295
297
298 return ret;
299 }
300
302 {
305
312
315 return 0;
316 }
317
318 #define OFFSET(x) offsetof(HLSContext, x)
319 #define E AV_OPT_FLAG_ENCODING_PARAM
321 {
"start_number",
"set first number in the sequence",
OFFSET(sequence),
AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX,
E},
326 };
327
333 };
334
335
339 .extensions = "m3u8",
347 .priv_class = &hls_class,
348 };