예제 #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
        /// <summary>
        /// Scans a bluray folder and returns a BDInfo object
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private static BDInfoExt ScanWorker(string path)
        {
            BDPlayerBuilder.LogInfo("Scanning bluray structure: {0}", path);
            BDInfoExt bluray = new BDInfoExt(path.ToUpper(), true); // For title selection we need all information here, but this can cause quite big delays for remote resources!

            bluray.Scan();
            return(bluray);
        }
예제 #3
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");
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Returns wether a choice was made and changes the file path
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns>True if playback should continue, False if user cancelled.</returns>
        private bool DoFeatureSelection(ref string filePath)
        {
            try
            {
                // If we have chosen a specific playlist, build the path directly without scanning the complete structure again
                if (_manualTitleSelection != null && !string.IsNullOrEmpty(_playlistFolder))
                {
                    filePath = Path.Combine(_playlistFolder, _manualTitleSelection.Name);
                    GetChapters(_manualTitleSelection);
                    _manualTitleSelection = null;
                    return(true);
                }

                BDInfoExt bluray;
                try
                {
                    bluray = ScanWorker(filePath);
                }
                catch (Exception)
                {
                    // If our parsing of BD structure fails, the splitter might still be able to handle the BDMV directly, so return "success" here.
                    return(true);
                }

                // Store all playlist files for title selection
                _bdTitles = bluray.PlaylistFiles.Values.Where(p => p.IsValid && !p.HasLoops).Distinct().ToList();
                int counter = 0;
                _bdTitleNames   = _bdTitles.Select(t => FormatTitle(t, ++counter)).ToArray();
                _playlistFolder = bluray.DirectoryPLAYLIST.FullName;

                List <TSPlaylistFile> allPlayLists = _bdTitles.OrderByDescending(p => p.TotalLength).ToList();

                // Feature selection logic
                TSPlaylistFile listToPlay;
                if (allPlayLists.Count == 0)
                {
                    BDPlayerBuilder.LogInfo("No valid playlists found, use default INDEX.BDMV.");
                    return(true);
                }
                if (allPlayLists.Count == 1)
                {
                    // if we have only one playlist to show just move on
                    BDPlayerBuilder.LogInfo("Found one valid playlist {0}.", allPlayLists[0].Name);
                    listToPlay = allPlayLists[0];
                }
                else
                {
                    // Show selection dialog
                    BDPlayerBuilder.LogInfo("Found {0} playlists, title selection available.", allPlayLists.Count);

                    // first make an educated guess about what the real features are (more than one chapter, no loops and longer than one hour)
                    // todo: make a better filter on the playlists containing the real features
                    List <TSPlaylistFile> playLists = allPlayLists.Where(p => (p.Chapters.Count > 1 || p.TotalLength >= MINIMAL_FULL_FEATURE_LENGTH) && !p.HasLoops).ToList();

                    // if the filter yields zero results just list all playlists
                    if (playLists.Count == 0)
                    {
                        playLists = allPlayLists;
                    }

                    listToPlay = playLists[0];
                }

                BDPlayerBuilder.LogInfo("Using playlist {0}.", listToPlay.Name);
                for (int idx = 0; idx < _bdTitles.Count; idx++)
                {
                    if (_bdTitles[idx] != listToPlay)
                    {
                        continue;
                    }
                    _currentTitleName = _bdTitleNames[idx];
                    break;
                }

                GetChapters(listToPlay);

                // Combine the chosen file path (playlist)
                filePath = Path.Combine(bluray.DirectoryPLAYLIST.FullName, listToPlay.Name);
                return(true);
            }
            catch (Exception e)
            {
                BDPlayerBuilder.LogError("Exception while reading bluray structure {0} {1}", e.Message, e.StackTrace);
                return(false);
            }
        }