Пример #1
0
        void TestDiskInfo()
        {
            int         hr;
            int         pulNumOfVolumes;
            int         pulVolume;
            DvdDiscSide pSide;
            int         pulNumOfTitles;
            int         pulDActualSize;

            hr = m_idi2.GetDVDVolumeInfo(out pulNumOfVolumes, out pulVolume, out pSide, out pulNumOfTitles);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pulNumOfTitles == 2, "TestDiskInfo");

            StringBuilder sb = new StringBuilder(255, 255);

            hr = m_idi2.GetDVDDirectory(sb, sb.Capacity, out pulDActualSize);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(sb.ToString() == MyDisk, "TestDiskInfo2");

            long l1;

            hr = m_idi2.GetDiscID(sb.ToString(), out l1);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(l1 == 6633412489990086489, "TestDiskInfo3");

            DvdMenuAttributes pMATR = new DvdMenuAttributes();

            hr = m_idi2.GetVMGAttributes(out pMATR);
            DsError.ThrowExceptionForHR(hr);

            Debug.Assert(pMATR.VideoAttributes.sourceResolutionX == 720, "TestDiskInfo4");
        }
Пример #2
0
        protected override void OnGraphRunning()
        {
            base.OnGraphRunning();
            VideoSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <VideoSettings>();

            int hr = _dvdCtrl.SelectVideoModePreference(_videoPref);

            if (hr != 0)
            {
                ServiceRegistration.Get <ILogger>().Error("DVDPlayer: Unable to set DVD video mode preference 0x{0:X}", hr);
            }

            hr = _dvdInfo.GetCurrentVideoAttributes(out _videoAttr);
            if (hr != 0)
            {
                ServiceRegistration.Get <ILogger>().Error("DVDPlayer: Unable to get DVD video attributes 0x{0:X}", hr);
            }

            DvdDiscSide side;
            int         titles, numOfVolumes, volume;

            hr = _dvdInfo.GetDVDVolumeInfo(out numOfVolumes, out volume, out side, out titles);
            if (hr < 0)
            {
                ServiceRegistration.Get <ILogger>().Error("DVDPlayer: Unable to get DVD volume info 0x{0:X}", hr);
            }

            if (titles <= 0)
            {
                ServiceRegistration.Get <ILogger>().Error("DVDPlayer: DVD does not contain any titles? (# titles = {0})", titles);
            }

            _pendingCmd = false;

            _dvdCtrl.SetSubpictureState(settings.EnableSubtitles, DvdCmdFlags.None, out _cmdOption);

            _line21Decoder = FilterGraphTools.FindFilterByInterface <IAMLine21Decoder>(_graphBuilder);
            if (_line21Decoder != null)
            {
                AMLine21CCState state = settings.EnableClosedCaption ? AMLine21CCState.On : AMLine21CCState.Off;
                if (_line21Decoder.SetServiceState(state) == 0)
                {
                    ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: {0} Closed Captions", settings.EnableClosedCaption ? "Enabled" : "Disabled");
                }
                else
                {
                    ServiceRegistration.Get <ILogger>().Debug("DVDPlayer: Failed to set Closed Captions state.");
                }
            }
        }
