public Smpte291M(byte[] bytes) { DataId = bytes[0]; SecondaryDataId = bytes[1]; DataCount = bytes[2]; CaptionDistributionPacketId = (bytes[3] << 8) + bytes[4]; CaptionDistributionPacketDataCount = bytes[5]; CaptionDistributionPacketFramingRate = (bytes[6] >> 4); CaptionDistributionPacketTimeCodeAdded = (bytes[7] & 0b10000000) > 0; CaptionDistributionPacketDataBlockAdded = (bytes[7] & 0b01000000) > 0; CaptionDistributionPacketServiceInfoAdded = (bytes[7] & 0b00100000) > 0; CaptionDistributionPacketServiceInfoStart = (bytes[7] & 0b00010000) > 0; CaptionDistributionPacketServiceInfoChanged = (bytes[7] & 0b00001000) > 0; CaptionDistributionPacketServiceInfoEnd = (bytes[7] & 0b00000100) > 0; CaptionDistributionPacketContainsCaptions = (bytes[7] & 0b00000010) > 0; CaptionDistributionPacketHeaderSequenceCounter = (bytes[8] << 8) + bytes[9]; CaptionDistributionPacketDataSection = bytes[10]; CaptionDistributionPacketCcData = new CaptionDistributionPacket(bytes, 10); var idx = 9 + CaptionDistributionPacketCcData.GetLength(); if (CaptionDistributionPacketServiceInfoAdded) { CcServiceInfoSection = new CcServiceInfoSection(bytes, idx + 1); idx += CcServiceInfoSection.GetLength(); } CaptionDistributionPacketFooterSection = bytes[1 + idx]; CaptionDistributionPacketHeaderSequenceCounter2 = (bytes[2 + idx] << 8) + bytes[3 + idx]; CaptionDistributionPacketChecksum = bytes[4 + idx]; }
public void CcServiceInfoSectionTest() { var input = new byte[] { 0x73, 0xF2, 0xE0, 0x20, 0x20, 0x20, 0x7E, 0x7F, 0xFF, 0xE1, 0x65, 0x6E, 0x67, 0xC1, 0x7F, 0xFF }; var serviceInfoSection = new CcServiceInfoSection(input, 0); var bytes = serviceInfoSection.GetBytes(); Assert.AreEqual(2, serviceInfoSection.CcServiceInfoSectionElements.Length); Assert.AreEqual(bytes.Length, input.Length); for (var index = 0; index < input.Length; index++) { Assert.AreEqual(input[index], bytes[index]); } }