DirectShow 的 PushSource 过滤器导致 IMediaControl::Run 返回 S_FALSE

发布于 2024-09-24 11:31:15 字数 1349 浏览 3 评论 0原文

我正在摆弄 DirectShow SDK 附带的 PushSource 示例过滤器,并且遇到以下问题:

当我调用 IMediaControl::Run() 时,它返回 S_FALSE,这意味着“图形正在准备运行,但某些过滤器尚未完成到运行状态的转换”。 MSDN 建议随后调用 IMediaControl::GetState() 并等待转换完成。

因此,我调用 IMediaControl::GetState(INFINITE, ...) 应该可以解决问题。

然而,相反,即使我指定了无限的等待时间,它也会返回 VFW_S_STATE_INTERMEDIATE。

我已经尝试了所有三种变体(位图、位图集和桌面),它们的行为方式都相同,这最初让我相信某处存在错误。

然而,然后,我尝试使用 IFilterGraph::AddSourceFilter 做同样的事情,它做了同样的事情,这一定意味着问题出在我的渲染代码上:

CoInitialize(0);

IGraphBuilder *graph = 0;
assert(S_OK == CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&graph));

IBaseFilter *pushSource = 0;
graph->AddSourceFilter(L"sample.bmp", L"Source", &pushSource);

IPin *srcOut = 0;
assert(S_OK == GetPin(pushSource, PINDIR_OUTPUT, &srcOut));
graph->Render(srcOut);



IMediaControl *c = 0;
IMediaEvent   *pEvent;
assert(S_OK == graph->QueryInterface(IID_IMediaControl, (void**)&c));
assert(S_OK == graph->QueryInterface(IID_IMediaEvent, (void**)&pEvent));

HRESULT hr = c->Run();
if(hr != S_OK)
{
    if(hr == S_FALSE)
    {
        OAFilterState state;
        hr = c->GetState(INFINITE, &state);

        assert(hr == S_OK );
    }

}

long code;
assert(S_OK == pEvent->WaitForCompletion(INFINITE, &code));

有人知道如何解决这个问题吗?

I'm messing around with the PushSource sample filter shipped with the DirectShow SDK and I'm having the following problem:

When I call IMediaControl::Run(), it returns S_FALSE which means "the graph is preparing to run, but some filters have not completed the transition to a running state". MSDN suggests to then call IMediaControl::GetState() and wait for the transition to finish.

And so, I call IMediaControl::GetState(INFINITE, ...) which is supposed to solve the problem.

However, to the contrary, it returns VFW_S_STATE_INTERMEDIATE even though I've specified an infinite waiting time.

I've tried all three variations (Bitmap, Bitmap Set and Desktop) and they all behave the same way, which initially lead me to believe there is a bug in there somewhere.

However, then, I tried using IFilterGraph::AddSourceFilter to do the same and it did the same thing, which must mean it's my rendering code that is the problem:

CoInitialize(0);

IGraphBuilder *graph = 0;
assert(S_OK == CoCreateInstance(CLSID_FilterGraph, 0, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)&graph));

IBaseFilter *pushSource = 0;
graph->AddSourceFilter(L"sample.bmp", L"Source", &pushSource);

IPin *srcOut = 0;
assert(S_OK == GetPin(pushSource, PINDIR_OUTPUT, &srcOut));
graph->Render(srcOut);



IMediaControl *c = 0;
IMediaEvent   *pEvent;
assert(S_OK == graph->QueryInterface(IID_IMediaControl, (void**)&c));
assert(S_OK == graph->QueryInterface(IID_IMediaEvent, (void**)&pEvent));

HRESULT hr = c->Run();
if(hr != S_OK)
{
    if(hr == S_FALSE)
    {
        OAFilterState state;
        hr = c->GetState(INFINITE, &state);

        assert(hr == S_OK );
    }

}

long code;
assert(S_OK == pEvent->WaitForCompletion(INFINITE, &code));

Anyone knows how to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰沐子 2024-10-01 11:31:15
IBaseFilter *pushSource = 0;
graph->AddSourceFilter(L"sample.bmp", L"Source", &pushSource);

AddSourceFilter 添加默认源过滤器,我认为它不会添加您的推送源示例过滤器。

我建议将图表添加到 ROT,以便您可以使用 graphedit 检查它。

如果不调用 GetState() 会发生什么?

hr = pMediaControl->Run();
if(FAILED(hr)) {
    /// handle error
}

long evCode=0;
while (evCode == 0) 
{
    pEvent->WaitForCompletion(1000, &evCode);
    /// other code
}
IBaseFilter *pushSource = 0;
graph->AddSourceFilter(L"sample.bmp", L"Source", &pushSource);

AddSourceFilter adds a default source filter, I don't think it will add your pushsource samplefilter.

I would recommend to add the graph to the ROT, so you can inspect it with graphedit.

And what happens if you don't call GetState()?

hr = pMediaControl->Run();
if(FAILED(hr)) {
    /// handle error
}

long evCode=0;
while (evCode == 0) 
{
    pEvent->WaitForCompletion(1000, &evCode);
    /// other code
}
何其悲哀 2024-10-01 11:31:15

打开 GraphEditPlus,添加过滤器,渲染其 pin 并按“运行”。然后,您将分别看到每个过滤器的状态,以便了解哪些过滤器未运行以及原因。

Open GraphEditPlus, add your filter, render its pin and press Run. Then you'll see states of each filter separately, so you'll see what filter didn't run and why.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文