Setting DirectShow Filter options by using IAMStreamConfig interface
Posted: 20 January 2010 01:36 PM   [ Ignore ]
New Member
Rank
Total Posts:  4
Joined  2010-01-19

I would like to be able to set the DS Filter by the IAMStreamConfig. 

First thing I noticed when enumerating the device.  You return RGB as 32 bit value.  So I guess this is RGBA.  Most web cams today do this as 24bit RGB value.  So some software might need changed to select this when looking for RGB.

After I iterate and find a matching frame size…I set it by calling IAMStreamConfig::SetFormat().  This appears to work as IAMStreamConfig::GetFormat() shows the new values.  But my app still receives a default 640 x 480 frame size.  Not the 320 x 240 I found. 

Is this expected.  Is there another approach to get this working in DirectShow? 

Is there a way I can hack the default to play around with the different settings.  I checked out the SDK, and it is not clear to me that I can set this value when using DirectShow here.  I am using C/C++ if that matters. 

Thx,
Matt

Profile
 
 
Posted: 21 January 2010 06:54 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17
tribalmatt - 20 January 2010 01:36 PM

I would like to be able to set the DS Filter by the IAMStreamConfig. 

First thing I noticed when enumerating the device.  You return RGB as 32 bit value.  So I guess this is RGBA.  Most web cams today do this as 24bit RGB value.  So some software might need changed to select this when looking for RGB.

After I iterate and find a matching frame size…I set it by calling IAMStreamConfig::SetFormat().  This appears to work as IAMStreamConfig::GetFormat() shows the new values.  But my app still receives a default 640 x 480 frame size.  Not the 320 x 240 I found. 

Is this expected.  Is there another approach to get this working in DirectShow? 

Is there a way I can hack the default to play around with the different settings.  I checked out the SDK, and it is not clear to me that I can set this value when using DirectShow here.  I am using C/C++ if that matters. 

Thx,
Matt

Matt,

Do you have a piece of your code that sets the format? I can take a look and test it.

AlexP

Profile
 
 
Posted: 22 January 2010 02:29 AM   [ Ignore ]   [ # 2 ]
Jr. Member
RankRank
Total Posts:  49
Joined  2010-01-15

Matt:

Are you checking caps for proper size before setting format?
Anyway,
code below works perfectly on my system (replace m_SizeX,m_SizeY with your sizes):

...
        
VIDEO_STREAM_CONFIG_CAPS caps;
        
pSC->GetNumberOfCapabilities(&iCount;, &iSize;);
        for (
ind 0ind iCountind++) {
            pSC
->GetStreamCaps(ind, &pmt;, (BYTE *)∩︀);
            if((
caps.guid == FORMAT_VideoInfo)&&
               (
caps.InputSize.cx == m_SizeX) &&
               (
caps.InputSize.cy == m_SizeY) )
            
{
                VIDEOINFOHEADER 
*pvi = (VIDEOINFOHEADER *)pmt->pbFormat;
                
pvi->AvgTimePerFrame caps.MinFrameInterval+1;            // <= you might need to modify here for lower framerate
                
pvi->bmiHeader.biWidth m_SizeX;
                
pvi->bmiHeader.biHeight m_SizeY;
                
pvi->bmiHeader.biSizeImage DIBSIZE(pvi->bmiHeader);
                 
pmt->lSampleSize pvi->bmiHeader.biSizeImage;
                
pSC->SetFormat(pmt);
                
DeleteMediaType(pmt);
                break; 
// found default setup, quit the loop
            
}
            DeleteMediaType
(pmt);
        
}
... 
Profile
 
 
 
 


RSS 2.0     Atom Feed