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

Function output_mpd

tools/sidxindex.c:232–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232static int output_mpd(struct Tracks *tracks, const char *filename)
233{
234 FILE *out;
235 int i, j, ret = 0;
236 struct Track **adaptation_sets_buf[2] = { NULL };
237 struct Track ***adaptation_sets;
238 int nb_tracks_buf[2] = { 0 };
239 int *nb_tracks;
240 int set, nb_sets;
241
242 if (!tracks->multiple_tracks_per_file) {
243 adaptation_sets = adaptation_sets_buf;
244 nb_tracks = nb_tracks_buf;
245 nb_sets = 2;
246 for (i = 0; i < 2; i++) {
247 adaptation_sets[i] = av_malloc_array(tracks->nb_tracks, sizeof(*adaptation_sets[i]));
248 if (!adaptation_sets[i]) {
249 ret = AVERROR(ENOMEM);
250 goto err;
251 }
252 }
253 for (i = 0; i < tracks->nb_tracks; i++) {
254 int set_index = -1;
255 if (tracks->tracks[i]->is_video)
256 set_index = 0;
257 else if (tracks->tracks[i]->is_audio)
258 set_index = 1;
259 else
260 continue;
261 adaptation_sets[set_index][nb_tracks[set_index]++] = tracks->tracks[i];
262 }
263 } else {
264 adaptation_sets = &tracks->tracks;
265 nb_tracks = &tracks->nb_tracks;
266 nb_sets = 1;
267 }
268
269 out = fopen(filename, "w");
270 if (!out) {
271 ret = AVERROR(errno);
272 perror(filename);
273 return ret;
274 }
275 fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
276 fprintf(out, "<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
277 "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n"
278 "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
279 "\txsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd\"\n"
280 "\tprofiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n"
281 "\ttype=\"static\"\n");
282 fprintf(out, "\tmediaPresentationDuration=\"");
283 write_time(out, tracks->duration, 1, AV_ROUND_DOWN);
284 fprintf(out, "\"\n");
285 fprintf(out, "\tminBufferTime=\"PT5S\">\n");
286
287 fprintf(out, "\t<Period start=\"PT0.0S\">\n");
288
289 for (set = 0; set < nb_sets; set++) {

Callers 1

mainFunction · 0.85

Calls 3

av_malloc_arrayFunction · 0.85
write_timeFunction · 0.70
av_freeFunction · 0.70

Tested by

no test coverage detected