* Apple HTTP Live Streaming demuxer
* Copyright (c) 2010 Martin Storsjo
*
- * This file is part of Libav.
+ * This file is part of FFmpeg.
*
- * Libav is free software; you can redistribute it and/or
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * Libav is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
+ * License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
* http://tools.ietf.org/html/draft-pantos-http-live-streaming
*/
-#define _XOPEN_SOURCE 600
#include "libavutil/avstring.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
+#include "libavutil/dict.h"
#include "avformat.h"
#include "internal.h"
#include <unistd.h>
free_segment_list(var);
var->finished = 0;
}
- while (!in->eof_reached) {
+ while (!url_feof(in)) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
if (v->n_segments == 0)
continue;
+ if (!(v->ctx = avformat_alloc_context())) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
v->index = i;
v->needed = 1;
v->parent = s;
NULL, 0, 0);
if (ret < 0)
goto fail;
- ret = av_open_input_stream(&v->ctx, &v->pb, v->segments[0]->url,
- in_fmt, NULL);
+ v->ctx->pb = &v->pb;
+ ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL);
if (ret < 0)
goto fail;
v->stream_offset = stream_offset;
}
avcodec_copy_context(st->codec, v->ctx->streams[j]->codec);
if (v->bandwidth)
- av_metadata_set2(&st->metadata, "variant_bitrate", bitrate_str,
+ av_dict_set(&st->metadata, "variant_bitrate", bitrate_str,
0);
}
stream_offset += v->ctx->nb_streams;
if (var->needed && !var->pkt.data) {
ret = av_read_frame(var->ctx, &var->pkt);
if (ret < 0) {
- if (!var->pb.eof_reached)
+ if (!url_feof(&var->pb))
return ret;
reset_packet(&var->pkt);
}
}
AVInputFormat ff_applehttp_demuxer = {
- "applehttp",
- NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming format"),
- sizeof(AppleHTTPContext),
- applehttp_probe,
- applehttp_read_header,
- applehttp_read_packet,
- applehttp_close,
- applehttp_read_seek,
+ .name = "applehttp",
+ .long_name = NULL_IF_CONFIG_SMALL("Apple HTTP Live Streaming format"),
+ .priv_data_size = sizeof(AppleHTTPContext),
+ .read_probe = applehttp_probe,
+ .read_header = applehttp_read_header,
+ .read_packet = applehttp_read_packet,
+ .read_close = applehttp_close,
+ .read_seek = applehttp_read_seek,
};