Click here to Skip to main content
15,913,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCBitmap from file Pin
ImrShah Shehpori26-Oct-03 20:19
sussImrShah Shehpori26-Oct-03 20:19 
GeneralRe: CBitmap from file Pin
Jarek G26-Oct-03 23:40
Jarek G26-Oct-03 23:40 
QuestionHow to access mysql database using C Pin
samhita26-Oct-03 19:57
samhita26-Oct-03 19:57 
AnswerRe: How to access mysql database using C Pin
Florin Ochiana27-Oct-03 0:34
Florin Ochiana27-Oct-03 0:34 
QuestionCan anybody see what I'm doing wrong? Pin
Oinka26-Oct-03 18:30
Oinka26-Oct-03 18:30 
AnswerRe: Can anybody see what I'm doing wrong? Pin
Roger Allen27-Oct-03 2:17
Roger Allen27-Oct-03 2:17 
GeneralThanks Roger! Pin
Oinka27-Oct-03 5:35
Oinka27-Oct-03 5:35 
GeneralDirectShow Problem: Error return 'E_INVALIDARG' when calling ICaptureGraphBuilder2::RenderStream Pin
Member 65339926-Oct-03 16:57
Member 65339926-Oct-03 16:57 
DirectShow Problem
Error return 'E_INVALIDARG' when calling ICaptureGraphBuilder2::RenderStream
at the second try.

My program flow is about :

1. (Application Initial)
Enumerate the capture devices and store the IMoniker pointer in a list.

*repeat
2. whenever creating new Class 'MyClass', I start to
a. build the Filter Graph(CLSID_FilterGraph)
b. build the Capture graph(CLSID_CaptureGraphBuilder2)
c. get IMediaControl, IVideoWindow, IMediaEvent from calling IGraphBuilder::QueryInterface.. etc....
d. get a IMoniker point from IMoniker list(built at first step.) to bind an SourceFilter
e. add the sourcefilter to the graph
f. call ICaptureGraphBuilder::RenderStream (return 'E_INVALIDARG' at the second try)
3. Destroy 'MyClass' object.
a. release all: IGraphBuilder, ICaptureGraphBuilder2, IMediaControl, IVideoWindow, IMediaEvent...
*end repeat

The problem is when I 'retry' to create a MyClass from step 2, the return value of the
function call 'ICaptureGraphBuilder::RenderStream' is turned to 'E_INVALIDARG', but all
is fine at the first time.


Is anyone have the same problem with me? Or something should be noticed I missed.

---program segment---
class MyClass<br />
{<br />
  ....<br />
public:<br />
  IVideoWindow *g_pVW;<br />
  IMediaControl *g_pMC;<br />
  IMediaEventEx *g_pME;<br />
  IGraphBuilder *g_pGraph;<br />
  ICaptureGraphBuilder2 *g_pCapture;<br />
  ......<br />
public:<br />
  MyClass() // constructor<br />
  {<br />
    InitialVideo();<br />
  }<br />
  HRESULT InitialVideo();<br />
}<br />
<br />
HRESULT MyClass::InitialVideo()<br />
{<br />
  HRESULT hr;<br />
  hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder, (void **) &g_pGraph);<br />
  ErrorCheck (hr);<br />
  hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC, IID_ICaptureGraphBuilder2, (void **) &g_pCapture);<br />
  ErrorCheck (hr);<br />
  hr = g_pGraph->QueryInterface(IID_IMediaControl,(LPVOID *) &g_pMC);<br />
  ErrorCheck (hr);<br />
  hr = g_pGraph->QueryInterface(IID_IVideoWindow, (LPVOID *) &g_pVW);<br />
  ErrorCheck (hr);<br />
  hr = g_pGraph->QueryInterface(IID_IMediaEvent, (LPVOID *) &g_pME);<br />
  ErrorCheck (hr);<br />
  hr = this->g_pCapture->SetFiltergraph(this->g_pGraph);<br />
  ErrorCheck (hr);<br />
  POSITION pos = this->m_capturefilterList.FindIndex(uDevId);<br />
  if (pos == NULL) return E_FAIL;<br />
  IMoniker *pM = (IMoniker *)this->m_capturefilterList.GetAt(pos);<br />
  if (pM == NULL) return E_FAIL;<br />
  IBaseFilter *pSrc = NULL;<br />
  hr = pM->BindToObject(0, 0, IID_IBaseFilter, (void**)&pSrc);<br />
  ErrorCheck (hr);<br />
  hr = g_pGraph->AddFilter(pSrc, L"Video source");<br />
  ErrorCheck (hr);<br />
  hr = g_pCapture->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, pSrc, NULL, NULL);<br />
<br />
  ErrorCheck (hr);<br />
  pSrc->Release();<br />
  return hr;<br />
}

GeneralDesign question Pin
alex.barylski26-Oct-03 13:39
alex.barylski26-Oct-03 13:39 
GeneralRe: Design question Pin
Ravi Bhavnani26-Oct-03 13:57
professionalRavi Bhavnani26-Oct-03 13:57 
GeneralRe: Design question Pin
alex.barylski27-Oct-03 6:55
alex.barylski27-Oct-03 6:55 
GeneralCListCtrl DeleteItem Pin
Jarek G26-Oct-03 13:05
Jarek G26-Oct-03 13:05 
GeneralRe: CListCtrl DeleteItem Pin
Daniel132426-Oct-03 13:53
Daniel132426-Oct-03 13:53 
GeneralRe: CListCtrl DeleteItem Pin
Ravi Bhavnani26-Oct-03 13:54
professionalRavi Bhavnani26-Oct-03 13:54 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G26-Oct-03 14:16
Jarek G26-Oct-03 14:16 
GeneralRe: CListCtrl DeleteItem Pin
Ravi Bhavnani26-Oct-03 14:39
professionalRavi Bhavnani26-Oct-03 14:39 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G26-Oct-03 23:32
Jarek G26-Oct-03 23:32 
GeneralRe: CListCtrl DeleteItem Pin
Roger Allen27-Oct-03 2:21
Roger Allen27-Oct-03 2:21 
GeneralRe: CListCtrl DeleteItem Pin
David Crow27-Oct-03 4:46
David Crow27-Oct-03 4:46 
GeneralRe: CListCtrl DeleteItem Pin
Jarek G27-Oct-03 7:59
Jarek G27-Oct-03 7:59 
GeneralRe: CListCtrl DeleteItem Pin
Abin27-Oct-03 14:09
Abin27-Oct-03 14:09 
GeneralCPP question Pin
alex.barylski26-Oct-03 12:22
alex.barylski26-Oct-03 12:22 
GeneralRe: CPP question Pin
Steve S27-Oct-03 1:46
Steve S27-Oct-03 1:46 
GeneralRe: CPP question Pin
alex.barylski27-Oct-03 6:53
alex.barylski27-Oct-03 6:53 
GeneralRe: CPP question Pin
Roger Allen27-Oct-03 2:32
Roger Allen27-Oct-03 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.