IAMStreamConfig Interface
Top  Previous  Next

Description

Provides an ability to set stream formats and to find out what types of formats the Capture Pin can be connected to.


Methods

HRESULT GetFormat( AM_MEDIA_TYPE **pmt
)
Retrieves the video stream's format.  
.  

HRESULT SetFormat( AM_MEDIA_TYPE
*pmt )
Sets the video stream's format.  

HRESULT GetNumberOfCapabilities( int
*piCount, int *piSize )
Retrieves the number of stream capabilities (video modes) available for the current camera.  
 
HRESULT GetStreamCaps( int
iIndex, AM_MEDIA_TYPE **pmt, BYTE *pSCC )
Obtains video capabilities of a stream.  


Parameters

pmt  
[in/out] Pointer to a AM_MEDIA_TYPE structure.  
piCount  
[out] Pointer to the number of VIDEO_STREAM_CONFIG_CAPS (video modes) supported.  
piSize  
[out] Pointer to the size of the VIDEO_STREAM_CONFIG_CAPS structure.  
iIndex  
[in] Index to the desired media type and capability pair.  
pSCC  
[out] Pointer to a stream configuration structure. The structure is defined as follows:  
 
typedef struct _VIDEO_STREAM_CONFIG_CAPS  
{  
GUID guid;         // set to MEDIATYPE_Video  
ULONG VideoStandard;      // set to AnalogVideo_None     
SIZE InputSize;         // maximum image size  
SIZE MinCroppingSize;      // minimum ROI size (Format 7)  
SIZE MaxCroppingSize;      // maximum ROI size (Format 7)  
int CropGranularityX;      // horizontal size granularity (Format 7)  
int CropGranularityY;      // vertical size granularity (Format 7)  
int CropAlignX;         // horizontal offset granularity (Format 7)  
int CropAlignY;         // vertical offset granularity (Format 7)  
SIZE MinOutputSize;      // same as MinCroppingSize  
SIZE MaxOutputSize;      // same as MaxCroppingSize  
int OutputGranularityX;      // set to zero  
int OutputGranularityY;      // set to zero  
int StretchTapsX;         // set to zero  
int StretchTapsY;         // set to zero  
int ShrinkTapsX;         // set to zero  
int ShrinkTapsY;         // set to zero  
LONGLONG MinFrameInterval;   // minimum frame interval in 100 nanoseconds  
LONGLONG MaxFrameInterval;   // maximum frame interval in 100 nanoseconds  
LONG MinBitsPerSecond;      // minimum bandwidth     
LONG MaxBitsPerSecond;      // maximum bandwidth  
} VIDEO_STREAM_CONFIG_CAPS;  
 
 
Return Values

S_OK  
Success  
E_FAIL  
Failure.  
E_INVALIDARG  
Invalid argument.  
 

Example


This C++ code request a pointer to IAMStreamConfig interface, collects available video modes from the video capture filter, finds a Format 7 mode with a horizontal resolution of 1024, sets ROI to 600x400 and switches the camera to this mode.

IAMStreamConfig* pSC;
if( pFilter->QueryInterface( IID_IAMStreamConfig, (void **)&pSC) == S_OK )
{
int iCount, iSize;
VIDEO_STREAM_CONFIG_CAPS caps;
pSC->GetNumberOfCapabilities(&iCount, &iSize);
for(int i=0;i<iCount;i++)
{
AM_MEDIA_TYPE *pmt = NULL;
if( pSC->GetStreamCaps(i, &pmt, (BYTE*)&caps) == S_OK )
{
if( caps.MaxOutputSize.cx == 1024 && caps.MaxOutputSize.cx!=caps.MinOutputSize)
{
   ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcSource.left=0;
   ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcSource.top=0;
   ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcSource.right=600;
   ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcSource.bottom=400;
   pConfig->SetFormat(pmt);
}
DeleteMediaType (pmt);
break;
}
DeleteMediaType (pmt);   
}
}      
 
 
Remarks

Use the GetNumberOfCapabilities and GetStreamCaps methods to collect the information about available video modes. The information in VIDEO_STREAM_CONFIG_CAPS structures is particularly usefull for specifying a Region of Interest (ROI) in partial scan modes (Format 7). In this case, MinCroppingSize and MaxCroppingSize fields define the range of possible ROI sizes, while CropGranularity and CropAlign define the ROI size and offset granularity. Modify the rcSource and AvgTimePerFrame fields of the VIDEOINFOHEADER block of a AM_MEDIA_TYPE structure in the SetFormat method to set up a specific ROI and frame rate.
Refer to Microsoft DirectX SDK documentation for more details.