public bool Append(Content content) { if (empty) { stream = content.Stream; position = content.Position; contFlag = content.ContFlag; timestamp = content.Timestamp; lastTimestamp = timestamp; dataBuffer.SetLength(0); dataBuffer.Write(content.Data, 0, content.Data.Length); empty = false; return(true); } else if (stream != content.Stream || contFlag != content.ContFlag || position + dataBuffer.Length != content.Position || Math.Abs((content.Timestamp - lastTimestamp).TotalMilliseconds) > 100.0 || dataBuffer.Length + content.Data.Length > 8 * 1024) { return(false); } else { lastTimestamp = content.Timestamp; dataBuffer.Write(content.Data, 0, content.Data.Length); return(true); } }
/// <summary> /// コンテントのストリーム番号、時刻、位置、内容を指定して初期化します /// </summary> /// <param name="stream">ストリーム番号</param> /// <param name="timestamp">時刻</param> /// <param name="pos">バイト位置</param> /// <param name="data">内容</param> /// <param name="cont">内容</param> public Content(int stream, TimeSpan timestamp, long pos, byte[] data, PCPChanPacketContinuation cont) { Stream = stream; Timestamp = timestamp; Position = pos; Data = data; ContFlag = cont; Serial = -1; }
public Content(int stream, TimeSpan timestamp, long pos, byte[] data, int offset, int length, PCPChanPacketContinuation cont) { Stream = stream; Timestamp = timestamp; Position = pos; Data = new byte[length]; Array.Copy(data, offset, this.Data, 0, length); ContFlag = cont; Serial = -1; }
public bool Append(Content content) { if (empty) { stream = content.Stream; position = content.Position; contFlag = content.ContFlag; timestamp = content.Timestamp; lastTimestamp = timestamp; dataBuffer.SetLength(0); dataBuffer.Write(content.Data.Span); empty = false; return(true); } else if (stream != content.Stream || contFlag != content.ContFlag || position + dataBuffer.Length != content.Position || Math.Abs((content.Timestamp - lastTimestamp).TotalMilliseconds) > 100.0) { return(false); } else if (dataBuffer.Length + content.Data.Length > LengthThreashold) { var unified_packets = (dataBuffer.Length + content.Data.Length + LengthThreashold - 1) / LengthThreashold; var independent_packets = (dataBuffer.Length + LengthThreashold - 1) / LengthThreashold + (content.Data.Length + LengthThreashold - 1) / LengthThreashold; if (unified_packets < independent_packets) { lastTimestamp = content.Timestamp; dataBuffer.Write(content.Data.Span); return(true); } else { return(false); } } else { lastTimestamp = content.Timestamp; dataBuffer.Write(content.Data.Span); return(true); } }
public static void SetChanPktCont(this IAtomCollection collection, PCPChanPacketContinuation value) { SetAtomTo(collection, new Atom(Atom.PCP_CHAN_PKT_CONTINUATION, (byte)value)); }