The ltmmCapture, ltmmConvert, and ltmmPlay objects implement the GetSubObject function so you can access DirectShow specific objects directly.
Suppose for example, you wanted access to the ltmmCapture objects underlying FilterGraph in order to set up the log file output.
The following code, in C, accomplishes this:
IltmmCapture *pCapture; // initialized elsewhereHANDLE hLogFile; // handle to logfile, set elsewhereHRESULT hr;IUnknown *pUnk;IGraphBuilder *pFg;// call the Capture object to retrieve the FilterGraphhr = IltmmCapture_GetSubObject(pCapture, ltmmCapture_Object_FilterGraph, &pUnk);if (SUCCEEDED(hr)){// retrieve the IGraphBuilder interfacehr = IUnknown_QueryInterface(pUnk, IID_IGraphBuilder, (void**)&pFg);IUnknown_Release(pUnk);if (SUCCEEDED(hr)){// assign the logfileIGraphBuilder _SetLogFile(pFg, (DWORD_PTR)hLogFile);IUnknown_Release(pFg);}}
In C++, you would do the following:
IltmmCapture *pCapture; // initialized elsewhereHANDLE hLogFile; // handle to logfile, set elsewhereHRESULT hr;IUnknown *pUnk;IGraphBuilder *pFg;// call the Capture object to retrieve the FilterGraphhr = pCapture->GetSubObject(ltmmCapture_Object_FilterGraph, &pUnk);if (SUCCEEDED(hr)){// retrieve the IGraphBuilder interfacehr = pUnk->QueryInterface(IID_IGraphBuilder, (void**)&pFg);pUnk->Release();if (SUCCEEDED(hr)){// assign the logfilepFg->SetLogFile((DWORD_PTR)hLogFile);pFg->Release();}}
Another example is to call the ltmmPlay object to retrieve the Video Renderer in order to enable RGB mode.
This is demonstrated, in C, as follows:
IltmmPlay *pPlay; // initialized elsewhereHRESULT hr;IUnknown *pUnk;IDirectDrawVideo *pDDV;// call the Play object to retrieve the VideoRendererhr = IltmmPlay_GetSubObject(pPlay, ltmmPlay_Object_VideoRenderer, &pUnk);if (SUCCEEDED(hr)){// retrieve the IDirectDrawVideo interfacehr = IUnknown_QueryInterface(pUnk, IID_IGraphBuilder, (void**)&pDDV);IUnknown_Release(pUnk);if (SUCCEEDED(hr)){// set rgb modeIDirectDrawVideo _SetSwitches(pDDV, AMDDS_RGB);IUnknown_Release(pDDV);}}
In C++, you would do the following:
IltmmPlay *pPlay; // initialized elsewhereHRESULT hr;IUnknown *pUnk;IDirectDrawVideo *pDDV;// call the Play object to retrieve the VideoRendererhr = pPlay->GetSubObject(ltmmPlay_Object_VideoRenderer, &pUnk);if (SUCCEEDED(hr)){// retrieve the IDirectDrawVideo interfacehr = pUnk->QueryInterface(IID_IGraphBuilder, (void**)&pDDV);pUnk->Release(pUnk);if (SUCCEEDED(hr)){// set rgb modepDDV->SetSwitches(AMDDS_RGB);pDDV->Release();}}
A third example is to call the ltmmConvert object to retrieve the video compressor in order to adjust the compression quality. This is demonstrated, in C, as follows:
IltmmConvert *pConvert; // initialized elsewhereHRESULT hr;IUnknown *pUnk;IAMVideoCompression *pVC;// call the Convert object to retrieve the Video Compressorhr = IltmmConvert_GetSubObject(pConvert, ltmmConvert_Object_VideoCompressor, &pUnk);if (SUCCEEDED(hr)){// retrieve the IAMVideoCompression interfacehr = IUnknown_QueryInterface(pUnk, IID_IAMVideoCompression, (void**)&pVC);IUnknown_Release(pUnk);if (SUCCEEDED(hr)){// set the quality to the best availableIAMVideoCompression_put_Quality(pVC, 1.0);IUnknown_Release(pVC);}}
In C++, you would do the following:
IltmmConvert *pConvert; // initialized elsewhereHRESULT hr;IUnknown *pUnk;IAMVideoCompression *pVC;// call the Convert object to retrieve the Video Compressorhr = pConvert->GetSubObject(ltmmConvert_Object_VideoCompressor, &pUnk);if (SUCCEEDED(hr)){// retrieve the IAMVideoCompression interfacehr = pUnk->QueryInterface(IID_IAMVideoCompression, (void**)&pVC);pUnk->Release(pUnk);if (SUCCEEDED(hr)){// set the quality to the best availablepVC->put_Quality(1.0);pVC->Release();}}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
