示例#1
0
        /// <summary>
        /// Adds the file source filter to the graph.
        /// </summary>
        protected override void AddFileSource()
        {
            string strFile = _resourceAccessor.LocalFileSystemPath;

            // Render the file
            strFile = Path.Combine(strFile.ToLower(), @"BDMV\index.bdmv");

            // only continue with playback if a feature was selected or the extension was m2ts.
            if (DoFeatureSelection(ref strFile))
            {
                // find the SourceFilter
                CodecInfo sourceFilter = ServiceRegistration.Get <ISettingsManager>().Load <BDPlayerSettings>().BDSourceFilter;

                // load the SourceFilter
                if (TryAdd(sourceFilter))
                {
                    IFileSourceFilter fileSourceFilter = FilterGraphTools.FindFilterByInterface <IFileSourceFilter>(_graphBuilder);
                    // load the file
                    int hr = fileSourceFilter.Load(strFile, null);
                    Marshal.ReleaseComObject(fileSourceFilter);
                    DsError.ThrowExceptionForHR(hr);
                }
                else
                {
                    BDPlayerBuilder.LogError("Unable to load DirectShowFilter: {0}", sourceFilter.Name);
                    throw new Exception("Unable to load DirectShowFilter");
                }
            }
        }
示例#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
        protected override void OnBeforeGraphRunning()
        {
            base.OnBeforeGraphRunning();

            IFileSourceFilter fileSourceFilter = FilterGraphTools.FindFilterByInterface <IFileSourceFilter>(_graphBuilder);

            // First all automatically rendered pins
            FilterGraphTools.RenderOutputPins(_graphBuilder, (IBaseFilter)fileSourceFilter);

            Marshal.ReleaseComObject(fileSourceFilter);

            // MSDN: "During the connection process, the Filter Graph Manager ignores pins on intermediate filters if the pin name begins with a tilde (~)."
            // then connect the skipped "~" output pins
            FilterGraphTools.RenderAllManualConnectPins(_graphBuilder);
        }
示例#4
0
        protected virtual void EnumerateChapters(bool forceRefresh)
        {
            if (_graphBuilder == null || !_initialized || !forceRefresh && _chapterTimestamps != null)
            {
                return;
            }

            // Try to find a filter implementing IAMExtendSeeking for chapter support
            IAMExtendedSeeking extendSeeking = FilterGraphTools.FindFilterByInterface <IAMExtendedSeeking>(_graphBuilder);

            if (extendSeeking == null)
            {
                return;
            }
            try
            {
                int markerCount;
                if (extendSeeking.get_MarkerCount(out markerCount) != 0 || markerCount <= 0)
                {
                    return;
                }

                _chapterTimestamps = new double[markerCount];
                _chapterNames      = new string[markerCount];
                for (int i = 1; i <= markerCount; i++)
                {
                    double markerTime;
                    string markerName;
                    extendSeeking.GetMarkerTime(i, out markerTime);
                    extendSeeking.GetMarkerName(i, out markerName);

                    _chapterTimestamps[i - 1] = markerTime;
                    _chapterNames[i - 1]      = !string.IsNullOrEmpty(markerName) ? markerName : GetChapterName(i);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(extendSeeking);
            }
        }
示例#5
0
        /// <summary>
        /// Adds a source filter to the graph and sets the input.
        /// </summary>
        protected override void AddSourceFilter()
        {
            // get a local file system path - will mount via DOKAN when resource is not on the local system
            ILocalFsResourceAccessor lfsr;

            if (!_resourceLocator.TryCreateLocalFsAccessor(out lfsr))
            {
                throw new IllegalCallException("The BDPlayer can only play file system resources");
            }
            string strFile = lfsr.LocalFileSystemPath;

            // Render the file
            strFile = Path.Combine(strFile.ToLower(), @"BDMV\index.bdmv");

            // only continue with playback if a feature was selected or the extension was m2ts.
            if (DoFeatureSelection(ref strFile))
            {
                // find the SourceFilter
                CodecInfo sourceFilter = ServiceRegistration.Get <ISettingsManager>().Load <BDPlayerSettings>().BDSourceFilter;

                // load the SourceFilter
                if (TryAdd(sourceFilter))
                {
                    IFileSourceFilter fileSourceFilter = FilterGraphTools.FindFilterByInterface <IFileSourceFilter>(_graphBuilder);
                    // load the file
                    int hr = fileSourceFilter.Load(strFile, null);
                    Marshal.ReleaseComObject(fileSourceFilter);
                    new HRESULT(hr).Throw();
                }
                else
                {
                    BDPlayerBuilder.LogError("Unable to load DirectShowFilter: {0}", sourceFilter.Name);
                    throw new Exception("Unable to load DirectShowFilter");
                }
            }
        }