[MPlayer-cvslog] r21616 - in trunk/stream: stream_dvdnav.c stream_dvdnav.h
nicodvb
subversion at mplayerhq.hu
Thu Dec 14 23:11:43 CET 2006
Author: nicodvb
Date: Thu Dec 14 23:11:43 2006
New Revision: 21616
Modified:
trunk/stream/stream_dvdnav.c
trunk/stream/stream_dvdnav.h
Log:
added dvdnav_aid_from_lang() to support -alang
Modified: trunk/stream/stream_dvdnav.c
==============================================================================
--- trunk/stream/stream_dvdnav.c (original)
+++ trunk/stream/stream_dvdnav.c Thu Dec 14 23:11:43 2006
@@ -473,6 +473,50 @@
}
/**
+ * \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
Modified: trunk/stream/stream_dvdnav.h
==============================================================================
--- trunk/stream/stream_dvdnav.h (original)
+++ trunk/stream/stream_dvdnav.h Thu Dec 14 23:11:43 2006
@@ -30,6 +30,7 @@
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);
More information about the MPlayer-cvslog
mailing list