AacsPacket.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace MatrixIO.IO.MpegTs
  6. {
  7. public enum AACSCopyControl
  8. {
  9. // TODO: Figure out what these mean from the AACS spec
  10. Unencrypted,
  11. Unknown1,
  12. Unknown2,
  13. Unknown3,
  14. }
  15. public class AacsPacket
  16. {
  17. public AACSCopyControl CopyControl { get; private set; }
  18. /// <summary>27Mhz Clock</summary>
  19. public uint Timestamp { get; private set; }
  20. public TsPacket TsPacket { get; private set; }
  21. public const int Length = 4+188;
  22. public AacsPacket(byte[] buffer, int offset)
  23. {
  24. CopyControl = (AACSCopyControl)((buffer[offset] & 0xC0) >> 6);
  25. Timestamp = (uint)(((buffer[offset++] << 24) & 0x3F) | (buffer[offset++] << 16) | (buffer[offset++] << 8) | buffer[offset++]);
  26. if (CopyControl == AACSCopyControl.Unencrypted)
  27. {
  28. TsPacket = new TsPacket(buffer, offset);
  29. }
  30. else
  31. {
  32. throw new FormatException("Encrypted content not currently supported.");
  33. }
  34. }
  35. }
  36. }