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

Function parse_cc_stream_mapstring

libavformat/hlsenc.c:2129–2204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2127}
2128
2129static int parse_cc_stream_mapstring(AVFormatContext *s)
2130{
2131 HLSContext *hls = s->priv_data;
2132 int nb_ccstreams = 0;
2133 char *p, *q, *ccstr, *keyval;
2134 char *saveptr1 = NULL, *saveptr2 = NULL;
2135 const char *val;
2136 ClosedCaptionsStream *ccs;
2137
2138 p = av_strdup(hls->cc_stream_map);
2139 if(!p)
2140 return AVERROR(ENOMEM);
2141
2142 q = p;
2143 while (av_strtok(q, " \t", &saveptr1)) {
2144 q = NULL;
2145 nb_ccstreams++;
2146 }
2147 av_freep(&p);
2148
2149 hls->cc_streams = av_mallocz(sizeof(*hls->cc_streams) * nb_ccstreams);
2150 if (!hls->cc_streams)
2151 return AVERROR(ENOMEM);
2152 hls->nb_ccstreams = nb_ccstreams;
2153
2154 p = hls->cc_stream_map;
2155 nb_ccstreams = 0;
2156 while (ccstr = av_strtok(p, " \t", &saveptr1)) {
2157 p = NULL;
2158
2159 if (nb_ccstreams < hls->nb_ccstreams)
2160 ccs = &(hls->cc_streams[nb_ccstreams++]);
2161 else
2162 return AVERROR(EINVAL);
2163
2164 while (keyval = av_strtok(ccstr, ",", &saveptr2)) {
2165 ccstr = NULL;
2166
2167 if (av_strstart(keyval, "ccgroup:", &val)) {
2168 ccs->ccgroup = val;
2169 } else if (av_strstart(keyval, "instreamid:", &val)) {
2170 ccs->instreamid = val;
2171 } else if (av_strstart(keyval, "language:", &val)) {
2172 ccs->language = val;
2173 } else {
2174 av_log(s, AV_LOG_ERROR, "Invalid keyval %s\n", keyval);
2175 return AVERROR(EINVAL);
2176 }
2177 }
2178
2179 if (!ccs->ccgroup || !ccs->instreamid) {
2180 av_log(s, AV_LOG_ERROR, "Insufficient parameters in cc stream map string\n");
2181 return AVERROR(EINVAL);
2182 }
2183
2184 if (av_strstart(ccs->instreamid, "CC", &val)) {
2185 if (atoi(val) < 1 || atoi(val) > 4) {
2186 av_log(s, AV_LOG_ERROR, "Invalid instream ID CC index %d in %s, range 1-4\n",

Callers 1

Calls 6

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

Tested by

no test coverage detected