summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
Diffstat (limited to 'player')
-rw-r--r--player/command.c7
-rw-r--r--player/core.h7
-rw-r--r--player/loadfile.c12
-rw-r--r--player/playloop.c4
-rw-r--r--player/timeline/tl_cue.c8
-rw-r--r--player/timeline/tl_matroska.c8
-rw-r--r--player/timeline/tl_mpv_edl.c14
7 files changed, 24 insertions, 36 deletions
diff --git a/player/command.c b/player/command.c
index dbe81bff15..2995f094a0 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1081,12 +1081,13 @@ static int mp_property_chapter_metadata(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
- struct demuxer *demuxer = mpctx->master_demuxer;
int chapter = get_current_chapter(mpctx);
- if (!demuxer || chapter < 0 || chapter >= demuxer->num_chapters)
+ if (chapter < 0 || chapter >= mpctx->num_chapters)
+ return M_PROPERTY_UNAVAILABLE;
+ if (!mpctx->chapters[chapter].metadata)
return M_PROPERTY_UNAVAILABLE;
- return tag_property(action, arg, demuxer->chapters[chapter].metadata);
+ return tag_property(action, arg, mpctx->chapters[chapter].metadata);
}
static int mp_property_vf_metadata(void *ctx, struct m_property *prop,
diff --git a/player/core.h b/player/core.h
index 445c0c7105..ae0a5c5dbb 100644
--- a/player/core.h
+++ b/player/core.h
@@ -47,11 +47,6 @@ struct timeline_part {
struct demuxer *source;
};
-struct chapter {
- double start;
- char *name;
-};
-
enum mp_osd_seek_info {
OSD_SEEK_INFO_BAR = 1,
OSD_SEEK_INFO_TEXT = 2,
@@ -195,7 +190,7 @@ typedef struct MPContext {
struct timeline_part *timeline;
int num_timeline_parts;
int timeline_part;
- struct chapter *chapters;
+ struct demux_chapter *chapters;
int num_chapters;
double video_offset;
diff --git a/player/loadfile.c b/player/loadfile.c
index a7905a8a36..efca08519c 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -797,16 +797,8 @@ static void load_chapters(struct MPContext *mpctx)
}
if (src && !mpctx->chapters) {
talloc_free(mpctx->chapters);
- int count = src->num_chapters;
- mpctx->chapters = talloc_array(NULL, struct chapter, count);
- mpctx->num_chapters = count;
- for (int n = 0; n < count; n++) {
- struct demux_chapter *dchapter = &src->chapters[n];
- mpctx->chapters[n] = (struct chapter){
- .start = dchapter->start / 1e9,
- .name = talloc_strdup(mpctx->chapters, dchapter->name),
- };
- }
+ mpctx->num_chapters = src->num_chapters;
+ mpctx->chapters = demux_copy_chapter_data(src->chapters, src->num_chapters);
}
if (free_src) {
struct stream *s = src->stream;
diff --git a/player/playloop.c b/player/playloop.c
index 8a0aba2ec8..22cc12f70d 100644
--- a/player/playloop.c
+++ b/player/playloop.c
@@ -451,7 +451,7 @@ int get_current_chapter(struct MPContext *mpctx)
double current_pts = get_current_time(mpctx);
int i;
for (i = 0; i < mpctx->num_chapters; i++)
- if (current_pts < mpctx->chapters[i].start)
+ if (current_pts < mpctx->chapters[i].pts)
break;
return MPMAX(mpctx->last_chapter_seek, i - 1);
}
@@ -490,7 +490,7 @@ double chapter_start_time(struct MPContext *mpctx, int chapter)
if (chapter == -1)
return get_start_time(mpctx);
if (chapter >= 0 && chapter < mpctx->num_chapters)
- return mpctx->chapters[chapter].start;
+ return mpctx->chapters[chapter].pts;
return MP_NOPTS_VALUE;
}
diff --git a/player/timeline/tl_cue.c b/player/timeline/tl_cue.c
index a4f23c45cf..8b8afeae17 100644
--- a/player/timeline/tl_cue.c
+++ b/player/timeline/tl_cue.c
@@ -361,8 +361,8 @@ void build_cue_timeline(struct MPContext *mpctx)
struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline,
track_count + 1);
- struct chapter *chapters = talloc_array_ptrtype(NULL, chapters,
- track_count);
+ struct demux_chapter *chapters = talloc_array_ptrtype(NULL, chapters,
+ track_count);
double starttime = 0;
for (int i = 0; i < track_count; i++) {
struct demuxer *source = mpctx->sources[1 + tracks[i].source];
@@ -387,8 +387,8 @@ void build_cue_timeline(struct MPContext *mpctx)
.source_start = tracks[i].start,
.source = source,
};
- chapters[i] = (struct chapter) {
- .start = timeline[i].start,
+ chapters[i] = (struct demux_chapter) {
+ .pts = timeline[i].start,
// might want to include other metadata here
.name = bstrdup0(chapters, tracks[i].title),
};
diff --git a/player/timeline/tl_matroska.c b/player/timeline/tl_matroska.c
index 6f64ae8484..e97a8ce594 100644
--- a/player/timeline/tl_matroska.c
+++ b/player/timeline/tl_matroska.c
@@ -380,7 +380,7 @@ static void build_timeline_loop(struct MPContext *mpctx,
uint64_t *missing_time,
uint64_t *last_end_time,
struct timeline_part **timeline,
- struct chapter *chapters,
+ struct demux_chapter *chapters,
int *part_count,
uint64_t skip,
uint64_t limit)
@@ -419,7 +419,7 @@ static void build_timeline_loop(struct MPContext *mpctx,
* needed to add chapters for external non-ordered segment loading
* as well since that part is not recursive. */
if (!limit) {
- chapters[i].start = *starttime / 1e9;
+ chapters[i].pts = *starttime / 1e9;
chapters[i].name = talloc_strdup(chapters, c->name);
}
@@ -560,8 +560,8 @@ void build_ordered_chapter_timeline(struct MPContext *mpctx)
talloc_free(uids);
struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline, 0);
- struct chapter *chapters =
- talloc_zero_array(NULL, struct chapter, m->num_ordered_chapters);
+ struct demux_chapter *chapters =
+ talloc_zero_array(NULL, struct demux_chapter, m->num_ordered_chapters);
uint64_t starttime = 0;
uint64_t missing_time = 0;
uint64_t last_end_time = 0;
diff --git a/player/timeline/tl_mpv_edl.c b/player/timeline/tl_mpv_edl.c
index e11b483935..4cd62fc497 100644
--- a/player/timeline/tl_mpv_edl.c
+++ b/player/timeline/tl_mpv_edl.c
@@ -158,20 +158,20 @@ static double demuxer_chapter_time(struct demuxer *demuxer, int n)
{
if (n < 0 || n >= demuxer->num_chapters)
return -1;
- return demuxer->chapters[n].start / 1e9;
+ return demuxer->chapters[n].pts;
}
// Append all chapters from src to the chapters array.
// Ignore chapters outside of the given time range.
-static void copy_chapters(struct chapter **chapters, int *num_chapters,
+static void copy_chapters(struct demux_chapter **chapters, int *num_chapters,
struct demuxer *src, double start, double len,
double dest_offset)
{
for (int n = 0; n < src->num_chapters; n++) {
double time = demuxer_chapter_time(src, n);
if (time >= start && time <= start + len) {
- struct chapter ch = {
- .start = dest_offset + time - start,
+ struct demux_chapter ch = {
+ .pts = dest_offset + time - start,
.name = talloc_strdup(*chapters, src->chapters[n].name),
};
MP_TARRAY_APPEND(NULL, *chapters, *num_chapters, ch);
@@ -208,7 +208,7 @@ static void resolve_timestamps(struct tl_part *part, struct demuxer *demuxer)
static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
{
- struct chapter *chapters = talloc_new(NULL);
+ struct demux_chapter *chapters = talloc_new(NULL);
int num_chapters = 0;
struct timeline_part *timeline = talloc_array_ptrtype(NULL, timeline,
parts->num_parts + 1);
@@ -244,8 +244,8 @@ static void build_timeline(struct MPContext *mpctx, struct tl_parts *parts)
}
// Add a chapter between each file.
- struct chapter ch = {
- .start = starttime,
+ struct demux_chapter ch = {
+ .pts = starttime,
.name = talloc_strdup(chapters, part->filename),
};
MP_TARRAY_APPEND(NULL, chapters, num_chapters, ch);