/// <summary> /// 将音频数据包转换到1078包 /// </summary> /// <param name="value"></param> /// <param name="sim"></param> /// <param name="channelNo"></param> /// <param name="jT1078AVType"></param> /// <param name="timestamp"></param> /// <returns></returns> public static List <JT1078Package> ConvertAudio(this byte[] value, string sim, int channelNo, JT1078AVType jT1078AVType, ulong timestamp) { List <JT1078Package> jT1078Packages = new List <JT1078Package>(); var buffer = Slice(value); if (buffer.Count == 1) { JT1078Package jT1078Package = new JT1078Package(); jT1078Package.SIM = sim; jT1078Package.LogicChannelNumber = (byte)channelNo; jT1078Package.SN = SeqUtil.Increment(sim); jT1078Package.Timestamp = timestamp; jT1078Package.Label2 = new JT1078Label2(1, jT1078AVType); jT1078Package.Label3 = new JT1078Label3(JT1078DataType.音频帧, JT1078SubPackageType.原子包_不可被拆分); jT1078Package.Bodies = buffer[0]; jT1078Packages.Add(jT1078Package); } else if (buffer.Count == 2) { JT1078Package jT1078Package1 = new JT1078Package(); jT1078Package1.SIM = sim; jT1078Package1.LogicChannelNumber = (byte)channelNo; jT1078Package1.SN = SeqUtil.Increment(sim); jT1078Package1.Timestamp = timestamp; jT1078Package1.Label2 = new JT1078Label2(0, jT1078AVType); jT1078Package1.Label3 = new JT1078Label3(JT1078DataType.音频帧, JT1078SubPackageType.分包处理时的第一个包); jT1078Package1.Bodies = buffer[0]; jT1078Packages.Add(jT1078Package1); JT1078Package jT1078Package2 = new JT1078Package(); jT1078Package2.SIM = sim; jT1078Package2.LogicChannelNumber = (byte)channelNo; jT1078Package2.SN = SeqUtil.Increment(sim); jT1078Package2.Timestamp = timestamp; jT1078Package2.Label2 = new JT1078Label2(1, jT1078AVType); jT1078Package2.Label3 = new JT1078Label3(JT1078DataType.音频帧, JT1078SubPackageType.分包处理时的最后一个包); jT1078Package2.Bodies = buffer[1]; jT1078Packages.Add(jT1078Package2); } else { for (var i = 0; i < buffer.Count; i++) { JT1078Package jT1078Package = new JT1078Package(); jT1078Package.SIM = sim; jT1078Package.LogicChannelNumber = (byte)channelNo; jT1078Package.SN = SeqUtil.Increment(sim); jT1078Package.Timestamp = timestamp; jT1078Package.Label2 = new JT1078Label2(0, jT1078AVType); jT1078Package.Label3 = new JT1078Label3(JT1078DataType.音频帧); jT1078Package.Bodies = buffer[i]; if (i == 0) { jT1078Package.Label3.SubpackageType = JT1078SubPackageType.分包处理时的第一个包; } else if (i == (buffer.Count - 1)) { jT1078Package.Label2.M = 1; jT1078Package.Label3.SubpackageType = JT1078SubPackageType.分包处理时的最后一个包; } else { jT1078Package.Label3.SubpackageType = JT1078SubPackageType.分包处理时的中间包; } jT1078Packages.Add(jT1078Package); } } return(jT1078Packages); }