DirectShow求救,怎样从一个IPin转换得到CBasePin?

zhangjianyu 2003-08-24 12:24:51
接触这方面时间不长,高手们不要见笑阿。
...全文
72 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangjianyu 2003-08-25
  • 打赏
  • 举报
回复
以前贴子里的东西,就是关于没有Preffered Media Type的办法,请看一下,我真的没办法了,我找了好多资料,但是我对COM不是很熟,谢谢了!
By default, the Sample Grabber has no preferred media types. Before you insert it into a filter graph, set the media type for the input pin by calling the ISampleGrabber::SetMediaType method. Setting a media type ensures that the filter graph manager inserts the Sample Grabber at the correct point in the graph.

The SetMediaType method takes a pointer to an AM_MEDIA_TYPE structure that describes the media type. Depending on the situation, you can set the subtype or format type to GUID_NULL, which indicates "unspecified."
whoo 2003-08-25
  • 打赏
  • 举报
回复
CBasePin是IPin的实现,如果你需要写一个IPin,那么才会用到他。你使用IPin的时候,绝对不可能用到IPin的具体实现的,否则接口还有什么意义?

如果一个IPin没有 Preffered Media Type, 那说明他不接受连接(如果不是in pin 的话)。

用SetMediaType的思路完全是不通的,想象一下,你能对一个mp3解码filer SetMediaType(MPEG4), 然后他就能解码 MPEG4 了么?
whoo 2003-08-25
  • 打赏
  • 举报
回复
不多说了,connect fail. 我想检查你的MediaType比想办法去SetMediaType更有意义。
zhangjianyu 2003-08-25
  • 打赏
  • 举报
回复
今天又莫名其妙的连接成功了,怪阿。

谢谢这位老兄,我想可能是有些地方我没写好,可能一不小心给改对了。回头再好好研究一下程序。

结贴拉!

zhangjianyu 2003-08-24
  • 打赏
  • 举报
回复
IPin不支持SetMediaType阿,我需要用这个函数,但是我能得到接口。
whoo 2003-08-24
  • 打赏
  • 举报
回复
为什么需要这种转换? IPin是接口,CBasePin是实现。

当你使用的时候,你只需要接口;当你实现的时候,你只需要CBasePin,IPin是继承的。还需要什么转换吗?
zhangjianyu 2003-08-24
  • 打赏
  • 举报
回复
是这样,有一个Filter他的Input Pin上没有Preffered Media Type,结果connect执行通不过,看到又一个例子说调用SetMediaType,然后就可以。

但是例子里用的是ISampleGrabber,它本身就支持SetMediaType,我的没有,所以想通过CBasePin::SetMediaType来实现,不知道思路对不对?
whoo 2003-08-24
  • 打赏
  • 举报
回复
不明白为什么要用SetMediaType..., IPin只需要connect就行了啊。CheckMediaType, SetMediaType那是connect内部的事情,使用的话用不着知道吧。

你自己写的Filter??

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