I want to get the default, max, and min values of control parameters from UVC camera like the picture.
I try to get the default value with the below function. However, it only gets the current value of XU control and I cannot get the default values of XU control or any value of Video Proc Amp/Camera Control like the above picture.
//Function to set/get parameters of UVC extension unit
HRESULT SetGetExtensionUnit(GUID xuGuid, DWORD dwExtensionNode, ULONG xuPropertyId, ULONG flags, void* data, int len, ULONG* readCount)
{
GUID pNodeType;
IUnknown* unKnown;
IKsControl* ks_control = NULL;
IKsTopologyInfo* pKsTopologyInfo = NULL;
KSP_NODE kspNode;
HRESULT hr = pVideoSource->QueryInterface(__uuidof(IKsTopologyInfo), (void**)&pKsTopologyInfo);
CHECK_HR_RESULT(hr, "IMFMediaSource::QueryInterface(IKsTopologyInfo)");
hr = pKsTopologyInfo->get_NodeType(dwExtensionNode, &pNodeType);
CHECK_HR_RESULT(hr, "IKsTopologyInfo->get_NodeType(...)");
hr = pKsTopologyInfo->CreateNodeInstance(dwExtensionNode, IID_IUnknown, (LPVOID*)&unKnown);
CHECK_HR_RESULT(hr, "ks_topology_info->CreateNodeInstance(...)");
hr = unKnown->QueryInterface(__uuidof(IKsControl), (void**)&ks_control);
CHECK_HR_RESULT(hr, "ks_topology_info->QueryInterface(...)");
kspNode.Property.Set = xuGuid; // XU GUID
kspNode.NodeId = (ULONG)dwExtensionNode; // XU Node ID
kspNode.Property.Id = xuPropertyId; // XU control ID
kspNode.Property.Flags = flags; // Set/Get request
hr = ks_control->KsProperty((PKSPROPERTY)&kspNode, sizeof(kspNode), (PVOID)data, len, readCount);
CHECK_HR_RESULT(hr, "ks_control->KsProperty(...)");
done:
SafeRelease(&ks_control);
return hr;
}
int main(void) {
...
SetGetExtensionUnit(xuGuidUVC, 2, 1,
KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY,
(void*)data, 1, &readCount) // XU_FUNC1 Get Value Pass
SetGetExtensionUnit(xuGuidUVC, 2, 1,
KSPROPERTY_TYPE_DEFAULTVALUES | KSPROPERTY_TYPE_TOPOLOGY,
(void*)data, 1, &readCount); // XU_FUNC1 Get Value FAIL
SetGetExtensionUnit(xuGuidUVC, 1, 2,
KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_TOPOLOGY,
(void*)data, 2, &readCount); // BRIGHTNESS Get Value FAIL
...
}
How could I get the default value but the current value from XU control?
I think I cannot get the parameters of Video Proc Amp/Camera Control because I set the XU GUID but the correct GUID.
How could I get the correct GUID and get the default, max, min values from UVC cameras?
I found the solution to my question. I use IAMVideoProcAmp
and IAMVideoProcAmp
to realize this function.
HRESULT hr;
IAMVideoProcAmp* procAmp = NULL;
IAMCameraControl* control = NULL;
...
hr = pVideoSource->QueryInterface(IID_PPV_ARGS(&procAmp));
if (SUCCEEDED(hr))
{
hr = procAmp->GetRange(prop, &min, &max, &step, &def, &caps);
procAmp->Release();
return hr;
}
...
hr = pVideoSource->QueryInterface(IID_PPV_ARGS(&control));
if (SUCCEEDED(hr))
{
hr = control->GetRange(prop, &min, &max, &step, &def, &caps);
control->Release();
return hr;
}