Fake AVStream driver for DirectShow filter

Hi,
We’ve developed a DirectShow filter which connects to a Webcam and expose itself as a Video capture device.
On Windows 7, any application that connects to a webcam could identify this DirectShow filter as a video capture device and connect to it.
On Windows 8, the Metro camera application don’t recognize the DirectShow filter as a Webcam source. I understand that it looks for a real Webcam - it looks for an Imaging class device.

Is there away to solve this restriction without using a video streaming driver?

In case not - I think the solution is to develop a basic AVStream driver which will be as a source filter to our filter. The main purpose of this driver is to be identified as a Imaging class device.
What is the easiest and simplest way to develop this driver and to connect it to the DirectShow filter?

Thanks
Haim.

xxxxx@gmail.com wrote:

We’ve developed a DirectShow filter which connects to a Webcam and expose itself as a Video capture device.

What kind of a webcam? How is it connected to the machine? What kind
of a driver does it use now?

On Windows 8, the Metro camera application don’t recognize the DirectShow filter as a Webcam source. I understand that it looks for a real Webcam - it looks for an Imaging class device.

Is there away to solve this restriction without using a video streaming driver?

I doubt it. I don’t think the Metro camera application is DirectShow at
all. The implications in the documentation make me think it is uses
Media Foundation.

In case not - I think the solution is to develop a basic AVStream driver which will be as a source filter to our filter. The main purpose of this driver is to be identified as a Imaging class device.
What is the easiest and simplest way to develop this driver and to connect it to the DirectShow filter?

If I am right, this won’t help you. I don’t know what it takes to fool
the Media Foundation Capture Engine into using something that isn’t a
genuine capture driver.


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

Hi Tim,

What kind of a webcam? How is it connected to the machine? What kind
of a driver does it use now?

Any Webcam (such as USB). My filter enumerate the video input device category class and choose a real camera.

If I am right, this won’t help you. I don’t know what it takes to fool
the Media Foundation Capture Engine into using something that isn’t a
genuine capture driver.

I’ve tried the avshws sample driver. I’ve changed the class from media to image. The Metro camera now recognize this device as a real camera.
Now I want to modify this sample driver so it will get the video from my DirectShow filter (which is connected to a real camera) instead of generating artificial frames. What do you advise?
Thanks!
Haim

xxxxx@gmail.com wrote:

> What kind of a webcam? How is it connected to the machine? What kind
> of a driver does it use now?
Any Webcam (such as USB). My filter enumerate the video input device category class and choose a real camera.

How does that work? Those webcams are, themselves, Kernel Streaming
devices that expect to operate as part of a graph. Does your DirectShow
source filter create its own secondary graph internally, so you can
fetch frames, manipulate them, and pass them on? You aren’t talking
directly to the Kernel Streaming APIs, like a reinvented ksproxy, are you?

I’ve tried the avshws sample driver. I’ve changed the class from media to image. The Metro camera now recognize this device as a real camera.
Now I want to modify this sample driver so it will get the video from my DirectShow filter (which is connected to a real camera) instead of generating artificial frames. What do you advise?

I advise great care. This is not going to be easy. Let’s say the Metro
camera app loads your driver. In order to do what you want to do, you
need to create a DirectShow graph in user mode. How are you going to do
that? A kernel driver can’t launch a user-mode process. You could, I
suppose, create a boot-time service that contains your graph, and have
that service communicate with the AVStream driver. That’s basically how
the Windows Media Center app operates.

You’d have to have the service register for device notifications to know
when the driver was coming up. Then, it could create a side-door
connection to the driver and submit some inverted call requests to
exchange information about (for example) what video formats the AVStream
driver should expose. You’d then have to start streaming and sending
frames in through your back door, so the driver could send them on upon
request.


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

Hi Tim,
I see in the next link that there is an option that the AVStream driver receives frames from a user-mode DirectShow filter and insert the video frames into the Queue
Is this solution looks feasible to my problem?
Thanks,
Haim.

http://msdn.microsoft.com/en-us/library/windows/hardware/ff554244(v=vs.85).aspx

Hi,
I’ve found the next post that seems to bed relevant:
http://www.osronline.com/showThread.cfm?link=214286
On this post Tim says:

> If you create an AVStream transform filter, standard applications (like
> AMCap) are not going to see it as a capture filter. It can only be used
> by custom applications that are creating their own DirectShow graphs –
> applications that know about your filter and how to hook it up.

Isn’t it possible to transform filter to registered as capture device?
Thanks,
Haim

xxxxx@gmail.com wrote:

Hi Tim,
I see in the next link that there is an option that the AVStream driver receives frames from a user-mode DirectShow filter and insert the video frames into the Queue
Is this solution looks feasible to my problem?

For what problem? If your AVStream driver has an input pin, then you
can certainly receive frames from a user-mode filter. In that case,
however, your driver is no longer a capture filter – it is a transform
filter. The DirectShow application would have to set the graph up this way.


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

xxxxx@gmail.com wrote:

Hi,
I’ve found the next post that seems to bed relevant:
http://www.osronline.com/showThread.cfm?link=214286
On this post Tim says:
>> If you create an AVStream transform filter, standard applications (like
>> AMCap) are not going to see it as a capture filter. It can only be used
>> by custom applications that are creating their own DirectShow graphs –
>> applications that know about your filter and how to hook it up.
Isn’t it possible to transform filter to registered as capture device?

