ipcamerasettings.h
1 /**************************************************************************
2  *
3  * File: ipcamerasettings.h
4  *
5  *
6  * Description: Contains the wrapper class definition for the IP camera API.
7  * The IP Camera API allows you to send and receive commands to a IP Camera that supports
8  * the ISO17215 standard. This simplifies handling and communication with IP cameras.
9  *
10  * Copyright (C) 2018 CrossControl AB
11  * All rights reserved.
12  * Contact: CrossControl AB (info@crosscontrol.com)
13  *
14 **************************************************************************/
15 
16 #ifndef IPCAMERASETTINGS_H
17 #define IPCAMERASETTINGS_H
18 
19 /*************************************************************************
20  * Include Files
21  *************************************************************************/
22 #include <string>
23 #include <vector>
24 #include "camtypes.h"
25 
26 /*************************************************************************
27  * Manifest constants, macros
28  *************************************************************************/
29 #ifndef MAX_WAIT_TIME_MS
30 #define MAX_WAIT_TIME_MS 1500
31 #endif
32 
33 class CameraSettings;
34 
35 namespace CrossControl {
36 
37 /*************************************************************************
38  * Class definition
39  *************************************************************************/
45 {
46 public:
47 
52 
58  IPCameraSettings(std::string ipAddress, int portNum, int clientID = 1);
59 
63  IPCameraSettings(IPCameraSettings &other) = delete;
64 
69 
75  IPCamStatus open();
76 
84  IPCamStatus open(std::string ipAddress, int portNum);
85 
93  IPCamStatus openServiceDiscovery(std::vector<std::string> multicastGroups, int portNumber);
94 
100  IPCamStatus openServiceDiscovery(int portNumber);
101 
106  IPCamStatus close();
107 
113 
120  IPCamStatus getDatasheet(Datasheet &datasheet, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
121 
128  IPCamStatus getCamStatus(CamStatus &camStatus, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
129 
136  IPCamStatus setCamExclusive(const int expireTimeSeconds = 5, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
137 
144  IPCamStatus eraseCamExclusive(const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
145 
153  IPCamStatus setRegionOfInterest(const RegionOfInterest regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
154 
163  IPCamStatus getRegionOfInterest(RegionOfInterest &regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
164 
171  IPCamStatus getRegionsOfInterest(std::vector<uint32_t> &roiIndices, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
172 
179  IPCamStatus eraseRegionOfInterest(const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
180 
187  IPCamStatus subscribeROIVideo(const uint32_t roiIndex = 0, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
188 
196  IPCamStatus subscribeROIVideo(VideoContent &videoContent, const uint32_t roiIndex = 0, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
197 
204  IPCamStatus unsubscribeROIVideo(const uint32_t roiIndex, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
205 
213  IPCamStatus setBrightnessControl(const SignedControl sControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
214 
221  IPCamStatus getBrightnessControl(SignedControl &sControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
222 
230  IPCamStatus setSaturationControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
231 
238  IPCamStatus getSaturationControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
239 
247  IPCamStatus setGammaControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
248 
256  IPCamStatus getGammaControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
257 
265  IPCamStatus setHeaterControl(const UnsignedControl uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
266 
273  IPCamStatus getHeaterControl(UnsignedControl &uControl, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
274 
281  IPCamStatus setCamRegister(const ImagerRegister imagerRegister, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
282 
291  IPCamStatus setCamRegister(const uint16_t regAddress, const uint16_t regValue, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
292 
300  IPCamStatus setCamRegisters(const std::vector<ImagerRegister> &imagerRegisters, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
301 
309  IPCamStatus getCamRegister(const uint16_t regAddress, uint16_t &regValue, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
310 
318  IPCamStatus getCamRegisters(const std::vector<uint16_t> &addressList, std::vector<ImagerRegister> &imagerRegisters, const int maxWaitTimeMs = MAX_WAIT_TIME_MS);
319 
326  IPCamStatus sendMessageNoResponse(const unsigned char *data, const size_t messageLength) const;
327 
337  IPCamStatus sendMessageWithResponse(const unsigned char * data, const size_t messageLength, unsigned char * responseData, size_t &responseLength, const int maxWaitTimeMs = MAX_WAIT_TIME_MS) const;
338 
345 
351  uint16_t getSessionID() const;
352 
358  void setSessionID(uint16_t arg);
359 
364  uint16_t getClientID() const;
365 
371  void setClientID(uint16_t arg);
372 
378  static std::string stringifyIPCamStatus(const IPCamStatus camStatus);
379 
380 private:
381  CameraSettings* m_cameraSettings;
382 };
383 }
384 
385 #endif // IPCAMERASETTINGS_H
The sIPv4Option struct Describes the IPv4EndpointOption.
Definition: camtypes.h:502
IPCamStatus unsubscribeROIVideo(const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Ends the transmission of a video stream for the requested ROI index.
IPCamStatus getBrightnessControl(SignedControl &sControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Brigthness Control data struct with data from the camera.
IPCamStatus subscribeROIVideo(const uint32_t roiIndex=0, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Starts the transmission of a video stream for the requested ROI index.
static std::string stringifyIPCamStatus(const IPCamStatus camStatus)
Returns the IPCamStatus enum as a std::string, useful for debugging.
IPCamStatus getCamRegisters(const std::vector< uint16_t > &addressList, std::vector< ImagerRegister > &imagerRegisters, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
getCamRegisters Attempts to read a list of imager registers
IPCamStatus setRegionOfInterest(const RegionOfInterest regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attehmps to set the parameters for the region of interest addressed by index.
IPCamStatus setGammaControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the gamma correction of the camera.
IPCamStatus setCamRegisters(const std::vector< ImagerRegister > &imagerRegisters, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to write (atomic access) the content of a register block of the camera imager.
Defines the region of interest. The ROIs (regions of interest) are used to acquire data from the came...
Definition: camtypes.h:452
IPCamStatus closeServiceDiscoverySocket()
Closes the Service Discovery socket.
IPCamStatus getGammaControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Gamma Control data struct with data from the camera.
IPCamStatus sendMessageWithResponse(const unsigned char *data, const size_t messageLength, unsigned char *responseData, size_t &responseLength, const int maxWaitTimeMs=MAX_WAIT_TIME_MS) const
Sends a custom message to the camera and reads the response.
IPCamStatus eraseCamExclusive(const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to remove the exclusive control look for the requesting client.
Definition: camtypes.h:26
IPCamStatus getCamStatus(CamStatus &camStatus, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to fill a struct with the status of the IP Camera.
Defines the camera status information.
Definition: camtypes.h:253
IPCamStatus setCamRegister(const ImagerRegister imagerRegister, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to writes the content of a register of the camera’s imager addressed by physical register a...
IPCamStatus getHeaterControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Heater Control data struct with data from the camera.
IPCamStatus setBrightnessControl(const SignedControl sControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the brightness circuits of the camera.
IPCamStatus getRegionsOfInterest(std::vector< uint32_t > &roiIndices, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Gets the indices for all the regions of interest.
IPCamStatus getSaturationControl(UnsignedControl &uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to populate the Saturation Control data struct with data from the camera.
IPCamStatus setCamExclusive(const int expireTimeSeconds=5, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to assign the control of the camera exclusively to the requesting client.
IPCamStatus close()
Closes the socket.
Definition of an address/value pair of imager register.
Definition: camtypes.h:218
IPCamStatus getCamRegister(const uint16_t regAddress, uint16_t &regValue, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Reads the content of a register block of the camera imager.
The IPCameraSettings class This class is the inteface between the IP Camera and the user...
Definition: ipcamerasettings.h:44
IPCamStatus eraseRegionOfInterest(const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempt to erases all parameters for the requested region of interest.
void setSessionID(uint16_t arg)
Sets a new session ID.
~IPCameraSettings()
Deletes the API class and frees all allocated memory.
IPCamStatus
Returncodes and error messages. Can be sent from either the camera or the API.
Definition: camtypes.h:67
uint16_t getClientID() const
Returns the client ID number.
IPCamStatus getDatasheet(Datasheet &datasheet, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to fill a struct with the datasheet of the camera.
IPCameraSettings()
Creates the API class.
IPCamStatus setHeaterControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the controls for the heater of the camera.
IPCamStatus getRegionOfInterest(RegionOfInterest &regionOfInterest, const uint32_t roiIndex, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Gets the parameters for the region of interest addressed by index.
IPCamStatus openServiceDiscovery(std::vector< std::string > multicastGroups, int portNumber)
Opens a socket to look for Service Discovery messages.
IPCamStatus open()
Opens a UDP-socket with the address and port number previously supplied.
void setClientID(uint16_t arg)
Sets the client ID.
IPCamStatus serviceDiscoveryGetIPv4(IPv4Option &option)
Reads the socket for a Service Discovery - Offer Service message with the IPv4 endpoint option...
IPCamStatus setSaturationControl(const UnsignedControl uControl, const int maxWaitTimeMs=MAX_WAIT_TIME_MS)
Attempts to set the control for the saturation circuits of the camera.
Definition of a signed camera control.
Definition: camtypes.h:274
Definition of a unsigned camera control.
Definition: camtypes.h:284
IPCamStatus sendMessageNoResponse(const unsigned char *data, const size_t messageLength) const
Sends a custom message, without expecting a response from the camera.
uint16_t getSessionID() const
Returns the session ID number.
Defines the format of a video content notification package.
Definition: camtypes.h:239
Defines the characteristics of the camera.
Definition: camtypes.h:398