MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / parse_variant_stream_mapstring

Function parse_variant_stream_mapstring

libavformat/hlsenc.c:1983–2127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1981}
1982
1983static int parse_variant_stream_mapstring(AVFormatContext *s)
1984{
1985 HLSContext *hls = s->priv_data;
1986 VariantStream *vs;
1987 int stream_index, i, j;
1988 enum AVMediaType codec_type;
1989 int nb_varstreams = 0, nb_streams;
1990 char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval;
1991 const char *val;
1992
1993 /**
1994 * Expected format for var_stream_map string is as below:
1995 * "a:0,v:0 a:1,v:1"
1996 * "a:0,agroup:a0,default:1,language:ENG a:1,agroup:a1,default:0 v:0,agroup:a0 v:1,agroup:a1"
1997 * This string specifies how to group the audio, video and subtitle streams
1998 * into different variant streams. The variant stream groups are separated
1999 * by space.
2000 *
2001 * a:, v:, s: are keys to specify audio, video and subtitle streams
2002 * respectively. Allowed values are 0 to 9 digits (limited just based on
2003 * practical usage)
2004 *
2005 * agroup: is key to specify audio group. A string can be given as value.
2006 * sgroup: is key to specify subtitle group. A string can be given as value.
2007 */
2008 p = av_strdup(hls->var_stream_map);
2009 if (!p)
2010 return AVERROR(ENOMEM);
2011
2012 q = p;
2013 while (av_strtok(q, " \t", &saveptr1)) {
2014 q = NULL;
2015 nb_varstreams++;
2016 }
2017 av_freep(&p);
2018
2019 hls->var_streams = av_mallocz(sizeof(*hls->var_streams) * nb_varstreams);
2020 if (!hls->var_streams)
2021 return AVERROR(ENOMEM);
2022 hls->nb_varstreams = nb_varstreams;
2023
2024 p = hls->var_stream_map;
2025 nb_varstreams = 0;
2026 while (varstr = av_strtok(p, " \t", &saveptr1)) {
2027 p = NULL;
2028
2029 if (nb_varstreams < hls->nb_varstreams) {
2030 vs = &(hls->var_streams[nb_varstreams]);
2031 vs->var_stream_idx = nb_varstreams;
2032 vs->is_default = 0;
2033 nb_varstreams++;
2034 } else
2035 return AVERROR(EINVAL);
2036
2037 q = varstr;
2038 while (1) {
2039 if (!av_strncasecmp(q, "a:", 2) || !av_strncasecmp(q, "v:", 2) ||
2040 !av_strncasecmp(q, "s:", 2))

Callers 1

Calls 9

av_strdupFunction · 0.85
av_strtokFunction · 0.85
av_freepFunction · 0.85
av_strncasecmpFunction · 0.85
av_strstartFunction · 0.85
av_logFunction · 0.85
av_isdigitFunction · 0.85
av_malloczFunction · 0.50

Tested by

no test coverage detected