Hi, I have to write virtual video source driver so that applications like MSN or Skype would be able to use it as a camera. I have to deliver video over network and feed into the driver. For simplicity let?s just say I have to feed bitmaps into the driver.
Here is a list of things I?ve tried so far:
-
I tried DirectShow video capture filters and found out that the Application I?m targeting can not accept DS filters as video source. So DirectShow is not an option for me (I guess?).
-
I compiled and installed the DDK sample driver TestCap and my application can see it as a video source device.
Looks like I could use TestCap as a start point and modify the ImageSynth() method. The only problem is that TestCap is a kernel driver and I?m not sure how my other app can feed bitmaps into it. I?m new to driver development and would like to ask few questions:
-
Is that true that writing a driver is my only option?
-
Is there any light weight samples that perform this common task? TestCap is a little overloaded with different options.
-
Should my driver be a kernel driver (I?m 99% sure it shouldn?t)?
-
How can I change TestCap to be a user mode driver and start using shared memory?
-
Is there any way to find out what kind of devices an application can accept as a video source?
I?ll keep reading on kernel drivers I/O though?
Thank you very much!
> - Should my driver be a kernel driver (I?m 99% sure it shouldn?t)?
Don’t know, probably you have registered your user-mode DS driver improperly, or made bugs in it, that’s why the app cannot use it.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
Other apps did see my DS capture filter: Skype, Windows Media encoder, VLC, AMCap (don’t remember exact name of the utility). But the app I’m targeting could only see the real webcam I have and TestCap device driver.
I really need just to target that one application, I won;t really use my driver in any other app like Skype, sorry about confusion.
Thanks!
xxxxx@rogers.com wrote:
Hi, I have to write virtual video source driver so that applications like MSN or Skype would be able to use it as a camera. I have to deliver video over network and feed into the driver. For simplicity let?s just say I have to feed bitmaps into the driver.
Here is a list of things I?ve tried so far:
- I tried DirectShow video capture filters and found out that the Application I?m targeting can not accept DS filters as video source. So DirectShow is not an option for me (I guess?).
Which application? I know for a fact that MSN and Skype work fine with
user-mode DirectShow source filters. It take a little extra registry
work to make a source filter look like a CLSID_VideoInputDeviceCategory
device, and the source filter samples in the Platform SDK don’t do
that. However, please remember that all AVStream capture devices
actually participate in DirectShow graphs through a perfectly normal
(although quite complicated) user-mode source filter called ksproxy.ax.
The ONLY app I’m aware of that can’t be “fooled” in this way is the
Windows Media Center application. It does additional checking to make
sure it is talking to a kernel driver.
- I compiled and installed the DDK sample driver TestCap and my application can see it as a video source device.
Looks like I could use TestCap as a start point and modify the ImageSynth() method. The only problem is that TestCap is a kernel driver and I?m not sure how my other app can feed bitmaps into it. I?m new to driver development and would like to ask few questions:
- Is that true that writing a driver is my only option?
I’m not sure we can answer that. I’m very dubious that a driver is your
only option.
- Is there any light weight samples that perform this common task? TestCap is a little overloaded with different options.
Not really. IF you need a kernel driver, then you have an uphill
battle. A kernel streaming driver is a complicated beast.
- How can I change TestCap to be a user mode driver and start using shared memory?
Unfortunately, you can’t Your two choices are (a) a user-mode
DirectShow source filter, or (b) an AVStream kernel driver.
- Is there any way to find out what kind of devices an application can accept as a video source?
Virtually 100% of capture applications use the system device
enumerator, CLSID_SystemDeviceEnum, to enumerate the devices in the
CLSID_VideoInputDeviceCategory category. That enumerator works strictly
through the registry, and enumerates user-mode filters. When you have a
kernel device, ksproxy.ax happens to respond to that enumeration as well.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
xxxxx@rogers.com wrote:
Other apps did see my DS capture filter: Skype, Windows Media encoder, VLC, AMCap (don’t remember exact name of the utility). But the app I’m targeting could only see the real webcam I have and TestCap device driver.
I really need just to target that one application, I won;t really use my driver in any other app like Skype, sorry about confusion.
If the app really refuses to talk to anything but kernel, then you have
to move forward with TestCap.
You will want to have some kind of a buffer queue in the capture driver,
to store the frames you want to forward. You can add a custom property
set to the driver to allow your application to feed in frames to that
queue. Then, instead of creating frames on the fly, you just pick the
next frame from your queue. You’ll have to decide what to do if the
driver runs out of frames.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Thanks for yo reply Tim!
As I mentioned above, my DirectShow capture filer was accessible from MSN, Skype etc. so I guess it was properly registered. Actually it was just that sample http://tmhare.mvps.org/downloads/vcam.zip
The application I’m targeting can be downloaded here: http://www.ifriends.net/download/current/ifcam96e.exe
This a really small app and installs/uninstalls in 3 secs.
I’m not sure if it checks for video source to be a kernel driver. I would really-really-really appreciate if somebody could run a quick check for me! 
Could you please point me to where I can read how an application can send some data to a kernel driver?
Thank you!
xxxxx@rogers.com wrote:
Thanks for yo reply Tim!
As I mentioned above, my DirectShow capture filer was accessible from MSN, Skype etc. so I guess it was properly registered. Actually it was just that sample http://tmhare.mvps.org/downloads/vcam.zip
The application I’m targeting can be downloaded here: http://www.ifriends.net/download/current/ifcam96e.exe
This a really small app and installs/uninstalls in 3 secs.
I’m not sure if it checks for video source to be a kernel driver. I would really-really-really appreciate if somebody could run a quick check for me! 
Not likely. Software downloaded from a soft-core site like that is
exactly the kind of thing that would introduce malware and advertising
bots into a system.
However, did you read all of the documents on their site? Did you read
the part where it says they really want 320x240 video? The March Hare’s
vcam.zip filter defaults to 640x480.
Did you put any code in your filter to spew out debug messages, then
watch the debug log to see if they get generated? I’ll wager real
dollars that your filter is actually getting loaded, but something is
failing during the format negotiation. Maybe you don’t have the right
format, or you don’t support some important interface that it wants.
That has to be a better path than starting down the kernel streaming
driver path.
Could you please point me to where I can read how an application can send some data to a kernel driver?
That’s not really the right question. What you have is more than just a
kernel driver – it’s a kernel streaming driver. They have a different
native interface. Communication to KS drivers is usually done via KS
properties. There are examples in testcap that show how to handle
properties.
However, remember that “testcap” is quite old. It is Kernel Streaming
version 1. There are samples in the WDK of AVStream capture drivers (in
src\avstream). You might find that a better place to start, if you
really have to go kernel.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Thanks a lot Tim! I’ll try one more time with the “vcam” DirectShow filter and set its resolution to what seems to be expected.
But still, that app allows to select video size and 640x480 is there too. When the app loads, DirectShow filters are not even listed in the video sources list. I doubt that it preloads each device before listing it in available source list.
I have installed both AVS sample drivers - non of them is visible from that ifCam application I’m targeting. They actually not even visible from AMCAP, only in GrapghEdit. I guess they dont register as video capture devices.
Looks like the only option is to tune the TestCap sample. I will take a look at the KS properties and if somebody can give me more details on how I could feed bitmap data into it I will really appreciate it!
Thank you!
You wrote:
I have installed both AVS sample drivers - non of them is visible from
that ifCam application I’m targeting. They actually not even visible
from AMCAP, only in GrapghEdit. I guess they dont register as video
capture devices.
That means you did something wrong during the installation process. They ARE video capture devices, they DO register as such, and they WILL appear inside AmCap. How did you install them? Did you use the INF files?
What version of the DDK are you using?
Looks like the only option is to tune the TestCap sample. I will take
a look at the KS properties and if somebody can give me more details
on how I could feed bitmap data into it I will really appreciate it!
Don’t jump to conclusions when you’re just shooting blind. The AVStream samples DO work. Fix your process before you start down this rathole.
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
> How did you install them? Did you use the INF files?
On my XP box I right clicked the avshws.inf -> Install. It starts driver installation, then it asks for .sys file. I browse for it as it’s located in the build output folder. Then, with AVS ones, I see in the right bottom corner PnP messages like “new hardware was detected etc.”.
After installation is completed I can see the driver in GraphEdit, but not in the Device Manager and in the AMCAP. Did not try to reboot though…(!)
What version of the DDK are you using?
3790.1830 downloaded from MS 2 weeks ago
Thanks Tim!
> 3790.1830 downloaded from MS 2 weeks ago
Long ago obsolete, the current is WDK 6001.18002
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
xxxxx@rogers.com wrote:
> How did you install them? Did you use the INF files?
>
On my XP box I right clicked the avshws.inf -> Install. It starts driver installation, then it asks for .sys file. I browse for it as it’s located in the build output folder. Then, with AVS ones, I see in the right bottom corner PnP messages like “new hardware was detected etc.”.
After installation is completed I can see the driver in GraphEdit, but not in the Device Manager and in the AMCAP. Did not try to reboot though…(!)
> What version of the DDK are you using?
>
3790.1830 downloaded from MS 2 weeks ago
That package is 4 years old. You need to be using the WDK, either 6000
or 6001.18002. You’ll find that the avshws INF file has changed. The
older version used the software enumerator and didn’t completely
register its interfaces. The new version is root enumerated. It will
appear in Device Manager and in Amcap. You can’t right-click to install
it anymore, but it’s a better solution.
However, I still think you would be better served by digging more into
the user-mode source filter issues first.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
I’m confused now… If I need my driver for w2k3 and XP. Do I need 2 different driver development kits for XP and WinServer 2003? For the XP it is that WDK 6001.18002 and for w2k3 it is Windows Server 2003 SP1 DDK is that correct?
I’m lost
Thanks Maxim and Tim!
The old DDK explains a lot.
xxxxx@rogers.com wrote:
I’m confused now… If I need my driver for w2k3 and XP. Do I need 2 different driver development kits for XP and WinServer 2003? For the XP it is that WDK 6001.18002 and for w2k3 it is Windows Server 2003 SP1 DDK is that correct?
No. The 6001.18002 WDK (which is the “Vista SP1” WDK) includes build
environments for Windows 2000, XP, 2003, Vista 32 bit, and Vista
64-bit. The general rule is that you use the build environment that
targets the oldest system you need. So, if you need XP and 2003, you’d
use the XP build environment.
There is no need to use anything older than 6000 today, although they
include samples that no longer exist, so I keep them around.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
>2003 SP1 DDK is that correct?
No.
You must always use the latest kit (6001.18002 for now), but the proper build env within this kit.
The build env version must not be newer then the target OS. The binary built by 2003 build env will not run on XP (sometimes it will, but this is unsupported and can fail due to a minor code change).
So, if you need the binary for XP, you must use XP or 2000 build env. As about binaries for newer OSes - it depends. You can still use the older OS’s build env, but then you will be limited to the older OS’s features.
One common approach is to build everything using the oldest OS build env - 2000 for 32bit, 2003 for 64bit. This will produce 1 binary runnable on all OSes from 2000 to 2008 (32 bit) and from XP/2003 to 2008 (64 bit). Drawbacks: you cannot use the newer features.
Another approach is to build several binaries, each with the target OS’s build env. Drawbacks: many binaries.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
Got the 6001.18002 WDK, compiled AVStream sample “avshws”, installed - my target app sees the virtual device and shows the generated video. This sample looks like exactly what I need, not overloaded with features, produces 320x240 stream. Now the only problem is how to feed bitmaps into it.
You will want to have some kind of a buffer queue in the capture driver, to store the frames you want >to forward. You can add a custom property set to the driver to allow your application to feed in >frames to that queue. Then, instead of creating frames on the fly, you just pick the next frame from >your queue. You’ll have to decide what to do if the driver runs out of frames.
Does it apply to the AVStream sample? Looks like it does as I still have a kernel streaming driver.
I have 2 questions regarding to implementing and using that driver property set:
- Where can I read or see an example of how to add a property set?
- Where can I read or see an example of how a user mode application can talk to a streaming kernel driver and feed some data into it via the property set?
Thank you very much!
You wrote:
>You will want to have some kind of a buffer queue in the capture
>driver, to store the frames you want to forward. You can add a custom property set to the driver to allow your application to feed in >frames to that queue. Then, instead of creating frames on the fly, you just pick the next frame from >your queue. You’ll have to decide what to do if the driver runs out of frames.
Does it apply to the AVStream sample? Looks like it does as I still
have a kernel streaming driver.
Can’t you figure this out? Have you READ the avshws code, or did you just compile it and install it?
I have 2 questions regarding to implementing and using that driver
property set:
- Where can I read or see an example of how to add a property set?
Avshws and avssamp both implement several properties in a couple of property sets. You just need to follow the same pattern. Create a GUID, add a new property set to the property set list, then add a couple of properties to the property set. Then implement the handler function. Follow the samples.
- Where can I read or see an example of how a user mode application
can talk to a streaming kernel driver and feed some data into it via
the property set?
There are lots of samples on the web. It’s just like finding a capture filter for a video capture graph, using normal COM stuff. I’ll give you some hints to Google for. You use CLSID_SystemDeviveEnum to look through the list of capture devices, looking for yours by checking the device name. Once you find your device, you use IMoniker::BindToObject to create an IBaseFilter object, and from that you get an IKsControl object. Then, IKsControl::KsProperty works just like DeviceIoControl.
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
Got the 6001.18002 WDK, compiled AVStream sample “avshws”, installed - my target app sees the virtual device and shows the generated video. This sample looks like exactly what I need, not overloaded with features, produces 320x240 stream. Now the only problem is how to feed bitmaps into it.
You will want to have some kind of a buffer queue in the capture driver, to store the frames you want >to forward. You can add a custom property set to the driver to allow your application to feed in >frames to that queue. Then, instead of creating frames on the fly, you just pick the next frame from >your queue. You’ll have to decide what to do if the driver runs out of frames.
Does it apply to the AVStream sample? Looks like it does as I still have a kernel streaming driver.
I have 2 questions regarding to implementing and using that driver property set:
- Where can I read or see an example of how to add a property set?
- Where can I read or see an example of how a user mode application can talk to a streaming kernel driver and feed some data into it via the property set?
Thank you very much!