public static FragUnitA Parse(byte[] data) { FragUnitA fu = new FragUnitA(); fu.Indicator = NaluHeader.Parse(data[0]); if (fu.Indicator.Type != NALU_TYPE) { throw new ArgumentException($"FU-B封包的指示字节的类型必须是{NALU_TYPE},当前类型是:" + fu.Indicator.Type); } fu.Header = FuHeader.Parse(data[1]); fu.Payload = BytesHelper.SubBytes(data, 2); return(fu); }
public static FragUnitB Parse(byte[] data) { FragUnitB fu = new FragUnitB(); fu.Indicator = NaluHeader.Parse(data[0]); if (fu.Indicator.Type != NALU_TYPE) { throw new ArgumentException($"FU-B封包的指示字节的类型必须是{NALU_TYPE},当前类型是:" + fu.Indicator.Type); } fu.Header = FuHeader.Parse(data[1]); //TODO:我们暂时认为所有的字节序均为BigEndian,如果传输失败,再做改正。 byte[] donBytes = new byte[] { data[3], data[2] }; fu.Don = BitConverter.ToInt16(donBytes, 0); fu.Payload = BytesHelper.SubBytes(data, 4); return(fu); }