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);

