虚拟网络摄像头驱动程序 [英] Virtual Webcam Driver

查看:841
本文介绍了虚拟网络摄像头驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个虚拟网络摄像头驱动程序,从用户模式我会传递图像到它,它将显示为网络摄像头输出。



我不想使用DirectX过滤器和CSourceStream等。因为他们不工作在一些程序,不使用DirectX捕获网络摄像头图像。



我必须写一个内核模式的设备驱动程序。



任何想法?我尝试从DDK样本的testcap,但它不处理来自用户模式的图像,并没有得到任何输入,只是它显示7种颜色在webcam ...



任何帮助将非常感谢。
感谢






谢谢大家!



我尝试从这里的代码:
http://tmhare.mvps.org/downloads.htm (查找捕获来源过滤器)



当我在Yahoo,MSN中编译它时效果很好,但它崩溃了AIM,Internet Explorer Flash Webcam,Firefox Flash网络摄像头和Skype ...崩溃在QueryInterface 8次调用,我发现它与跟踪它很多技巧..



现在我知道,它崩溃8次调用
HRESULT CVCamStream :: QueryInterface(REFIID riid,void ** ppv)



当它到达最后一次时,我的意思是:
return CSourceStream: :QueryInterface(riid,ppv);



它在Filters.cpp的第17行





感谢大家指导我找到DirectShow而不是驱动程序的正确解决方案




  • Twain:

    用于从扫描仪等单一图像捕获。

  • WIA:这似乎已经退化为单个图像编解码器库。

  • VfW:

  • DirectShow:之前一部分在DirectX SDK中,目前在平台SDK中的一部分,它只能用于视频文件编码/解码,但支持一些视频采集。

  • Windows Media / Media Foundation:这似乎更适合视频播放/重新编码。

  • 制造商特定库:Pylon / Halcon /成像控制/...



DirectShow专用:



要在Windows下创建图像采集设备,您必须提供一个实现streamclasses接口(或更新的Avstream)的设备(驱动程序),或者必须编写一个usermode COM对象添加到VideoInputCategory枚举器。



Avstream示例提供真实图像采集设备的一切。



如果您可以设计一个设备,您应该创建它与DCAM或UVC兼容。





如何编写软件源设备:



您必须创建一个DirectShow过滤器,它提供至少一个输出引脚并在VideoInputCategory下注册。可能存在某些应用程序需要来自捕获应用程序的几个接口,但这些依赖于应用程序本身。



一些代码:

  #include< InitGuid.h> 
#include< streams.h>


const AMOVIESETUP_MEDIATYPE s_VideoPinType =
{
& MEDIATYPE_Video,//主要类型
& MEDIATYPE_NULL //小型类型
};

const AMOVIESETUP_PIN s_VideoOutputPin =
{
LOutput,// Pin字符串名称
FALSE,//渲染
TRUE,//它是一个输出
FALSE,//我们可以没有
FALSE,//我们可以有很多
& CLSID_NULL,//连接到过滤器
NULL,// Connects到pin
1,//类型数量
& s_VideoPinType //针详细信息
};

const AMOVIESETUP_FILTER s_Filter =
{
& CLSID_MyFilter,// Filter CLSID
Lbla,// String name
MERIT_DO_NOT_USE,//过滤器优点
1,//数字引脚
& s_VideoOutputPin //引脚详细信息
};

REGFILTER2 rf2;
rf2.dwVersion = 1;
rf2.dwMerit = MERIT_DO_NOT_USE;
rf2.cPins = 1;
rf2.rgPins = s_Filter.lpPin;

HRESULT hr = pFilterMapper-> RegisterFilter(CLSID_MyFilter,_FriendlyName.c_str(),0,
& CLSID_VideoInputDeviceCategory,_InstanceID.c_str(),& rf2);
if(FAILED(hr))
{
return false;
}

