设置SetFormat()不成功,请高手看看!

死亡幻影 2006-08-03 01:27:20
程序代码:
IAMStreamConfig *pConfig;
HRESULT hr = m_pBuilder->FindInterface(&PIN_CATEGORY_PREVIEW, 0,m_pVCap,
IID_IAMStreamConfig, (void **)&pConfig);
if (FAILED(hr))
{
hr = m_pBuilder->FindInterface( &PIN_CATEGORY_CAPTURE, // Capture pin.
0, // Any media type.
m_pVCap, // Pointer to the capture filter.
IID_IAMStreamConfig, (void**)&pConfig);
if (FAILED(hr))
{
SAFE_RELEASE(pConfig);
return FALSE;
}
}

AM_MEDIA_TYPE *pmt;
int iNum;
int iSize;
VIDEO_STREAM_CONFIG_CAPS vscc;

pConfig->GetNumberOfCapabilities(&iNum,&iSize);

for(int i=0;i<iNum;i++)
{
pConfig->GetStreamCaps(i,&pmt,(BYTE*)&vscc);
if(FORMAT_VideoInfo == pmt->formattype
&& MEDIASUBTYPE_RGB24 == pmt->subtype)
{
VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmt->pbFormat;
if (pVih->bmiHeader.biWidth == _width
&& pVih->bmiHeader.biHeight == _height )
{
VideoStop();
HRESULT hrTmp = pConfig->SetFormat(pmt);
if (S_OK == hrTmp)
{
// resize our window to the default capture size
ResizeVideoWindow(HEADER(pmt->pbFormat)->biWidth,
ABS(HEADER(pmt->pbFormat)->biHeight));
VideoRun();
MyDeleteMediaType(pmt);
SAFE_RELEASE(pConfig);
return TRUE;
}
VideoRun();
}
}
}

MyDeleteMediaType(pmt);
SAFE_RELEASE(pConfig);

...全文
644 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyhzpk 2006-08-10
  • 打赏
  • 举报
回复
int iCount = 0, iSize = 0;
hr = pCfg->GetNumberOfCapabilities(&iCount, &iSize);
// AM_MEDIA_TYPE *pmtConfig2;
// Check the size to make sure we pass in the correct structure.
if (iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
{
// Use the video capabilities structure.
for (int iFormat = 0; iFormat < iCount; iFormat++)
{
VIDEO_STREAM_CONFIG_CAPS scc;
VIDEOINFOHEADER* pVih;
BITMAPINFOHEADER* pBih = NULL;
AM_MEDIA_TYPE *pmtConfig;
hr = pCfg->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc);
if (SUCCEEDED(hr))
{
/* Examine the format, and possibly use it. */
pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;
pBih = &pVih->bmiHeader;
int width = pBih->biWidth;
int height = pBih->biHeight;
if (width == m_iWidth && (height == m_iHeight || height == -m_iHeight))
{
pVih->AvgTimePerFrame = 10000000/m_nFrameRate;
hr = pCfg->SetFormat(pmtConfig);
// Delete the media type when you are done.
DeleteMediaType(pmtConfig);
pmtConfig = NULL;
hr = pCfg->GetFormat(&pmtConfig);
pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;
pBih = &pVih->bmiHeader;
DeleteMediaType(pmtConfig);
break;
}
}
}

2,542

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