Ejemplo n.º 1
0
        void TestStrings()
        {
            int hr;
            int pulwActualSize;
            int pulActualSize;
            DvdTextStringType pType;
            DvdTextStringType pwType;
            int            pulNumOfLangs;
            int            pulNumOfStrings;
            int            pLangCode;
            DvdTextCharSet pbCharacterSet;

            hr = m_idi2.GetDVDTextNumberOfLanguages(out pulNumOfLangs);
            DsError.ThrowExceptionForHR(hr);

            if (pulNumOfLangs > 0)
            {
                hr = m_idi2.GetDVDTextLanguageInfo(0, out pulNumOfStrings, out pLangCode, out pbCharacterSet);
                DsError.ThrowExceptionForHR(hr);

                StringBuilder sb1 = new StringBuilder(255, 255);
                hr = m_idi2.GetDVDTextStringAsNative(0, pulNumOfStrings - 1, sb1, sb1.Capacity, out pulActualSize, out pType);
                DsError.ThrowExceptionForHR(hr);

                Debug.Assert(sb1.Length > 0, "GetDVDTextStringAsNative");

                StringBuilder sb2 = new StringBuilder(255, 255);
                hr = m_idi2.GetDVDTextStringAsUnicode(0, pulNumOfStrings - 1, sb2, sb2.Capacity, out pulwActualSize, out pwType);
                DsError.ThrowExceptionForHR(hr);

                Debug.Assert(sb2.Length > 0, "GetDVDTextStringAsUnicode");
            }
        }
Ejemplo n.º 2
0
        private void FetchDVDInformation_DS(string volumePath)
        {
            IDvdGraphBuilder dvdGraphBuilder =
                Activator.CreateInstance(Type.GetTypeFromCLSID(Filters.DvdGraphBuilder, true))
                as IDvdGraphBuilder;

            AMDvdRenderStatus status;

            dvdGraphBuilder.TryRenderDVD(volumePath, out status);

            if (status.bDvdVolInvalid)
            {
                throw new COMException(ErrDvdVolume, -1);
            }

            object comobj = null;

            dvdGraphBuilder.GetDvdInterface(typeof(IDvdInfo2).GUID, out comobj);

            IDvdInfo2    dvdInfo    = comobj as IDvdInfo2;
            IDvdControl2 dvdControl = comobj as IDvdControl2;

            dvdControl.SetOption(DvdOptionFlag.HMSFTimeCodeEvents, true);       // use new HMSF timecode format
            dvdControl.SetOption(DvdOptionFlag.ResetOnStop, false);

            // Try getting the frame rate and the video size
            dvdInfo.GetVMGAttributes(out _dma);

            this.FrameRate = new FrameRate(_dma.VideoAttributes.frameRate);
            this.VideoSize = new VSize(_dma.VideoAttributes.sourceResolutionX, _dma.VideoAttributes.sourceResolutionY);

            // Try getting the DVD volume name.
            // Stage 1: Get the number of available languages.
            int numLangs = 0;

            dvdInfo.GetDVDTextNumberOfLanguages(out numLangs);

            if (numLangs > 0)
            {
                // Stage 2: Get string count for the first language.
                int            numStrings = 0;
                int            langId     = 0;
                DvdTextCharSet charSet    = DvdTextCharSet.CharSet_Unicode;

                dvdInfo.GetDVDTextLanguageInfo(0, out numStrings, out langId, out charSet);

                // Stage 3: Iterate through the string collection and identify the volume name
                for (int i = 0; i < numStrings; i++)
                {
                    int maxSize = 4096;

                    StringBuilder     sb      = new StringBuilder(maxSize);
                    int               txtSize = 0;
                    DvdTextStringType textType;

                    dvdInfo.GetDVDTextStringAsUnicode(0, i, sb, maxSize, out txtSize, out textType);

                    // Is this the volume name ?
                    if (textType == DvdTextStringType.DVD_General_Name)
                    {
                        // Volume name was found, so exit iteration.
                        _label = sb.ToString();
                        break;
                    }
                }
            }

            // Try getting the titles, chapters and overall duration info
            int         numVolumes = 0, volumeNumber = 0, numTitles = 0;
            DvdDiscSide sideInfo;

            dvdInfo.GetDVDVolumeInfo(out numVolumes, out volumeNumber, out sideInfo, out numTitles);

            for (int i = 1; i <= numTitles; i++)
            {
                int numChapters = 0;
                try
                {
                    DvdMenuAttributes  menuAttr;
                    DvdTitleAttributes titleAttr = new DvdTitleAttributes();

                    if (i == 1)
                    {
                        dvdInfo.GetTitleAttributes(i, out menuAttr, titleAttr);

                        for (int j = 0; j < titleAttr.ulNumberOfSubpictureStreams; j++)
                        {
                            _subtitles.Add(titleAttr.SubpictureAttributes[j]);
                        }
                    }

                    dvdInfo.GetNumberOfChapters(i, out numChapters);
                    _chaptersPerTitle.Add(numChapters);
                }
                catch { }
            }
        }