locked
How to set sinkwriter input to MFAudioFormat_Float RRS feed

  • Question

  • While trying to SetInputMediaType to MFAudioFormat_Float on Win8 it fails with invalidmediatype. How do I correct this?

     ComPtr<IMFMediaType> _spTypeOut; 
     CHK(MFCreateMediaType(&_spTypeOut));  
     CHK(_spTypeOut->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio));    
     CHK(_spTypeOut->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_MP3));

     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100));
     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 16000));
     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, 2));
     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16));
     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 1));
     CHK(_spTypeOut->SetUINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1));

     // Add a stream of mediatype mp3 to the writer
     CHK(_spSinkWriter->AddStream(_spTypeOut.Get(), &_OutputStreamIndex));

     // Create a common input type for the sinkwriter
     ComPtr<IMFMediaType> _spMFTypeIn; 
     CHK(MFCreateMediaType(&_spMFTypeIn)); 
     CHK(_spMFTypeIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Audio));    
     CHK(_spMFTypeIn->SetGUID(MF_MT_SUBTYPE, MFAudioFormat_Float));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_AVG_BYTES_PER_SECOND, 16000));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_NUM_CHANNELS, 2));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_BITS_PER_SAMPLE, 16));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_BLOCK_ALIGNMENT, 1));
     //CHK(_spMFTypeIn->SetUINT32(MF_MT_AUDIO_PREFER_WAVEFORMATEX, 1));

     hr = _spSinkWriter->SetInputMediaType( _OutputStreamIndex, _spMFTypeIn.Get(), NULL ) ;

    Tuesday, April 16, 2013 4:21 AM