2015-02-17 22:46:12 +00:00
|
|
|
#include "common/common.h"
|
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "demux.h"
|
|
|
|
|
|
|
|
#include "timeline.h"
|
|
|
|
|
|
|
|
struct timeline *timeline_load(struct mpv_global *global, struct mp_log *log,
|
|
|
|
struct demuxer *demuxer)
|
|
|
|
{
|
|
|
|
if (!demuxer->desc->load_timeline)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
struct timeline *tl = talloc_ptrtype(NULL, tl);
|
|
|
|
*tl = (struct timeline){
|
|
|
|
.global = global,
|
|
|
|
.log = log,
|
2018-05-18 13:48:14 +00:00
|
|
|
.cancel = demuxer->cancel,
|
2015-02-17 22:46:12 +00:00
|
|
|
.demuxer = demuxer,
|
|
|
|
.track_layout = demuxer,
|
|
|
|
};
|
|
|
|
|
|
|
|
demuxer->desc->load_timeline(tl);
|
|
|
|
|
|
|
|
if (tl->num_parts)
|
|
|
|
return tl;
|
|
|
|
timeline_destroy(tl);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void timeline_destroy(struct timeline *tl)
|
|
|
|
{
|
|
|
|
if (!tl)
|
|
|
|
return;
|
|
|
|
for (int n = 0; n < tl->num_sources; n++) {
|
|
|
|
struct demuxer *d = tl->sources[n];
|
2017-01-30 18:38:43 +00:00
|
|
|
if (d != tl->demuxer && d != tl->track_layout)
|
2018-05-19 12:41:06 +00:00
|
|
|
demux_free(d);
|
2015-02-17 22:46:12 +00:00
|
|
|
}
|
2017-01-30 18:38:43 +00:00
|
|
|
if (tl->track_layout && tl->track_layout != tl->demuxer)
|
2018-05-19 12:41:06 +00:00
|
|
|
demux_free(tl->track_layout);
|
2015-02-17 22:46:12 +00:00
|
|
|
talloc_free(tl);
|
|
|
|
}
|