summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-11 17:25:46 +0000
committerptt <ptt@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-11 17:25:46 +0000
commit68613bbee71c87fa321fff8827837d7ce4d02581 (patch)
tree41e05a922e802b55653031e42807be5aacc40082
parentd0947a5bb7255ef357c35191260a5f1fc93d61a3 (diff)
downloadmpv-68613bbee71c87fa321fff8827837d7ce4d02581.tar.bz2
mpv-68613bbee71c87fa321fff8827837d7ce4d02581.tar.xz
added OSD audio switching visualization
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20162 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--help/help_mp-en.h1
-rw-r--r--libmpdemux/demux_mkv.c34
-rw-r--r--libmpdemux/matroska.h2
-rw-r--r--mplayer.c84
-rw-r--r--stream/stream_dvd.c13
-rw-r--r--stream/stream_dvd.h1
6 files changed, 120 insertions, 15 deletions
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index 77d3a68d97..aba94763a4 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -207,6 +207,7 @@ static char help_text[]=
#define MSGTR_OSDenabled "enabled"
#define MSGTR_OSDdisabled "disabled"
+#define MSGTR_OSDAudio "Audio: %s"
#define MSGTR_OSDChannel "Channel: %s"
#define MSGTR_OSDSubDelay "Sub delay: %d ms"
#define MSGTR_OSDSpeed "Speed: x %6.2f"
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c
index cc25d712f3..4ebc707b1e 100644
--- a/libmpdemux/demux_mkv.c
+++ b/libmpdemux/demux_mkv.c
@@ -3954,6 +3954,40 @@ demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
}
}
+/** \brief Get the language code for an audio track.
+
+ Retrieves the language code for an audio track if it is known.
+ If the language code is "und" then do not copy it ("und" = "undefined").
+
+ \param demuxer The demuxer to work on
+ \param track_num The n'th audio track to get the language from
+ \param lang Store the language here
+ \param maxlen The maximum number of characters to copy into lang
+*/
+void
+demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang,
+ int maxlen)
+{
+ mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
+ mkv_track_t *track;
+ int i, num;
+
+ num = 0;
+ for (i = 0; i < mkv_d->num_tracks; i++)
+ {
+ track = mkv_d->tracks[i];
+ if (track->type == MATROSKA_TRACK_AUDIO)
+ num++;
+ if (num == (track_num + 1))
+ {
+ if ((track->language != NULL) &&
+ strcmp(track->language, "und"))
+ strlcpy(lang, track->language, maxlen);
+ return;
+ }
+ }
+}
+
demuxer_desc_t demuxer_desc_matroska = {
"Matroska demuxer",
diff --git a/libmpdemux/matroska.h b/libmpdemux/matroska.h
index 2246f7dff8..c0c342a3c8 100644
--- a/libmpdemux/matroska.h
+++ b/libmpdemux/matroska.h
@@ -63,6 +63,8 @@
int demux_mkv_num_subs(demuxer_t *demuxer);
int demux_mkv_change_subs(demuxer_t *demuxer, int new_num);
+void demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang,
+ int maxlen);
void demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen);
diff --git a/mplayer.c b/mplayer.c
index 827d222c71..23f37ecfc2 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -193,6 +193,10 @@ static int max_framesize=0;
#include "libmpcodecs/vd.h"
//**************************************************************************//
+
+static void reinit_audio_chain(void);
+
+//**************************************************************************//
//**************************************************************************//
// Common FIFO functions, and keyboard/event FIFO code
@@ -1781,6 +1785,68 @@ static int mp_property_channels(m_option_t* prop,int action,void* arg) {
return m_property_int_ro(prop,action,arg,sh_audio->channels);
}
+/// Selected audio id (RW)
+static int mp_property_audio(m_option_t* prop,int action,void* arg) {
+ int current_id = -1;
+
+ if(!sh_audio) return M_PROPERTY_UNAVAILABLE;
+
+ switch(action) {
+ case M_PROPERTY_GET:
+ if(!arg) return 0;
+ *(int*)arg = audio_id;
+ return 1;
+ case M_PROPERTY_PRINT:
+ if(!arg) return 0;
+ *(char**)arg = malloc(64);
+ (*(char**)arg)[63] = 0;
+
+ if (demuxer->type == DEMUXER_TYPE_MATROSKA && audio_id >= 0) {
+ char lang[40] = MSGTR_Unknown;
+ demux_mkv_get_audio_lang(demuxer, audio_id, lang, 9);
+ lang[39] = 0;
+ snprintf(*(char**)arg, 63, "(%d) %s", audio_id, lang);
+ return 1;
+ }
+#ifdef USE_DVDREAD
+ if (audio_id >= 0) {
+ char lang[3] = "\0\0\0";
+ int code = 0;
+ code = dvd_lang_from_aid(stream, audio_id);
+ if (code) {
+ lang[0] = code >> 8;
+ lang[1] = code;
+ }
+ snprintf(*(char**)arg, 63, "(%d) %s", audio_id, code ? lang : MSGTR_Unknown);
+ return 1;
+ }
+#endif
+ snprintf(*(char**)arg, 63, MSGTR_Disabled);
+ return 1;
+
+ case M_PROPERTY_STEP_UP:
+ current_id = demuxer->audio->id;
+ audio_id = demuxer_switch_audio(demuxer, -1);
+ if(audio_id > -1 && demuxer->audio->id != current_id) {
+ sh_audio_t *sh2;
+ uninit_player(INITED_AO | INITED_ACODEC);
+ sh2 = demuxer->a_streams[demuxer->audio->id];
+ if(sh2) {
+ sh2->ds = demuxer->audio;
+ sh_audio = sh2;
+ reinit_audio_chain();
+ }
+ }
+ mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id);
+
+ break;
+ default:
+ return M_PROPERTY_NOT_IMPLEMENTED;
+ }
+
+ return 1;
+}
+
///@}
/// \defgroup VideoProperties Video properties
@@ -2352,6 +2418,8 @@ static m_option_t mp_properties[] = {
0, 0, 0, NULL },
{ "channels", mp_property_channels, CONF_TYPE_INT,
0, 0, 0, NULL },
+ { "switch_audio", mp_property_audio, CONF_TYPE_INT,
+ -1, -1, 0, NULL },
// Video
{ "fullscreen", mp_property_fullscreen, CONF_TYPE_FLAG,
@@ -2471,6 +2539,7 @@ static struct {
{ "volume", MP_CMD_VOLUME, 0, OSD_VOLUME, -1, MSGTR_Volume },
{ "mute", MP_CMD_MUTE, 1, 0, -1, MSGTR_MuteStatus },
{ "audio_delay", MP_CMD_AUDIO_DELAY, 0, 0, -1, MSGTR_AVDelayStatus },
+ { "switch_audio", MP_CMD_SWITCH_AUDIO, 1, 0, -1, MSGTR_OSDAudio },
// video
{ "fullscreen", MP_CMD_VO_FULLSCREEN, 1, 0, -1, NULL },
{ "panscan", MP_CMD_PANSCAN, 0, OSD_PANSCAN, -1, MSGTR_Panscan },
@@ -5107,21 +5176,6 @@ if(step_sec>0) {
pos = playing_audio_pts(sh_audio, d_audio, audio_out);
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
} break;
- case MP_CMD_SWITCH_AUDIO : {
- int current_id = demuxer->audio->id;
- int v = demuxer_switch_audio(demuxer, cmd->args[0].v.i);
- if(v > -1 && demuxer->audio->id != current_id) {
- sh_audio_t *sh2;
- uninit_player(INITED_AO | INITED_ACODEC);
- sh2 = demuxer->a_streams[demuxer->audio->id];
- if(sh2) {
- sh2->ds = demuxer->audio;
- sh_audio = sh2;
- reinit_audio_chain();
- }
- }
- mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", v);
- } break;
case MP_CMD_RUN : {
#ifndef __MINGW32__
if(!fork()) {
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index c3bdb0b3df..030343fb56 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -140,6 +140,19 @@ int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell)
return chapter;
}
+int dvd_lang_from_aid(stream_t *stream, int id) {
+ dvd_priv_t *d;
+ if (!stream) return 0;
+ d = stream->priv;
+ if (!d) return 0;
+ int i;
+ for(i=0;i<d->nr_of_channels;i++) {
+ if(d->audio_streams[i].id==id)
+ return d->audio_streams[i].language;
+ }
+ return 0;
+}
+
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang) {
dvd_priv_t *d=stream->priv;
int code,i;
diff --git a/stream/stream_dvd.h b/stream/stream_dvd.h
index 4968e752a8..1a2b314f35 100644
--- a/stream/stream_dvd.h
+++ b/stream/stream_dvd.h
@@ -45,6 +45,7 @@ typedef struct {
} dvd_priv_t;
int dvd_number_of_subs(stream_t *stream);
+int dvd_lang_from_aid(stream_t *stream, int id);
int dvd_lang_from_sid(stream_t *stream, int id);
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang);
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang);