⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_25669.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:25669 发表者:ni_jj 发表日期:2002-12-24 17:42:24
<br>主题:connect的问题
<br>内容:CoCreateInstance(CLSID_MPEG1Splitter, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&amp;g_pMpegSplitter);<BR>CoCreateInstance(CLSID_CMpegAudioCodec, NULL, CLSCTX_INPROC_SERVER, <BR>IID_IBaseFilter, (void**)&amp;g_pMpegAudioDecoder);<BR>CoCreateInstance(CLSID_CMpegVideoCodec, NULL, CLSCTX_INPROC_SERVER, <BR>IID_IBaseFilter, (void**)&amp;g_pMpegVideoDecoder);<BR><BR>当g_pMpegSplitter的outpin和g_pMpegAudioDecoder的inpin连接时,return s_ok,<BR>而g_pMpegSplitter的outpin和g_pMpegVideoDecoder的inpin连接时,return VFW_E_CANNOT_CONNECT.
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:禽兽 回复日期:2002-12-24 18:48:44
<br>内容:你是怎么确定IPin口?<BR>一个IPin不能连两次。<BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ni_jj 回复日期:2002-12-24 21:08:15
<br>内容:用EnumPins()枚举出g_pMpegSplitter的Outpin,<BR>用EnumPins()枚举出g_pMpegVideoDecoder的Inpin,<BR>用IGraphBuilder的Connect()连接这两个Ipin口。<BR>根据GraphEdit,g_pMpegSplitter有Audio和Video两个出口呀。<BR><BR>就算一次连一个,连接g_pMpegVideoDecoder也不行,但连接g_pMpegAudioDecoder就可以。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:禽兽 回复日期:2002-12-24 22:09:05
<br>内容:你枚举出Pin口后直接Render。<BR>如果还不行,你把枚举Pin口的代码贴出来。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ni_jj 回复日期:2002-12-25 10:03:45
<br>内容:以下是我的程序,在//connect fail行出错望.高人指点一二.<BR><BR>---------------------------------------------------------------------------<BR>#include &lt;windows.h&gt;<BR>#include &lt;Dshow.h&gt;<BR><BR>IGraphBuilder* g_pGraphBuilder = NULL;<BR>IBaseFilter* g_pSource = NULL;<BR>IBaseFilter* g_pMpegSplitter = NULL;<BR>IBaseFilter* g_pMpegAudioDecoder = NULL;<BR>IBaseFilter* g_pMpegVideoDecoder = NULL;<BR>IBaseFilter* g_pSoundRender = NULL;<BR>IBaseFilter* g_pVideoRender = NULL;<BR>IMediaControl*&nbsp;&nbsp;&nbsp;&nbsp;g_pMediaControl = NULL;<BR>IMediaEvent*&nbsp;&nbsp;&nbsp;&nbsp;g_pEvent = NULL;<BR><BR>void&nbsp;&nbsp;&nbsp;&nbsp;ConnectPins();<BR>IPin*&nbsp;&nbsp;&nbsp;&nbsp;GetPin(IBaseFilter* pFilter,PIN_DIRECTION PinDir);<BR><BR><BR>int main(int argc, char* argv[])<BR>{<BR>HRESULT hr;<BR>LONG evCode;<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoInitialize(NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IGraphBuilder, (void **)&amp;g_pGraphBuilder);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pSource);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_MPEG1Splitter, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pMpegSplitter);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_CMpegAudioCodec, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pMpegAudioDecoder);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_CMpegVideoCodec, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pMpegVideoDecoder);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_DSoundRender, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pSoundRender);<BR>&nbsp;&nbsp;&nbsp;&nbsp;CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER, <BR>&nbsp;&nbsp;&nbsp;&nbsp;IID_IBaseFilter, (void**)&amp;g_pVideoRender);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pSource,NULL);<BR>IFileSourceFilter *Source;<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pSource-&gt;QueryInterface(IID_IFileSourceFilter, (void**)&amp;Source);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = Source-&gt;Load(L".\\water.mpg",NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;Source-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pMpegSplitter,NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pMpegAudioDecoder,NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pMpegVideoDecoder,L"CLSID_CMpegVideoCodec");<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pSoundRender,NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;AddFilter(g_pVideoRender,NULL);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;QueryInterface(IID_IMediaControl, (void **)&amp;g_pMediaControl);<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;QueryInterface(IID_IMediaEvent, (void **)&amp;g_pEvent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;ConnectPins();<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pMediaControl-&gt;Run();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pEvent-&gt;WaitForCompletion(INFINITE, &amp;evCode);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;//release all&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pMediaControl-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pEvent-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pMpegVideoDecoder-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pMpegAudioDecoder-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pMpegSplitter-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pSource-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pSoundRender-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pVideoRender-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;g_pGraphBuilder-&gt;Release();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;CoUninitialize();<BR>&nbsp;&nbsp;&nbsp;&nbsp;return 0;<BR>}<BR><BR>void ConnectPins()<BR>{<BR>IPin*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutPin;<BR>IPin*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InPin;<BR>HRESULT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hr;<BR>//find g_pSource&nbsp;&nbsp;outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pSource,PINDIR_OUTPUT);<BR>//find g_pMpegSplitter inpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin = GetPin(g_pMpegSplitter,PINDIR_INPUT);<BR>// connect --<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;Connect(OutPin, InPin);<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin-&gt;Release();<BR>//find g_pMpegSplitter outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pMpegSplitter,PINDIR_OUTPUT);<BR>//find g_pMpegVideoDecoder inpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin = GetPin(g_pMpegVideoDecoder,PINDIR_INPUT);<BR>// connect --<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;Connect(OutPin, InPin);<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin-&gt;Release();<BR>//find g_pMpegSplitter outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pMpegSplitter,PINDIR_OUTPUT);<BR>//find g_pMpegVideoDecoder inpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin = GetPin(g_pMpegAudioDecoder,PINDIR_INPUT);<BR>// connect --<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;Connect(OutPin, InPin);//connect fail why?<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin-&gt;Release();<BR><BR><BR>//find g_pMpegAudioDecoder outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pMpegAudioDecoder,PINDIR_OUTPUT);<BR>//find g_pSounderRender inpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin = GetPin(g_pSoundRender,PINDIR_INPUT);<BR>// connect --<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;Connect(OutPin, InPin);<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin-&gt;Release();<BR>//find g_pMpegVideoDecoder outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pMpegVideoDecoder,PINDIR_OUTPUT);<BR>//find g_pVideoRender inpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin = GetPin(g_pVideoRender,PINDIR_INPUT);<BR>// connect --<BR>&nbsp;&nbsp;&nbsp;&nbsp;hr = g_pGraphBuilder-&gt;Connect(OutPin, InPin);<BR>&nbsp;&nbsp;&nbsp;&nbsp;InPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin-&gt;Release();<BR>}<BR><BR>IPin*&nbsp;&nbsp;&nbsp;&nbsp;GetPin(IBaseFilter* pFilter,PIN_DIRECTION PinDir)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;BOOL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bFound = FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;IEnumPins&nbsp;&nbsp;*pEnum;<BR>&nbsp;&nbsp;&nbsp;&nbsp;IPin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *pPin;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;pFilter-&gt;EnumPins(&amp;pEnum);<BR>&nbsp;&nbsp;&nbsp;&nbsp;while(pEnum-&gt;Next(1, &amp;pPin, 0) == S_OK)<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIN_DIRECTION PinDirThis;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pPin-&gt;QueryDirection(&amp;PinDirThis);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (bFound = (PinDir == PinDirThis))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pPin-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;pEnum-&gt;Release();<BR>&nbsp;&nbsp;&nbsp;&nbsp;return (bFound ? pPin : 0);&nbsp;&nbsp;<BR>}<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:super 回复日期:2002-12-25 12:09:20
<br>内容:失败的原因是因为<BR>//find g_pMpegSplitter outpin<BR>&nbsp;&nbsp;&nbsp;&nbsp;OutPin = GetPin(g_pMpegSplitter,PINDIR_OUTPUT);<BR>的结果还是返回第一个OutputPin<BR><BR>所以你应该在GetPin函数中再增加一个参数,int nIndex.<BR>当PinDir == PinDirThis时判断index
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:ni_jj 回复日期:2002-12-25 12:46:26
<br>内容:改了,成功了,谢谢.<BR>但是如何得知g_pMpegSplitter的第一个OUTPIN是AUDIO,第二个OUTPIN是VIDEO呢?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -