I'm trying to use the Desktop capture filter that comes with the SDK (PushSourceDesktop). I compiled it and seem to use it successfully as it actually captures my desktop and saves it to a file. But the application crashes when its done/exits.
When I break on the error it only says no source available and the call stack location is KernelBase.dll!7560280C().
I thought I give it a shot here to see if anyone can recognize some issue or if I am doing something blatantly wrong that might cause the crash. Thanks in advance!
EDIT: working code
int main() { HRESULT hr; hr = CoInitialize(NULL); { CComPtr pMux; CComPtr pMC; CComPtr pFilterr; CComPtr pGraph; CComPtr pBuild; CComPtr pUnk; hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, (void**)&pBuild); hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**)(&pGraph)); hr = pBuild->SetFiltergraph(pGraph); static CLSID const clsid = {0x4ea6930a, 0x2c8a, 0x4ae6, {0xa5, 0x61, 0x56, 0xe4, 0xb5, 0x4, 0x44, 0x37}}; //Pushsourcedesktop hr = CreateObjectFromPath(TEXT("c:\\filters\\PushSource.dll"), clsid, &pUnk); pFilterr = pUnk; if (SUCCEEDED(hr)) { HRESULT hr = pGraph->AddFilter(pFilterr, L"Private Filter"); } hr = pBuild->SetOutputFileName( &MEDIASUBTYPE_Avi, // Specifies AVI for the target file. L"C:\\wav\\Example2.avi", // File name. (IBaseFilter**)&pMux, // Receives a pointer to the mux. NULL); hr = pBuild->RenderStream( NULL,//PIN_CATEGORY_CAPTURE,//NULL,//&PIN_CATEGORY_CAPTURE, // Pin category. NULL,//&MEDIATYPE_Video,//&MEDIATYPE_Interleaved,//NULL,//&MEDIATYPE_Audio, // Media type. pFilterr,//pSrc, // Capture filter. NULL,//pCompression2, //pCompression, // Intermediate filter (optional). (IBaseFilter*)pMux); // Mux or file sink filter. hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pMC); printf("START"); pMC->Pause(); hr = pMC->Run(); Sleep(4000); hr = pMC->Stop(); printf("END"); } CoUninitialize(); return 0; }