How to output a bitmap from a mediasource

Hello,

I write a mediasource which can output a bitmap.
But It cannot show to screen.
No matter the bitmap content, it always shows blank.
I try to transform the sample to AYUV format, but it is no used.
I guess maybe some media attributes are wrong. but I cannot make sure it.
does anyone kindly have a look what happend ?

the media type I fill

hr = MFCreateMediaType(&pMediaType);

// Initialize the media type
pMediaType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);

VIDEOINFOHEADER vi;
ZeroMemory(&vi, sizeof(vi));
vi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
vi.bmiHeader.biWidth = 800;
vi.bmiHeader.biHeight = 600;
vi.bmiHeader.biPlanes = 1;
vi.bmiHeader.biBitCount = 32;

// If the bitmap is not compressed, set the BI_RGB flag.
vi.bmiHeader.biCompression = 'VUYA'; // FOURCC for 'AYUV'
vi.bmiHeader.biSizeImage = 0;
vi.bmiHeader.biClrImportant = 0;
vi.AvgTimePerFrame = 333333;

hr = MFInitMediaTypeFromVideoInfoHeader(pMediaType, &vi, sizeof(vi), &MEDIASUBTYPE_AYUV);

pMediaType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1);
pMediaType->SetUINT32(MF_MT_FIXED_SIZE_SAMPLES, 1);
pMediaType->SetUINT64(MF_MT_FRAME_RATE, 30LL << 32 | 1);

the media sample I output

CComPtr<IMFMediaBuffer> pBuffer;
CComPtr<IMFSample> pSample;
hr = MFCreateMemoryBuffer(800*600*4, &pBuffer);

<.... fill the sample ....>

hr = pBuffer->SetCurrentLength(cbBuffer);
hr = MFCreateSample(&pSample);
hr = pSample->AddBuffer(pBuffer);
hr = pSample->SetSampleTime(m_rtCurrentPosition);
hr = pSample->SetSampleDuration(333333);
hr = pSample->SetSampleFlags( MF_SAMPLE_FLAG_CLEANPOINT );
hr = pSample->SetUINT32(MFSampleExtension_StreamNumber, 0);
hr = pSample->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, 1);
hr = pSample->SetUINT32(MF_MT_FIXED_SIZE_SAMPLES, 1);
hr = pSample->SetUINT32(MF_MT_DEFAULT_STRIDE, 800 * 4);
hr = pSample->SetUINT64(MF_MT_FRAME_RATE, 30LL << 32 | 1);

[3480 byte] By [Fei-tian] at [2008-2-7]
# 1

First things first: Can you tell us a little more about how you're using your Media Source?

Are you pulling samples out of it and using them directly, or are you using your Media Source inside a Media Foundation pipeline (i.e. using the Media Session)?

If you are using the Media Session, did your IMFMediaSession::SetTopology and IMFMediaSession::Start operations both complete successfully? Note that an operation is successful if both the call itself returned a success code and the event (MESessionTopologySet, MESessionStarted, etc) that signals the end of the operation has a successful status code.

BeckyWeiss-MSFT at 2007-9-10 > top of Msdn Tech,Audio and Video Development,Media Foundation Development...
# 2

In addition to the above, another thing to note, if you're using the MF pipeline and getting past all of the above things I mentioned, is that we don't handle topologies with an uncompressed video source connected directly to the video renderer. This is because we require Media Sources to provide their own buffers, whereas the Enhanced Video Renderer (EVR) in Media Foundation needs to receive DXVA surfaces.

Our favorite workaround for this is to write a very simple MFT (IMFTransform) that just copies samples. Insert this between the source node and the output node in your partial topology, and this might fix your problem, if that's indeed it.

Best of luck,

BeckyWeiss-MSFT at 2007-9-10 > top of Msdn Tech,Audio and Video Development,Media Foundation Development...