Implementing KSPROPERTYSETID_ExtendedCameraControl

Hi everyone,

I am working on virtual camera driver based on TestCap sample.
A while ago I found an interesting issue with MediaFoundation/Windows 8.1 (http://www.osronline.com/showthread.cfm?link=255004). Hopefully, it was solved (thanks to Tim R.).

Now, I need to implement “Exposure” option.
That’s what I do (works under Windows 8, not 8.1)

// Define property table
DEFINE_KSPROPERTY_TABLE(CameraControlPropertyTable)
{
DEFINE_KSPROPERTY_ITEM(
KSPROPERTY_CAMERACONTROL_EXPOSURE,
TRUE,
sizeof(KSPROPERTY_CAMERACONTROL_S),
sizeof(KSPROPERTY_CAMERACONTROL_S),
TRUE,
&ExposureValues, // I do not list these values here, 'cause they work OK
0,
NULL,
NULL,
sizeof(ULONG))
};

// Add property table to adapter property set
DEFINE_KSPROPERTY_SET_TABLE(AdapterPropertyTable)
{
// …
DEFINE_KSPROPERTY_SET
(
&PROPSETID_VIDCAP_CAMERACONTROL,
SIZEOF_ARRAY(CameraControlPropertyTable),
CameraControlPropertyTable,
0,
NULL
),
// …
};

Then, I can handle GET/SET requests in my functions:
VOID STREAMAPI AdapterGetProperty( PHW_STREAM_REQUEST_BLOCK pSrb );
VOID STREAMAPI AdapterSetProperty( PHW_STREAM_REQUEST_BLOCK pSrb );

The problem is that media foundation apps (e.g. Camera) in Windows 8.1 do not recognize this property (the Exposure control does not appear in Camera app).
Starting with Windows 8.1, Microsoft introduces extended properties http://msdn.microsoft.com/en-us/library/windows/hardware/dn567570(v=vs.85).aspx
But I feel they are not just additional, but are the replacement for all previous ones.
E.g. the exposure should be now controlled via the KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE property.(http://msdn.microsoft.com/en-us/library/windows/hardware/dn567573(v=vs.85).aspx)

I tried to add them as follows:

// Define property table
DEFINE_KSPROPERTY_TABLE(ExtendedCameraControlProperty)
{
DEFINE_KSPROPERTY_ITEM(
KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE,
TRUE,
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING),
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING),
TRUE,
NULL,
0,
NULL,
NULL,
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING)
)
};

// Add property table to adapter property set
DEFINE_KSPROPERTY_SET_TABLE(AdapterPropertyTable)
{
// …
DEFINE_KSPROPERTY_SET
(
&KSPROPERTYSETID_ExtendedCameraControl,
SIZEOF_ARRAY(ExtendedCameraControlProperty),
ExtendedCameraControlProperty,
0,
NULL
),
// …
};

As a result, I never get the KSPROPERTYSETID_ExtendedCameraControl in my AdapterGetProperty/AdapterSetProperty handlers.
Maybe something is wrong with MinProperty,MinData and Serialized fields in PropertyTable? I just don’t get it…

Please advice.

Thanks,
Anton

xxxxx@gmail.com wrote:

Hi everyone,

I am working on virtual camera driver based on TestCap sample.

You understand this is an antique, right? This is a Stream-class
driver. Virtual camera drivers are almost always easier in AVStream.

A while ago I found an interesting issue with MediaFoundation/Windows 8.1 (http://www.osronline.com/showthread.cfm?link=255004). Hopefully, it was solved (thanks to Tim R.).

Now, I need to implement “Exposure” option.
That’s what I do (works under Windows 8, not 8.1)

// Define property table
DEFINE_KSPROPERTY_TABLE(CameraControlPropertyTable)
{
DEFINE_KSPROPERTY_ITEM(
KSPROPERTY_CAMERACONTROL_EXPOSURE,
TRUE,
sizeof(KSPROPERTY_CAMERACONTROL_S),
sizeof(KSPROPERTY_CAMERACONTROL_S),
TRUE,
&ExposureValues, // I do not list these values here, 'cause they work OK
0,
NULL,
NULL,
sizeof(ULONG))
};

Despite what the sample says, that’s not correct. For properties on a
filter or a pin, the MinProperty value (third item) should be
sizeof(KSPROPERTY). For properties on a node, is should be
sizeof(KSP_NODE). The documentation does not help here, either.

Do you actually handle serialize requests? Very few drivers do. If
not, that last value should be 0.

The problem is that media foundation apps (e.g. Camera) in Windows 8.1 do not recognize this property (the Exposure control does not appear in Camera app).

This has long been a failing in Microsoft documentation. The KS
property set is incredibly “rich”, as the terminology goes. There are
many thousands of properties and methods, most of which are very obscure
and used by no one. We can seen “required” and “optional”, but there is
no clue as to which properties are “important”. What driver writers
desperately need is a document that says “ksproxy.ax looks for THESE KS
properties, and turns them into THESE DirectShow interfaces”, and
another document giving the same information for “devproxy” for Media
Foundation. Instead, we have to guess.

I tried to add them as follows:

// Define property table
DEFINE_KSPROPERTY_TABLE(ExtendedCameraControlProperty)
{
DEFINE_KSPROPERTY_ITEM(
KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE,
TRUE,
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING),

That should be sizeof(KSPROPERTY).

sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING),
TRUE,
NULL,
0,
NULL,
NULL,
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING)

