ProgramAssociationTable.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace MatrixIO.IO.MpegTs.Tables
  6. {
  7. public class ProgramAssociationTable : TsTable<ProgramAssociation>
  8. {
  9. public ushort Identifier { get { return _identifier; } set { _identifier = value; } }
  10. public ProgramAssociationTable() : base() {}
  11. public ProgramAssociationTable(byte[] buffer, int offset, int length) : base(buffer, offset, length)
  12. {
  13. while (_position < _sectionLengthStartOffset + SectionLength - 4 && _position < offset + length - 4)
  14. {
  15. var row = new ProgramAssociation(buffer, _position);
  16. _position += row.Length;
  17. Rows.Add(row);
  18. }
  19. }
  20. }
  21. public class ProgramAssociation
  22. {
  23. public int Length { get { return 2 + 2; } }
  24. public ushort ProgramNumber { get; set; }
  25. public ushort PacketIdentifier { get; set; }
  26. public ProgramAssociation() { }
  27. public ProgramAssociation(byte[] buffer, int offset)
  28. {
  29. int position = offset;
  30. ProgramNumber = (ushort) ((buffer[position++] << 8) | buffer[position++]);
  31. PacketIdentifier = (ushort) (((buffer[position++] << 8) | buffer[position]) & 0x1FFF);
  32. }
  33. }
  34. }