도전2022
참고, directshow 코드 본문
SMALL
while(1)
{
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent *pEvent = NULL;
IBaseFilter *pInputFileFilter = NULL;
IBaseFilter *pVideoRenderer = NULL;
IPin *pFileOut = NULL, *pVidIn = NULL;
IVideoWindow *VidWindow=NULL;
string s=openfilename();
wstring ws;
ws.assign (s.begin (), s.end ());
// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
printf("ERROR - Could not initialize COM library");
return 1;
}
// Create the filter graph manager and query for interfaces.
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER,
IID_IGraphBuilder, (void **)&pGraph);
if (FAILED(hr))
{
printf("ERROR - Could not create the Filter Graph Manager.");
return 1;
}
hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);
// And add the filter to the filter graph
// using the member function AddFilter.
hr = pGraph->AddSourceFilter(ws.c_str(), ws.c_str(), &pInputFileFilter);
if (SUCCEEDED(hr))
{
// Now create an instance of the video renderer
// and obtain a pointer to its IBaseFilter interface.
hr = CoCreateInstance(CLSID_VideoMixingRenderer9,NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,
(void **)&pVideoRenderer);
if (SUCCEEDED(hr))
{
hr = pGraph->AddFilter(pVideoRenderer, L"Video Renderer");
//pVideoRenderer->QueryInterface(IID_IVideoWindow,(void**)&VidWindow);
if (SUCCEEDED(hr))
{
// Now we need to connect the output pin of the source
// to the input pin of the renderer.
// Obtain the output pin of the source filter.
// The local function GetPin does this.
pFileOut = GetPin(pInputFileFilter, PINDIR_OUTPUT);
if (pFileOut != NULL)
{ // Is the pin good?
// Obtain the input pin of the WAV renderer.
// Obtain the input pin of the WAV renderer.
pVidIn = GetPin(pVideoRenderer, PINDIR_INPUT);
if (pVidIn != NULL)
{ // Is the pin good?
// Connect the pins together:
// We use the Filter Graph Manager's
// member function Connect,
// which uses Intelligent Connect.
// If this fails, DirectShow couldn't
// render the media file.
hr = pGraph->Connect(pFileOut, pVidIn);
}
}
}
}
}
if (SUCCEEDED(hr))
{
//VidWindow->put_FullScreenMode(OATRUE);
//VidWindow->put_Owner(NULL);
// Run the graph.
hr = pControl->Run();
if (SUCCEEDED(hr))
{
// Wait for completion.
long evCode;
pEvent->WaitForCompletion(INFINITE, &evCode);
// Note: Do not use INFINITE in a real application, because it
// can block indefinitely.
}
hr = pControl->Stop();
}
// Now release everything we instantiated--
// that is, if it got instantiated.
if(pFileOut)
{ // If it exists, non-NULL
pFileOut->Release(); // Then release it
}
if (pVidIn)
{
pVidIn->Release();
}
if (pInputFileFilter)
{
pInputFileFilter->Release();
}
if (pVideoRenderer)
{
pVideoRenderer->Release();
}
//VidWindow->Release();
pControl->Release();
pEvent->Release();
pGraph->Release();
CoUninitialize();
}
LIST
'참고자료' 카테고리의 다른 글
PC 일체형 시대, 터치도 곧 모두 되겠네. (0) | 2012.03.29 |
---|---|
알집 광고에 지쳐서 다시 7zip으로 ㅠㅠ (0) | 2012.03.17 |
참고, directshow 코드 (0) | 2012.03.17 |
Cheat Sheet: Unicode-enabling Microsoft C/C++ Source Code (0) | 2012.03.16 |
플래시로 ebook 넘기는 효과 관련된 글. (0) | 2012.03.15 |