The SDK provides a channel for app developers and FW developers to communicate with custom device property codes, which can facilitate FW to add extended functions that you want to control through the app. This channel is based on the Device property code of the PIMA protocol.
Interface provided by SDK
The SDK encapsulates the PTP protocol, leaving only the necessary interfaces, so App developers do not need to understand the the PTP protocol.
Interface description
Java
Class:
com.icatchtek.control.ICatchCameraProperty
Mehtods:
boolean setPropertyValue(int propId, int value);boolean setPropertyValue(int propId, int value, int timeoutInSecs);int getCurrentPropertyValue(int propId);int getCurrentPropertyValue(int propId, int timeoutInSecs);List<Integer> getSupportedPropertyValues(int propId);List<Integer> getSupportedPropertyValues(int propId, int timeoutInSecs);
As an example, we removed the exception throwing statement behind the method.
C++
Class:
com::icatchtek::control::ICatchCameraPropertyMethods:
int setPropertyValue(int propId, unsigned int value);int setPropertyValue(int propId, unsigned int value, int timeoutInSecs);int getCurrentPropertyValue(int propId, unsigned int& value);int getCurrentPropertyValue(int propId, unsigned int& value, int timeoutInSecs);int getSupportedPropertyValues(int propId, vector<unsigned int>& values);int getSupportedPropertyValues(int propId, vector<unsigned int>& values, int timeoutInSecs);
Interface introduction
- Interfaces are divided into three categories:
- Set current value:
setPropertyValue - Get current value:
getCurrentPropertyValue - Get the list of supported values:
getSupportedPropertyValues
- Set current value:
- Each type of interface has an overload method, which is used to specify the timeout for method execution. if the corresponding DPC command takes a long time, you can use the overloaded interface and specify a more reasonable timeout.
- However, these interfaces require certain restrictions on the FW’s implement.
- The data type should be unsigned 32 bit integer
PTP_DTC_UINT32 0x0006 - Device property form flag should be Enum
PTP_DPFF_Enumeration 0x02 - If FW does not support setting operations when implementing the corresponding DPC command, calling
setPropertyValuemay fail。
Only read support:PTP_DPGS_Get 0x00
Read-write support:PTP_DPGS_GetSet 0x01
- The data type should be unsigned 32 bit integer
Example
Assume that the camera capture delay command attribute is a new extended DPC command (in fact, it is a standard command, but it meets the above requirements on the FW‘s implementation)
Here I want to set the camera capture delay time to the last value in the list of values supported by the camera.
ICatchCameraProperty property = null;try {property = this.cameraSession.getPropertyClient();} catch (IchInvalidSessionException e) {e.printStackTrace();}if (property == null) {Log.i("__dpc_sample__","Could not get property client from camera session," +" may be you forget to prepare the session.");return;}int CAPTURE_DELAY = 0x5012; // the dpc comand we want to usetry {/* >>> step1: get supported property values. */List<Integer> delayList = property.getSupportedPropertyValues(CAPTURE_DELAY);if (delayList == null || delayList.size() <= 0) {Log.i("__dpc_sample__", "could not get valid support capture delay values.");return;}/* choose the value which we want */int theLastValue = delayList.get(delayList.size() - 1);/* if it's already the camera's current value, do not set again *//* >>> step2: get current property value. */int currentValue = property.getCurrentPropertyValue(CAPTURE_DELAY);if (theLastValue == currentValue) {Log.i("__dpc_sample__", "The one we choose is equal with the camera's current value");return;}/* Set the value, apply new value to the camera *//* >>> step3: set property value. */boolean retVal = property.setPropertyValue(CAPTURE_DELAY, 1);if (retVal == false) {Log.i("__dpc_sample__", "failed, the choose value does not been applied to camera");}/* All operation execute succeed. */}catch (Exception ex) {ex.printStackTrace();}
FW related implementation
Most importantly, there are already some dpc commands defined. The newly defined commands cannot be the same with the existing commands.
The defined DPC commands in FW will add later, you can contact the project window for detail information.
