IMFCapturePreviewSink with Audio

0

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.

audio
ms-media-foundation
asked on Stack Overflow Sep 15, 2016 by Sean Daly • edited Mar 1, 2017 by Igal S.

1 Answer

0

You should investigate SetSampleCallback method and IMFCaptureEngineOnSampleCallback interface

All others method from IMFCapturePreviewSink relate to the video stream.

answered on Stack Overflow Sep 16, 2016 by mofo77

User contributions licensed under CC BY-SA 3.0