locked
Windows Media Foundation Source Reader RRS feed

  • Question

  • Hello,
    I would like to ask a question related to newly released Windows 7 SDK (more precisely - SourceReader interface: IMFSourceReader ). Source reader allows a developer to capture audio/video streams from any available device or URL. The application on which I am working at the moment, has to capture audio stream from an FM Tuner in a specific format (5500 Hz, Mono). As the FM Tuner presents the audio stream in a different format (44100 Hz, Stereo), I am interested in converting the stream to the one which fits my needs. Thus, I am using WAVEFORMATEX structure in order to specify the format of the Media Type , which will be used to read the data from the SourceReader . The problem is that at the moment then I set the Media Type of the SourceReader through SetCurrentMediaType method, the method returns MF_E_TOPO_CODEC_NOT_FOUND error. Is this the problem related to the lack of Codecs on my machine (Windows 7 by the way), or am I doing something wrong? Any help will be greatly appreciated.

    Following is presented the code:

    IMFMediaType *pPartialType = NULL;

    // Creates an empty media type.
    hr = MFCreateMediaType(&pPartialType);

    //Initialize the
    WAVEFORMATEX waveformat;
    waveformat.wFormatTag = WAVE_FORMAT_PCM;
    waveformat.nChannels = 1;
    waveformat.nSamplesPerSec = 5500;
    waveformat.wBitsPerSample = 16;
    waveformat.nBlockAlign = ((waveformat.wBitsPerSample * waveformat.nChannels) / 8);
    waveformat.nAvgBytesPerSec = (waveformat.nSamplesPerSec * waveformat.nBlockAlign);
    waveformat.cbSize = 0;

    //Initialize Media Type from Waveformat
    hr = MFInitMediaTypeFromWaveFormatEx(
                pPartialType,
                &waveformat,
                (UINT32)sizeof(waveformat));

    //Set current media type of the Source Reader /*pReader is of type IMFSourceReader */
    hr = pReader->SetCurrentMediaType(
                    (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM,
                    NULL,
                    pPartialType
                    );

    Thanks in advance!
    Wednesday, February 17, 2010 1:29 PM

All replies