I use the MediaFoundation API to get samples from the camera and faced such a problem.
Сreating an source reader object (for example, with the function MFCreateSourceReaderFromMediaSource), we can use IMFSourceReader in asynchronous mode. For this, we must set the MF_SOURCE_READER_ASYNC_CALLBACK attribute on the attribute store. This attribute store is then passed to MFCreateSourceReaderFromMediaSource function.
HRESULT hr = S_OK;
IMFAttributes *pAttributes = NULL;
hr = MFCreateAttributes(&pAttributes, 1);
// set our callback
hr = pAttributes->SetUnknown(MF_SOURCE_READER_ASYNC_CALLBACK, pCallback);
// pass attributes and create source reader
hr = MFCreateSourceReaderFromMediaSource(pMediaSource, pAttributes, ppSourceReader);
Logically, the parameters we set when creating the IMFSourceReader should be stored somewhere in it.
Actually, the question. Is it possible to get the IMFAttributes of IMFSourceReader object (especially value of MF_SOURCE_READER_ASYNC_CALLBACK attribute), which we passed in MFCreateSourceReaderFromMediaSource?
I tried to get them with QueryInterface
pSourceReader->QueryInterface(IID_IMFAttributes, (void**)&pAttributes);
but the return value says that the interface is not supported.
Media source object returns attributes but does not contain the necessary attributes. I think it is possible to get what I am looking for using IMFSourceReader::GetServiceForStream method, but I don't know what service is needed.
Thanks in advance, I will be glad of any help.
There is no defined method to read the value of callback back.