diff options
author | wm4 <wm4@nowhere> | 2012-08-03 12:24:55 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-08-03 13:25:41 +0200 |
commit | 9c02ae7e9510897826334ddf79fa3a0cf65a78a2 (patch) | |
tree | 813c9a2b757b2531d3fd29cf483ac1ba89093f7f /libmpdemux/stheader.h | |
parent | d722f8fe61296e5b277ed94be055bb9ef1c99e19 (diff) | |
download | mpv-9c02ae7e9510897826334ddf79fa3a0cf65a78a2.tar.bz2 mpv-9c02ae7e9510897826334ddf79fa3a0cf65a78a2.tar.xz |
demuxer: introduce a general stream struct
There are different C types for each stream type: sh_video for video,
sh_audio for audio, sh_sub for sub. There is no type that handles all
stream types in a generic way. Instead, there's a macro SH_COMMON, that
is used to define common fields for all 3 stream structs. Accessing
the common fields is hard if you want to be independent from the stream
type.
Introduce an actual generic stream struct (struct sh_stream), which is
supposed to unify all 3 stream types one day. Once all fields defined
by SH_COMMON have been moved into sh_stream, the transition is complete.
Move some fields into sh_stream, and rewrite osd_show_tracks to use
them.
Diffstat (limited to 'libmpdemux/stheader.h')
-rw-r--r-- | libmpdemux/stheader.h | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h index c93bcf8185..c0bf9e4db0 100644 --- a/libmpdemux/stheader.h +++ b/libmpdemux/stheader.h @@ -26,23 +26,43 @@ struct MPOpts; struct demuxer; -enum STREAM_TYPE { +enum stream_type { STREAM_VIDEO = 1, STREAM_AUDIO, - STREAM_SUBTITLE, + STREAM_SUB, }; // Stream headers: -// id: the type specific id, e.g. aid or sid -// index: index into stream array (currently one array per type) -// demuxer_id: demuxer specific ID (-1 if unknown, otherwise >= 0) +struct sh_stream { + enum stream_type type; + // Index into demuxer->streams. + int index; + // The (possibly) type specific id, e.g. aid or sid. + int tid; + // Index into stream array (currently one array per type, e.g. a_streams). + int stream_index; + // Demuxer specific ID (-1 if unknown, otherwise >= 0). + int demuxer_id; + // Abomination. + struct sh_common *common_header; + // One of these is non-NULL, the others are NULL, depending on the stream + // type. + struct sh_audio *audio; + struct sh_video *video; + struct sh_sub *sub; + + char *title; + bool default_track; + + // shouldn't exist type of stuff + struct MPOpts *opts; +}; + #define SH_COMMON \ - enum STREAM_TYPE stream_type; \ int id; \ - int index; \ - int demuxer_id; \ + struct sh_stream *gsh; \ const char *demuxer_codecname; \ struct MPOpts *opts; \ struct demux_stream *ds; \ @@ -64,8 +84,6 @@ enum STREAM_TYPE { void *context; \ const char *codecname; \ char *lang; /* track language */ \ - char *title; /* track title */ \ - bool default_track; \ typedef struct sh_common { SH_COMMON |