Descartes56
Programmer
Hello,I want to change the webcamformat from 352x288 to 640x480 on the Logitech messenger, but the source dont work? thanks for helping me.
ps: amcap.cpp from DX SDK works fine.
my source:
//----------------------------------------------------------------
// void CamFormat()
// desc : set size of video
//----------------------------------------------------------------
void CamFormat()
{
HRESULT hr;
CComPtr<ICaptureGraphBuilder2> graphBuilder2_;
hr = graphBuilder2_.CoCreateInstance( CLSID_CaptureGraphBuilder2 );
IAMStreamConfig *pSC;
// Default Cap device
IBaseFilter *pCap;
GetDefaultCapDevice( &pCap );
graphBuilder2_->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,
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(hDlg, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL);
CoTaskMemFree(cauuid.pElems);
pSpec->Release();
}
pSC->Release();
} // end CamFormat.
Compile no errors,
The error is in this part of the code:
==============================================================
hr = OleCreatePropertyFrame(hDlg, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL);
==============================================================
error while debug
Unhandled exception at 0x583e7666 in Golem.exe: 0xC0000005: Access violation reading location 0x00000000.
=============================================================================
when I use // Default Cap device IBaseFilter *pCap; GetDefaultCapDevice( &pCap ); (IUnknown **)&pCap,in place of (IUnknown **)&pSC, i have the menu from the webcam but i cannot acces the values in the dialog box..I am ussing the source from Amcap.cpp from the DX 9.0 as example, work fine but not in my source. Thanks for helping me.
ps: source from DX 9.0 AmCap.cpp works good.
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();
ps: amcap.cpp from DX SDK works fine.
my source:
//----------------------------------------------------------------
// void CamFormat()
// desc : set size of video
//----------------------------------------------------------------
void CamFormat()
{
HRESULT hr;
CComPtr<ICaptureGraphBuilder2> graphBuilder2_;
hr = graphBuilder2_.CoCreateInstance( CLSID_CaptureGraphBuilder2 );
IAMStreamConfig *pSC;
// Default Cap device
IBaseFilter *pCap;
GetDefaultCapDevice( &pCap );
graphBuilder2_->FindInterface(&PIN_CATEGORY_CAPTURE,&MEDIATYPE_Video,pCap,
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(hDlg, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL);
CoTaskMemFree(cauuid.pElems);
pSpec->Release();
}
pSC->Release();
} // end CamFormat.
Compile no errors,
The error is in this part of the code:
==============================================================
hr = OleCreatePropertyFrame(hDlg, 30, 30, NULL, 1,
(IUnknown **)&pSC, cauuid.cElems,
(GUID *)cauuid.pElems, 0, 0, NULL);
==============================================================
error while debug
Unhandled exception at 0x583e7666 in Golem.exe: 0xC0000005: Access violation reading location 0x00000000.
=============================================================================
when I use // Default Cap device IBaseFilter *pCap; GetDefaultCapDevice( &pCap ); (IUnknown **)&pCap,in place of (IUnknown **)&pSC, i have the menu from the webcam but i cannot acces the values in the dialog box..I am ussing the source from Amcap.cpp from the DX 9.0 as example, work fine but not in my source. Thanks for helping me.
ps: source from DX 9.0 AmCap.cpp works good.
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();