public RTMPMessage(RTMPConnection connection, RTMPMessageHeader header, RTMPMessageBody body) { Connection = connection; Header = header; header.ParentMessage = this; Body = body; body.ParentMessage = this; }
public RTMPMessageBody(RTMPConnection connection, RTMPMessageHeader header, RTMPLib.Internal.BinaryReader br) { Connection = connection; byte[] buffer = null; if (header.MessageLength < 0) //this is a follow up message { RTMPChunkStream csinfo = Connection.GetChunkStream((int)header.ChunkStreamID); buffer = br.ReadBytes(Math.Min(csinfo.RemainingBytes, Connection.IncomingChunkSize)); } else { buffer = br.ReadBytes(Math.Min(header.MessageLength, Connection.IncomingChunkSize)); } ms.Write(buffer, 0, buffer.Length); /*int remaining = connection.IncomingChunkSize; * * while (remaining > 0) * { * byte[] buffer = br.ReadBytes(remaining); * ms.Write(buffer, 0, buffer.Length); * remaining -= ParentMessage.Connection.IncomingChunkSize; * } * * int remaining = ParentMessage.Header.MessageLength; * while (remaining > 0) * { * byte[] buffer = br.ReadBytes(Math.Min(ParentMessage.Connection.IncomingChunkSize,remaining)); * ms.Write(buffer,0,buffer.Length); * remaining -= ParentMessage.Connection.IncomingChunkSize; * if (remaining > 0) * { * new RTMPMessageHeader(ParentMessage, br); // read the header for the next message piece * } * }*/ ms.Position = 0; MemoryReader = new RTMPLib.Internal.BinaryReader(ms); }
public RTMPMessageBody(RTMPConnection connection, RTMPMessageHeader header, RTMPLib.Internal.BinaryReader br) { Connection = connection; byte[] buffer = null; if (header.MessageLength < 0) //this is a follow up message { RTMPChunkStream csinfo = Connection.GetChunkStream((int)header.ChunkStreamID); buffer = br.ReadBytes(Math.Min(csinfo.RemainingBytes, Connection.IncomingChunkSize)); } else { buffer = br.ReadBytes(Math.Min(header.MessageLength, Connection.IncomingChunkSize)); } ms.Write(buffer, 0, buffer.Length); /*int remaining = connection.IncomingChunkSize; while (remaining > 0) { byte[] buffer = br.ReadBytes(remaining); ms.Write(buffer, 0, buffer.Length); remaining -= ParentMessage.Connection.IncomingChunkSize; } int remaining = ParentMessage.Header.MessageLength; while (remaining > 0) { byte[] buffer = br.ReadBytes(Math.Min(ParentMessage.Connection.IncomingChunkSize,remaining)); ms.Write(buffer,0,buffer.Length); remaining -= ParentMessage.Connection.IncomingChunkSize; if (remaining > 0) { new RTMPMessageHeader(ParentMessage, br); // read the header for the next message piece } }*/ ms.Position = 0; MemoryReader = new RTMPLib.Internal.BinaryReader(ms); }
private RTMPMessage ReceiveNextMessage() { RTMPMessageHeader header = new RTMPMessageHeader(this, br); RTMPMessageBody body = new RTMPMessageBody(this, header, br); RTMPMessage newmessage = new RTMPMessage(this, header, body); RTMPChunkStream csinfo = GetChunkStream((int)header.ChunkStreamID); return csinfo.AddFragment(newmessage); }
public RTMPMessage(RTMPConnection connection) { Connection = connection; Header = new RTMPMessageHeader(this); Body = new RTMPMessageBody(this); }