C++/VB - Question about implementing IBaseFilte

Asked By SaxenK
24-Jul-08 12:24 AM
I am writing a virtual video capture device. I write it as a source
filter.
My IBaseFilter needs to export IAMStramConfig interface. But I can't
get
enough information when AMCap use
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
gcap.pVCap,
IID_IAMStreamConfig, (void
**)&gcap.pVSC);
to query my IAMStramConfig interface. I can't get the inputs about the
first
1 and 2 parameters. The standard IUnknown QI only has two inputs.
QueryInterface( REFIID riid, void** ppv )
Is there anyone who knows how to get additional information?
Thanks.
IAMStreamConfig
(1)
IAMStramConfig
(1)
CSNBaseFilter
(1)
ICaptureGraphBuilder2
(1)
IKsPropertySet
(1)
IBaseFilter
(1)
IBaseFilte
(1)
PropID
(1)
  The March Hare [MVP] replied...
21-Jul-08 10:38 PM
From the documentation, you need to support IKsPropertySet on your capture
pin and return PIN_CATEGORY_CAPTURE for Get(AMPROPSETID_Pin,
AMPROPERTY_PIN_CATEGORY, ...).  See the SDK docs topic "Pin Property Set".
It has sample code for querying for this interface.

Also, there is a sample virtual video capture device on my downloads page
(provided by Vivek).  I don't know if he implemented support for this.


--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
  SaxenK replied...
