是否有可能为一个directshow源过滤器从应用程序读取数据? [英] Is it possible to for a directshow source filter to read data from application?

查看:206
本文介绍了是否有可能为一个directshow源过滤器从应用程序读取数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要写一个directshow源过滤器,从应用程序读取数据,而不是从文件/套接字/设备读取相同。
首先是可能吗?如果是这样我怎么能实现呢?
我在gstreamer使用appsrc插件做了相同的,因为我是新的directshow可以有人请解释。



场景:
设备 - 应用程序 - >(DirectShow Source Filter) - >(DirectShow DecoderFilter) - >(DirectShow Sink)



提前感谢。

解决方案

感谢罗马。



现在我可以通过界面从应用程序传递数据到源驱动程序。
我从directshow示例中使用pushsource过滤器,并使用下面的示例为它添加了一个附加界面



将此内容包含在公共头文件中

  DECLARE_INTERFACE_(IMySettingsInterface,IUnknown)
{

STDMETHOD(GetParamInt)(char * szName,int * pParam )= 0;
STDMETHOD(SetParamInt)(char * szName,int nParam)= 0;

};

// {F350FE9E-65BA-4AC1-A6C0-FD9F2979D342}


DEFINE_GUID(IID_IMySettings,

0xf350fe9e,0x65ba,0x4ac1 ,0xa6,0xc0,0xfd,0x9f,0x29,0x79,0xd3,0x42);

对CPushSourceDesktop类所做的更改

  class CPushSourceDesktop:public CSource,public IMySettingsInterface 

{

private:

//构造函数是私有的,因为必须使用CreateInstance

CPushSourceDesktop(IUnknown * pUnk,HRESULT * phr);

〜CPushSourceDesktop();

CPushPinDesktop * m_pPin;

public:

DECLARE_IUNKNOWN;

static CUnknown * WINAPI CreateInstance(IUnknown * pUnk,HRESULT * phr);

STDMETHODIMP NonDelegatingQueryInterface(REFIID riid,void ** ppv);

//接口支持的方法

STDMETHODIMP GetParamInt(char * szName,int * pParam);

STDMETHODIMP SetParamInt(char * szName,int nParam);

};

我使用VS的create GUID工具生成了UUID。



在我的过滤器中定义这些接口方法

  STDMETHODIMP CPushSourceDesktop :: NonDelegatingQueryInterface(REFIID riid,void ** ppv) 
{
if(riid ==(IID_IMySettings))
{
return GetInterface((IMySettingsInterface *)this,ppv);
}
else
{
return CSource :: NonDelegatingQueryInterface(riid,ppv);
}
}


STDMETHODIMP CPushSourceDesktop :: GetParamInt(char * szName,int * pParam)

{
/ / Example

* pParam = 10;

return 0;
}

STDMETHODIMP CPushSourceDesktop :: SetParamInt(char * szName,int pParam)
{

//示例
return 0;
}



我将使用另一种方法将应用程序缓冲区传递到源过滤队列。 p>

再次感谢。


I am looking to write a directshow source filter that reads data from an application rather that reading the same from file/socket/device. First of all is is possible? If so how can I achieve it? I have done the same in gstreamer using appsrc plugin and since I am new to directshow can somebody please explain.

Scenario: Device -> Application -> (DirectShow Source Filter) -> (DirectShow DecoderFilter) -> (DirectShow Sink)

Thanks in advance.

解决方案

Thanks roman.

I am now able to pass data to the source driver from application through an interface. I took pushsource filter from the directshow samples and added an additional interface to it using the sample below

Including this in a common header file

DECLARE_INTERFACE_(IMySettingsInterface, IUnknown)
{

STDMETHOD(GetParamInt)(char* szName, int *pParam) = 0;
STDMETHOD(SetParamInt)(char* szName, int nParam) = 0;

};

// {F350FE9E-65BA-4AC1-A6C0-FD9F2979D342}


DEFINE_GUID(IID_IMySettings,

0xf350fe9e, 0x65ba, 0x4ac1, 0xa6, 0xc0, 0xfd, 0x9f, 0x29, 0x79, 0xd3, 0x42);

Change made to CPushSourceDesktop class

class CPushSourceDesktop : public CSource, public IMySettingsInterface

{

private:

// Constructor is private because you have to use CreateInstance

CPushSourceDesktop(IUnknown *pUnk, HRESULT *phr);

~CPushSourceDesktop();

CPushPinDesktop *m_pPin;

public:

DECLARE_IUNKNOWN;

static CUnknown * WINAPI CreateInstance(IUnknown *pUnk, HRESULT *phr);  

STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);

//Methods the interface supports

STDMETHODIMP GetParamInt(char* szName, int *pParam);

STDMETHODIMP SetParamInt(char* szName, int nParam);

};

I generated the UUID using create GUID tool of VS.

Defined these interface methods in my filter

STDMETHODIMP CPushSourceDesktop::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
    if (riid == (IID_IMySettings))
    {
        return GetInterface((IMySettingsInterface*) this, ppv);
    }
    else
    {
        return CSource::NonDelegatingQueryInterface(riid, ppv);
    }
}


STDMETHODIMP CPushSourceDesktop::GetParamInt(char* szName, int *pParam)

{
    // Example

    *pParam = 10;

    return 0;
}

STDMETHODIMP CPushSourceDesktop::SetParamInt(char* szName, int pParam)
{

    //Example
    return 0;
}

I will use another method to pass application buffers to source filter queue.

Thanks again.

这篇关于是否有可能为一个directshow源过滤器从应用程序读取数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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