void RTMFP::Encode(RTMFPEngine& aesEncrypt,PacketWriter& packet) { // paddingBytesLength=(0xffffffff-plainRequestLength+5)&0x0F int paddingBytesLength = (0xFFFFFFFF-packet.size()+5)&0x0F; // Padd the plain request with paddingBytesLength of value 0xff at the end while (paddingBytesLength-->0) packet.write8(0xFF); WriteCRC(packet); // Encrypt the resulted request aesEncrypt.process(packet.data()+4,(UInt8*)packet.data()+4,packet.size()-4); }
void RTMFP::Pack(PacketWriter& packet,UInt32 farId) { PacketReader reader(packet.data(),packet.size()); reader.next(4); BinaryWriter(packet.data(),4).write32(reader.read32()^reader.read32()^farId); }
void RTMFP::WriteCRC(PacketWriter& packet) { // Compute the CRC and add it at the beginning of the request PacketReader reader(packet.data(),packet.size()); reader.next(6); BinaryWriter(packet.data()+4,2).write16(CheckSum(reader)); }