public DataCompressedDvcPdu[] CreateCompressedDataPdu(uint channelId, byte[] data, int channelChunkLength = 1599)
{
MemoryStream ms = new MemoryStream(data);
List<DataCompressedDvcPdu> pdus = new List<DataCompressedDvcPdu>();
//TODO: Here the compress algorithm has bug and cannot compress the data correctly. The size will become bigger than before comprssion
byte[] compressed = CompressDataToRdp8BulkEncodedData(data, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);
DataCompressedDvcPdu pdu = new DataCompressedDvcPdu();
pdu.HeaderBits.Cmd = Cmd_Values.DataCompressed;
pdu.HeaderBits.Sp = 0x0;
pdu.HeaderBits.CbChannelId = cbChId_Values.OneByte;
pdu.ChannelId = channelId;
//RDP8_BULK_ENCODED_DATA rdp8BulkEncodedData = new RDP8_BULK_ENCODED_DATA();
//rdp8BulkEncodedData.descriptor = 0xE0; //Single
//rdp8BulkEncodedData.header = 0x26;//PACKET_COMPRESSED (0x2), PACKET_CMPR_TYPE_RDP8_LITE (0x06)
//rdp8BulkEncodedData.data = compressed;
byte[] rdp8Header = new byte[] { 0xE0, 0x26 }; //0xE0; Single 0x26:PACKET_COMPRESSED (0x2), PACKET_CMPR_TYPE_RDP8_LITE (0x06)
var s = new MemoryStream();
s.Write(rdp8Header, 0, rdp8Header.Length);
s.Write(compressed, 0, compressed.Length);
byte[] rdp8BulkEncodedData = s.ToArray();
pdu.Data = rdp8BulkEncodedData;
pdus.Add(pdu);
return pdus.ToArray();
}