Пример #1
0
        void TestAudio()
        {
            int hr;

            int pLanguage;

            hr = m_idi2.GetAudioLanguage(0, out pLanguage);
            DsError.ThrowExceptionForHR(hr);
            DvdAudioAttributes pAATR;

            Debug.Assert(pLanguage == 1033, "TestAudio");

            int             pALLanguage;
            DvdAudioLangExt pAudioExtension;

            hr = m_idi2.GetDefaultAudioLanguage(out pALLanguage, out pAudioExtension);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pALLanguage == -1, "TestAudio2");

            hr = m_idi2.GetAudioAttributes(0, out pAATR);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pAATR.dwFrequency == 48000, "TestAudio3");

            bool pbEnabled;

            hr = m_idi2.IsAudioStreamEnabled(0, out pbEnabled);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pbEnabled, "TestAudio4");
        }
Пример #2
0
        protected override bool EnumerateStreams(bool forceRefresh)
        {
            if (_dvdInfo == null || !_initialized)
            {
                return(false);
            }

            StreamInfoHandler audioStreams;
            StreamInfoHandler subtitleStreams;

            lock (SyncObj)
            {
                audioStreams    = _streamInfoAudio;
                subtitleStreams = _streamInfoSubtitles;
            }

            if (forceRefresh || audioStreams == null || subtitleStreams == null)
            {
                audioStreams    = new StreamInfoHandler();
                subtitleStreams = new StreamInfoHandler();

                int streamsAvailable, currentStream;
                _dvdInfo.GetCurrentAudio(out streamsAvailable, out currentStream);
                for (int i = 0; i < streamsAvailable; ++i)
                {
                    int audioLanguage;
                    DvdAudioAttributes attr;
                    _dvdInfo.GetAudioLanguage(i, out audioLanguage);
                    _dvdInfo.GetAudioAttributes(i, out attr);

                    int    currentLCID  = (audioLanguage & 0x3ff);
                    string languageName = GetLanguageName(currentLCID);

                    StringBuilder currentAudio = new StringBuilder();
                    currentAudio.AppendFormat("{0} ({1}/{2} ch/{3} KHz)", languageName, attr.AudioFormat, attr.bNumberOfChannels, (attr.dwFrequency / 1000));

                    switch (attr.LanguageExtension)
                    {
                    case DvdAudioLangExt.NotSpecified:
                    case DvdAudioLangExt.Captions:
                        break;

                    case DvdAudioLangExt.VisuallyImpaired:
                    case DvdAudioLangExt.DirectorComments1:
                    case DvdAudioLangExt.DirectorComments2:
                        currentAudio.AppendFormat(" ({0})", ServiceRegistration.Get <ILocalization>().ToString("[Playback." + attr.LanguageExtension + "]"));
                        break;
                    }
                    audioStreams.AddUnique(new StreamInfo(null, i, currentAudio.ToString(), currentLCID));
                }

                bool isDisabled;
                _dvdInfo.GetCurrentSubpicture(out streamsAvailable, out currentStream, out isDisabled);
                for (int i = 0; i < streamsAvailable; ++i)
                {
                    DvdSubpictureAttributes attr;
                    int iLanguage;
                    _dvdInfo.GetSubpictureLanguage(i, out iLanguage);
                    _dvdInfo.GetSubpictureAttributes(i, out attr);
                    int    currentLCID  = (iLanguage & 0x3ff);
                    string languageName = GetLanguageName(currentLCID);

                    String localizationTag = attr.LanguageExtension.ToString();
                    String currentSubtitle = String.Format("{0} {1}", languageName,
                                                           ServiceRegistration.Get <ILocalization>().ToString("[Playback." + localizationTag + "]") ?? localizationTag);

                    subtitleStreams.AddUnique(new StreamInfo(null, i, currentSubtitle, currentLCID));
                }

                lock (SyncObj)
                {
                    _streamInfoAudio     = audioStreams;
                    _streamInfoSubtitles = subtitleStreams;
                }
                return(true); // refreshed
            }
            return(false);
        }