If you do that, who do you think is going to be feeding the input pin?
Someone, somewhere, has to load a filter into the graph and hook it up
to your transform filter’s input pin. AMCap is not going to do that.

With a custom capture application, sure, this is an option (although
then you don’t need it to be registered as a capture device). To work
in general-purpose capture applications, no, this won’t work.


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

Hi,

If you do that, who do you think is going to be feeding the input pin?
Someone, somewhere, has to load a filter into the graph and hook it up
to your transform filter’s input pin. AMCap is not going to do that.

So if I’ll run a user mode DirectShow application (kind of a proxy) that connects between my DirectShow filter and the AVStream driver (input pin) and feed the input pin (according to the media type defined by the driver) - that will do it?

With a custom capture application, sure, this is an option (although
then you don’t need it to be registered as a capture device). To work
in general-purpose capture applications, no, this won’t work.

Is the AVStream transform filter driver (that registered as Image class device) is still going to be identified as real Camera by Metro applications?

Actually my DirectShow filter is composed by 2 different entities - A COM server which captures the real camera (using DirectShow interface) and a DirectShow filter that communicate with the COM server and receive the video using memory mapped file and Win32 mutex/events.

If I’ll change my Directshow filter into Media foundation filter - can it be recognized as Image class device by Metro application? Is is actually possible to have Media foundation capture filter?

Can I connect my COM server to the AVStream driver (using user mode/KMDF driver communication) and deliver the real camera video into the “Fake” camera driver?

Is there an option to add filter driver to the real camera AVStream driver and duplicate+direct the camera frames into the “Fake” camera driver?

Thanks,
Haim.

xxxxx@gmail.com wrote:

> If you do that, who do you think is going to be feeding the input pin?
> Someone, somewhere, has to load a filter into the graph and hook it up
> to your transform filter’s input pin. AMCap is not going to do that.
So if I’ll run a user mode DirectShow application (kind of a proxy) that connects between my DirectShow filter and the AVStream driver (input pin) and feed the input pin (according to the media type defined by the driver) - that will do it?

Only within the same graph. That is, if you have an app that creates a
graph that looks like this:

[AVStream]
[Feeder] -> [Capture/Transform] -> [Render]

it would work, but that solution doesn’t cross applications. I think
YOU are thinking you could have application 1 feed the input pin, then
use those frames in standard capture application 2. That won’t work.

Is the AVStream transform filter driver (that registered as Image class device) is still going to be identified as real Camera by Metro applications?

That’s just registry stuff. At that point, the app doesn’t know source
vs transform vs sink. However, as I said, an unaware application is
going to expect to USE it like a source filter – it would create a
feeder filter.

If I’ll change my Directshow filter into Media foundation filter - can it be recognized as Image class device by Metro application? Is is actually possible to have Media foundation capture filter?

I know virtually nothing about Media Foundation. It has simply never
come up for any of my clients.

Can I connect my COM server to the AVStream driver (using user mode/KMDF driver communication) and deliver the real camera video into the “Fake” camera driver?

An AVStream driver can have ksproxy plugins that get loaded when the
driver is instantiated in a DirectShow graph. That ksproxy plugin is a
standard COM server that sits between the graph and the driver. That
plug-in could conceivably connect to your COM server and feed frames down.

Is there an option to add filter driver to the real camera AVStream driver and duplicate+direct the camera frames into the “Fake” camera driver?

I don’t know how that would help. If you’re writing an AVStream driver,
you already have a driver. A filter doesn’t add anything.


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

Tim Roberts wrote:

> Is the AVStream transform filter driver (that registered as Image class device) is still going to be identified as real Camera by Metro applications?
That’s just registry stuff. At that point, the app doesn’t know source
vs transform vs sink. However, as I said, an unaware application is
going to expect to USE it like a source filter – it would create a
feeder filter.

Make that “wouldn’t”.


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

Thanks Tim for your helpful response.

An AVStream driver can have ksproxy plugins that get loaded when the
driver is instantiated in a DirectShow graph. That ksproxy plugin is a
standard COM server that sits between the graph and the driver. That
plug-in could conceivably connect to your COM server and feed frames down.

I understand that seems to be the quickest solution to my problem.
I have to modify the avshws sample driver so it won’t generate the synthetic frames. Instead it will get the frames from ksproxy plugin (that gets it from my COM server)
Is there some reference sample code for that?
Thanks
Haim.

xxxxx@gmail.com wrote:

I understand that seems to be the quickest solution to my problem.
I have to modify the avshws sample driver so it won’t generate the synthetic frames. Instead it will get the frames from ksproxy plugin (that gets it from my COM server)
Is there some reference sample code for that?

The only reference sample for ksproxy plugins is Max Paklin’s excellent
article in the old WD-3 newsletter:
http://www.wd-3.com/archive/KsProxyPlugin.htm

I still use this sample as a basis for all the plugins I write. It’s
too bad there aren’t other samples, because it is a very useful technology.

The overview is that your driver must expose a custom KS property set
with your own GUID. Through registry magic (described in the article),
that property set gets associated with a COM server. ksproxy.ax does a
CoCreateInstance on that GUID, and that’s how your plugin start
running. The plugin gets handed an IKsPropertySet interface that you
use to talk to your driver.

The article describes implementing both a proxy and a property page.
You aren’t required to expose a property page, but it can make debugging
nicer.


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

Thanks Tim for your helpful support!