libvisiontransfer  10.6.0
imageprotocol.h
1 /*******************************************************************************
2  * Copyright (c) 2023 Allied Vision Technologies GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_IMAGEPROTOCOL_H
16 #define VISIONTRANSFER_IMAGEPROTOCOL_H
17 
18 #include "visiontransfer/common.h"
19 #include "visiontransfer/imageset.h"
20 
21 #include <vector>
22 
23 namespace visiontransfer {
24 
40 class VT_EXPORT ImageProtocol {
41 public:
43  enum ProtocolType {
45  PROTOCOL_TCP,
46 
48  PROTOCOL_UDP
49  };
50 
58  ImageProtocol(bool server, ProtocolType protType, int maxUdpPacketSize = 1472);
59 
60  ~ImageProtocol();
61 
71  void setTransferImageSet(const ImageSet& imageSet);
72 
103  void setRawTransferData(const ImageSet& metaData, const std::vector<unsigned char*>& imageData,
104  int firstTileWidth = 0, int middleTilesWidth = 0, int lastTileWidth = 0);
105 
115  void setRawValidBytes(const std::vector<int>& validBytes);
116 
125  const unsigned char* getTransferMessage(int& length);
126 
130  bool transferComplete();
131 
136  void resetTransfer();
137 
152  bool getReceivedImageSet(ImageSet& imageSet);
153 
176  bool getPartiallyReceivedImageSet(ImageSet& imageSet, int& validRows, bool& complete);
177 
181  bool imagesReceived() const;
182 
189  unsigned char* getNextReceiveBuffer(int& maxLength);
190 
206  void processReceivedMessage(int length);
207 
215  int getNumDroppedFrames() const;
216 
221  void resetReception();
222 
227  bool newClientConnected();
228 
232  bool isConnected() const;
233 
243  const unsigned char* getNextControlMessage(int& length);
244 
245 #ifndef DOXYGEN_SHOULD_SKIP_THIS
246  std::string statusReport();
248 #endif
249 
250 private:
251  // We follow the pimpl idiom
252  class Pimpl;
253  Pimpl* pimpl;
254 
255  // This class cannot be copied
256  ImageProtocol(const ImageProtocol& other);
257  ImageProtocol& operator=(const ImageProtocol&);
258 };
259 
260 } // namespace
261 
262 #endif
Allied Vision