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 /mplayer.c | |
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 'mplayer.c')
-rw-r--r-- | mplayer.c | 48 |
1 files changed, 15 insertions, 33 deletions
@@ -383,29 +383,25 @@ char *get_metadata(struct MPContext *mpctx, metadata_t type) return talloc_strdup(NULL, ""); } -static void print_stream(struct MPContext *mpctx, sh_common_t *s) +static void print_stream(struct MPContext *mpctx, struct sh_stream *s) { const char *tname = "?"; const char *selopt = "?"; const char *langopt = "?"; - switch (s->stream_type) { + switch (s->type) { case STREAM_VIDEO: tname = "video"; selopt = "vid"; langopt = "vlang"; break; case STREAM_AUDIO: tname = "audio"; selopt = "aid"; langopt = "alang"; break; - case STREAM_SUBTITLE: + case STREAM_SUB: tname = "subtitle"; selopt = "sid"; langopt = "slang"; break; } mp_msg(MSGT_CPLAYER, MSGL_INFO, "[stream] ID %d: %s", s->demuxer_id, tname); - mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%d", selopt, s->id); - char *lang = NULL; - if (s->stream_type == STREAM_AUDIO) - lang = demuxer_audio_lang(mpctx->demuxer, s->index); - if (s->stream_type == STREAM_SUBTITLE) - lang = demuxer_sub_lang(mpctx->demuxer, s->index); + mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%d", selopt, s->tid); + char *lang = demuxer_stream_lang(mpctx->demuxer, s); if (lang) mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%s", langopt, lang); if (s->default_track) @@ -413,10 +409,11 @@ static void print_stream(struct MPContext *mpctx, sh_common_t *s) if (s->title) mp_msg(MSGT_CPLAYER, MSGL_INFO, " '%s'", s->title); mp_msg(MSGT_CPLAYER, MSGL_INFO, " ("); - if (s->format) { + if (s->common_header->format) { + int format = s->common_header->format; // not sure about endian crap - char name[sizeof(s->format) + 1] = {0}; - memcpy(name, &s->format, sizeof(s->format)); + char name[sizeof(format) + 1] = {0}; + memcpy(name, &format, sizeof(format)); bool ok = true; for (int n = 0; name[n]; n++) { if ((name[n] < 32 || name[n] >= 128) && name[n] != 0) @@ -425,9 +422,9 @@ static void print_stream(struct MPContext *mpctx, sh_common_t *s) if (ok && strlen(name) > 0) { mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); } else { - mp_msg(MSGT_CPLAYER, MSGL_INFO, "%#x", s->format); + mp_msg(MSGT_CPLAYER, MSGL_INFO, "%#x", format); } - } else if (s->stream_type == STREAM_SUBTITLE) { + } else if (s->type == STREAM_SUB) { char t = ((sh_sub_t*)s)->type; const char *name = NULL; switch (t) { @@ -439,8 +436,8 @@ static void print_stream(struct MPContext *mpctx, sh_common_t *s) name = (char[2]){t, '\0'}; mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); } - if (s->demuxer_codecname) - mp_msg(MSGT_CPLAYER, MSGL_INFO, "/%s", s->demuxer_codecname); + if (s->common_header->demuxer_codecname) + mp_msg(MSGT_CPLAYER, MSGL_INFO, "/%s", s->common_header->demuxer_codecname); mp_msg(MSGT_CPLAYER, MSGL_INFO, ")"); mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); } @@ -520,23 +517,8 @@ static void print_file_properties(struct MPContext *mpctx, const char *filename) } } } - // xxx I think this might be invalid C - // should resolve the crapmess in stheader.h - for (int n = 0; n < MAX_V_STREAMS; n++) { - sh_common_t *s = (sh_common_t*)mpctx->demuxer->v_streams[n]; - if (s) - print_stream(mpctx, s); - } - for (int n = 0; n < MAX_A_STREAMS; n++) { - sh_common_t *s = (sh_common_t*)mpctx->demuxer->a_streams[n]; - if (s) - print_stream(mpctx, s); - } - for (int n = 0; n < MAX_S_STREAMS; n++) { - sh_common_t *s = (sh_common_t*)mpctx->demuxer->s_streams[n]; - if (s) - print_stream(mpctx, s); - } + for (int n = 0; n < mpctx->demuxer->num_streams; n++) + print_stream(mpctx, mpctx->demuxer->streams[n]); } /// step size of mixer changes |