简体   繁体   English

C++ 中的虚拟网络摄像头

[英]Virtual Webcam in C++

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.我想编写一个新的虚拟网络摄像头驱动程序,例如,它将采用 AVI 或实时流作为屏幕并将其作为网络摄像头源进行流式传输。

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.如果我应该在 DirectShow 中执行此操作,如何将网络摄像头设备添加到控制面板的网络摄像头列表中,例如在 Yahoo messenger 中,我可以选择该设备作为网络摄像头并将我的桌面作为网络摄像头图像进行流式传输。

How can I get started?我该如何开始?

You need to write a DirectShow source filter.您需要编写一个 DirectShow 源过滤器。 The Windows SDK contains a library called baseclasses which helps you developing such a filter. Windows SDK 包含一个名为baseclasses的库,可帮助您开发此类过滤器。 See CSourceStream for a good starting point.请参阅CSourceStream以获得一个好的起点。

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.要让设备显示在其他视频流设备下,您必须在 CLSID_VideoInputCategory 下使用 DirectShow API 注册您的过滤器。 You don't need to/shouldn't write a kernel driver.您不需要/不应该编写内核驱动程序。

You can get start with the sample "amcap" under DirectShow package, it is a excellent sample for beginner.您可以从 DirectShow 包下的示例“amcap”开始,这是一个非常适合初学者的示例。 If you want to list webcam devices, go to ChooseDevices() method.如果要列出网络摄像头设备,请转到 ChooseDevices() 方法。

You would need to develop DirectShow Source Filter for creating Virtual camera, Read this first您需要开发 DirectShow Source Filter 来创建虚拟摄像机,请先阅读此内容
https://docs.microsoft.com/en-us/windows/win32/directshow/writing-source-filters https://docs.microsoft.com/en-us/windows/win32/directshow/writing-source-filters

Then you can adopt然后你可以采用
https://github.com/roman380/tmhare.mvps.org-vcam https://github.com/roman380/tmhare.mvps.org-vcam

You can work on top of this sample virtual camera.您可以在此示例虚拟相机之上工作。

This implements IAMStreamConfig and IKsPropertySet interfaces这实现了IAMStreamConfigIKsPropertySet接口
This is built using CSourceStream and CSource class which implements IPin and IBaseFilter这是使用实现IPinIBaseFilter CSourceStreamCSourceIBaseFilter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM