I've asked a very similar question before for a video renderer filter.
See here: Custom DirectShow Video Renderer Filter - Dynamic Resolution Change
But this time, I need a solution for a source filter. This source filter connects directly to the video renderer. Decoder is embedded.
I'm able to get the resolution changes from the stream. I also resize the buffers when I get a new resolution. But I don't know how to notify my new resolution through the pin. Should I somehow create an instance from CMediaType
, fill in the new values and call pin's SetMediaType()
method or what is the proper solution? I'm currently doing this.
if(nWidth * nHeight * 3 != reader->m_RGB24BufferSize) { // if resolution changed
reader->m_RGB24BufferSize = nWidth * nHeight * 3;
reader->m_RGB24Buffer = (BYTE*)malloc(reader->m_RGB24BufferSize);
reader->m_pin->m_bmpInfo.biWidth = nWidth;
reader->m_pin->m_bmpInfo.biHeight = nHeight;
reader->m_pin->m_bmpInfo.biSizeImage = GetBitmapSize(&reader->m_pin->m_bmpInfo);
// Now what? How to notify the video renderer?
}
m_pin
is the only output pin of the source filter here which is declared like;
class MyPin : public CSourceStream { ... };
I know the answer should be simple and there should be many examples around but since I'm a little bit confused about these subjects, I prefer a nice explanation besides the example.