24-Jul-08 12:24 AM
On 7$B7n(B22$BF|(B, $B>e8a(B10$B;~(B38$BJ,(B, "The March Hare [MVP]"
Thanks for your reply, but actually I am not talking about the IPin. I
am wondering the IBaseFilter..
For example, below are codes from AMCap.cpp:
// !!! What if this interface isn't supported?
// we use this interface to set the frame rate and get the capture
size
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved,
gcap.pVCap, IID_IAMStreamConfig,
(void **)&gcap.pVSC);
if(hr != NOERROR)
{
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video,
gcap.pVCap,
IID_IAMStreamConfig, (void
**)&gcap.pVSC);
if(hr != NOERROR)
{
// this means we can't set frame rate (non-DV only)
ErrMsg(TEXT("Error %x: Cannot find
VCapture:IAMStreamConfig"), hr);
}
}
/*----------------*/
The AMCap will try to QI IAMStreamConfig that is belong to
PIN_CATEGORY_CAPTURE and MEDIATYPE_Video or MEDIATYPE_Interleaved
through IBaseFilter. In my IBaseFilter, I need to know upper layer is
querying PIN_CATEGORY_CAPTURE or PIN_CATEGORY_PREVIEW?
MEDIATYPE_Interleaved or MEDIATYPE_Video? my declare is
STDMETHODIMP CSNBaseFilter::QueryInterface( REFIID riid, void** ppv );
So I could only get two input. riid is IID of the Interface's GUID and
ppv is for return. I don't have any information about the Category
GUID. Without the right Category GUID, I may return
MEDIATYPE_Interleaved's IAMStreamConfig even I don't support
MEDIATYPE_Interleaved. It is really bad and wrong. And it will make
the AMCap to get wrong config about my device.
So I would like to know if there any function can get these
information I need?
  The March Hare [MVP] replied...
22-Jul-08 12:09 AM
You will need to implement IAMStreamConfig on the pins rather than the
filter (and implement the interface I wrote in my first post on the pins).
FindInterface also checks the media type against those supported by the
each pin so you will not end up getting IAMStreamConfig for a pin that
doesn't support the media type you requested.

According to the docs:

The simplest way to find an interface is to use the
ICaptureGraphBuilder2::FindInterface method. This method walks the graph
(filters *AND PINS*) until it locates the desired interface. You can
specify the starting point for the search, and you can limit the search to
filters upstream or downstream from the starting point.


This is what the code does from what I can see on MSDN Code Center Premium.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
  SaxenK replied...
03-Aug-08 03:57 AM
On 7$B7n(B22$BF|(B, $B2<8a(B12$B;~(B09$BJ,(B, "The March Hare [MVP]"

Actually I don't want to know how using
ICaptureGraphBuilder2::FindInterface, I want to know is what does it
do? Because I am write a IBaseFilter and IPin interface. The AP will
call FindInterface to get Interface from my filter or pins. Besides, I
have written my own IAMStreamConfig too. So I need to know which one
is AP querying.
Let me simplify the question: When IBaseFilter receive QI
IAMStreamConfig, how to know which category and media type is
restricted?
  The March Hare [MVP] replied...
29-Jul-08 11:50 PM
AFIAK, you can't and you are approaching the problem incorrectly.  You need
to use the approach I outlined already by implementing the IAMStreamConfig
on each of the pins and supporting IKsPropertySet on them.

Why do you think implementing IAMStreamConfig the filter instead of the
pins will work?  Did you read that this can support what you want
somewhere?  From what I understood reading the Windows source code, I don't
think it is possible.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
  SaxenK replied...
03-Aug-08 03:57 AM
On 7$B7n(B30$BF|(B, $B>e8a(B11$B;~(B50$BJ,(B, "The March Hare [MVP]"
Sure. I have implemented IAMStreamConfig and IKsPropertySet on my
created IPin. But it never come into my IPin to QI IAMStreamConfig.
And on IKsPropertySet, I saw it query AMPROPSETID_Pin and PropID=0.
And I return PIN_CATEGORY_CAPTURE. It looks nothing about the
IAMStreamConfig. I really wondering about where does it come.

My propose is to change the Pin property page's content without
writing a new property page. I can use system provided page and change
its content as I desire.
  SaxenK replied...
03-Aug-08 03:57 AM
Oh! I found what is going wrong. I do not reply the correct answer on
IBaseFilter:EnumPins. So it nerver get into my IPin's function. What
stupid am I.
March, Thanks and sorry for wasting your time.
  The March Hare [MVP] replied...
30-Jul-08 03:10 AM
Aren't we all at times... I certainly am :)


You're welcome.  I'm glad it worked out.  You might have found that Vivek
had implemented this interface on the pins in his sample that I mentioned
in my first post (I haven't checked).

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution
Create New Account
help
I get a green pixels video C++ / VB Hello, I'm using the ICaptureGraphBuilder2 to save a portion of a video, I got to save it, a portion exactly pRender) { IGraphBuilder pGraph = null; IMediaControl pControl = null; IMediaEvent pEvent = null; pRender.SetTimelineObject(pTL); pRender.ConnectFrontEnd(); ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); pRender.GetFilterGraph(out pGraph); pBuilder.SetFiltergraph(pGraph); IBaseFilter pMux = null; ; IFileSinkFilter ppSink = null pRender) { IGraphBuilder pGraph = null; IMediaControl pControl = null; IMediaEvent pEvent = null; pRender.SetTimelineObject(pTL); pRender.ConnectFrontEnd(); ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); pRender.GetFilterGraph(out pGraph); pBuilder.SetFiltergraph(pGraph); IBaseFilter pMux = null; ; IFileSinkFilter ppSink = null 3D null; IMediaControl pControl = 3D null; IMediaEvent pEvent = 3D null; pRender.SetTimelineObject(pTL); pRender.ConnectFrontEnd(); ICaptureGraphBuilder2 pBuilder = 3D(ICaptureGraphBuilder2) new CaptureGraphBuilder2(); pRender.GetFilterGraph(out pGraph); pBuilder.SetFiltergraph(pGraph); IBaseFilter pMux = 3D null; ; IFileSinkFilter ppSink pRender) { IGraphBuilder pGraph = null; IMediaControl pControl = null; IMediaEvent pEvent = null; pRender.SetTimelineObject(pTL); pRender.ConnectFrontEnd(); ICaptureGraphBuilder2 pBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2(); pRender.GetFilterGraph(out pGraph); pBuilder.SetFiltergraph(pGraph); IBaseFilter pMux = null; ; IFileSinkFilter
how does the application choose which it will use? Thanks! Mechi Win32 DirectX Video Discussions IAMStreamConfig (1) CBaseOutputPin (1) IKsPropertySet (1) CVCamStream (1) DecideBufferSize (1) AgreeMediaType (1) IMemAllocator (1) GetStreamCaps (1) Hi, You might be with GraphEdit and GraphStudio. For AMCap you need to implement minimal set of interfaces, including IAMStreamConfig (even if it actually does nothing, AMCap still needs it). VLC is unable to use two methods the applications use to select particular resolution. In most cases, they will use IAMStreamConfig and you need to implement this interface to expose capabilities and accept desired resolution. The the resolution and let filters agree on some resolutions themselves. The application might look for IAMStreamConfig on the output pin of the video capture source filter and choose the resolution using and connect the pin using this media type. You will cover most cases by implementing IAMStreamConfig. ming ould I e RenderStream will connect filters while the graph is stopped. Typically the case you need to use media type agreed on the output pin. If you implement IAMStreamConfig, you might also receive desired media type through IAMStreamConfig::SetFormat in which case your filter should use this format as preferred when it is
Configuring a Video Source (Again) C++ / VB Having used IAMStreamConfig for years I'm now finding cards that I can't seem to set up card but other new cards exhibit the same problem] Win32 DirectX Video Discussions AMAnalogVideoDecoder (1) IAMStreamConfig (1) MinOutputSize (1) MaxOutputSize (1) TVFormat (1) WinTV (1) RenderStream (1) DirectShow (1) Many capture AM_MEDIA_TYPE of the pin (within the specified min and max sizes), otherwise use the old IAMStreamConfig::SetFormat method (which, incidently, in the "new" cards returns S_OK but causes subsequent RenderStream calls interlace confirms I have pucka PAL. TTFN, Jon Jon, Where did you read about deprecation? IAMStreamConfig and its methods do not have such a notice http: / / msdn.microsoft.com / en-us should avoid using the values in this structure. Instead, use the AM_MEDIA_TYPE structure returned by IAMStreamConfig::GetFormat in the pmt parameter. " I would add that ". . avoid using the values in this else locating the output pin and try setting formats on the pin directly. And as IAMStreamConfig::GetFormat returns only the current or prefferred output I fail to see how it helps in any way with determining supported resolutions and formats. However do not use IAMStreamConfig::SetFormat as although not documented it seems any cards not bothering to fill in the formats for currently selected resolution. Roman keywords: Configuring, a, Video, Source, (Again) description: Having used IAMStreamConfig for years I'm now finding cards that I can't seem to set up
Questions about IAMStreamConfig C++ / VB Hey gang, Here is a snippet of what I am doing to retrieve video capture pin info: IAMStreamConfig* pStreamConfig = NULL; hr = pin-> QueryInterface(IID_IAMStreamConfig, (void * *) &pStreamConfig); if(SUCCEEDED(hr)) { int iCount = 0; int as represented in GraphEdit.exe). Anybody have any ideas? Thanks / Loren Win32 DirectX Video Discussions IAMStreamConfig (1) GetNumberOfCapabilities (1) IEnumMediaTypes (1) EnumMediaTypes (1) IStreamConfig (1) GetStreamCaps (1) QueryInterface (1) PStreamConfig (1 did attempt to implement the IEnumMediaTypes on the IPin interface with the same results as IAMStreamConfig (1 AMT) for this particular device. I am not sure what you meant by the mvpnews at riseoftheants dot com / / http: / / www.riseoftheants.com / mmx / faq.htm keywords: Questions, about, IAMStreamConfig description: Hey gang, Here is a snippet of what I am doing to retrieve video capture pin info: IAMStreamConfig* pStreamConfig = NULL; hr = pin-QueryInterface(IID_IAM
problem? Regards Dominik Win32 DirectX Video Discussions IAMFilterMiscFlags (1) Adobe (1) IAMCameraControl (1) IAMDeviceRemoval (1) IAMStreamConfig (1) IAMOpenProgress (1) Hello To add some information, maybe I'll change the question. How I can see that Skype and Adobe Flash are quering my device for following interfaces: IAMStreamConfig IAMOpenProgress IAMDeviceRemoval IPersistPropertyBag IAMExtDevice IMediaFilter IAMVideoCompression IBasicVideo IVideoWindow IBasicAudio IReferenceClock IMediaSeeking IMediaPosition IAMCameraControl From which i implement only IAMStreamConfig IPersistPropertyBag IMediaFilter This is enough for Skype to work but for web browser with Flash support IPersistStreamInit / IPersistStream, IAMFilterMiscFlags but it is not mandatory. 2. On the output pin: - IPin - IKsPropertySet (to indicate capture pin) - IAMStreamConfig Roman Ok This is ok now for me. I managed to have my filter working