public static int ComparePlaylistFiles( TSPlaylistFile x, TSPlaylistFile y) { if (x == null && y == null) { return 0; } else if (x == null && y != null) { return 1; } else if (x != null && y == null) { return -1; } else { if (x.TotalLength > y.TotalLength) { return -1; } else if (y.TotalLength > x.TotalLength) { return 1; } else { return x.Name.CompareTo(y.Name); } } }
public static int ComparePlaylistFiles( TSPlaylistFile x, TSPlaylistFile y ) { if (x == null && y == null) { return(0); } else if (x == null && y != null) { return(1); } else if (x != null && y == null) { return(-1); } else { if (x.TotalLength > y.TotalLength) { return(-1); } else if (y.TotalLength > x.TotalLength) { return(1); } else { return(x.Name.CompareTo(y.Name)); } } }
protected bool BDROM_PlaylistFileScanError(TSPlaylistFile playlistFile, Exception ex) { System.Console.WriteLine(string.Format( "An error occurred while scanning the playlist file {0}.\n\nThe disc may be copy-protected or damaged.\n\nDo you want to continue scanning the playlist files?", playlistFile.Name)); return(GetYorNdefaultY()); }
private void buttonChart_Click( object sender, EventArgs e) { if (Playlists == null || comboBoxPlaylist.SelectedItem == null || comboBoxStream.SelectedItem == null || comboBoxAngle.SelectedItem == null || comboBoxChartType.SelectedItem == null) { return; } TSPlaylistFile playlist = (TSPlaylistFile)comboBoxPlaylist.SelectedItem; TSVideoStream videoStream = (TSVideoStream)comboBoxStream.SelectedItem; int angleIndex = (int)comboBoxAngle.SelectedItem; string chartType = comboBoxChartType.SelectedItem.ToString(); FormChart chart = new FormChart(); chart.Generate( chartType, playlist, videoStream.PID, angleIndex); chart.Show(); }
private void listViewPlaylistFiles_SelectedIndexChanged( object sender, EventArgs e) { TSPlaylistFile playlist = SelectedPlaylist; if (playlist != null) { LoadPlaylist(listViewStreamFiles, playlist.StreamClips); } }
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 }; }
private void buttonOK_Click( object sender, EventArgs e) { DialogResult = DialogResult.OK; TSPlaylistFile playlist = new TSPlaylistFile(BDROM, textBoxName.Text, StreamClips); BDROM.PlaylistFiles[playlist.Name] = playlist; OnFinished(); Close(); }
private void buttonAddAll_Click(object sender, EventArgs e) { TSPlaylistFile playlist = SelectedPlaylist; if (playlist != null) { foreach (TSStreamClip clip in playlist.StreamClips) { StreamClips.Add(clip); } LoadPlaylist(listViewTargetFiles, StreamClips); LoadPlaylists(); } CheckOK(); }
public static Playlist Transform(TSPlaylistFile playlistFile) { return new Playlist { FileName = playlistFile.Name, FullPath = playlistFile.FullName, FileSize = playlistFile.FileSize, Length = TimeSpan.FromMilliseconds(playlistFile.TotalLength * 1000), StreamClips = StreamClipTransformer.Transform(playlistFile.StreamClips), Tracks = TrackTransformer.Transform(playlistFile.SortedStreams), Chapters = ChapterTransformer.Transform(playlistFile.Chapters), HasDuplicateStreamClips = playlistFile.HasDuplicateClips, HasLoops = playlistFile.HasLoops }; }
private void buttonAdd_Click( object sender, EventArgs e) { if (listViewStreamFiles.SelectedItems.Count == 0) { return; } TSPlaylistFile playlist = SelectedPlaylist; if (playlist != null) { int clipIndex = listViewStreamFiles.SelectedIndices[0]; if (clipIndex < playlist.StreamClips.Count) { StreamClips.Add(playlist.StreamClips[clipIndex]); } LoadPlaylist(listViewTargetFiles, StreamClips); LoadPlaylists(); } CheckOK(); listViewStreamFiles.Focus(); }
private void comboBoxPlaylist_SelectedIndexChanged(object sender, EventArgs e) { TSPlaylistFile playlist = (TSPlaylistFile)comboBoxPlaylist.SelectedItem; comboBoxAngle.Items.Clear(); for (int i = 0; i <= playlist.AngleStreams.Count; i++) { comboBoxAngle.Items.Add(i); } if (comboBoxAngle.Items.Count > 0) { comboBoxAngle.SelectedIndex = 0; } comboBoxStream.Items.Clear(); foreach (TSVideoStream videoStream in playlist.VideoStreams) { comboBoxStream.Items.Add(videoStream); } if (comboBoxStream.Items.Count > 0) { comboBoxStream.SelectedIndex = 0; } }
public void GenerateFrameSizeChart( TSPlaylistFile playlist, ushort PID, int angleIndex) { UnitText = "KB"; GraphControl.GraphPane.XAxis.Title.Text = "Time (minutes)"; GraphControl.GraphPane.YAxis.Title.Text = "Size (KB)"; PointPairList pointsMin = new PointPairList(); PointPairList pointsMax = new PointPairList(); PointPairList pointsAvg = new PointPairList(); double pointPosition = 0; double pointSeconds = 1.0; double pointMin = double.MaxValue; double pointMax = 0; double pointAvg = 0; int pointCount = 0; double overallMax = 0; foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List <TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; if (diag.Tag == null) { continue; } string frameType = diag.Tag; double frameSize = diag.Bytes / 1024; pointPosition = diag.Marker - clip.TimeIn + clip.RelativeTimeIn; if (frameSize > overallMax) { overallMax = frameSize; } if (frameSize < pointMin) { pointMin = frameSize; } if (frameSize > pointMax) { pointMax = frameSize; } pointCount++; pointAvg += frameSize; if (pointPosition >= pointSeconds) { for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointsMax.Add(pointMinutes, pointMax); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } } } for (double x = pointSeconds; x < playlist.TotalLength; x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); } LineItem avgCurve = GraphControl.GraphPane.AddCurve( "Avg", pointsAvg, Color.Gray, SymbolType.None); avgCurve.Line.IsSmooth = true; LineItem minCurve = GraphControl.GraphPane.AddCurve( "Min", pointsMin, Color.LightGray, SymbolType.None); minCurve.Line.IsSmooth = true; minCurve.Line.Fill = new Fill(Color.White); LineItem maxCurve = GraphControl.GraphPane.AddCurve( "Max", pointsMax, Color.LightGray, SymbolType.None); maxCurve.Line.IsSmooth = true; maxCurve.Line.Fill = new Fill(Color.LightGray); GraphControl.GraphPane.XAxis.Scale.Min = 0; GraphControl.GraphPane.XAxis.Scale.Max = playlist.TotalLength / 60; GraphControl.GraphPane.YAxis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.IsVisible = true; GraphControl.AxisChange(); }
public void GenerateFrameTypeChart( TSPlaylistFile playlist, ushort PID, int angleIndex, bool isSizes) { IsHoverDisabled = true; GraphControl.GraphPane.XAxis.Title.Text = "Frame Type"; if (isSizes) { UnitText = "KB"; GraphControl.GraphPane.YAxis.Title.Text = "Average / Peak Size (KB)"; } else { UnitText = ""; GraphControl.GraphPane.YAxis.Title.Text = "Count"; } Dictionary <string, double> frameCount = new Dictionary <string, double>(); Dictionary <string, double> frameSizes = new Dictionary <string, double>(); Dictionary <string, double> framePeaks = new Dictionary <string, double>(); foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List <TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; if (diag.Tag == null) { continue; } string frameType = diag.Tag; double frameSize = diag.Bytes / 1024; if (!framePeaks.ContainsKey(frameType)) { framePeaks[frameType] = frameSize; } else if (frameSize > framePeaks[frameType]) { framePeaks[frameType] = frameSize; } if (!frameCount.ContainsKey(frameType)) { frameCount[frameType] = 0; } frameCount[frameType]++; if (!frameSizes.ContainsKey(frameType)) { frameSizes[frameType] = 0; } frameSizes[frameType] += frameSize; } } string[] labels = new string[frameCount.Keys.Count]; double[] values = new double[frameCount.Keys.Count]; double[] peaks = new double[frameCount.Keys.Count]; Dictionary <string, int> frameTypes = new Dictionary <string, int>(); frameCount.Keys.CopyTo(labels, 0); double totalFrameCount = 0; for (int i = 0; i < labels.Length; i++) { string label = labels[i]; frameTypes[label] = i; if (isSizes) { values[i] = frameSizes[label] / frameCount[label]; peaks[i] = framePeaks[label]; } else { values[i] = frameCount[label]; } totalFrameCount += frameCount[label]; } if (isSizes) { BarItem barItem = GraphControl.GraphPane.AddBar( "Average", null, values, Color.Black); barItem.Bar.Fill.Type = FillType.Solid; BarItem barItemMax = GraphControl.GraphPane.AddBar( "Peak", null, peaks, Color.Black); barItemMax.Bar.Fill.Type = FillType.None; GraphControl.GraphPane.XAxis.MajorTic.IsBetweenLabels = true; GraphControl.GraphPane.XAxis.Scale.TextLabels = labels; GraphControl.GraphPane.XAxis.Type = AxisType.Text; GraphControl.AxisChange(); GraphControl.GraphPane.YAxis.Scale.Max += GraphControl.GraphPane.YAxis.Scale.MajorStep; BarItem.CreateBarLabels(GraphControl.GraphPane, false, "f0"); GraphControl.GraphPane.Legend.IsVisible = true; } else { GraphControl.GraphPane.Chart.Fill.Type = FillType.None; GraphControl.GraphPane.XAxis.IsVisible = false; GraphControl.GraphPane.YAxis.IsVisible = false; int drgb = (int)Math.Truncate(255.0 / labels.Length); int rgb = 0; List <SortableFrameCount> sortedFrameCounts = new List <SortableFrameCount>(); foreach (string frameType in frameCount.Keys) { sortedFrameCounts.Add(new SortableFrameCount(frameType, frameCount[frameType])); } sortedFrameCounts.Sort(); int j = sortedFrameCounts.Count; for (int i = 0; i < j; i++) { AddPieSlice(sortedFrameCounts[i].Name, sortedFrameCounts[i].Count, totalFrameCount, rgb); rgb += drgb; if (--j > i) { AddPieSlice(sortedFrameCounts[j].Name, sortedFrameCounts[j].Count, totalFrameCount, rgb); rgb += drgb; } } GraphControl.GraphPane.AxisChange(); } GraphControl.IsShowHScrollBar = false; GraphControl.IsAutoScrollRange = false; GraphControl.IsEnableHPan = false; GraphControl.IsEnableHZoom = false; GraphControl.IsEnableSelection = false; GraphControl.IsEnableWheelZoom = false; }
public void GenerateWindowChart( TSPlaylistFile playlist, ushort PID, int angleIndex, double windowSize) { UnitText = "Mbps"; GraphControl.GraphPane.XAxis.Title.Text = "Time (minutes)"; GraphControl.GraphPane.YAxis.Title.Text = "Bitrate (Mbps)"; PointPairList pointsMin = new PointPairList(); PointPairList pointsMax = new PointPairList(); PointPairList pointsAvg = new PointPairList(); Queue <double> windowBits = new Queue <double>(); Queue <double> windowSeconds = new Queue <double>(); double windowBitsSum = 0; double windowSecondsSum = 0; double pointPosition = 0; double pointSeconds = 1.0; double pointMin = double.MaxValue; double pointMax = 0; double pointAvg = 0; int pointCount = 0; foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List <TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; //if (diag.Tag == null) continue; pointPosition = diag.Marker - clip.TimeIn + clip.RelativeTimeIn; double seconds = diag.Interval; double bits = diag.Bytes * 8.0; windowSecondsSum += seconds; windowSeconds.Enqueue(seconds); windowBitsSum += bits; windowBits.Enqueue(bits); if (windowSecondsSum > windowSize) { double bitrate = windowBitsSum / windowSecondsSum / 1000000; if (bitrate < pointMin) { pointMin = bitrate; } if (bitrate > pointMax) { pointMax = bitrate; } pointCount++; pointAvg += bitrate; for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } if (pointPosition >= pointSeconds) { double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsMax.Add(pointMinutes, pointMax); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } windowBitsSum -= windowBits.Dequeue(); windowSecondsSum -= windowSeconds.Dequeue(); } if (pointPosition >= pointSeconds) { for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointsMax.Add(pointMinutes, pointMax); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } } } for (double x = pointSeconds; x < playlist.TotalLength; x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); } LineItem avgCurve = GraphControl.GraphPane.AddCurve( "Avg", pointsAvg, Color.Gray, SymbolType.None); avgCurve.Line.IsSmooth = true; LineItem minCurve = GraphControl.GraphPane.AddCurve( "Min", pointsMin, Color.LightGray, SymbolType.None); minCurve.Line.IsSmooth = true; minCurve.Line.Fill = new Fill(Color.White); LineItem maxCurve = GraphControl.GraphPane.AddCurve( "Max", pointsMax, Color.LightGray, SymbolType.None); maxCurve.Line.IsSmooth = true; maxCurve.Line.Fill = new Fill(Color.LightGray); GraphControl.GraphPane.XAxis.Scale.Min = 0; GraphControl.GraphPane.XAxis.Scale.Max = playlist.TotalLength / 60; GraphControl.GraphPane.YAxis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.IsVisible = true; GraphControl.AxisChange(); }
/// <summary> /// Sets the current title. /// </summary> /// <param name="title">Title</param> public override void SetTitle(string title) { bool found = false; int idx; for (idx = 0; idx < Titles.Length; idx++) if (Titles[idx] == title) { found = true; break; } if (!found) return; _manualTitleSelection = _bdTitles[idx]; Shutdown(true); SetMediaItem(_resourceLocator, Titles[idx]); }
public static int ComparePlaylistFiles( TSPlaylistFile x, TSPlaylistFile y) { if (x == null && y == null) { return 0; } else if (x == null && y != null) { return 1; } else if (x != null && y == null) { return -1; } else { // x > y --> -1 // y > x --> +1 if (x.IsFeatureLength && !y.IsFeatureLength) return -1; else if (y.IsFeatureLength && !x.IsFeatureLength) return +1; else if (!x.HasDuplicateClips && y.HasDuplicateClips) return -1; else if (!y.HasDuplicateClips && x.HasDuplicateClips) return 1; else if (x.TotalLength > y.TotalLength) return -1; else if (y.TotalLength > x.TotalLength) return 1; else { int xName, yName; Int32.TryParse(Path.GetFileNameWithoutExtension(x.Name), out xName); Int32.TryParse(Path.GetFileNameWithoutExtension(y.Name), out yName); int diff = xName - yName; return diff > 0 ? +1 : (diff < 0 ? -1 : 0); } } }
public void SelectPlayList() { if (BDROM == null) { System.Console.WriteLine("Cannot select playlist, BDROM Error"); return; } bool hasHiddenTracks = false; List <List <TSPlaylistFile> > groups = new List <List <TSPlaylistFile> >(); TSPlaylistFile[] sortedPlaylistFiles = new TSPlaylistFile[BDROM.PlaylistFiles.Count]; BDROM.PlaylistFiles.Values.CopyTo(sortedPlaylistFiles, 0); Array.Sort(sortedPlaylistFiles, ComparePlaylistFiles); foreach (TSPlaylistFile playlist1 in sortedPlaylistFiles) { if (!playlist1.IsValid) { continue; } int matchingGroupIndex = 0; for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List <TSPlaylistFile> group = groups[groupIndex]; foreach (TSPlaylistFile playlist2 in group) { if (!playlist2.IsValid) { continue; } foreach (TSStreamClip clip1 in playlist1.StreamClips) { foreach (TSStreamClip clip2 in playlist2.StreamClips) { if (clip1.Name == clip2.Name) { matchingGroupIndex = groupIndex + 1; break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { groups[matchingGroupIndex - 1].Add(playlist1); } else { groups.Add(new List <TSPlaylistFile> { playlist1 }); } } System.Console.WriteLine(String.Format("{0,-4}{1,-7}{2,-15}{3,-10}{4,-16}{5,-16}\n", "#", "Group", "Playlist File", "Length", "Estimated Bytes", "Measured Bytes")); int index = 1; Dictionary <int, TSPlaylistFile> plsDict = new Dictionary <int, TSPlaylistFile>(); for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List <TSPlaylistFile> group = groups[groupIndex]; group.Sort(ComparePlaylistFiles); foreach (TSPlaylistFile playlist in group) { if (!playlist.IsValid) { continue; } plsDict[index] = playlist; if (playlist.HasHiddenTracks) { hasHiddenTracks = true; } String groupString = (groupIndex + 1).ToString(); TimeSpan playlistLengthSpan = new TimeSpan((long)(playlist.TotalLength * 10000000)); String length = string.Format( "{0:D2}:{1:D2}:{2:D2}", playlistLengthSpan.Hours, playlistLengthSpan.Minutes, playlistLengthSpan.Seconds); String fileSize; if (BDInfoSettings.EnableSSIF && playlist.InterleavedFileSize > 0) { fileSize = playlist.InterleavedFileSize.ToString("N0"); } else if (playlist.FileSize > 0) { fileSize = playlist.FileSize.ToString("N0"); } else { fileSize = "-"; } String fileSize2; if (playlist.TotalAngleSize > 0) { fileSize2 = (playlist.TotalAngleSize).ToString("N0"); } else { fileSize2 = "-"; } System.Console.WriteLine(String.Format("{0,-4:G}{1,-7}{2,-15}{3,-10}{4,-16}{5,-16}", index.ToString(), groupString, playlist.Name, length, fileSize, fileSize2)); index++; } } if (hasHiddenTracks) { System.Console.WriteLine("(*) Some playlists on this disc have hidden tracks. These tracks are marked with an asterisk."); } //selectedPlayLists.Add(plsDict[getIntIndex(1, index-1)]); }
/// <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; } }
public void GenerateFrameTypeChart( TSPlaylistFile playlist, ushort PID, int angleIndex, bool isSizes) { IsHoverDisabled = true; GraphControl.GraphPane.XAxis.Title.Text = "Frame Type"; if (isSizes) { UnitText = "KB"; GraphControl.GraphPane.YAxis.Title.Text = "Average / Peak Size (KB)"; } else { UnitText = ""; GraphControl.GraphPane.YAxis.Title.Text = "Count"; } Dictionary<string, double> frameCount = new Dictionary<string, double>(); Dictionary<string, double> frameSizes = new Dictionary<string, double>(); Dictionary<string, double> framePeaks = new Dictionary<string, double>(); foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List<TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; if (diag.Tag == null) continue; string frameType = diag.Tag; double frameSize = diag.Bytes / 1024; if (!framePeaks.ContainsKey(frameType)) { framePeaks[frameType] = frameSize; } else if (frameSize > framePeaks[frameType]) { framePeaks[frameType] = frameSize; } if (!frameCount.ContainsKey(frameType)) { frameCount[frameType] = 0; } frameCount[frameType]++; if (!frameSizes.ContainsKey(frameType)) { frameSizes[frameType] = 0; } frameSizes[frameType] += frameSize; } } string[] labels = new string[frameCount.Keys.Count]; double[] values = new double[frameCount.Keys.Count]; double[] peaks = new double[frameCount.Keys.Count]; Dictionary<string, int> frameTypes = new Dictionary<string, int>(); frameCount.Keys.CopyTo(labels, 0); double totalFrameCount = 0; for (int i = 0; i < labels.Length; i++) { string label = labels[i]; frameTypes[label] = i; if (isSizes) { values[i] = frameSizes[label] / frameCount[label]; peaks[i] = framePeaks[label]; } else { values[i] = frameCount[label]; } totalFrameCount += frameCount[label]; } if (isSizes) { BarItem barItem = GraphControl.GraphPane.AddBar( "Average", null, values, Color.Black); barItem.Bar.Fill.Type = FillType.Solid; BarItem barItemMax = GraphControl.GraphPane.AddBar( "Peak", null, peaks, Color.Black); barItemMax.Bar.Fill.Type = FillType.None; GraphControl.GraphPane.XAxis.MajorTic.IsBetweenLabels = true; GraphControl.GraphPane.XAxis.Scale.TextLabels = labels; GraphControl.GraphPane.XAxis.Type = AxisType.Text; GraphControl.AxisChange(); GraphControl.GraphPane.YAxis.Scale.Max += GraphControl.GraphPane.YAxis.Scale.MajorStep; BarItem.CreateBarLabels(GraphControl.GraphPane, false, "f0"); GraphControl.GraphPane.Legend.IsVisible = true; } else { GraphControl.GraphPane.Chart.Fill.Type = FillType.None; GraphControl.GraphPane.XAxis.IsVisible = false; GraphControl.GraphPane.YAxis.IsVisible = false; int drgb = (int)Math.Truncate(255.0 / labels.Length); int rgb = 0; List<SortableFrameCount> sortedFrameCounts = new List<SortableFrameCount>(); foreach (string frameType in frameCount.Keys) { sortedFrameCounts.Add(new SortableFrameCount(frameType, frameCount[frameType])); } sortedFrameCounts.Sort(); int j = sortedFrameCounts.Count; for (int i = 0; i < j; i++) { AddPieSlice(sortedFrameCounts[i].Name, sortedFrameCounts[i].Count, totalFrameCount, rgb); rgb += drgb; if (--j > i) { AddPieSlice(sortedFrameCounts[j].Name, sortedFrameCounts[j].Count, totalFrameCount, rgb); rgb += drgb; } } GraphControl.GraphPane.AxisChange(); } GraphControl.IsShowHScrollBar = false; GraphControl.IsAutoScrollRange = false; GraphControl.IsEnableHPan = false; GraphControl.IsEnableHZoom = false; GraphControl.IsEnableSelection = false; GraphControl.IsEnableWheelZoom = false; }
protected bool BDROM_PlaylistFileScanError(TSPlaylistFile playlistFile, Exception ex) { System.Console.WriteLine(string.Format( "An error occurred while scanning the playlist file {0}.\n\nThe disc may be copy-protected or damaged.\n\nDo you want to continue scanning the playlist files?", playlistFile.Name)); return GetYorNdefaultY(); }
// 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); } }
public void GenerateWindowChart( TSPlaylistFile playlist, ushort PID, int angleIndex, double windowSize) { UnitText = "Mbps"; GraphControl.GraphPane.XAxis.Title.Text = "Time (minutes)"; GraphControl.GraphPane.YAxis.Title.Text = "Bitrate (Mbps)"; PointPairList pointsMin = new PointPairList(); PointPairList pointsMax = new PointPairList(); PointPairList pointsAvg = new PointPairList(); Queue<double> windowBits = new Queue<double>(); Queue<double> windowSeconds = new Queue<double>(); double windowBitsSum = 0; double windowSecondsSum = 0; double pointPosition = 0; double pointSeconds = 1.0; double pointMin = double.MaxValue; double pointMax = 0; double pointAvg = 0; int pointCount = 0; foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List<TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; //if (diag.Tag == null) continue; pointPosition = diag.Marker - clip.TimeIn + clip.RelativeTimeIn; double seconds = diag.Interval; double bits = diag.Bytes * 8.0; windowSecondsSum += seconds; windowSeconds.Enqueue(seconds); windowBitsSum += bits; windowBits.Enqueue(bits); if (windowSecondsSum > windowSize) { double bitrate = windowBitsSum / windowSecondsSum / 1000000; if (bitrate < pointMin) pointMin = bitrate; if (bitrate > pointMax) pointMax = bitrate; pointCount++; pointAvg += bitrate; for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } if (pointPosition >= pointSeconds) { double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsMax.Add(pointMinutes, pointMax); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } windowBitsSum -= windowBits.Dequeue(); windowSecondsSum -= windowSeconds.Dequeue(); } if (pointPosition >= pointSeconds) { for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointsMax.Add(pointMinutes, pointMax); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } } } for (double x = pointSeconds; x < playlist.TotalLength; x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); } LineItem avgCurve = GraphControl.GraphPane.AddCurve( "Avg", pointsAvg, Color.Gray, SymbolType.None); avgCurve.Line.IsSmooth = true; LineItem minCurve = GraphControl.GraphPane.AddCurve( "Min", pointsMin, Color.LightGray, SymbolType.None); minCurve.Line.IsSmooth = true; minCurve.Line.Fill = new Fill(Color.White); LineItem maxCurve = GraphControl.GraphPane.AddCurve( "Max", pointsMax, Color.LightGray, SymbolType.None); maxCurve.Line.IsSmooth = true; maxCurve.Line.Fill = new Fill(Color.LightGray); GraphControl.GraphPane.XAxis.Scale.Min = 0; GraphControl.GraphPane.XAxis.Scale.Max = playlist.TotalLength / 60; GraphControl.GraphPane.YAxis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.IsVisible = true; GraphControl.AxisChange(); }
/// <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 GetLengthFromPlaylist(string filePath) { try { //bool ChecklistToPlay = false; Func<string, BDInfo> scanner = scanWorker; IAsyncResult result = scanner.BeginInvoke(filePath, null, scanner); BDInfo bluray = scanner.EndInvoke(result); // Put the bluray info into a member variable (for later use) currentMediaInfo = bluray; List<TSPlaylistFile> allPlayLists = bluray.PlaylistFiles.Values.Where(p => p.IsValid).OrderByDescending(p => p.TotalLength).Distinct().ToList(); // find movie lenght from selection logger.Info("Found {0} playlists, showing selection dialog.", 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 >= MinimalFullFeatureLength) && !p.HasLoops).ToList(); // if the filter yields zero results just list all playlists if (playLists.Count == 0) { playLists = allPlayLists; } // Take first movie Length TSPlaylistFile playList = playLists[0]; _duration = (int)playList.TotalLength * 1000; // put the choosen playlist into our member variable for later use currentPlaylistFile = playLists[0]; return true; } catch (Exception e) { logger.Error("Exception while reading bluray structure {0} {1}", e.Message, e.StackTrace); return false; } }
public void Generate( string chartType, TSPlaylistFile playlist, ushort PID, int angleIndex) { this.Text = string.Format("{0}: {1}", playlist.Name, chartType); GraphControl.GraphPane.Title.Text = chartType; GraphControl.IsEnableHEdit = false; GraphControl.IsEnableVEdit = false; GraphControl.IsEnableVPan = false; GraphControl.IsEnableVZoom = false; GraphControl.IsShowHScrollBar = true; GraphControl.IsAutoScrollRange = true; GraphControl.IsEnableHPan = true; GraphControl.IsEnableHZoom = true; GraphControl.IsEnableSelection = true; GraphControl.IsEnableWheelZoom = true; GraphControl.GraphPane.Legend.IsVisible = false; GraphControl.GraphPane.XAxis.Scale.IsUseTenPower = false; GraphControl.GraphPane.YAxis.Scale.IsUseTenPower = false; if (BDInfoSettings.UseImagePrefix) { DefaultFileName = BDInfoSettings.UseImagePrefixValue; } else { DefaultFileName = string.Format( "{0}-{1}-", FixVolumeLabel(playlist.BDROM.VolumeLabel), Path.GetFileNameWithoutExtension(playlist.Name)); } switch (chartType) { case "Video Bitrate: 1-Second Window": GenerateWindowChart(playlist, PID, angleIndex, 1); DefaultFileName += "bitrate-01s"; break; case "Video Bitrate: 5-Second Window": GenerateWindowChart(playlist, PID, angleIndex, 5); DefaultFileName += "bitrate-05s"; break; case "Video Bitrate: 10-Second Window": GenerateWindowChart(playlist, PID, angleIndex, 10); DefaultFileName += "bitrate-10s"; break; case "Video Frame Size (Min / Max)": GenerateFrameSizeChart(playlist, PID, angleIndex); DefaultFileName += "frame-size"; break; case "Video Frame Type Counts": GenerateFrameTypeChart(playlist, PID, angleIndex, false); DefaultFileName += "frame-type-count"; break; case "Video Frame Type Sizes": GenerateFrameTypeChart(playlist, PID, angleIndex, true); DefaultFileName += "frame-type-size"; break; } DefaultFileName += ".png"; }
public void GenerateFrameSizeChart( TSPlaylistFile playlist, ushort PID, int angleIndex) { UnitText = "KB"; GraphControl.GraphPane.XAxis.Title.Text = "Time (minutes)"; GraphControl.GraphPane.YAxis.Title.Text = "Size (KB)"; PointPairList pointsMin = new PointPairList(); PointPairList pointsMax = new PointPairList(); PointPairList pointsAvg = new PointPairList(); double pointPosition = 0; double pointSeconds = 1.0; double pointMin = double.MaxValue; double pointMax = 0; double pointAvg = 0; int pointCount = 0; double overallMax = 0; foreach (TSStreamClip clip in playlist.StreamClips) { if (clip.AngleIndex != angleIndex || clip.StreamFile == null || clip.StreamFile.StreamDiagnostics == null || !clip.StreamFile.StreamDiagnostics.ContainsKey(PID)) { continue; } List<TSStreamDiagnostics> diagList = clip.StreamFile.StreamDiagnostics[PID]; for (int i = 0; i < diagList.Count; i++) { TSStreamDiagnostics diag = diagList[i]; if (diag.Tag == null) continue; string frameType = diag.Tag; double frameSize = diag.Bytes / 1024; pointPosition = diag.Marker - clip.TimeIn + clip.RelativeTimeIn; if (frameSize > overallMax) overallMax = frameSize; if (frameSize < pointMin) pointMin = frameSize; if (frameSize > pointMax) pointMax = frameSize; pointCount++; pointAvg += frameSize; if (pointPosition >= pointSeconds) { for (double x = pointSeconds; x < (pointPosition - 1); x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); pointSeconds += 1; } double pointMinutes = (pointSeconds - 1) / 60; pointsMin.Add(pointMinutes, pointMin); pointsAvg.Add(pointMinutes, pointAvg / pointCount); pointsMax.Add(pointMinutes, pointMax); pointMin = double.MaxValue; pointMax = 0; pointAvg = 0; pointCount = 0; pointSeconds += 1; } } } for (double x = pointSeconds; x < playlist.TotalLength; x++) { double pointX = (x - 1) / 60; pointsMin.Add(pointX, 0); pointsAvg.Add(pointX, 0); pointsMax.Add(pointX, 0); } LineItem avgCurve = GraphControl.GraphPane.AddCurve( "Avg", pointsAvg, Color.Gray, SymbolType.None); avgCurve.Line.IsSmooth = true; LineItem minCurve = GraphControl.GraphPane.AddCurve( "Min", pointsMin, Color.LightGray, SymbolType.None); minCurve.Line.IsSmooth = true; minCurve.Line.Fill = new Fill(Color.White); LineItem maxCurve = GraphControl.GraphPane.AddCurve( "Max", pointsMax, Color.LightGray, SymbolType.None); maxCurve.Line.IsSmooth = true; maxCurve.Line.Fill = new Fill(Color.LightGray); GraphControl.GraphPane.XAxis.Scale.Min = 0; GraphControl.GraphPane.XAxis.Scale.Max = playlist.TotalLength / 60; GraphControl.GraphPane.YAxis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.Scale.Min = 0; GraphControl.GraphPane.Y2Axis.IsVisible = true; GraphControl.AxisChange(); }
private string FormatTitle(TSPlaylistFile playlist, int counter) { return string.Format("{0} Title {1} - {2}", _mediaItemTitle, counter, FormatLength(playlist.TotalLength)); }
public ListPlaylistInfo LoadPlaylists(bool wholeDisc = false) { selectedPlaylists = new List <TSPlaylistFile>(); if (BDROM == null) { return(new ListPlaylistInfo()); } bool hasHiddenTracks = false; //Dictionary<string, int> playlistGroup = new Dictionary<string, int>(); List <List <TSPlaylistFile> > groups = new List <List <TSPlaylistFile> >(); TSPlaylistFile[] sortedPlaylistFiles = new TSPlaylistFile[BDROM.PlaylistFiles.Count]; BDROM.PlaylistFiles.Values.CopyTo(sortedPlaylistFiles, 0); Array.Sort(sortedPlaylistFiles, ComparePlaylistFiles); foreach (TSPlaylistFile playlist1 in sortedPlaylistFiles) { if (!playlist1.IsValid) { continue; } int matchingGroupIndex = 0; for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List <TSPlaylistFile> group = groups[groupIndex]; foreach (TSPlaylistFile playlist2 in group) { if (!playlist2.IsValid) { continue; } foreach (TSStreamClip clip1 in playlist1.StreamClips) { foreach (TSStreamClip clip2 in playlist2.StreamClips) { if (clip1.Name == clip2.Name) { matchingGroupIndex = groupIndex + 1; break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { break; } } if (matchingGroupIndex > 0) { groups[matchingGroupIndex - 1].Add(playlist1); } else { groups.Add(new List <TSPlaylistFile> { playlist1 }); //matchingGroupIndex = groups.Count; } //playlistGroup[playlist1.Name] = matchingGroupIndex; } int playlistIdx = 1; Dictionary <int, TSPlaylistFile> playlistDict = new Dictionary <int, TSPlaylistFile>(); var playlistInfos = new ListPlaylistInfo(); for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List <TSPlaylistFile> group = groups[groupIndex]; group.Sort(ComparePlaylistFiles); foreach (TSPlaylistFile playlist in group) //in BDROM.PlaylistFiles.Values) { if (!playlist.IsValid) { continue; } playlistDict[playlistIdx] = playlist; if (wholeDisc) { selectedPlaylists.Add(playlist); } if (playlist.HasHiddenTracks) { hasHiddenTracks = true; } String groupString = (groupIndex + 1).ToString(); TimeSpan playlistLengthSpan = new TimeSpan((long)(playlist.TotalLength * 10000000)); String fileSize; if (BDInfoSettings.EnableSSIF && playlist.InterleavedFileSize > 0) { fileSize = playlist.InterleavedFileSize.ToString("N0"); } else if (playlist.FileSize > 0) { fileSize = playlist.FileSize.ToString("N0"); } else { fileSize = "-"; } String fileSize2; if (playlist.TotalAngleSize > 0) { fileSize2 = (playlist.TotalAngleSize).ToString("N0"); } else { fileSize2 = "-"; } // System.Console.WriteLine(String.Format("{0,-4:G}{1,-7}{2,-15}{3,-10}{4,-16}{5,-16}", playlistIdx.ToString(), groupString, playlist.Name, length, fileSize, fileSize2)); var info = new PlaylistInfo() { Index = playlistIdx, Group = groupIndex, Name = playlist.Name, Length = playlistLengthSpan, Size = BDInfoSettings.EnableSSIF && playlist.InterleavedFileSize > 0 ? playlist.InterleavedFileSize : playlist.FileSize > 0 ? playlist.FileSize : 0, }; playlistInfos.Add(info); playlistIdx++; } } if (hasHiddenTracks) { System.Console.WriteLine( "(*) Some playlists on this disc have hidden tracks. These tracks are marked with an asterisk."); } return(playlistInfos); }
private void GetChapters(TSPlaylistFile playlistFile) { if (playlistFile == null || playlistFile.Chapters == null) return; _chapterTimestamps = playlistFile.Chapters.ToArray(); _chapterNames = new string[_chapterTimestamps.Length]; for (int c = 0; c < _chapterNames.Length; c++) _chapterNames[c] = GetChapterName(c + 1); }
protected bool BDROM_PlaylistFileScanError(TSPlaylistFile playlistFile, Exception ex) { logger.Debug("Playlist File Scan Error"); scanfailed = true; return false; }
protected bool BDROM_PlaylistFileScanError(TSPlaylistFile playlistFile, Exception ex) { DialogResult result = MessageBox.Show(string.Format( "An error occurred while scanning the playlist file {0}.\n\nThe disc may be copy-protected or damaged.\n\nDo you want to continue scanning the playlist files?", playlistFile.Name), "BDInfo Scan Error", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) return true; else return false; }
private void LoadPlaylists() { listViewPlaylistFiles.Items.Clear(); listViewStreamFiles.Items.Clear(); listViewStreams.Items.Clear(); if (BDROM == null) return; bool hasHiddenTracks = false; //Dictionary<string, int> playlistGroup = new Dictionary<string, int>(); List<List<TSPlaylistFile>> groups = new List<List<TSPlaylistFile>>(); TSPlaylistFile[] sortedPlaylistFiles = new TSPlaylistFile[BDROM.PlaylistFiles.Count]; BDROM.PlaylistFiles.Values.CopyTo(sortedPlaylistFiles, 0); Array.Sort(sortedPlaylistFiles, ComparePlaylistFiles); foreach (TSPlaylistFile playlist1 in sortedPlaylistFiles) { if (!playlist1.IsValid) continue; int matchingGroupIndex = 0; for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List<TSPlaylistFile> group = groups[groupIndex]; foreach (TSPlaylistFile playlist2 in group) { if (!playlist2.IsValid) continue; foreach (TSStreamClip clip1 in playlist1.StreamClips) { foreach (TSStreamClip clip2 in playlist2.StreamClips) { if (clip1.Name == clip2.Name) { matchingGroupIndex = groupIndex + 1; break; } } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) { groups[matchingGroupIndex - 1].Add(playlist1); } else { groups.Add(new List<TSPlaylistFile> { playlist1 }); //matchingGroupIndex = groups.Count; } //playlistGroup[playlist1.Name] = matchingGroupIndex; } for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List<TSPlaylistFile> group = groups[groupIndex]; group.Sort(ComparePlaylistFiles); foreach (TSPlaylistFile playlist in group) //in BDROM.PlaylistFiles.Values) { if (!playlist.IsValid) continue; if (playlist.HasHiddenTracks) { hasHiddenTracks = true; } ListViewItem.ListViewSubItem playlistIndex = new ListViewItem.ListViewSubItem(); playlistIndex.Text = (groupIndex + 1).ToString(); playlistIndex.Tag = groupIndex; ListViewItem.ListViewSubItem playlistName = new ListViewItem.ListViewSubItem(); playlistName.Text = playlist.Name; playlistName.Tag = playlist.Name; TimeSpan playlistLengthSpan = new TimeSpan((long)(playlist.TotalLength * 10000000)); ListViewItem.ListViewSubItem playlistLength = new ListViewItem.ListViewSubItem(); playlistLength.Text = string.Format( "{0:D2}:{1:D2}:{2:D2}", playlistLengthSpan.Hours, playlistLengthSpan.Minutes, playlistLengthSpan.Seconds); playlistLength.Tag = playlist.TotalLength; ListViewItem.ListViewSubItem playlistSize = new ListViewItem.ListViewSubItem(); if (BDInfoSettings.EnableSSIF && playlist.InterleavedFileSize > 0) { playlistSize.Text = playlist.InterleavedFileSize.ToString("N0"); playlistSize.Tag = playlist.InterleavedFileSize; } else if (playlist.FileSize > 0) { playlistSize.Text = playlist.FileSize.ToString("N0"); playlistSize.Tag = playlist.FileSize; } else { playlistSize.Text = "-"; playlistSize.Tag = playlist.FileSize; } ListViewItem.ListViewSubItem playlistSize2 = new ListViewItem.ListViewSubItem(); if (playlist.TotalAngleSize > 0) { playlistSize2.Text = (playlist.TotalAngleSize).ToString("N0"); } else { playlistSize2.Text = "-"; } playlistSize2.Tag = playlist.TotalAngleSize; ListViewItem.ListViewSubItem[] playlistSubItems = new ListViewItem.ListViewSubItem[] { playlistName, playlistIndex, playlistLength, playlistSize, playlistSize2 }; ListViewItem playlistItem = new ListViewItem(playlistSubItems, 0); listViewPlaylistFiles.Items.Add(playlistItem); } } if (hasHiddenTracks) { textBoxDetails.Text += "(*) Some playlists on this disc have hidden tracks. These tracks are marked with an asterisk."; } if (listViewPlaylistFiles.Items.Count > 0) { listViewPlaylistFiles.Items[0].Selected = true; } ResetColumnWidths(); }
public void SelectPlayList() { if (BDROM == null) { System.Console.WriteLine("Cannot select playlist, BDROM Error"); return; } bool hasHiddenTracks = false; List<List<TSPlaylistFile>> groups = new List<List<TSPlaylistFile>>(); TSPlaylistFile[] sortedPlaylistFiles = new TSPlaylistFile[BDROM.PlaylistFiles.Count]; BDROM.PlaylistFiles.Values.CopyTo(sortedPlaylistFiles, 0); Array.Sort(sortedPlaylistFiles, ComparePlaylistFiles); foreach (TSPlaylistFile playlist1 in sortedPlaylistFiles) { if (!playlist1.IsValid) continue; int matchingGroupIndex = 0; for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List<TSPlaylistFile> group = groups[groupIndex]; foreach (TSPlaylistFile playlist2 in group) { if (!playlist2.IsValid) continue; foreach (TSStreamClip clip1 in playlist1.StreamClips) { foreach (TSStreamClip clip2 in playlist2.StreamClips) { if (clip1.Name == clip2.Name) { matchingGroupIndex = groupIndex + 1; break; } } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) break; } if (matchingGroupIndex > 0) { groups[matchingGroupIndex - 1].Add(playlist1); } else { groups.Add(new List<TSPlaylistFile> { playlist1 }); } } System.Console.WriteLine(String.Format("{0,-4}{1,-7}{2,-15}{3,-10}{4,-16}{5,-16}\n", "#", "Group", "Playlist File", "Length", "Estimated Bytes", "Measured Bytes")); int index = 1; Dictionary<int,TSPlaylistFile> plsDict = new Dictionary<int,TSPlaylistFile>(); for (int groupIndex = 0; groupIndex < groups.Count; groupIndex++) { List<TSPlaylistFile> group = groups[groupIndex]; group.Sort(ComparePlaylistFiles); foreach (TSPlaylistFile playlist in group) { if (!playlist.IsValid) continue; plsDict[index] = playlist; if (playlist.HasHiddenTracks) { hasHiddenTracks = true; } String groupString = (groupIndex + 1).ToString(); TimeSpan playlistLengthSpan = new TimeSpan((long)(playlist.TotalLength * 10000000)); String length = string.Format( "{0:D2}:{1:D2}:{2:D2}", playlistLengthSpan.Hours, playlistLengthSpan.Minutes, playlistLengthSpan.Seconds); String fileSize; if (BDInfoSettings.EnableSSIF && playlist.InterleavedFileSize > 0) { fileSize = playlist.InterleavedFileSize.ToString("N0"); } else if (playlist.FileSize > 0) { fileSize = playlist.FileSize.ToString("N0"); } else { fileSize = "-"; } String fileSize2; if (playlist.TotalAngleSize > 0) { fileSize2 = (playlist.TotalAngleSize).ToString("N0"); } else { fileSize2 = "-"; } System.Console.WriteLine(String.Format("{0,-4:G}{1,-7}{2,-15}{3,-10}{4,-16}{5,-16}", index.ToString(), groupString, playlist.Name, length, fileSize, fileSize2)); index++; } } if (hasHiddenTracks) { System.Console.WriteLine("(*) Some playlists on this disc have hidden tracks. These tracks are marked with an asterisk."); } selectedPlayLists.Add(plsDict[getIntIndex(1, index-1)]); }