avformat/hls: open playlists immediately when AVDISCARD_ALL is dropped

Do not try to delay opening newly required playlists until a segment
switch. Applications expect that newly selected undiscarded streams are
available immediately, especially with alternative rendition streams
(selectable audio/subtitle tracks).

One might think that delaying variant stream switch until a segment
switch would allow a "seamless" switch without us having to download a
specific segment from two different variant playlists. However, that is
not the case, since the application would have to keep the previous
stream available (undiscarded) until the first packet of the newly
selected stream arrives, but by that time the demuxer would have already
downloaded the next segment of both variants.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
This commit is contained in:
Anssi Hannula 2014-01-03 10:51:55 +02:00
parent 05ce529a59
commit ad701326b4
1 changed files with 2 additions and 12 deletions

View File

@ -164,7 +164,6 @@ typedef struct HLSContext {
struct rendition **renditions; struct rendition **renditions;
int cur_seq_no; int cur_seq_no;
int end_of_segment;
int first_packet; int first_packet;
int64_t first_timestamp; int64_t first_timestamp;
int64_t cur_timestamp; int64_t cur_timestamp;
@ -1053,7 +1052,6 @@ reload:
v->input = NULL; v->input = NULL;
v->cur_seq_no++; v->cur_seq_no++;
c->end_of_segment = 1;
c->cur_seq_no = v->cur_seq_no; c->cur_seq_no = v->cur_seq_no;
goto restart; goto restart;
@ -1480,13 +1478,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
HLSContext *c = s->priv_data; HLSContext *c = s->priv_data;
int ret, i, minplaylist = -1; int ret, i, minplaylist = -1;
if (c->first_packet) { recheck_discard_flags(s, c->first_packet);
recheck_discard_flags(s, 1);
c->first_packet = 0;
}
start:
c->end_of_segment = 0;
for (i = 0; i < c->n_playlists; i++) { for (i = 0; i < c->n_playlists; i++) {
struct playlist *pls = c->playlists[i]; struct playlist *pls = c->playlists[i];
/* Make sure we've got one buffered packet from each open playlist /* Make sure we've got one buffered packet from each open playlist
@ -1551,10 +1544,7 @@ start:
} }
} }
} }
if (c->end_of_segment) {
if (recheck_discard_flags(s, 0))
goto start;
}
/* If we got a packet, return it */ /* If we got a packet, return it */
if (minplaylist >= 0) { if (minplaylist >= 0) {
struct playlist *pls = c->playlists[minplaylist]; struct playlist *pls = c->playlists[minplaylist];