libvisiontransfer  10.6.0
asynctransfer.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_ASYNCTRANSFER_H
16 #define VISIONTRANSFER_ASYNCTRANSFER_H
17 
18 #include "visiontransfer/common.h"
19 #include "visiontransfer/imagetransfer.h"
20 #include "visiontransfer/imageset.h"
21 #include "visiontransfer/imageprotocol.h"
22 #include "visiontransfer/deviceinfo.h"
23 
24 namespace visiontransfer {
25 
33 class VT_EXPORT AsyncTransfer {
34 public:
51  AsyncTransfer(const char* address, const char* service = "7681",
53  bool server = false, int bufferSize = 16*1048576, int maxUdpPacketSize = 1472);
54 
64  AsyncTransfer(const DeviceInfo& device, int bufferSize = 16*1048576, int maxUdpPacketSize = 1472);
65 
66  ~AsyncTransfer();
67 
81  void sendImageSetAsync(const ImageSet& imageSet, bool deleteData = false);
82 
83 #ifndef DOXYGEN_SHOULD_SKIP_THIS
84  DEPRECATED("Use sendImageSetAsync() instead")
85  inline void sendImagePairAsync(const ImageSet& imageSet, bool deleteData = false) {
86  sendImageSetAsync(imageSet, deleteData);
87  }
88 #endif
89 
106  bool collectReceivedImageSet(ImageSet& imageSet, double timeout = -1);
107 
108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
109  DEPRECATED("Use collectReceivedImageSet() instead")
110  inline bool collectReceivedImagePair(ImageSet& imageSet, double timeout = -1) {
111  return collectReceivedImageSet(imageSet, timeout);
112  }
113 #endif
114 
122  int getNumDroppedFrames() const;
123 
133  bool tryAccept();
134 
138  bool isConnected() const;
139 
145  void disconnect();
146 
152  std::string getRemoteAddress() const;
153 
154 private:
155  // We follow the pimpl idiom
156  class Pimpl;
157  Pimpl* pimpl;
158 
159  // This class cannot be copied
160  AsyncTransfer(const AsyncTransfer& other);
161  AsyncTransfer& operator=(const AsyncTransfer&);
162 };
163 
164 } // namespace
165 
166 #endif
visiontransfer::ImageProtocol::PROTOCOL_UDP
@ PROTOCOL_UDP
The connection-less UDP transport protocol.
Definition: imageprotocol.h:84
visiontransfer::ImageProtocol::ProtocolType
ProtocolType
Supported network protocols.
Definition: imageprotocol.h:67
Allied Vision