IMFSinkWriterCallback永远不会发生

时间:2015-12-09 21:35:27

标签: ms-media-foundation

我正试图让我的IMFSinkWriter的Finalize()调用异步。

所以我创建了这个

class MyMFSinkWriterCallback : public IMFSinkWriterCallback
{
public:
    MyMFSinkWriterCallback();
    virtual ~MyMFSinkWriterCallback();

    // IMFSinkWriterCallback methods
    STDMETHODIMP OnFinalize(HRESULT hrStatus);
    STDMETHODIMP OnMarker(DWORD dwStreamIndex, LPVOID pvContext);

    // IUnknown methods
    STDMETHODIMP QueryInterface(REFIID iid, void** ppv);
    STDMETHODIMP_(ULONG) AddRef();
    STDMETHODIMP_(ULONG) Release();

private:
    long m_nRefCount;
};

HRESULT MyMFSinkWriterCallback::OnFinalize(HRESULT hrStatus)
{
    OutputDebugStringA("MyMFSinkWriterCallback::OnFinalize\n");
    return S_OK;
}

我像这样安装了

hr = pAttributes->SetUnknown(MF_SINK_WRITER_ASYNC_CALLBACK, new MyMFSinkWriterCallback());

if (SUCCEEDED(hr))
{
    hr = MFCreateSinkWriterFromURL(L"C:\test.mp4", NULL, pAttributes, &MySinkWriter);
}

QueryInterface,AddRef和Release都被调用但是当我像这样结束我的捕获时

OutputDebugStringA("MySinkWriter->Finalize START\n");
HRESULT hr = MySinkWriter->Finalize();
OutputDebugStringA("MySinkWriter->Finalize END\n");

我在输出日志中看到的只有

MySinkWriter->完成START

MySinkWriter->结束END

我从未见过

MyMFSinkWriterCallback :: OnFinalize

0 个答案:

没有答案