* Apple HTTP Live Streaming Protocol Handler
* 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
*/
char url[MAX_URL_SIZE];
};
-typedef struct AppleHTTPContext {
+typedef struct HLSContext {
char playlisturl[MAX_URL_SIZE];
int target_duration;
int start_seq_no;
int cur_seq_no;
URLContext *seg_hd;
int64_t last_load_time;
-} AppleHTTPContext;
+} HLSContext;
static int read_chomp_line(AVIOContext *s, char *buf, int maxlen)
{
return len;
}
-static void free_segment_list(AppleHTTPContext *s)
+static void free_segment_list(HLSContext *s)
{
int i;
for (i = 0; i < s->n_segments; i++)
s->n_segments = 0;
}
-static void free_variant_list(AppleHTTPContext *s)
+static void free_variant_list(HLSContext *s)
{
int i;
for (i = 0; i < s->n_variants; i++)
static int parse_playlist(URLContext *h, const char *url)
{
- AppleHTTPContext *s = h->priv_data;
+ HLSContext *s = h->priv_data;
AVIOContext *in;
int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
char line[1024];
free_segment_list(s);
s->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}};
return ret;
}
-static int applehttp_close(URLContext *h)
+static int hls_close(URLContext *h)
{
- AppleHTTPContext *s = h->priv_data;
+ HLSContext *s = h->priv_data;
free_segment_list(s);
free_variant_list(s);
return 0;
}
-static int applehttp_open(URLContext *h, const char *uri, int flags)
+static int hls_open(URLContext *h, const char *uri, int flags)
{
- AppleHTTPContext *s = h->priv_data;
+ HLSContext *s = h->priv_data;
int ret, i;
const char *nested_url;
ret = AVERROR(EINVAL);
goto fail;
}
+ av_log(h, AV_LOG_WARNING,
+ "Using the hls protocol is discouraged, please try using the "
+ "hls demuxer instead. The hls demuxer should be more complete "
+ "and work as well as the protocol implementation. (If not, "
+ "please report it.) To use the demuxer, simply use %s as url.\n",
+ s->playlisturl);
if ((ret = parse_playlist(h, s->playlisturl)) < 0)
goto fail;
return 0;
fail:
- applehttp_close(h);
+ hls_close(h);
return ret;
}
-static int applehttp_read(URLContext *h, uint8_t *buf, int size)
+static int hls_read(URLContext *h, uint8_t *buf, int size)
{
- AppleHTTPContext *s = h->priv_data;
+ HLSContext *s = h->priv_data;
const char *url;
int ret;
int64_t reload_interval;
#if FF_API_APPLEHTTP_PROTO
URLProtocol ff_applehttp_protocol = {
.name = "applehttp",
- .url_open = applehttp_open,
- .url_read = applehttp_read,
- .url_close = applehttp_close,
+ .url_open = hls_open,
+ .url_read = hls_read,
+ .url_close = hls_close,
.flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
- .priv_data_size = sizeof(AppleHTTPContext),
+ .priv_data_size = sizeof(HLSContext),
};
#endif
URLProtocol ff_hls_protocol = {
.name = "hls",
- .url_open = applehttp_open,
- .url_read = applehttp_read,
- .url_close = applehttp_close,
+ .url_open = hls_open,
+ .url_read = hls_read,
+ .url_close = hls_close,
.flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
- .priv_data_size = sizeof(AppleHTTPContext),
+ .priv_data_size = sizeof(HLSContext),
};