3,248
社区成员
发帖
与我相关
我的任务
分享
void CVideoCaptureFilter::SetResolution(void)
{
if (mDevice && mFilter)
{
IAMAnalogVideoDecoder * pDecoder = GetAnalogDecoder();
if (pDecoder) pDecoder->put_TVFormat(mDevice->GetVideoResolution());
}
}
IAMAnalogVideoDecoder * CVideoCaptureFilter::GetAnalogDecoder(void)
{
IAMAnalogVideoDecoder * pDecoder = NULL;
if (mFilter)
{
mFilter->QueryInterface(IID_IAMAnalogVideoDecoder, (void**)&pDecoder);
if (pDecoder)
{
// keep no outstanding reference count
pDecoder->Release();
return pDecoder;
}
}
return NULL;
}IUnknown::QueryInterface:
Remarks:
If the application does not need to use the interface retrieved by a call to this method,
it must call the IUnknown::Release method for that interface to free it.
The IUnknown::QueryInterface method makes it possible to extend objects without interfering with functionality.
IUnknown::QueryInterface
Determines whether the object supports a particular COM interface. If it does, the system increases the object's reference count, and the application can use that interface immediately.
If the application does not need to use the interface retrieved by a call to this method, it must call the IUnknown::Release method for that interface to free it.
#include <Strmif.h>
#include <assert.h>
#include <dshow.h>
#define null 0
int main(int argc, char *argv[])
{
IGraphBuilder * mFilter = NULL;
IBaseFilter * pDecoder = NULL;
CoInitialize(NULL);
assert(SUCCEEDED(CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_ALL, IID_IGraphBuilder, (void **)&mFilter)));
assert(2 == mFilter->AddRef());
assert(3 == mFilter->AddRef());
assert(2 == mFilter->Release());
assert(SUCCEEDED(mFilter->QueryInterface(IID_IBasicVideo, (void**)&pDecoder)));
assert(4 == mFilter->AddRef());
assert(5 == pDecoder->AddRef());
assert(6 == mFilter->AddRef());
assert(5 == mFilter->Release());
assert(4 == pDecoder->Release());
assert(3 == mFilter->Release());
assert(2 == mFilter->Release());
assert(1 == pDecoder->Release());
assert(null == pDecoder->Release());
//assert(1 == mFilter->AddRef()); ///< Failed
getchar();
}