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;
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:
159 }
160
162 {
165 int err = 0;
166
171 }
173
176 return err;
177
180
181 return 0;
182 }
183
185 {
188 char *p;
189 const char *pattern = "%d.ts";
190 int basename_size = strlen(s->
filename) + strlen(pattern) + 1;
191
193
196
200
203 "More than a single video stream present, "
204 "expect issues decoding it.\n");
205
207
210 goto fail;
211 }
212
214
217 goto fail;
218 }
219
221
223
224 if (p)
225 *p = '0円';
226
228
230 goto fail;
231
233 goto fail;
234
237
238
239 fail:
240 if (ret) {
244 }
246 }
247
249 {
254 int is_ref_pkt = 1;
255 int ret, can_split = 1;
256
260 }
261
266 }
268 is_ref_pkt = can_split = 0;
269
270 if (is_ref_pkt)
273
277 if (ret)
279
282
285
287
288 if (ret)
290
292
295 }
296
298
300 }
301
303 {
306
313
316 return 0;
317 }
318
319 #define OFFSET(x) offsetof(HLSContext, x)
320 #define E AV_OPT_FLAG_ENCODING_PARAM
322 {
"start_number",
"set first number in the sequence",
OFFSET(sequence),
AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX,
E},
326 { NULL },
327 };
328
334 };
335
336
340 .extensions = "m3u8",
348 .priv_class = &hls_class,
349 };