mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-03-17 20:17:55 +02:00
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>
This commit is contained in:
parent
8a33210d1b
commit
5cdd3b995c
@ -212,9 +212,14 @@ static int parse_playlist(HLSContext *c, const char *url,
|
|||||||
int close_in = 0;
|
int close_in = 0;
|
||||||
|
|
||||||
if (!in) {
|
if (!in) {
|
||||||
|
AVDictionary *opts = NULL;
|
||||||
close_in = 1;
|
close_in = 1;
|
||||||
if ((ret = avio_open2(&in, url, AVIO_FLAG_READ,
|
/* Some HLS servers dont like being sent the range header */
|
||||||
c->interrupt_callback, NULL)) < 0)
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,17 +330,20 @@ fail:
|
|||||||
|
|
||||||
static int open_input(struct variant *var)
|
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];
|
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) {
|
if (seg->key_type == KEY_NONE) {
|
||||||
return ffurl_open(&var->input, seg->url, AVIO_FLAG_READ,
|
ret = ffurl_open(&var->input, seg->url, AVIO_FLAG_READ,
|
||||||
&var->parent->interrupt_callback, NULL);
|
&var->parent->interrupt_callback, &opts);
|
||||||
|
goto cleanup;
|
||||||
} else if (seg->key_type == KEY_AES_128) {
|
} else if (seg->key_type == KEY_AES_128) {
|
||||||
char iv[33], key[33], url[MAX_URL_SIZE];
|
char iv[33], key[33], url[MAX_URL_SIZE];
|
||||||
int ret;
|
|
||||||
if (strcmp(seg->key, var->key_url)) {
|
if (strcmp(seg->key, var->key_url)) {
|
||||||
URLContext *uc;
|
URLContext *uc;
|
||||||
if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ,
|
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))
|
if (ffurl_read_complete(uc, var->key, sizeof(var->key))
|
||||||
!= sizeof(var->key)) {
|
!= sizeof(var->key)) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
|
av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
|
||||||
@ -357,18 +365,23 @@ static int open_input(struct variant *var)
|
|||||||
snprintf(url, sizeof(url), "crypto:%s", seg->url);
|
snprintf(url, sizeof(url), "crypto:%s", seg->url);
|
||||||
if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ,
|
if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ,
|
||||||
&var->parent->interrupt_callback)) < 0)
|
&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, "key", key, 0);
|
||||||
av_opt_set(var->input->priv_data, "iv", iv, 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);
|
ffurl_close(var->input);
|
||||||
var->input = NULL;
|
var->input = NULL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = AVERROR(ENOSYS);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
av_dict_free(&opts);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return AVERROR(ENOSYS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int read_data(void *opaque, uint8_t *buf, int buf_size)
|
static int read_data(void *opaque, uint8_t *buf, int buf_size)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user