Advertisement

12.03.2008 at 07:39AM PST, ID: 23953498 | Points: 250
[x]
Attachment Details

DirectShow Graph

Asked by ralph78 in Windows MFC Programming, DirectX Graphics & Game Programming

Tags: , ,

Hi!

I recently created a rendering filter. It works perfectly in Graphedit. (the filters takes a video and an audio stream and produces fingerprint).

However, when I build the graph in my app, it doesn't work at all:
everything returns S_OK, and the built graph is exactly like the one I manually made with graphedit, however the call to WaitForCompletion always returns VFW_E_WRONG_STATE.

Since it works correctly in graphedit, I guess I'm doing something wrong in my app, but I can't see what. If you have any clue...

regards,

RaphStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
extern "C" bool APIENTRY ExtractVideoDigest(char * p_VideoFile, char * p_DigestPath)
{
	IGraphBuilder	*pGB   = NULL;
	IMediaControl	*pMC   = NULL;
	IMediaEventEx	*pME   = NULL;	
	IBasicVideo		*pBV   = NULL;
	IVideoFP		*pVideoFP = NULL;
	IBaseFilter		*filter = NULL;
	IBaseFilter		*pSF = NULL;
	IEnumPins		*pEnumSource = NULL;
	IEnumPins		*pEnumRender = NULL;
	IPin			*pSourcePin = NULL;
	IPin			*pRenderPin = NULL;
	HRESULT			hr;
	bool			ret = true;
	DWORD rot = 0;
	
	CoInitialize(NULL);
 
	hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&pGB);
	ret = (hr==S_OK);
 
 
	if(ret)
	{
		AddGraphToRot(pGB,&rot);
		hr = CoCreateInstance(CLSID_VideoFP, NULL, CLSCTX_INPROC_SERVER, IID_IVideoFP, (void **)&pVideoFP);
		ret = (hr==S_OK);
	}
 
	if(ret)
	{		
		pVideoFP->SetFileName(p_DigestPath);
		WCHAR buf[255];
		MultiByteToWideChar(CP_UTF8,0,"Video FP",255,buf,255);
 
		pVideoFP->QueryInterface(IID_IBaseFilter,(void **)&filter);
		pGB->AddFilter(filter,NULL);
		
		MultiByteToWideChar(CP_UTF8,0,p_VideoFile,255,buf,255);
		ret = (pGB->AddSourceFilter(buf,NULL,&pSF)==S_OK);
 
		if(ret)
		{
			//we try to connect every pin (source->render)
			hr = pSF->EnumPins(&pEnumSource);
			hr = filter->EnumPins(&pEnumRender);
 
			while(pEnumRender->Next(1, &pRenderPin, 0)==S_OK)
			{
				pEnumSource->Reset();
				while(pEnumSource->Next(1, &pSourcePin, 0)==S_OK)
				{
					
					//try to connect
			        	hr = pGB->Connect(pSourcePin, pRenderPin);
					SAFE_RELEASE(pSourcePin);
					if(hr==S_OK) break;
				}				
				SAFE_RELEASE(pRenderPin);				
			}
 
			pEnumSource->Release();	
			pEnumRender->Release();
		}   
    
	
		pGB->QueryInterface(IID_IMediaControl, (void **)&pMC);
		pGB->QueryInterface(IID_IMediaEventEx, (void **)&pME);
		pGB->QueryInterface(IID_IBasicVideo, (void **)&pBV);
 
		hr = pMC->Run();
 
		long evtcode = 0;
 
		hr = pME->WaitForCompletion(INFINITE, &evtcode);			//FAILS HERE!
		pMC->Stop();
			
	} 
 
	RemoveGraphFromRot(rot);
 
	SAFE_RELEASE(pSF);
	SAFE_RELEASE(pME);
	SAFE_RELEASE(pMC);
	SAFE_RELEASE(pBV);  
	SAFE_RELEASE(filter);
	SAFE_RELEASE(pVideoFP);
       SAFE_RELEASE(pGB);
	CoUninitialize();
 
	return ret;
}
[+][-]12.03.2008 at 02:36PM PST, ID: 23091045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.04.2008 at 12:00AM PST, ID: 23093319

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.04.2008 at 01:34AM PST, ID: 23093674

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12.17.2008 at 10:53AM PST, ID: 23196677

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12.18.2008 at 01:18AM PST, ID: 23201671

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 - Hierarchy / EE_QW_3_20080625