mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-19 14:00:43 +00:00
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
This commit is contained in:
parent
406cb21b63
commit
5846d8a91e
@ -387,6 +387,7 @@ fail:
|
|||||||
static int open_input(HLSContext *c, struct playlist *pls)
|
static int open_input(HLSContext *c, struct playlist *pls)
|
||||||
{
|
{
|
||||||
AVDictionary *opts = NULL;
|
AVDictionary *opts = NULL;
|
||||||
|
AVDictionary *opts2 = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
struct segment *seg = pls->segments[pls->cur_seq_no - pls->start_seq_no];
|
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, "headers", c->headers, 0);
|
||||||
av_dict_set(&opts, "seekable", "0", 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) {
|
if (seg->key_type == KEY_NONE) {
|
||||||
ret = ffurl_open(&pls->input, seg->url, AVIO_FLAG_READ,
|
ret = ffurl_open(&pls->input, seg->url, AVIO_FLAG_READ,
|
||||||
&pls->parent->interrupt_callback, &opts);
|
&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)) {
|
if (strcmp(seg->key, pls->key_url)) {
|
||||||
URLContext *uc;
|
URLContext *uc;
|
||||||
if (ffurl_open(&uc, seg->key, AVIO_FLAG_READ,
|
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))
|
if (ffurl_read_complete(uc, pls->key, sizeof(pls->key))
|
||||||
!= sizeof(pls->key)) {
|
!= sizeof(pls->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",
|
||||||
@ -430,9 +434,7 @@ static int open_input(HLSContext *c, struct playlist *pls)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
av_opt_set(pls->input->priv_data, "key", key, 0);
|
av_opt_set(pls->input->priv_data, "key", key, 0);
|
||||||
av_opt_set(pls->input->priv_data, "iv", iv, 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) {
|
if ((ret = ffurl_connect(pls->input, &opts)) < 0) {
|
||||||
ffurl_close(pls->input);
|
ffurl_close(pls->input);
|
||||||
pls->input = NULL;
|
pls->input = NULL;
|
||||||
@ -445,6 +447,7 @@ static int open_input(HLSContext *c, struct playlist *pls)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
av_dict_free(&opts);
|
av_dict_free(&opts);
|
||||||
|
av_dict_free(&opts2);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user