|
|
|
@ -149,6 +149,11 @@ typedef struct DASHContext { |
|
|
|
|
char *allowed_extensions; |
|
|
|
|
AVDictionary *avio_opts; |
|
|
|
|
int max_url_size; |
|
|
|
|
|
|
|
|
|
/* Flags for init section*/ |
|
|
|
|
int is_init_section_common_video; |
|
|
|
|
int is_init_section_common_audio; |
|
|
|
|
|
|
|
|
|
} DASHContext; |
|
|
|
|
|
|
|
|
|
static int ishttp(char *url) |
|
|
|
@ -1862,6 +1867,45 @@ fail: |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int init_section_compare_video(DASHContext *c) |
|
|
|
|
{ |
|
|
|
|
int i = 0; |
|
|
|
|
char *url = c->videos[0]->init_section->url; |
|
|
|
|
int64_t url_offset = c->videos[0]->init_section->url_offset; |
|
|
|
|
int64_t size = c->videos[0]->init_section->size; |
|
|
|
|
for (i=0;i<c->n_videos;i++) { |
|
|
|
|
if (av_strcasecmp(c->videos[i]->init_section->url,url) || c->videos[i]->init_section->url_offset != url_offset || c->videos[i]->init_section->size != size) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int init_section_compare_audio(DASHContext *c) |
|
|
|
|
{ |
|
|
|
|
int i = 0; |
|
|
|
|
char *url = c->audios[0]->init_section->url; |
|
|
|
|
int64_t url_offset = c->audios[0]->init_section->url_offset; |
|
|
|
|
int64_t size = c->audios[0]->init_section->size; |
|
|
|
|
for (i=0;i<c->n_audios;i++) { |
|
|
|
|
if (av_strcasecmp(c->audios[i]->init_section->url,url) || c->audios[i]->init_section->url_offset != url_offset || c->audios[i]->init_section->size != size) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void copy_init_section(struct representation *rep_dest, struct representation *rep_src) |
|
|
|
|
{ |
|
|
|
|
memcpy(rep_dest->init_section, rep_src->init_section, sizeof(rep_src->init_section)); |
|
|
|
|
rep_dest->init_sec_buf = av_mallocz(rep_src->init_sec_buf_size); |
|
|
|
|
memcpy(rep_dest->init_sec_buf, rep_src->init_sec_buf, rep_src->init_sec_data_len); |
|
|
|
|
rep_dest->init_sec_buf_size = rep_src->init_sec_buf_size; |
|
|
|
|
rep_dest->init_sec_data_len = rep_src->init_sec_data_len; |
|
|
|
|
rep_dest->cur_timestamp = rep_src->cur_timestamp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int dash_read_header(AVFormatContext *s) |
|
|
|
|
{ |
|
|
|
|
void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb; |
|
|
|
@ -1890,19 +1934,35 @@ static int dash_read_header(AVFormatContext *s) |
|
|
|
|
s->duration = (int64_t) c->media_presentation_duration * AV_TIME_BASE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (c->n_videos) { |
|
|
|
|
c->is_init_section_common_video = init_section_compare_video(c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Open the demuxer for video and audio components if available */ |
|
|
|
|
for (i = 0; i < c->n_videos; i++) { |
|
|
|
|
struct representation *cur_video = c->videos[i]; |
|
|
|
|
if (i > 0 && c->is_init_section_common_video) { |
|
|
|
|
copy_init_section(cur_video,c->videos[0]); |
|
|
|
|
} |
|
|
|
|
ret = open_demux_for_component(s, cur_video); |
|
|
|
|
|
|
|
|
|
if (ret) |
|
|
|
|
goto fail; |
|
|
|
|
cur_video->stream_index = stream_index; |
|
|
|
|
++stream_index; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (c->n_audios) { |
|
|
|
|
c->is_init_section_common_audio = init_section_compare_audio(c); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (i = 0; i < c->n_audios; i++) { |
|
|
|
|
struct representation *cur_audio = c->audios[i]; |
|
|
|
|
if (i > 0 && c->is_init_section_common_audio) { |
|
|
|
|
copy_init_section(cur_audio,c->audios[0]); |
|
|
|
|
} |
|
|
|
|
ret = open_demux_for_component(s, cur_audio); |
|
|
|
|
|
|
|
|
|
if (ret) |
|
|
|
|
goto fail; |
|
|
|
|
cur_audio->stream_index = stream_index; |
|
|
|
|