std :: wstring inputCat = GUIDToWString(CLSID_VideoInputDeviceCategory);
std :: wstring regPath = LCLSID\\+ inputCat + L\\Instance;
win32_utils :: CRegKey hKeyInstancesDir;
LONG rval = openKey(HKEY_CLASSES_ROOT,regPath,KEY_WRITE,hKeyInstancesDir);
if(rval == ERROR_SUCCESS)
{
win32_utils :: CRegKey hKeyInstance;
rval = createKey(hKeyInstancesDir,_InstanceID,KEY_WRITE,hKeyInstance);

....

_InstanceID是为此虚拟设备条目。


I want to develop a virtual webcam driver which from User mode I'll pass image to it and it will display as webcam output.

I don't want to use DirectX filter and CSourceStream etc. Because they don't work on some programs which doesn't use DirectX for capturing webcam image.

I have to write a kernel mode device driver so.

Any ideas? I tried testcap from DDK samples, but it doesn't process image from user mode and doesn't get any input, just it displays 7 colors in webcam...

Any help would be greatly appreciated. Thanks


Thank you all!

I tried code from here: http://tmhare.mvps.org/downloads.htm (find Capture Source Filter)

It worked well when I compiled it in Yahoo, MSN, but it crashed AIM, Internet Explorer Flash Webcam, Firefox Flash webcam and Skype... I got crash in QueryInterface after 8 time call to that, I found it with tracing it with a lot of tricks..

Now I know, it crashes on 8th call to HRESULT CVCamStream::QueryInterface(REFIID riid, void **ppv)

8th call when it reaches to last if, I mean: return CSourceStream::QueryInterface(riid, ppv);

It's in 17th line of Filters.cpp

Why do you think I'm getting crash??

Thank you all for guiding me to find correct solution which is DirectShow, not driver

解决方案

There are several APIs from Microsoft which provide access to image data.

  • Twain: Used for single image capture from scanners, etc.
  • WIA: This seems to have degenerated to a single image codec library.
  • VfW: A very old (Win16) API which really works only Video-File encoding/decoding, but has support for some video acquisition.
  • DirectShow: previously part in the DirectX SDK, currently in the Platform SDK. This is the place to go for current (general) streaming solutions.
  • Windows Media/Media Foundation: This seems more to be geared at video playback/reencoding.
  • Manufacturer Specific Libraries: Pylon/Halcon/Imaging Control/...

DirectShow specific :

To create image acquisition devices under windows, you have to provide either a device (driver) which implements the streamclasses interfaces (or newer Avstream) or you have to write a usermode COM object which has to be added to the VideoInputCategory enumerator.

The Avstream sample provides everything for a real image acquisition device. Only the lower layer for the actual device really is missing.

If you can design a device, you should either create it DCAM or UVC compatible. For both there are built-in drivers supplied by windows.


How to write a software source device :

You have to create a DirectShow filter which provides at least one output pin and register this under the VideoInputCategory. There may be several interfaces certain applications require from a capture application, but these depend on the application itself. Simple applications to try out filters are GraphEdit and AMCap which are supplied in the Plattform SDK.

Some code :

#include <InitGuid.h>
#include <streams.h>


const AMOVIESETUP_MEDIATYPE s_VideoPinType =
{
    &MEDIATYPE_Video,	// Major type
    &MEDIATYPE_NULL		// Minor type
};

const AMOVIESETUP_PIN s_VideoOutputPin =
{
    L"Output",              // Pin string name
    FALSE,                  // Is it rendered
    TRUE,                   // Is it an output
    FALSE,                  // Can we have none
    FALSE,                  // Can we have many
    &CLSID_NULL,            // Connects to filter
    NULL,                   // Connects to pin
    1,                      // Number of types
    &s_VideoPinType			// Pin details
};

const AMOVIESETUP_FILTER s_Filter =
{
    &CLSID_MyFilter,		// Filter CLSID
    L"bla",			// String name
    MERIT_DO_NOT_USE,				// Filter merit
    1,								// Number pins
    &s_VideoOutputPin				// Pin details
};

    REGFILTER2 rf2;
    rf2.dwVersion = 1;
    rf2.dwMerit = MERIT_DO_NOT_USE;
    rf2.cPins = 1;
    rf2.rgPins = s_Filter.lpPin;

    HRESULT hr = pFilterMapper->RegisterFilter( CLSID_MyFilter, _FriendlyName.c_str(), 0, 
    	&CLSID_VideoInputDeviceCategory, _InstanceID.c_str(), &rf2 );
    if( FAILED( hr ) )
    {
    	return false;
    }

    std::wstring inputCat = GUIDToWString( CLSID_VideoInputDeviceCategory );
    std::wstring regPath = L"CLSID\\" + inputCat + L"\\Instance";
    win32_utils::CRegKey hKeyInstancesDir;
    LONG rval = openKey( HKEY_CLASSES_ROOT, regPath, KEY_WRITE, hKeyInstancesDir );
    if( rval == ERROR_SUCCESS )
    {
    	win32_utils::CRegKey hKeyInstance;
    	rval = createKey( hKeyInstancesDir, _InstanceID, KEY_WRITE, hKeyInstance );

        ....

_InstanceID is a GUID created for this 'virtual device' entry.

这篇关于虚拟网络摄像头驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