aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-14 22:11:43 +0000
committerGravatar nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-14 22:11:43 +0000
commit1b5ce67b7eb4a824f6ea14c71778bb23576aad2a (patch)
tree4bf5355864adec3bf2bc9ebe33ef412c66af8ba9
parent2025452bd0abd0e2c15dfebf4e402cbcb263eca3 (diff)
added dvdnav_aid_from_lang() to support -alang
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21616 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--stream/stream_dvdnav.c44
-rw-r--r--stream/stream_dvdnav.h1
2 files changed, 45 insertions, 0 deletions
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index c651837ed2..90172be1ab 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -473,6 +473,50 @@ void mp_dvdnav_update_mouse_pos(stream_t *stream, int32_t x, int32_t y, int* but
}
/**
+ * \brief dvdnav_aid_from_lang() returns the audio id corresponding to the language code 'lang'
+ * \param stream: - stream pointer
+ * \param lang: 2-characters language code[s], eventually separated by spaces of commas
+ * \return -1 on error, current subtitle id if successful
+ */
+int dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) {
+ dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv;
+ int k;
+ uint8_t format, lg;
+ uint16_t lang, lcode;;
+
+#ifdef DVDNAV_FORMAT_AC3
+ //this macro is defined only in libdvdnav-cvs
+ while(language && strlen(language)>=2) {
+ lcode = (language[0] << 8) | (language[1]);
+ for(k=0; k<32; k++) {
+ lg = dvdnav_get_audio_logical_stream(priv->dvdnav, k);
+ if(lg == 0xff) continue;
+ lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg);
+ if(lang != 0xFFFF && lang == lcode) {
+ format = dvdnav_audio_stream_format(priv->dvdnav, lg);
+ switch(format) {
+ case DVDNAV_FORMAT_AC3:
+ return k+128;
+ case DVDNAV_FORMAT_DTS:
+ return k+136;
+ case DVDNAV_FORMAT_LPCM:
+ return k+160;
+ case DVDNAV_FORMAT_MPEGAUDIO:
+ return k;
+ default:
+ return -1;
+ }
+ }
+ }
+ language += 2;
+ while(language[0]==',' || language[0]==' ') ++language;
+ }
+#endif
+ return -1;
+}
+
+
+/**
* \brief dvdnav_sid_from_lang() returns the subtitle id corresponding to the language code 'lang'
* \param stream: - stream pointer
* \param lang: 2-characters language code[s], eventually separated by spaces of commas
diff --git a/stream/stream_dvdnav.h b/stream/stream_dvdnav.h
index 4d10eb4b6a..22086b2b1a 100644
--- a/stream/stream_dvdnav.h
+++ b/stream/stream_dvdnav.h
@@ -30,6 +30,7 @@ typedef struct {
int dvdnav_number_of_subs(stream_t *stream);
+int dvdnav_aid_from_lang(stream_t *stream, unsigned char *language);
int dvdnav_sid_from_lang(stream_t *stream, unsigned char *language);
int dvdnav_lang_from_sid(stream_t *stream, int sid, unsigned char *buf);
int mp_dvdnav_handle_input(stream_t *stream, int cmd, int *button);