1

I have to configure my video camera display resolution before capturing and processing the data. Initially I did it as follows.

  1. Created all necessary interfaces.

  2. Added camera and renderer filters

  3. Did RenderStream with Capture and Preview PIN Categories.

  4. Then did the looping through AM_MEDIA_TYPE structures and setting the params.

This worked for a lot of cameras, but a few cameras failed. Then I changed the order of 3 and 4 given above. That is, I did the setting of params before the RenderStream. This time, the error cases went through, but a few On board cameras in SONY VAIO laptop etc seem to fail.

Now, my questions are

  1. Which is the optimal and correct method of getting and setting AM_MEDIA_TYPE parameters and running the graph?

  2. If there are different cameras, if I get an indication of which order is the best for a particular camera by going through the camera's DirectShow interfaces, that will also serve my purpose.

Please help me in this at the earliest,

Thanks and regards,

Shiju

Jo Bell
  • 11
  • 5

1 Answers1

3

IAMStreamConfig::SetFormat needs to be used to set capture format before the pin is connected and rendered. This way the downstream subchain of filters is built with proper media types.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Hi, that means SetFormat should be before the IGraphBuilder::AddFilter call and the ICaptureGraphBuilder2::RenderStream right? Now also there are error case for on board video cams. Others pass through. The error code is 80004005 when I try SetFormat. I am attaching the relevant flow from my side at http://pastebin.com/FYt83Ame. Could you please check? – Jo Bell Mar 23 '12 at 08:05
  • 1
    No, `SetFormat` should be after `AddFilter` but before `RenderStream` and/or other methods that get your output pin in question connected. – Roman R. Mar 23 '12 at 08:11
  • Thanks for the answer. But for a beginner in Direct Show it is not really helpfull. Can you please tell me where I get the IAMStreamConfig interface from? In my code I have a IGraphBuilder, ICaptureGraphBuilder2, IBaseFilter, IVMRWindowlessControl9, IMediaControl. A peace of code would be VERY helpfull! – Elmue Apr 06 '16 at 15:18
  • @Elmue: This does not look relevant to the original question, so I won't update my answer here. You can look into DirectShow samples, capture ones, how they locate `IAMStreamConfig` with `ICaptureGraphBuilder2.FindInterface`. It is not the only way (and I myself never did it this way) but it is still a good example. Or, ask your own question and you will get more detailed response. – Roman R. Apr 06 '16 at 15:32
  • OK. I found this, and it works: https://msdn.microsoft.com/en-us/library/windows/desktop/dd318240%28v=vs.85%29.aspx , though I changed PIN_CATEGORY_PREVIEW into PIN_CATEGORY_CAPTURE – Elmue Apr 06 '16 at 22:49