That should probably be 0.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Tim,

thank you for your answer.

> You understand this is an antique, right? This is a Stream-class driver. Virtual camera drivers are almost always easier in AVStream.
Yes, I do. Perhaps, I will move to AVStream in the nearest future but now I am stuck to current (Testcap) implementation for a few reasons.

> Do you actually handle serialize requests? Very few drivers do. If not, that last value should be 0.
You are right, I don’t handle serialization requests.

I have modified code as you recommended (actually I have tried a lot of various combinations, just like “monkey”):

DEFINE_KSPROPERTY_TABLE(ExtendedCameraControlProperty)
{
DEFINE_KSPROPERTY_ITEM(
KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE,
TRUE,
sizeof(KSPROPERTY),
sizeof(KSPROPERTY) + sizeof(KSCAMERA_EXTENDEDPROP_HEADER) + sizeof(KSCAMERA_EXTENDEDPROP_VIDEOPROCSETTING),
TRUE,
NULL,
0,
NULL,
NULL,
0
),
};

Still no success. Maybe I am missing something from documentation? But as you said, it is very poor unfortunately.

Thanks,
Anton

I also thought about attacking a problem from the different side - i.e. try to get extended camera properties from the client mode to see some error like “Interface not supported” or maybe something more concrete. But I also can’t find the way.

For example, in Media Foundation code I can easily query IAMCameraControl interface from the IMFMediaSource object and set/get exposure values in old manner (all requests goes through PROPSETID_VIDCAP_CAMERACONTROL property).

What interface should I use in client mode to request the extended properties?

> What driver writers desperately need is a document that says
> “ksproxy.ax looks for THESE KS properties, and turns them into THESE DirectShow interfaces”
Absolutely!
However, this document http://msdn.microsoft.com/en-us/library/windows/hardware/ff568714(v=vs.85).aspx at least mentions DirectShow interfaces for video capture minidriver property sets … but not for the KSPROPERTYSETID_ExtendedCameraControl *facepalm*

Thanks,
Anton

I just performed one more test.
My Logitech C270 Webcam supports exposure option in Camera app under Windows 8.1, so I tried to obtain it programmatically.

CComPtr pks = nullptr;
DWORD dw = 0;
HRESULT hr = S_OK;
hr = _sourceFilter->QueryInterface(IID_PPV_ARGS(&pks));
if (FAILED(hr))
return;

hr = pks->QuerySupported(
PROPSETID_VIDCAP_CAMERACONTROL,
KSPROPERTY_CAMERACONTROL_EXPOSURE,
&dw);

hr = pks->QuerySupported(
KSPROPERTYSETID_ExtendedCameraControl,
KSPROPERTY_CAMERACONTROL_EXTENDED_EXPOSUREMODE,
&dw);

It turned out that it supports PROPSETID_VIDCAP_CAMERACONTROL (my virtual camera supports it as well),
but it does not support KSPROPERTYSETID_ExtendedCameraControl (E_PROP_SET_UNSUPPORTED).

This is weird.
Maybe my guess was wrong and the problem is not about new ExtendedCameraControl at all?
Maybe I have to set up the PROPSETID_VIDCAP_CAMERACONTROL property somehow differently for Windows 8.1.

I will continue investigating this, any help would be so much appreciated.

Thanks,
Anton

Hi everyone,

I have found a solution.
My previous clue was correct - I do not need the KSPROPERTYSETID_ExtendedCameraControl.

Actually, my KSPROPERTY_CAMERACONTROL_EXPOSURE implementation was absolutely correct.
So why didn’t “Exposure” button appear in “Camera” application in Windows 8.1?
Because despite the fact that button has name “EXPOSURE” - it actually controls the “BRIGHTNESS”!
Since the brightness option wasn’t implemented, I never saw this button.

Why Microsoft names the “Brightness” as “Exposure”?
Well, obviously these guys do not see the difference LOL.

Regards,
Anton

xxxxx@gmail.com wrote:

Actually, my KSPROPERTY_CAMERACONTROL_EXPOSURE implementation was absolutely correct.
So why didn’t “Exposure” button appear in “Camera” application in Windows 8.1?
Because despite the fact that button has name “EXPOSURE” - it actually controls the “BRIGHTNESS”!
Since the brightness option wasn’t implemented, I never saw this button.

Why Microsoft names the “Brightness” as “Exposure”?
Well, obviously these guys do not see the difference LOL.

I have found much to dislike about the “Camera” application in Win 8.1.
If you use a DirectShow app like Amcap or graphedt and look at the
filter properties, the Exposure control maps to
KSPROPERTY_CAMERACONTROL_EXPOSURE, and the Brightness control maps to
KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.