summaryrefslogtreecommitdiffstats
path: root/libmpdemux/demuxer.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-08-19 18:01:30 +0200
committerwm4 <wm4@nowhere>2012-09-18 21:04:45 +0200
commit0f155921b046c9e6cfed3fe601aa891c2d2a8b16 (patch)
treeced8b2b76d00f3461bf12d0b5063ce2cf6fb8fe8 /libmpdemux/demuxer.h
parent13482fb397ce6bbcec8a9342015f21d48fb7efe6 (diff)
downloadmpv-0f155921b046c9e6cfed3fe601aa891c2d2a8b16.tar.bz2
mpv-0f155921b046c9e6cfed3fe601aa891c2d2a8b16.tar.xz
core: manage tracks in the frontend
Introduce a general track struct for every audio/video/subtitle track known to the frontend. External files (subtitles) are now represented as tracks too. This mainly serves to clean up the subtitle selection code: now every subtitle is simply a track, instead of using a messy numbering that goes by subtitle type (as it was stored in the global_sub_pos field). The mplayer fontend will list external subtitle files as additional tracks. The timeline code now tries to match the exact demuxer IDs of all tracks. This may cause problems when Matroska files with different track numberings are used with EDL timelines. Change demux_lavf not to set demuxer IDs, since most time they are not set.
Diffstat (limited to 'libmpdemux/demuxer.h')
-rw-r--r--libmpdemux/demuxer.h28
1 files changed, 11 insertions, 17 deletions
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index 63910240bc..50ab0525c4 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -28,6 +28,7 @@
#include "bstr.h"
#include "mpcommon.h"
#include "demux_packet.h"
+#include "stheader.h"
struct MPOpts;
@@ -103,6 +104,7 @@ enum timestamp_type {
#define MP_INPUT_BUFFER_PADDING_SIZE 16
typedef struct demux_stream {
+ enum stream_type stream_type;
int buffer_pos; // current buffer position
int buffer_size; // current buffer size
unsigned char *buffer; // current buffer, never free() it, always use free_demux_packet(buffer_ref);
@@ -233,6 +235,9 @@ typedef struct demuxer {
bool accurate_seek;
enum timestamp_type timestamp_type;
+ struct demux_stream *ds[STREAM_TYPE_COUNT]; // video/audio/sub buffers
+
+ // These correspond to ds[], e.g.: audio == ds[STREAM_AUDIO]
struct demux_stream *audio; // audio buffer/demuxer
struct demux_stream *video; // video buffer/demuxer
struct demux_stream *sub; // dvd subtitle buffer/demuxer
@@ -261,8 +266,6 @@ typedef struct demuxer {
char **info; // metadata
struct MPOpts *opts;
struct demuxer_params *params;
-
- int new_stream_id;
} demuxer_t;
typedef struct {
@@ -295,6 +298,8 @@ struct demuxer *new_demuxer(struct MPOpts *opts, struct stream *stream,
char *filename);
void free_demuxer(struct demuxer *demuxer);
+struct sh_stream *ds_gsh(struct demux_stream *ds);
+
void ds_add_packet(struct demux_stream *ds, struct demux_packet *dp);
void ds_read_packet(struct demux_stream *ds, struct stream *stream, int len,
double pts, off_t pos, bool keyframe);
@@ -369,8 +374,8 @@ char *demux_info_get(struct demuxer *demuxer, const char *opt);
int demux_info_print(struct demuxer *demuxer);
int demux_control(struct demuxer *demuxer, int cmd, void *arg);
-int demuxer_switch_audio(struct demuxer *demuxer, int index);
-int demuxer_switch_video(struct demuxer *demuxer, int index);
+void demuxer_switch_track(struct demuxer *demuxer, enum stream_type type,
+ struct sh_stream *stream);
int demuxer_type_by_filename(char *filename);
@@ -398,19 +403,8 @@ int demuxer_set_angle(struct demuxer *demuxer, int angle);
/// Get number of angles.
int demuxer_angles_count(struct demuxer *demuxer);
-/* Get the index of a track.
- * lang is a string list, NULL is same as empty list
- * Sort tracks based on the following criteria:
- * 1) earlier match in lang list, or last no match
- * 2) track is marked default (default wins)
- * 3) track number (lower wins)
- * For audio, select best track according to these criteria; only return -1
- * if there are no tracks at all.
- * For subs, select best track according to the same criteria, but return -1
- * if all tracks are no-lang-match, not-default.
- */
-int demuxer_audio_track_by_lang_and_default(struct demuxer *d, char **langt);
-int demuxer_sub_track_by_lang_and_default(struct demuxer *d, char **langt);
+struct sh_stream *demuxer_stream_by_demuxer_id(struct demuxer *d,
+ enum stream_type t, int id);
char *demuxer_stream_lang(demuxer_t *d, struct sh_stream *s);