TSStreamClip.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. using System.Text;
  22. namespace BDInfo
  23. {
  24. public class TSStreamClip
  25. {
  26. public int AngleIndex = 0;
  27. public string Name;
  28. public double TimeIn;
  29. public double TimeOut;
  30. public double RelativeTimeIn;
  31. public double RelativeTimeOut;
  32. public double Length;
  33. public ulong FileSize = 0;
  34. public ulong InterleavedFileSize = 0;
  35. public ulong PayloadBytes = 0;
  36. public ulong PacketCount = 0;
  37. public double PacketSeconds = 0;
  38. public List<double> Chapters = new List<double>();
  39. public TSStreamFile StreamFile = null;
  40. public TSStreamClipFile StreamClipFile = null;
  41. public TSStreamClip(
  42. TSStreamFile streamFile,
  43. TSStreamClipFile streamClipFile)
  44. {
  45. if (streamFile != null)
  46. {
  47. Name = streamFile.Name;
  48. StreamFile = streamFile;
  49. FileSize = (ulong)StreamFile.FileInfo.Length;
  50. if (StreamFile.InterleavedFile != null)
  51. {
  52. InterleavedFileSize = (ulong)StreamFile.InterleavedFile.FileInfo.Length;
  53. }
  54. }
  55. StreamClipFile = streamClipFile;
  56. }
  57. public string DisplayName
  58. {
  59. get
  60. {
  61. if (StreamFile != null &&
  62. StreamFile.InterleavedFile != null &&
  63. BDInfoSettings.EnableSSIF)
  64. {
  65. return StreamFile.InterleavedFile.Name;
  66. }
  67. return Name;
  68. }
  69. }
  70. public ulong PacketSize
  71. {
  72. get
  73. {
  74. return PacketCount * 192;
  75. }
  76. }
  77. public ulong PacketBitRate
  78. {
  79. get
  80. {
  81. if (PacketSeconds > 0)
  82. {
  83. return (ulong)Math.Round(((PacketSize * 8.0) / PacketSeconds));
  84. }
  85. return 0;
  86. }
  87. }
  88. public bool IsCompatible(TSStreamClip clip)
  89. {
  90. foreach (TSStream stream1 in StreamFile.Streams.Values)
  91. {
  92. if (clip.StreamFile.Streams.ContainsKey(stream1.PID))
  93. {
  94. TSStream stream2 = clip.StreamFile.Streams[stream1.PID];
  95. if (stream1.StreamType != stream2.StreamType)
  96. {
  97. return false;
  98. }
  99. }
  100. }
  101. return true;
  102. }
  103. }
  104. }