summaryrefslogtreecommitdiff
path: root/libavformat/hls.c
diff options
context:
space:
mode:
authorMikael Finstad <finstaden@gmail.com>2014-01-27 11:05:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-28 18:50:58 +0100
commit5846d8a91ebd953ad7cdad6a27267509e87e0821 (patch)
tree13784edd8ff1008816246aec98c3a2b97d189c5b /libavformat/hls.c
parent406cb21b63658b6ff310e1f8493cf35ec28d8682 (diff)
avformat/hls: Fix cookies and user agent with encrypted HLS streams
Session data (cookies, user-agent) is not being sent on payload requests with encrypted HLS streams This causes services like Akamai to give a 403 forbidden when requesting the TS files, because they expect the same cookies and user-agent on all requests
Diffstat (limited to 'libavformat/hls.c')
-rw-r--r--libavformat/hls.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 148c79650c..e291950597 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -387,6 +387,7 @@ fail:
static int open_input(HLSContext *c, struct playlist *pls)
{
AVDictionary *opts = NULL;
+ AVDictionary *opts2 = NULL;
int ret;
struct segment *seg = pls->segments[pls->cur_seq_no - pls->start_seq_no];
@@ -396,6 +397,9 @@ static int open_input(HLSContext *c, struct playlist *pls)
av_dict_set(&opts, "headers", c->headers, 0);
av_dict_set(&opts, "seekable", "0", 0);
+ // Same opts for key request (ffurl_open mutilates the opts so it cannot be used twice)
+ av_dict_copy(&opts2, opts, 0);
+
if (seg->key_type == KEY_NONE) {
ret = ffurl_open(&pls->input, seg->url, AVIO_FLAG_READ,
&pls->parent->interrupt_callback, &opts);
@@ -405,7 +409,7 @@ static int open_input(HLSContext *c, struct playlist *pls)
if (strcmp(seg->key, pls->key_url)) {
URLContext *uc;
if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ,
- &pls->parent->interrupt_callback, &opts) == 0) {
+ &pls->parent->interrupt_callback, &opts2) == 0) {
if (ffurl_read_complete(uc, pls->key, sizeof(pls->key))
!= sizeof(pls->key)) {
av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
@@ -430,9 +434,7 @@ static int open_input(HLSContext *c, struct playlist *pls)
goto cleanup;
av_opt_set(pls->input->priv_data, "key", key, 0);
av_opt_set(pls->input->priv_data, "iv", iv, 0);
- /* Need to repopulate options */
- av_dict_free(&opts);
- av_dict_set(&opts, "seekable", "0", 0);
+
if ((ret = ffurl_connect(pls->input, &opts)) < 0) {
ffurl_close(pls->input);
pls->input = NULL;
@@ -445,6 +447,7 @@ static int open_input(HLSContext *c, struct playlist *pls)
cleanup:
av_dict_free(&opts);
+ av_dict_free(&opts2);
return ret;
}