Scan() public method

public Scan ( ) : void
return void
Esempio n. 1
0
        public override List<ChapterInfo> GetStreams(string location)
        {
            ChapterInfo pgc = new ChapterInfo();
              pgc.Chapters = new List<ChapterEntry>();
              pgc.SourceHash = ChapterExtractor.ComputeMD5Sum(location);
              pgc.SourceName = location;
              pgc.Title = Path.GetFileNameWithoutExtension(location);
              pgc.SourceType = "Blu-Ray";
              pgc.Extractor = Application.ProductName + " " + Application.ProductVersion;

              FileInfo fileInfo = new FileInfo(location);

              OnStreamDetected(pgc);
              TSPlaylistFile mpls = new TSPlaylistFile(fileInfo);
              //Dictionary<string, TSStreamClipFile> clips = new Dictionary<string,TSStreamClipFile>();
              mpls.Scan();
              foreach (double d in mpls.Chapters)
              {
            pgc.Chapters.Add(new ChapterEntry()
              {
            Name = string.Empty,
            Time = new TimeSpan((long)(d * (double)TimeSpan.TicksPerSecond))
              });
              }

              pgc.Duration = new TimeSpan((long)(mpls.TotalLength * (double)TimeSpan.TicksPerSecond));

              foreach (TSStreamClip clip in mpls.StreamClips)
              {
              try
              {
              clip.StreamClipFile.Scan();
                foreach (TSStream stream in clip.StreamClipFile.Streams.Values)
                {
                  if (stream.IsVideoStream)
                  {
                    pgc.FramesPerSecond = (double)((TSVideoStream)stream).FrameRateEnumerator /
                    (double)((TSVideoStream)stream).FrameRateDenominator;
                    break;
                  }
                }
                if (pgc.FramesPerSecond != 0) break;
              }
              catch (Exception ex)
              {
              Trace.WriteLine(ex);
              }
              }

              OnChaptersLoaded(pgc);
              OnExtractionComplete();
              return new List<ChapterInfo>() { pgc };
        }
Esempio n. 2
0
        // not used anymore, but still there ;)
        private void SetRefreshRateBDold()
        {
            if (!_changeRefreshRate)
            {
            return;
            }

            Log.Info("Blu-Ray Player Launcher: SetRefreshRate for BDs");

            if (_driveLetter == null)
            {
            Log.Error("Blu-Ray Player Launcher: SetRefreshRate - drive letter not assigned!");
            return;
            }

            FileInfo[] files = null;
            double fps = -1;
            try
            {
            DirectoryInfo dir = new DirectoryInfo(_driveLetter + "\\BDMV\\PLAYLIST");
            PlaylistFiles.Clear();
            StreamFiles.Clear();
            StreamClipFiles.Clear();

            files = dir.GetFiles("*.MPLS");
            foreach (FileInfo file in files)
            {
                TSPlaylistFile playlistFile = new TSPlaylistFile(file);
                PlaylistFiles.Add(file.Name.ToUpper(), playlistFile);
                //Log.Info("Blu-Ray Player Launcher: MPLS - {0} {1}", file.Name, playlistFile.TotalSize);
            }

            dir = new DirectoryInfo(_driveLetter + "\\BDMV\\STREAM");
            files = dir.GetFiles("*.M2TS");
            foreach (FileInfo file in files)
            {
                TSStreamFile streamFile = new TSStreamFile(file);
                StreamFiles.Add(file.Name.ToUpper(), streamFile);
            }

            dir = new DirectoryInfo(_driveLetter + "\\BDMV\\CLIPINF");
            files = dir.GetFiles("*.CLPI");
            foreach (FileInfo file in files)
            {
                TSStreamClipFile streamClipFile = new TSStreamClipFile(file);
                StreamClipFiles.Add(file.Name.ToUpper(), streamClipFile);
            }

            foreach (TSStreamClipFile streamClipFile in StreamClipFiles.Values)
            {
                streamClipFile.Scan();
            }
            foreach (TSStreamFile streamFile in StreamFiles.Values)
            {
                streamFile.Scan(null, false);
            }

            double maxLenght = 0;

            foreach (TSPlaylistFile playlistFile in PlaylistFiles.Values)
            {
                playlistFile.Scan(StreamFiles, StreamClipFiles);
                Log.Info("Blu-Ray Player Launcher: total size - {0} - {1}", playlistFile.TotalLength, playlistFile.VideoStreams[0].FrameRate.ToString());

                if (maxLenght < playlistFile.TotalLength)
                {
                    // find the largest movie clip, might not work with seamless branching movies...
                    maxLenght = playlistFile.TotalLength;

                    switch (playlistFile.VideoStreams[0].FrameRate)
                    {
                        case TSFrameRate.FRAMERATE_23_976:
                            fps = 23.976;
                            break;
                        case TSFrameRate.FRAMERATE_24:
                            fps = 24;
                            break;
                        case TSFrameRate.FRAMERATE_25:
                            fps = 25;
                            break;
                        case TSFrameRate.FRAMERATE_29_97:
                            fps = 29.97;
                            break;
                        case TSFrameRate.FRAMERATE_50:
                            fps = 50;
                            break;
                        case TSFrameRate.FRAMERATE_59_94:
                            fps = 59.94;
                            break;
                    }
                }
                playlistFile.ClearBitrates();
            }
            }
            catch (Exception e)
            {
            Log.Error("Blu-Ray Player Launcher: SetRefreshRate - failed to get refresh rate from disk!");
            Log.Error("Blu-Ray Player Launcher: SetRefreshRate - exception {0}", e);
            return;
            }

            try
            {
            Log.Info("Blu-Ray Player Launcher: calling SetRefreshRateBasedOnFPS() - {0}Hz", fps);
            RefreshRateChanger.SetRefreshRateBasedOnFPS(fps, "", RefreshRateChanger.MediaType.Video);
            _refreshRateChangeSuccessful = true;
            }
            catch (Exception e)
            {
            Log.Error("Blu-Ray Player Launcher:SetRefreshRate - exception {0}", e);
            }
        }