From b55a18019fec460902b6a1f1e5d598486e0fc957 Mon Sep 17 00:00:00 2001 From: nicodvb Date: Thu, 14 Dec 2006 23:08:09 +0000 Subject: implemented dvdnav_lang_from_aid() to retrieve audio language git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21619 b3059339-0415-0410-9bf9-f77b7e298cf2 --- stream/stream_dvdnav.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'stream/stream_dvdnav.c') diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 90172be1ab..e5fd6028c1 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -515,6 +515,36 @@ int dvdnav_aid_from_lang(stream_t *stream, unsigned char *language) { return -1; } +/** + * \brief dvdnav_lang_from_aid() assigns to buf the language corresponding to audio id 'aid' + * \param stream: - stream pointer + * \param sid: physical subtitle id + * \param buf: buffer to contain the 2-chars language string + * \return 0 on error, 1 if successful + */ +int dvdnav_lang_from_aid(stream_t *stream, int aid, unsigned char *buf) { + uint8_t lg; + uint16_t lang; + dvdnav_priv_t * priv=(dvdnav_priv_t*)stream->priv; + + if(aid >= 0x80 && aid < 0x88) + aid -= 0x80; + else if(aid >= 0x88 && aid <= 0x8F) + aid -= 0x88; + else if(aid >= 0xA0 && aid <= 0xAF) + aid -= 0xA0; + if(aid < 0) + return 0; + lg = dvdnav_get_audio_logical_stream(priv->dvdnav, aid); + if(lg == 0xff) return 0; + lang = dvdnav_audio_stream_to_lang(priv->dvdnav, lg); + if(lang == 0xffff) return 0; + buf[0] = lang >> 8; + buf[1] = lang & 0xFF; + buf[2] = 0; + return 1; +} + /** * \brief dvdnav_sid_from_lang() returns the subtitle id corresponding to the language code 'lang' -- cgit v1.2.3