@@ -1666,9 +1666,10 @@ reload:
goto restart;
}
-static void add_renditions_to_variant(HLSContext *c, struct variant *var,
- enum AVMediaType type, const char *group_id)
+static int add_renditions_to_variant(HLSContext *c, struct variant *var,
+ enum AVMediaType type, const char *group_id)
{
+ int ret;
int i;
for (i = 0; i < c->n_renditions; i++) {
@@ -1676,18 +1677,26 @@ static void add_renditions_to_variant(HLSContext *c, struct variant *var,
if (rend->type == type && !strcmp(rend->group_id, group_id)) {
- if (rend->playlist)
+ if (rend->playlist) {
/* rendition is an external playlist
* => add the playlist to the variant */
- dynarray_add(&var->playlists, &var->n_playlists, rend->playlist);
- else
+ ret = av_dynarray_add_nofree(&var->playlists, &var->n_playlists,
+ rend->playlist);
+ if (ret < 0)
+ return ret;
+ } else {
/* rendition is part of the variant main Media Playlist
* => add the rendition to the main Media Playlist */
- dynarray_add(&var->playlists[0]->renditions,
- &var->playlists[0]->n_renditions,
- rend);
+ ret = av_dynarray_add_nofree(&var->playlists[0]->renditions,
+ &var->playlists[0]->n_renditions,
+ rend);
+ if (ret < 0)
+ return ret;
+ }
}
}
+
+ return 0;
}
static void add_metadata_from_renditions(AVFormatContext *s, struct playlist *pls,
@@ -1987,12 +1996,24 @@ static int hls_read_header(AVFormatContext *s)
for (i = 0; i < c->n_variants; i++) {
struct variant *var = c->variants[i];
- if (var->audio_group[0])
- add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO, var->audio_group);
- if (var->video_group[0])
- add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO, var->video_group);
- if (var->subtitles_group[0])
- add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE, var->subtitles_group);
+ if (var->audio_group[0]) {
+ ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_AUDIO,
+ var->audio_group);
+ if (ret < 0)
+ return ret;
+ }
+ if (var->video_group[0]) {
+ ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_VIDEO,
+ var->video_group);
+ if (ret < 0)
+ return ret;
+ }
+ if (var->subtitles_group[0]) {
+ ret = add_renditions_to_variant(c, var, AVMEDIA_TYPE_SUBTITLE,
+ var->subtitles_group);
+ if (ret < 0)
+ return ret;
+ }
}
/* Create a program for each variant */