【发布时间】:2018-09-28 18:34:46
【问题描述】:
我在尝试将 GMFBridge 过滤器与 Euresys UxH264 卡的输出一起使用时遇到了一个奇怪的问题。
我正在尝试将此卡集成到我们的解决方案中,该解决方案依赖 GMFBridge 来处理连续捕获多个文件的能力,执行多路复用和文件拆分,而无需停止捕获图。
此卡从模拟输入捕获视频和音频。它提供了一个 DirectShow 过滤器,同时公开视频输入的原始流和硬件编码的 H.264 流。音频流仅作为未压缩流提供。
当我尝试将 Euresys 源滤波器的任何输出引脚直接连接到 GMFBridge 接收器的输入引脚时,它们都会被拒绝,代码为 VFW_E_NO_ALLOCATOR。 (过去我已经成功地将 H.264 和原始音频流连接到网桥)。
抓住吸管,我在 Euresys 卡式过滤器和桥式接收器过滤器之间插入了一对 SampleGrabber 过滤器,并且 - 就像那样 - 样本采集器和接收器之间的连接被接受。
但是,我在网桥的另一侧(多路复用图)没有收到任何数据包。我使用 GraphStudioNext 检查了正在运行的捕获图,并且以某种方式样本抓取器似乎与我的图分离,即使我在将它们连接到源过滤器时得到了成功的确认!。
这是创建图表的源代码。
void EuresysSourceBox::BuildGraph() {
HRESULT hRes;
CComPtr<IGraphBuilder> pGraph;
COM_CALL(pGraph.CoCreateInstance(CLSID_FilterGraph));
#ifdef REGISTER_IN_ROT
_rotEntry1 = FilterTools::RegisterGraphInROT(IntPtr(pGraph), "euresys graph");
#endif
// [*Video Source*]
String^ filterName = "Ux H.264 Visual Source";
Guid category = _GUIDToGuid((GUID)AM_KSCATEGORY_CAPTURE);
FilterMonikerList^ videoSourceList = FilterTools::GetFilterMonikersByName(category, filterName);
CComPtr<IBaseFilter> pVideoSource;
int monikerIndex = config->BoardIndex; // a filter instance will be retrieved for every installed board
clr_scoped_ptr<CComPtr<IMoniker>>^ ppVideoSourceMoniker = videoSourceList[monikerIndex];
COM_CALL((*ppVideoSourceMoniker->get())->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pVideoSource));
COM_CALL(pGraph->AddFilter(pVideoSource, L"VideoSource"));
// [Video Source]
//
// [*Audio Source*]
filterName = "Ux H.264 Audio Encoder";
FilterMonikerList^ audioSourceList = FilterTools::GetFilterMonikersByName(category, filterName);
CComPtr<IBaseFilter> pAudioSource;
clr_scoped_ptr<CComPtr<IMoniker>>^ ppAudioSourceMoniker = audioSourceList[monikerIndex];
COM_CALL((*ppAudioSourceMoniker->get())->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)&pAudioSource));
COM_CALL(pGraph->AddFilter(pAudioSource, L"AudioSource"));
CComPtr<IPin> pVideoCompressedOutPin(FilterTools::GetPin(pVideoSource, "Encoded"));
CComPtr<IPin> pAudioOutPin(FilterTools::GetPin(pAudioSource, "Audio"));
CComPtr<IBaseFilter> pSampleGrabber;
COM_CALL(pSampleGrabber.CoCreateInstance(CLSID_SampleGrabber));
COM_CALL(pGraph->AddFilter(pSampleGrabber, L"SampleGrabber"));
CComPtr<IPin> pSampleGrabberInPin(FilterTools::GetPin(pSampleGrabber, "Input"));
COM_CALL(pGraph->ConnectDirect(pVideoCompressedOutPin, pSampleGrabberInPin, NULL)); // DOES NOT FAIL!!
CComPtr<IBaseFilter> pSampleGrabber2;
COM_CALL(pSampleGrabber2.CoCreateInstance(CLSID_SampleGrabber));
COM_CALL(pGraph->AddFilter(pSampleGrabber2, L"SampleGrabber2"));
CComPtr<IPin> pSampleGrabber2InPin(FilterTools::GetPin(pSampleGrabber2, "Input"));
COM_CALL(pGraph->ConnectDirect(pAudioOutPin, pSampleGrabber2InPin, NULL)); // DOES NOT FAIL!!
// [Video Source]---
// |-->[*Bridge Sink*]
// [Audio Source]---
CComPtr<IPin> pSampleGrabberOutPin(FilterTools::GetPin(pSampleGrabber, "Output"));
CComPtr<IPin> pSampleGrabber2OutPin(FilterTools::GetPin(pSampleGrabber2, "Output"));
CreateGraphBridge(
IntPtr(pGraph),
IntPtr(pSampleGrabberOutPin),
IntPtr(pSampleGrabber2OutPin)
);
// Root graph to parent object
_ppCaptureGraph.reset(new CComPtr<IGraphBuilder>(pGraph));
}
COM_CALL 是我的HRESULT 检查宏,如果结果不是S_OK,它将引发托管异常。所以管脚之间的连接成功了,但是运行时图表看起来是这样的:
所以,我有三个问题:
1) 在这种情况下VFW_E_NO_ALLOCATOR 是什么意思?(源过滤器可以成功连接到其他组件,例如 LAV 视频解码器或 ffdshow 视频解码器)。
2) 是否有已知的解决方法来规避VFW_E_NO_ALLOCATOR 问题?
3) 过滤器是否有可能在运行时断开连接,就像我的情况一样?
【问题讨论】:
标签: c++-cli directshow