0

Now I have create an ogg decoder in media foundation.

I have decode the ogg data to PCM data in IMFTransform::ProcessOutput.

but I cannot play the PCM data, so now how to play the pcm data?

This is my ProcessOutput code:

HRESULT OggDecoder:: ProcessOutput( 
DWORD dwFlags, DWORD cOutputBufferCount,
MFT_OUTPUT_DATA_BUFFER  *pOutputSamples, // one per stream
DWORD *pdwStatus  )
{   
   if (dwFlags != 0)
    {
        return E_INVALIDARG;
    }

    if (pOutputSamples == NULL || pdwStatus == NULL)
    {
        return E_POINTER;
    }

    // Must be exactly one output buffer.
    if (cOutputBufferCount != 1)
    {
        return E_INVALIDARG;
    }

    // It must contain a sample.
    if (pOutputSamples[0].pSample == NULL)
    {
        return E_INVALIDARG;
    }

    EnterCriticalSection(&m_critSec);

    HRESULT hr = S_OK;
    DWORD cbData = 0;

    IMFMediaBuffer *pOutput = NULL;

    // If we don't have an input sample, we need some input before
    // we can generate any output.
    if (!HasPendingOutput())
    {
        hr = MF_E_TRANSFORM_NEED_MORE_INPUT;
    }

    // Get the output buffer.

    if (SUCCEEDED(hr))
    {
        hr = pOutputSamples[0].pSample->GetBufferByIndex(0, &pOutput);
    }

    if (SUCCEEDED(hr))
    {
        hr = pOutput->GetMaxLength(&cbData);
    }

    if (SUCCEEDED(hr))
    {
                    BYTE* pPCM=NULL;
                    pOutputBuffer->Lock(&pPCM,NULL,NULL);
                    GetPCMData(&pPCM); // decode audio data here
                    pOutputBuffer->SetCurrentLength(nLength);
                    pOutputSamples[0].pSample->SetSampleTime(sampleTime);
                    pOutputSamples[0].pSample->SetSampleDuration(sampleDuration);
                    pOutputBuffer->Unlock();
    }

    SafeRelease(&pOutput);
    LeaveCriticalSection(&m_critSec);
    return hr;
}

Is there I missing something or what' wrong with this code. thanks.

oguz ismail
  • 1
  • 16
  • 47
  • 69
troyou
  • 190
  • 1
  • 13

1 Answers1

0

if you use topoedit.exe for debug, it can add one resampler DMO automatically which is a DMO for converting pcm to float format. you can write the player app, and create the topology by youself, and then you add the resamplyer dmo node.

ayuppie
  • 45
  • 6