aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/hls.c
diff options
context:
space:
mode:
authorDuncan Salerno <duncan.salerno@gmail.com>2012-10-02 22:22:44 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-10-05 05:15:55 +0200
commit5cdd3b995c9dd79ab6ab852a27e75a21c0eb4f5f (patch)
tree101f28160b9faaffe618057eb64b993207bac473 /libavformat/hls.c
parent8a33210d1b104db04743f127ea617ab40e2bcdda (diff)
downloadffmpeg-5cdd3b995c9dd79ab6ab852a27e75a21c0eb4f5f.tar.gz
hls: Disable http seekability probing
Some HLS servers return 403 when the Range header is present. Disabling http seekability probing prevents the header from being added. Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/hls.c')
-rw-r--r--libavformat/hls.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 00c3cf01fb..1f5309b642 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -212,9 +212,14 @@ static int parse_playlist(HLSContext *c, const char *url,
int close_in = 0;
if (!in) {
+ AVDictionary *opts = NULL;
close_in = 1;
- if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
- c->interrupt_callback, NULL)) < 0)
+ /* Some HLS servers dont like being sent the range header */
+ av_dict_set(&opts, "seekable", "0", 0);
+ ret = avio_open2(&in, url, AVIO_FLAG_READ,
+ c->interrupt_callback, &opts);
+ av_dict_free(&opts);
+ if (ret < 0)
return ret;
}
@@ -325,17 +330,20 @@ fail:
static int open_input(struct variant *var)
{
+ AVDictionary *opts = NULL;
+ int ret;
struct segment *seg = var->segments[var->cur_seq_no - var->start_seq_no];
+ av_dict_set(&opts, "seekable", "0", 0);
if (seg->key_type == KEY_NONE) {
- return ffurl_open(&var->input, seg->url, AVIO_FLAG_READ,
- &var->parent->interrupt_callback, NULL);
+ ret = ffurl_open(&var->input, seg->url, AVIO_FLAG_READ,
+ &var->parent->interrupt_callback, &opts);
+ goto cleanup;
} else if (seg->key_type == KEY_AES_128) {
char iv[33], key[33], url[MAX_URL_SIZE];
- int ret;
if (strcmp(seg->key, var->key_url)) {
URLContext *uc;
if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ,
- &var->parent->interrupt_callback, NULL) == 0) {
+ &var->parent->interrupt_callback, &opts) == 0) {
if (ffurl_read_complete(uc, var->key, sizeof(var->key))
!= sizeof(var->key)) {
av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
@@ -357,17 +365,22 @@ static int open_input(struct variant *var)
snprintf(url, sizeof(url), "crypto:%s", seg->url);
if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ,
&var->parent->interrupt_callback)) < 0)
- return ret;
+ goto cleanup;
av_opt_set(var->input->priv_data, "key", key, 0);
av_opt_set(var->input->priv_data, "iv", iv, 0);
- if ((ret = ffurl_connect(var->input, NULL)) < 0) {
+ if ((ret = ffurl_connect(var->input, &opts)) < 0) {
ffurl_close(var->input);
var->input = NULL;
- return ret;
+ goto cleanup;
}
- return 0;
+ ret = 0;
}
- return AVERROR(ENOSYS);
+ else
+ ret = AVERROR(ENOSYS);
+
+cleanup:
+ av_dict_free(&opts);
+ return ret;
}
static int read_data(void *opaque, uint8_t *buf, int buf_size)