PartitionFile() public method

Partition a file in packets and adds the packet to the arraylist.
public PartitionFile ( byte Data, int FileSize ) : void
Data byte
FileSize int
return void
        public void BitmapAcquiredCBHandler(Bitmap aNewBitmap)
        {
            byte[] newBA = aCodecUtility.CompressBmpToJPEGArray(aImageQuality, aNewBitmap);
            int FileID = aRandomGenerator.Next();

            //Total size of the packet to send including header  +  data.
            PacketPartitionner pp = new PacketPartitionner(FileID, newBA.Length, Packet.GetHeaderSize() + Packet.DEFAULT_PACKET_SIZE, null);
            pp.PartitionFile(newBA, newBA.Length);

            //Console.WriteLine("Partition File ID " + FileID + " In " + pp.GetPartitionnedPackets().Count + " Packets");

            //Remove prints to the console
            for (int i = 0; i < pp.GetPartitionnedPackets().Count; i++)
            {
                Packet p = ((Packet)(pp.GetPartitionnedPackets()[i]));

                //Console.WriteLine("Send Packet:"+i);

                byte[] SerializedPacket = p.GetBytes();

                //Sending the data to a blocking queue that gets process by a thread generate additionnal delay
                //The best solution to reduce the lag for now is to send the data directly with SendNow method.
                //aUDPSender.SendDataUDP(SerializedPacket, SerializedPacket.Length);

                aUDPSender.SendBytesNow(SerializedPacket, SerializedPacket.Length);

            }

            pp.GetPartitionnedPackets().Clear();
        }
Esempio n. 2
0
        public void BitmapAcquiredCBHandler(Bitmap aNewBitmap)
        {
            byte[] newBA  = aCodecUtility.CompressBmpToJPEGArray(aImageQuality, aNewBitmap);
            int    FileID = aRandomGenerator.Next();

            //Total size of the packet to send including header  +  data.
            PacketPartitionner pp = new PacketPartitionner(FileID, newBA.Length, Packet.GetHeaderSize() + Packet.DEFAULT_PACKET_SIZE, null);

            pp.PartitionFile(newBA, newBA.Length);

            //Console.WriteLine("Partition File ID " + FileID + " In " + pp.GetPartitionnedPackets().Count + " Packets");

            //Remove prints to the console
            for (int i = 0; i < pp.GetPartitionnedPackets().Count; i++)
            {
                Packet p = ((Packet)(pp.GetPartitionnedPackets()[i]));

                //Console.WriteLine("Send Packet:"+i);

                byte[] SerializedPacket = p.GetBytes();

                //Sending the data to a blocking queue that gets process by a thread generate additionnal delay
                //The best solution to reduce the lag for now is to send the data directly with SendNow method.
                //aUDPSender.SendDataUDP(SerializedPacket, SerializedPacket.Length);

                aUDPSender.SendBytesNow(SerializedPacket, SerializedPacket.Length);
            }

            pp.GetPartitionnedPackets().Clear();
        }