public override byte[] GetBytes() { var bytes = new byte[15]; int startIndex = 0; // 消息类型 bytes[startIndex++] = (byte)this.FrameType; // 序列号 var tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // sender timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // Responsor last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.ReceiverLastSendTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // sender last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderLastRecvTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; return(bytes); }
public override byte[] GetBytes() { var bytes = new byte[25]; int startIndex = 0; // 消息类型 bytes[startIndex++] = (byte)this.FrameType; // 序列号 var tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // Padding startIndex += SaiFrame.TtsPaddingLength; // 初始值 tempBuf = RsspEncoding.ToNetUInt32(this.InitialValue); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // 版本 tempBuf = RsspEncoding.ToNetUInt32(this.Version); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // EC周期 tempBuf = RsspEncoding.ToNetUInt16(this.Interval); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); return(bytes); }
public override byte[] GetBytes() { if (this.UserDataLength > SaiFrame.MaxUserDataLength) { throw new ArgumentException(string.Format("SAI层用户数据长度不能超过{0}。", SaiFrame.MaxUserDataLength)); } var bytes = new byte[19 + this.UserDataLength]; int startIndex = 0; // 消息类型 bytes[startIndex++] = (byte)this.FrameType; // 序列号 var tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // Padding startIndex += SaiFrame.TtsPaddingLength; // EC计数 tempBuf = RsspEncoding.ToNetUInt32(this.EcValue); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // user data if (this.UserData != null) { Array.Copy(this.UserData, 0, bytes, startIndex, this.UserData.Length); } return(bytes); }
public override byte[] GetBytes() { var bytes = new byte[25]; int startIndex = 0; // 消息类型 bytes[startIndex++] = (byte)this.FrameType; // 序列号 var tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // sender timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // Responsor last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.ReceiverLastSendTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // sender last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderLastRecvTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // 偏移标志 bytes[startIndex++] = (this.OffsetMin >= 0) ? (byte)0 : (byte)1; // |最小偏移值| tempBuf = RsspEncoding.ToNetUInt32((uint)Math.Abs(this.OffsetMin)); Array.Copy(tempBuf, 0, bytes, startIndex, 4); startIndex += 4; // 偏移标志 bytes[startIndex++] = (this.OffsetMax >= 0) ? (byte)0 : (byte)1; // |最大偏移值| tempBuf = RsspEncoding.ToNetUInt32((uint)Math.Abs(this.OffsetMax)); Array.Copy(tempBuf, 0, bytes, startIndex, 4); startIndex += 4; return(bytes); }
/// <summary> /// 获取序列化后的字节流。 /// </summary> public byte[] GetBytes() { var bytes = new byte[AleFrame.HeadLength + this.UserDataLength]; var startIndex = 0; // 包长度 var tempBuf = RsspEncoding.ToNetUInt16(this.PacketLength); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += AleFrame.SizeofHeadLen; // 版本 bytes[startIndex++] = this.Version; // 应用类型 bytes[startIndex++] = this.ApplicationType; // 传输序列号 tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // N/R标志 bytes[startIndex++] = (byte)(this.IsNormal ? 1 : 0); // 包类型 bytes[startIndex++] = (byte)this.FrameType; // 校验和 var crcValue = CrcTool.CaculateCCITT16(bytes, 0, 8); //tempBuf = BitConverter.GetBytes(crcValue); tempBuf = RsspEncoding.ToNetUInt16(crcValue); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // 用户数据 var userData = this.UserData.GetBytes(); if (userData != null) { Array.Copy(userData, 0, bytes, startIndex, this.UserDataLength); } return(bytes); }
public override byte[] GetBytes() { if (this.UserDataLength > SaiFrame.MaxUserDataLength) { throw new ArgumentException(string.Format("SAI层用户数据长度不能超过{0}。", SaiFrame.MaxUserDataLength)); } var bytes = new byte[15 + this.UserDataLength]; int startIndex = 0; // 消息类型 bytes[startIndex++] = (byte)this.FrameType; // 序列号 var tempBuf = RsspEncoding.ToNetUInt16(this.SequenceNo); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 2; // sender timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // Responsor last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.ReceiverLastSendTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // sender last timestamp tempBuf = RsspEncoding.ToNetUInt32(this.SenderLastRecvTimestamp); Array.Copy(tempBuf, 0, bytes, startIndex, tempBuf.Length); startIndex += 4; // user data if (this.UserData != null) { Array.Copy(this.UserData, 0, bytes, startIndex, this.UserData.Length); } return(bytes); }