IEnumPins *pEnumPins;
pCap->EnumPins(&pEnumPins);
IPin *pPin;
PIN_DIRECTION PinDir;
while(pEnumPins->Next(1, &pPin, 0)==S_OK) {
pPin->QueryDirection(&PinDir);
if(PinDir == PINDIR_OUTPUT) {
CComQIPtr pAMSC (pPin);
int iCount, iSize;
VIDEO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE *pmt;
pAMSC->GetNumberOfCapabilities(&iCount, &iSize);
if(sizeof(scc) != iSize)
{
// This is not the structure we were expecting.
return E_FAIL;
}
// Get the first format.
hr = pAMSC->GetStreamCaps(0, &pmt, reinterpret_cast(&scc));
if(hr == S_OK)
{
pmt->subtype = MEDIASUBTYPE_RGB24;
VIDEOINFOHEADER *vih = reinterpret_cast(pmt->pbFormat);
vih->bmiHeader.biWidth = 640;
vih->bmiHeader.biHeight = 480;
vih->bmiHeader.biSizeImage = 640*480*3;
pmt->lSampleSize = 640*480*3;
pAMSC->SetFormat(pmt);
}
break;
}
}
IAMStreamConfig
- 웹캠 영상 사이즈 640x480 으로 변경하기 2009.02.13
- IAMStreamConfig 인터페이스 사용 예 2009.02.13
웹캠 영상 사이즈 640x480 으로 변경하기
2009. 2. 13. 13:07
IAMStreamConfig 인터페이스 사용 예
2009. 2. 13. 10:42
IEnumPins *pEnumPins;
pFilterMP3Encoder->EnumPins(&pEnumPins);
IPin *pPin;
PIN_DIRECTION PinDir;
while(pEnumPins->Next(1, &pPin, 0)==S_OK) {
pPin->QueryDirection(&PinDir);
if(PinDir == PINDIR_OUTPUT) {
CComQIPtr pAMSC (pPin);
int iCount, iSize;
AUDIO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE *pmt;
pAMSC->GetNumberOfCapabilities(&iCount, &iSize);
if (sizeof(scc) != iSize)
{
// This is not the structure we were expecting.
return E_FAIL;
}
// Get the first format.
hr = pAMSC->GetStreamCaps(0, &pmt, reinterpret_cast<byte*>(&scc));
if (hr == S_OK)
{
if (pmt->formattype == FORMAT_WaveFormatEx &&
pmt->subtype == FORMAT_DYNA_MPEG3)
{
// Modify the format block.
WAVEFORMATEX *wave =
reinterpret_cast<waveformatex*>(pmt->pbFormat);
wave->nSamplesPerSec = 22050;
// Now set the format.
hr = pAMSC->SetFormat(pmt);
if (FAILED(hr))
{
AfxMessageBox("SetFormat Failed");
}
DeleteMediaType(pmt);
}
}
break;
}
}