15 #ifndef VISIONTRANSFER_DATABLOCKPROTOCOL_H 16 #define VISIONTRANSFER_DATABLOCKPROTOCOL_H 21 #include "visiontransfer/alignedallocator.h" 42 static const int MAX_UDP_BYTES_TRANSFER = 1472;
44 static const int MAX_TCP_BYTES_TRANSFER = 0xFFFF;
45 static const int MAX_OUTSTANDING_BYTES = 2*MAX_TCP_BYTES_TRANSFER;
54 return protType == PROTOCOL_UDP ?
sizeof(
unsigned short) : 0;
89 void setTransferData(
unsigned char* data,
int size,
int validBytes = 0x7FFFFFFF);
171 static const int MIN_UDP_BYTES_TRANSFER = 512;
173 ProtocolType protType;
179 unsigned char* rawData;
183 unsigned short transferSeqNum;
184 unsigned short overwrittenTransferData;
185 bool restoreTransferData;
188 std::vector<unsigned char, AlignedAllocator<unsigned char> > receiveBuffer;
190 unsigned short receiveSeqNum;
191 unsigned char unprocessedMsgPart[MAX_OUTSTANDING_BYTES];
192 int unprocessedMsgLength;
193 int receiveTotalSize;
197 const unsigned char* extractPayload(
const unsigned char* data,
int& length,
bool& error);
void setReceiveDataSize(int size)
Sets the total size of the data that shall be received.
const unsigned char * getTransferMessage(int &length)
Gets the next network message for the current transfer.
A protocol for transmitting large blocks of data over a network.
int getProtocolOverhead() const
Returns the size of the overhead data that is required for transferring a single network message...
unsigned char * getReceivedData(int &length)
Returns the data that has been received for the current data block.
void resetTransfer()
Stops the current transfer.
unsigned char * getNextReceiveBuffer(int maxLength)
Gets a buffer for receiving the next network message.
void resetReception()
Resets the message reception.
int getMaxPayloadSize() const
Returns the maximum paload size that can be transferred / received.
bool transferComplete()
Returns true if the current transfer has been completed.
bool processReceivedMessage(int length)
Handles a received network message.
void setTransferData(unsigned char *data, int size, int validBytes=0x7FFFFFFF)
Sets a new chunk of data that should be transferred.
void startTransfer()
Starts the transfer of a new data block.
void finishReception()
Finishes reception of the current data block.
void setTransferValidBytes(int validBytes)
Updates the number of valid bytes in a partial transmission.