TSStreamClip.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. //============================================================================
  2. // BDInfo - Blu-ray Video and Audio Analysis Tool
  3. // Copyright © 2010 Cinema Squid
  4. //
  5. // This library is free software; you can redistribute it and/or
  6. // modify it under the terms of the GNU Lesser General Public
  7. // License as published by the Free Software Foundation; either
  8. // version 2.1 of the License, or (at your option) any later version.
  9. //
  10. // This library is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. // Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public
  16. // License along with this library; if not, write to the Free Software
  17. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. //=============================================================================
  19. using System;
  20. using System.Collections.Generic;
  21. namespace BDInfo
  22. {
  23. public class TSStreamClip
  24. {
  25. public int AngleIndex = 0;
  26. public string Name;
  27. public double TimeIn;
  28. public double TimeOut;
  29. public double RelativeTimeIn;
  30. public double RelativeTimeOut;
  31. public double Length;
  32. public ulong FileSize = 0;
  33. public ulong InterleavedFileSize = 0;
  34. public ulong PayloadBytes = 0;
  35. public ulong PacketCount = 0;
  36. public double PacketSeconds = 0;
  37. public List<double> Chapters = new List<double>();
  38. public TSStreamFile StreamFile = null;
  39. public TSStreamClipFile StreamClipFile = null;
  40. public TSStreamClip(
  41. TSStreamFile streamFile,
  42. TSStreamClipFile streamClipFile)
  43. {
  44. if (streamFile != null)
  45. {
  46. Name = streamFile.Name;
  47. StreamFile = streamFile;
  48. FileSize = (ulong)StreamFile.FileInfo.Length;
  49. if (StreamFile.InterleavedFile != null)
  50. {
  51. InterleavedFileSize = (ulong)StreamFile.InterleavedFile.FileInfo.Length;
  52. }
  53. }
  54. StreamClipFile = streamClipFile;
  55. }
  56. public string DisplayName
  57. {
  58. get
  59. {
  60. if (StreamFile != null &&
  61. StreamFile.InterleavedFile != null &&
  62. BDInfoSettings.EnableSSIF)
  63. {
  64. return StreamFile.InterleavedFile.Name;
  65. }
  66. return Name;
  67. }
  68. }
  69. public ulong PacketSize => PacketCount * 192;
  70. public ulong PacketBitRate
  71. {
  72. get
  73. {
  74. if (PacketSeconds > 0)
  75. {
  76. return (ulong)Math.Round(((PacketSize * 8.0) / PacketSeconds));
  77. }
  78. return 0;
  79. }
  80. }
  81. public bool IsCompatible(TSStreamClip clip)
  82. {
  83. foreach (var stream1 in StreamFile.Streams.Values)
  84. {
  85. if (clip.StreamFile.Streams.ContainsKey(stream1.PID))
  86. {
  87. var stream2 = clip.StreamFile.Streams[stream1.PID];
  88. if (stream1.StreamType != stream2.StreamType)
  89. {
  90. return false;
  91. }
  92. }
  93. }
  94. return true;
  95. }
  96. }
  97. }