Get the Camera Properties

After the connection is established, camera property can be acquired by the GetDeviceProperties() function. This function has three parameters. The first one is the device handle that specifies the device, the second one is the pointer to CrDeviceProperty pointer that receives the acquired property list, and the third one receives the size of the CrDeviceProperty list. The CrDeviceProperty returned from GetDeviceProperties() is allocated in Camera Remote SDK and the memory MUST be freed by calling ReleaseDeviceProperties() function.

Example:

void GetProperties(CrDeviceHandle handle) {
    CrDeviceProperty *pProperties;
    CrInt32 numofProperties = 0;
    SCRSDK::GetDeviceProperties(handle, &pProperties, &numofProperties);
    if (pProperties) { // the property list is received successfully
        for (CrInt32 n = 0; n < numofProperties; n++) {
            SCRSDK::CrDataType type = pProperties[n].GetValueType();
            int dataLen = sizeof(CrInt64u); // Maximum length
            if (type & SCRSDK::CrDataType_UInt8) {
                dataLen = sizeof(CrInt8u);
            } else if (type & SCRSDK::CrDataType_UInt16) {
                dataLen = sizeof(CrInt16u);
            :
            }
            int numofValue = pProperties[n].GetValueSize() / dataLen;
            switch (pProperties[n].GetCode()) {
            case CrDeviceProperty_FNumber:
            // code to parse the properties...
                    :
    }
    SCRSDK::ReleaseDeviceProperties(handle, pProperties);

In the sample code above, for code simplification, the return value of GetDeviceProperties() is not checked, but it has to be checked. If the camera has already disconnected, it returns CrError_Invalid_Parameter. Additionally, in case of device property memory allocation error, it returns CrError_Generic_Unknown.

The content of the property list depends on the camera features. It is not expected that all of the properties are defined in enum of CrDevicePropertyCode in CrDeviceProperty.h. Some properties defined in CrDevicePropertyCode will also be acquired by the GetLiveViewProperties() function as described in the following section.

This function does not communicate with the camera. This function returns the copy of the latest property list. The camera properties are updated automatically inside this Camera Remote SDK. In case of one or other properties are changed, Camera Remote SDK calls OnPropertyChanged() and more callback functions. Camera Remote SDK assumes that GetDeviceProperties() is called at the beginning of the camera operation, and when Camera Remote SDK calls the OnPropertyChanged() call back function. But calling the GetDeviceProperties() function in the OnPropertyChanged() or other callback function is not recommended, because the callback function is called on the thread that communicates with the camera. All callback functions are expected to return as soon as possible.

The following sample code is one of the references to get updated properties and to update the user interface items in Windows.

Example:

void MyDeviceCallback::OnConnected() {
    ::PostMessage(wnd, WM_APP_UPDATE_PROPERTIES, 0L, 0L);
}
void MyDeviceCallback::OnPropertyChanged() {
    ::PostMessage(wnd, WM_APP_UPDATE_PROPERTIES, 0L, 0L);
}

ON_MESSAGE(WM_APP_UPDATE_PROPERTIES, OnMessageUpdateProperties)

void CAppWnd::OnMessageUpdateProperties(WPARAM wp, LPARAM lp)
{
    CrDeviceProperty *pProps;
    CrInt32 numofProps = 0;
    GetDeviceProperties(handle, &pProps, &numOfProps);
    :  // update user interface items

The following sample code is an example using the API and callback functions added from Version 1.05.00.

It is possible to call the GetSelectDeviceProperties() with the information notified in the OnPropertyChangedCodes callback to get only the specified device properties.

Example:

void MyDeviceCallback:: OnPropertyChangedCodes(CrInt32u num, CrInt32u* codes) {
    COPYDATASTRUCT cds;
    cds.dwData = 0;
    cds.lpData = codes;
    cds.cbData = num * sizeof(CrInt32u);
    ::SendMessage(wnd, WM_APP_UPDATE_PROPERTIES_DIFF, num, &cds);
}

ON_MESSAGE(WM_APP_UPDATE_PROPERTIES_DIFF, OnMessageUpdateProperties2)

void CAppWnd::OnMessageUpdateProperties2(WPARAM wp, LPARAM lp)
{
    CrDeviceProperty *pProps;
    CrInt32 numofProps = 0;
    GetSelectDeviceProperties(handle, wp, lp, &pProps, &numofProps);
    :  // update user interface items