调出属性页进行设置 用DXshow的例子AMCAP的代码 else if(id - MENU_DIALOG0 == gcap.iVCapCapturePinDialogPos) { // You can change this pin's output format in these dialogs. // If the capture pin is already connected to somebody who's // fussy about the connection type, that may prevent using // this dialog(!) because the filter it's connected to might not // allow reconnecting to a new format. (EG: you switch from RGB // to some compressed type, and need to pull in a decoder) // I need to tear down the graph downstream of the // capture filter before bringing up these dialogs. // In any case, the graph must be STOPPED when calling them. if(gcap.fWantPreview) StopPreview(); // make sure graph is stopped // The capture pin that we are trying to set the format on is connected if // one of these variable is set to TRUE. The pin should be disconnected // for the dialog to work properly. if(gcap.fCaptureGraphBuilt || gcap.fPreviewGraphBuilt) { DbgLog((LOG_TRACE,1,TEXT("Tear down graph for dialog"))); TearDownGraph(); // graph could prevent dialog working } IAMStreamConfig *pSC; hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Interleaved, gcap.pVCap, IID_IAMStreamConfig, (void **)&pSC); if(hr != NOERROR) hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, gcap.pVCap, IID_IAMStreamConfig, (void **)&pSC); ISpecifyPropertyPages *pSpec; CAUUID cauuid; hr = pSC->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpec); if(hr == S_OK) { hr = pSpec->GetPages(&cauuid); hr = OleCreatePropertyFrame(ghwndApp, 30, 30, NULL, 1, (IUnknown **)&pSC, cauuid.cElems, (GUID *)cauuid.pElems, 0, 0, NULL); // !!! What if changing output formats couldn't reconnect // and the graph is broken? Shouldn't be possible... if(gcap.pVSC) { AM_MEDIA_TYPE *pmt; // get format being used NOW hr = gcap.pVSC->GetFormat(&pmt); // DV capture does not use a VIDEOINFOHEADER if(hr == NOERROR) { if(pmt->formattype == FORMAT_VideoInfo) { // resize our window to the new capture size ResizeWindow(HEADER(pmt->pbFormat)->biWidth, abs(HEADER(pmt->pbFormat)->biHeight)); } DeleteMediaType(pmt); } } CoTaskMemFree(cauuid.pElems); pSpec->Release(); } pSC->Release(); if(gcap.fWantPreview) { BuildPreviewGraph(); StartPreview(); } } else if(id - MENU_DIALOG0 == gcap.iVCapPreviewPinDialogPos) { // this dialog may not work if the preview pin is connected // already, because the downstream filter may reject a format // change, so we better kill the graph. (EG: We switch from // capturing RGB to some compressed fmt, and need to pull in // a decompressor) if(gcap.fWantPreview) { StopPreview(); TearDownGraph(); } IAMStreamConfig *pSC; // This dialog changes the preview format, so it might affect // the format being drawn. Our app's window size is taken // from the size of the capture pin's video, not the preview // pin, so changing that here won't have any effect. All in all, // this probably won't be a terribly useful dialog in this app. hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Interleaved, gcap.pVCap, IID_IAMStreamConfig, (void **)&pSC); if (hr != NOERROR) { hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, gcap.pVCap, IID_IAMStreamConfig, (void **)&pSC); } ISpecifyPropertyPages *pSpec; CAUUID cauuid; hr = pSC->QueryInterface(IID_ISpecifyPropertyPages, (void **)&pSpec);
CComQIPtr< IVideoWindow, &IID_IVideoWindow > pWindow
pWindow->put_Left( 0 );
pWindow->put_Top( 0 );
pWindow->put_Width(xxwide);
pWindow->put_Height(xxhigh);
用DXshow的例子AMCAP的代码 else if(id - MENU_DIALOG0 == gcap.iVCapCapturePinDialogPos)
{
// You can change this pin's output format in these dialogs.
// If the capture pin is already connected to somebody who's
// fussy about the connection type, that may prevent using
// this dialog(!) because the filter it's connected to might not
// allow reconnecting to a new format. (EG: you switch from RGB
// to some compressed type, and need to pull in a decoder)
// I need to tear down the graph downstream of the
// capture filter before bringing up these dialogs.
// In any case, the graph must be STOPPED when calling them.
if(gcap.fWantPreview)
StopPreview(); // make sure graph is stopped // The capture pin that we are trying to set the format on is connected if
// one of these variable is set to TRUE. The pin should be disconnected
// for the dialog to work properly.
if(gcap.fCaptureGraphBuilt || gcap.fPreviewGraphBuilt)
{
DbgLog((LOG_TRACE,1,TEXT("Tear down graph for dialog")));
TearDownGraph(); // graph could prevent dialog working
} IAMStreamConfig *pSC;
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Interleaved, gcap.pVCap,
IID_IAMStreamConfig, (void **)&pSC); if(hr != NOERROR)
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, gcap.pVCap,
IID_IAMStreamConfig, (void **)&pSC); ISpecifyPropertyPages *pSpec;
CAUUID cauuid; hr = pSC->QueryInterface(IID_ISpecifyPropertyPages,
(void **)&pSpec); if(hr == S_OK)
{
hr = pSpec->GetPages(&cauuid);
hr = OleCreatePropertyFrame(ghwndApp, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL); // !!! What if changing output formats couldn't reconnect
// and the graph is broken? Shouldn't be possible... if(gcap.pVSC)
{
AM_MEDIA_TYPE *pmt;
// get format being used NOW
hr = gcap.pVSC->GetFormat(&pmt); // DV capture does not use a VIDEOINFOHEADER
if(hr == NOERROR)
{
if(pmt->formattype == FORMAT_VideoInfo)
{
// resize our window to the new capture size
ResizeWindow(HEADER(pmt->pbFormat)->biWidth,
abs(HEADER(pmt->pbFormat)->biHeight));
}
DeleteMediaType(pmt);
}
} CoTaskMemFree(cauuid.pElems);
pSpec->Release();
} pSC->Release();
if(gcap.fWantPreview)
{
BuildPreviewGraph();
StartPreview();
}
}
else if(id - MENU_DIALOG0 == gcap.iVCapPreviewPinDialogPos)
{
// this dialog may not work if the preview pin is connected
// already, because the downstream filter may reject a format
// change, so we better kill the graph. (EG: We switch from
// capturing RGB to some compressed fmt, and need to pull in
// a decompressor)
if(gcap.fWantPreview)
{
StopPreview();
TearDownGraph();
} IAMStreamConfig *pSC; // This dialog changes the preview format, so it might affect
// the format being drawn. Our app's window size is taken
// from the size of the capture pin's video, not the preview
// pin, so changing that here won't have any effect. All in all,
// this probably won't be a terribly useful dialog in this app.
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Interleaved, gcap.pVCap,
IID_IAMStreamConfig, (void **)&pSC);
if (hr != NOERROR)
{
hr = gcap.pBuilder->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, gcap.pVCap,
IID_IAMStreamConfig, (void **)&pSC);
} ISpecifyPropertyPages *pSpec;
CAUUID cauuid; hr = pSC->QueryInterface(IID_ISpecifyPropertyPages,
(void **)&pSpec);
if(hr == S_OK)
{
hr = pSpec->GetPages(&cauuid); hr = OleCreatePropertyFrame(ghwndApp, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL); CoTaskMemFree(cauuid.pElems);
pSpec->Release();
} pSC->Release();
if(gcap.fWantPreview)
{
BuildPreviewGraph();
StartPreview();
}
}
{
hr = pBuild->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,IID_IAMStreamConfig,(void **)&pConfig);
if(hr == NOERROR)
AfxMessageBox("load config filter succeed!");
else
{
AfxMessageBox("load config filter failed!");
return;
}
}3.设置参数(取原来的参数,修改想要改变的部分)AM_MEDIA_TYPE * mmt;pConfig->GetFormat(&mmt); //取得默认参数VIDEOINFOHEADER * vvih = (VIDEOINFOHEADER*) mmt->pbFormat;AM_MEDIA_TYPE * pmt = mmt;VIDEOINFOHEADER * pvih = (VIDEOINFOHEADER*) pmt->pbFormat;pvih->bmiHeader.biHeight=288; //修改采集视频的高为288
pvih->bmiHeader.biWidth=352; //修改采集视频的宽为352pmt->pbFormat = (unsigned char *) pvih;pConfig->SetFormat(pmt); //重新设置参数这样,DirectShow采集的视频的Data Flow被设置为宽为352,高为288..