Permalink
Browse files

[DVDInputStreamNavigator/Players] Use a struct and dvdnav_get_audio_i…

…nfo(...) to query all required audio stream info at once.

[Fixes]
- Fix stream type, e.g. "(Directors Comments)", recognition. It is stored in code_extension not in lang_extension.

- Properly set the number of channels of a dvd audio stream.

- Set the stream language of dvd audio tracks properly/consistent with other audio streams, i.e. set it to a three char code.

- Set the stream name of dvd audio tracks properly/consistent with other audio streams.
  • Loading branch information...
1 parent 89bd125 commit 63bb4a64007caefaf6815e52306fb4c9a65e7731 @ace20022 committed Mar 4, 2013
@@ -27,6 +27,7 @@
#include "utils/log.h"
#include "guilib/Geometry.h"
#include "utils/URIUtils.h"
+#include "utils/StringUtils.h"
#if defined(TARGET_DARWIN)
#include "osx/CocoaInterface.h"
#endif
@@ -925,37 +926,101 @@ int CDVDInputStreamNavigator::GetActiveAudioStream()
return activeStream;
}
-std::string CDVDInputStreamNavigator::GetAudioStreamLanguage(int iId)
+void CDVDInputStreamNavigator::SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes)
{
- if (!m_dvdnav) return NULL;
+ switch( audio_attributes.code_extension )
+ {
+ case DVD_AUDIO_LANG_EXT_VisuallyImpaired:
+ info.name = "(Visually Impaired)";
+ break;
+ case DVD_AUDIO_LANG_EXT_DirectorsComments1:
+ info.name = "(Directors Comments)";
+ break;
+ case DVD_AUDIO_LANG_EXT_DirectorsComments2:
+ info.name = "(Directors Comments 2)";
+ break;
+ case DVD_AUDIO_LANG_EXT_NotSpecified:
+ case DVD_AUDIO_LANG_EXT_NormalCaptions:
+ default:
+ break;
+ }
- CStdString strLanguage;
+ switch(audio_attributes.audio_format)
+ {
+ case DVD_AUDIO_FORMAT_AC3:
+ info.name += " AC3";
+ break;
+ case DVD_AUDIO_FORMAT_MPEG1:
+ case DVD_AUDIO_FORMAT_MPEG1_DRC:
+ info.name += " MP1";
+ break;
+ case DVD_AUDIO_FORMAT_MPEG2:
+ case DVD_AUDIO_FORMAT_MPEG2_DRC:
+ info.name += " MP2";
+ break;
+ case DVD_AUDIO_FORMAT_LPCM:
+ info.name += " LPCM";
+ break;
+ case DVD_AUDIO_FORMAT_DTS:
+ info.name += " DTS";
+ break;
+ case DVD_AUDIO_FORMAT_SDDS:
+ info.name += " SDDS";
+ break;
+ default:
+ info.name += " Other";
+ break;
+ }
+
+ switch(audio_attributes.channels + 1)
+ {
+ case 1:
+ info.name += " Mono";
+ break;
+ case 2:
+ info.name += " Stereo";
+ break;
+ case 6:
+ info.name += " 5.1";
+ break;
+ case 7:
+ info.name += " 6.1";
+ break;
+ default:
+ char temp[32];
+ sprintf(temp, " %d-chs", audio_attributes.channels + 1);
+ info.name += temp;
+ }
+
+ StringUtils::TrimLeft(info.name);
+
+}
+
+bool CDVDInputStreamNavigator::GetAudioStreamInfo(const int iId, DVDNavStreamInfo &info)
+{
+ if (!m_dvdnav) return false;
- audio_attr_t audio_attributes;
int streamId = ConvertAudioStreamId_XBMCToExternal(iId);
+ audio_attr_t audio_attributes;
+
if( m_dll.dvdnav_get_audio_info(m_dvdnav, streamId, &audio_attributes) == DVDNAV_STATUS_OK )
{
- if (!g_LangCodeExpander.Lookup(strLanguage, audio_attributes.lang_code)) strLanguage = "Unknown";
+ SetAudioStreamName(info, audio_attributes);
- switch( audio_attributes.lang_extension )
- {
- case DVD_AUDIO_LANG_EXT_VisuallyImpaired:
- strLanguage+= " (Visually Impaired)";
- break;
- case DVD_AUDIO_LANG_EXT_DirectorsComments1:
- strLanguage+= " (Directors Comments)";
- break;
- case DVD_AUDIO_LANG_EXT_DirectorsComments2:
- strLanguage+= " (Directors Comments 2)";
- break;
- case DVD_AUDIO_LANG_EXT_NotSpecified:
- case DVD_AUDIO_LANG_EXT_NormalCaptions:
- default:
- break;
- }
- }
+ char lang[3];
+ lang[2] = 0;
+ lang[1] = (audio_attributes.lang_code & 255);
+ lang[0] = (audio_attributes.lang_code >> 8) & 255;
- return strLanguage;
+ CStdString temp;
+ g_LangCodeExpander.ConvertToThreeCharCode(temp, lang);
+ info.language = temp;
+
+ info.channels = audio_attributes.channels + 1;
+
+ return true;
+ }
+ return false;
}
int CDVDInputStreamNavigator::GetAudioStreamCount()
@@ -44,6 +44,15 @@ class CDVDOverlayPicture;
struct dvdnav_s;
+struct DVDNavStreamInfo
+{
+ std::string name;
+ std::string language;
+ int channels;
+
+ DVDNavStreamInfo() : channels(0) {}
+};
+
class DVDNavResult
{
public:
@@ -104,9 +113,9 @@ class CDVDInputStreamNavigator
bool IsSubtitleStreamEnabled();
int GetActiveAudioStream();
- std::string GetAudioStreamLanguage(int iId);
int GetAudioStreamCount();
bool SetActiveAudioStream(int iId);
+ bool GetAudioStreamInfo(const int iId, DVDNavStreamInfo &info);
bool GetNavigatorState(std::string &xmlstate);
bool SetNavigatorState(std::string &xmlstate);
@@ -145,6 +154,8 @@ class CDVDInputStreamNavigator
int ConvertSubtitleStreamId_XBMCToExternal(int id);
int ConvertSubtitleStreamId_ExternalToXBMC(int id);
+ void SetAudioStreamName(DVDNavStreamInfo &info, const audio_attr_t audio_attributes);
+
DllDvdNav m_dll;
bool m_bCheckButtons;
bool m_bEOF;
@@ -318,10 +318,14 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
s.source = source;
s.type = STREAM_AUDIO;
s.id = i;
- s.name = nav->GetAudioStreamLanguage(i);
s.flags = CDemuxStream::FLAG_NONE;
s.filename = filename;
- s.channels = 0;
+
+ DVDNavStreamInfo info;
+ nav->GetAudioStreamInfo(i, info);
+ s.name = info.name;
+ s.language = info.language;
+ s.channels = info.channels;
Update(s);
}
@@ -318,10 +318,14 @@ void COMXSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
s.source = source;
s.type = STREAM_AUDIO;
s.id = i;
- s.name = nav->GetAudioStreamLanguage(i);
s.flags = CDemuxStream::FLAG_NONE;
s.filename = filename;
- s.channels = 0;
+
+ DVDNavStreamInfo info;
+ nav->GetAudioStreamInfo(i, info);
+ s.name = info.name;
+ s.language = info.language;
+ s.channels = info.channels;
Update(s);
}

0 comments on commit 63bb4a6

Please sign in to comment.