9

I want to write a new virtual webcam driver, which for example will take an AVI or live stream for example for screen and stream it as webcam source.

I'll not have webcam really, I want to add a virtual webcam which streams desktop screen.

I should write a webcam in kernel mode to do so ? If so, could you guide me to a sample webcam driver?

If I should do it in DirectShow, how can I add a webcam device to list in webcams list in Control panel, so for example in Yahoo messenger, I can choose that device as webcam and stream my desktop as webcam images.

How can I get started?

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
Franklin
  • 319
  • 2
  • 3
  • 5
  • 6
    Admit it: you just want to do the old 'Hall of Mirrors' effect... – Shog9 Oct 20 '09 at 18:24
  • DirectShow's Push Source Filters Sample will help given at https://learn.microsoft.com/en-us/windows/win32/directshow/push-source-filters-sample – user16516930 Aug 28 '21 at 11:17

3 Answers3

7

You need to write a DirectShow source filter. The Windows SDK contains a library called baseclasses which helps you developing such a filter. See CSourceStream for a good starting point.

To get the device to show up under the other Video Streaming Devices, you have to register your filter with the DirectShow API under the CLSID_VideoInputCategory. You don't need to/shouldn't write a kernel driver.

Christopher
  • 8,912
  • 3
  • 33
  • 38
  • Is this valid if I am not writing the code that is finding the camera and reading from. Say I implement this, will skype or chrome or any other app find this source when they look for cameras in the system ? I understand that I can register it and later on I can find it in Media Foundation or DirectShow. But would other applications find it from the system. Would it show in list of devices ? – Evren Bingøl Jul 04 '19 at 18:46
  • please help in https://stackoverflow.com/questions/65839449/directshow-based-virtual-camera-is-not-showing-any-frame-in-zoom – Alok Jan 23 '21 at 11:38
2

You can get start with the sample "amcap" under DirectShow package, it is a excellent sample for beginner. If you want to list webcam devices, go to ChooseDevices() method.

Susie Shu
  • 71
  • 2
1

You would need to develop DirectShow Source Filter for creating Virtual camera, Read this first
https://learn.microsoft.com/en-us/windows/win32/directshow/writing-source-filters

Then you can adopt
https://github.com/roman380/tmhare.mvps.org-vcam

You can work on top of this sample virtual camera.

This implements IAMStreamConfig and IKsPropertySet interfaces
This is built using CSourceStream and CSource class which implements IPin and IBaseFilter

Alok
  • 7,734
  • 8
  • 55
  • 100