0
votes

The IMFCapturePreviewSink doc

(https://msdn.microsoft.com/en-us/library/windows/desktop/hh447865(v=vs.85).aspx)

says it supports audio and video.

I've got video working using MF_CAPTURE_ENGINE_PREFERRED_SOURCE_STREAM_FOR_VIDEO_PREVIEW

However there is no audio equivalent in mfcaptureengine.h.

I tried adding the streams directly

for (DWORD i = 0; i < streamCount; i++)
{
    CComPtr<IMFMediaType> pMediaType = NULL;
    if (SUCCEEDED_Xb(hr))
    {
        hr = pSource->GetCurrentDeviceMediaType(i, &pMediaType);
    }
    if (SUCCEEDED_Xb(hr))
    {
        DWORD dwSinkStreamIndex = 0;
        hr = m_pPreview->AddStream(i, pMediaType, NULL, &dwSinkStreamIndex);
    }
}`

Again video only worked.

The audio stream gave no error in this code but after StartPreview was called I got an IMFMediaEvent error of

hr(0xc00d36b2)(MF_E_INVALIDREQUEST) err(The request is invalid in the current state.)"

Also capturing these same sources to disk works just fine.

1

1 Answers

0
votes

You should investigate SetSampleCallback method and IMFCaptureEngineOnSampleCallback interface

All others method from IMFCapturePreviewSink relate to the video stream.