Пример #3
0
        private void dvdControlContextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // build the list of Title/Chapter menu items
            if (_videoWindow != null && _videoWindow.DVDControl != null)
            {
                chaptersToolStripMenuItem.DropDown.Items.Clear();
                IDvdInfo2 dvdinfo = _videoWindow.DVDControl as IDvdInfo2;
                if (dvdinfo != null)
                {
                    int         numVol;
                    DvdDiscSide side = new DvdDiscSide();
                    int         vol;
                    int         numTitles;

                    int hr = dvdinfo.GetDVDVolumeInfo(out numVol, out vol, out side, out numTitles);
                    if (hr == 0)
                    {
                        for (int i = 0; i < numTitles; i++)
                        {
                            ToolStripMenuItem titlemi = new ToolStripMenuItem("Title " + (i + 1).ToString());
                            chaptersToolStripMenuItem.DropDown.Items.Add(titlemi);
                            int numChapters;
                            hr = dvdinfo.GetNumberOfChapters(i + 1, out numChapters);
                            if (hr == 0)
                            {
                                for (int x = 0; x < numChapters; x++)
                                {
                                    ToolStripMenuItem chapmi = new ToolStripMenuItem("Chapter " + (x + 1).ToString());
                                    chapmi.Tag    = new DVDTitleChapterPair(i + 1, x + 1);
                                    chapmi.Click += new EventHandler(chaptermenuitem_Click);
                                    titlemi.DropDown.Items.Add(chapmi);
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        /// <summary> handling the very first start of dvd playback. </summary>
        private bool FirstPlayDvd(string file)
        {
            int hr;

            try
            {
                _pendingCmd = true;
                CloseDVDInterfaces();
                string path = null;
                _currentFile = file;

                if (MediaPortal.Util.VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(file)))
                {
                    file = MediaPortal.Util.DaemonTools.GetVirtualDrive() + @"\VIDEO_TS\VIDEO_TS.IFO";
                }

                // Cyberlink navigator needs E:\\VIDEO_TS formatted path with double \
                path = file.Replace(@"\\", @"\").Replace(Path.GetFileName(file), "").Replace(@"\", @"\\");

                if (!GetDVDInterfaces(path))
                {
                    logger.Error("DVDPlayer:Unable getinterfaces()");
                    CloseDVDInterfaces();
                    return(false);
                }



                if (_basicVideo != null)
                {
                    _basicVideo.SetDefaultSourcePosition();
                    _basicVideo.SetDefaultDestinationPosition();
                }

/*                hr = _mediaCtrl.Run();
 *              if (hr < 0 || hr > 1)
 *              {
 *                  MediaPortal.Util.HResult hrdebug = new MediaPortal.Util.HResult(hr);
 *                  logger.Info(hrdebug.ToDXString());
 *                  Log.Error("DVDPlayer:Unable to start playing() 0x:{0:X}", hr);
 *                  CloseDVDInterfaces();
 *                  return false;
 *              }
 */
                DvdDiscSide side;
                int         titles, numOfVolumes, volume;
                hr = _dvdInfo.GetDVDVolumeInfo(out numOfVolumes, out volume, out side, out titles);
                if (hr < 0)
                {
                    logger.Error("DVDPlayer:Unable to get dvdvolumeinfo 0x{0:X}", hr);
                    CloseDVDInterfaces();
                    return(false);    // can't read disc
                }
                else
                {
                    if (titles <= 0)
                    {
                        logger.Error("DVDPlayer:DVD does not contain any titles? {0}", titles, 1);
                        //return false;
                    }
                }
                hr = _dvdCtrl.SelectVideoModePreference(_videoPref);
                DvdVideoAttributes videoAttr;
                hr           = _dvdInfo.GetCurrentVideoAttributes(out videoAttr);
                _videoWidth  = videoAttr.sourceResolutionX;
                _videoHeight = videoAttr.sourceResolutionY;

                _state = PlayState.Playing;

                _pendingCmd = false;
                logger.Info("DVDPlayer:Started playing()");
                if (_currentFile == string.Empty)
                {
                    for (int i = 0; i <= 26; ++i)
                    {
                        string dvd = String.Format("{0}:", (char)('A' + i));
                        if (MediaPortal.Util.Utils.IsDVD(dvd))
                        {
                            _currentFile = String.Format(@"{0}:\VIDEO_TS\VIDEO_TS.IFO", (char)('A' + i));
                            if (File.Exists(_currentFile))
                            {
                                break;
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                logger.ErrorException("DVDPlayer:Could not start DVD:{0} {1} {2}", ex);
                CloseDVDInterfaces();
                return(false);
            }
        }
Пример #5
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 { }
            }
        }