المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Why moniker?



C++ Programming
03-10-2013, 11:22 PM
This is not a programming "how to", just looking for short explanation/ verification of usage of "moniker".
My basic understanding is that it's function is similar to DOS path, allowing access to an object.
Now it this particular sequence I do not get the enumeration, followed by getting the first moniker and bind it to , I guess filter.
This is part of my code to get data from USB camera and I am still learning how to put all this COM and DirectShow stuff together.
This is what I understand so far – the enumeration identify the “object class” in my case USB cameras and than I can select which one using the Next in loop ( this snippet gets only the first one) and than let the filter “connect / bind “ to the selected camera.
This is still plain COM code , no DirectShow.
Am I right so far?
Thanks for reading.
Cheers Vaclav


TRACE("\nObtain a category enumerator by calling ICreateDevEnum::CreateClassEnumerator with the CLSID of the desired category");
IEnumMoniker* cams = 0;
hr = devs?devs->CreateClassEnumerator (CLSID_VideoInputDeviceCategory, &cams, 0)http://www.barakasoft.com/script/Forums/Images/smiley_redface.gif ;
if (FAILED(hr))
{
TRACE("\nFailed devs->CreateClassEnumerator (CLSID_VideoInputDeviceCategory");
return;
}
ASSERT(cams); // redundant

TRACE("\nget first found capture device (webcam?)");
// moniker - similar to DOS path to get info on object
IMoniker* mon = 0;
hr = cams->Next (1,&mon,0); // get first found capture device (webcam?)
if (FAILED(hr))
{
TRACE("\nFailed get first found capture device (webcam?)");
return;
}
ASSERT( mon);

TRACE("\nBind moniker ( mon) to object ( cam)");
IBaseFilter* cam = 0;
hr = mon->BindToObject(0,0,IID_IBaseFilter, (void**)&cam);
if (FAILED(hr))
{
TRACE("\nFailed Bind moniter ( mon) to object ( cam)");
return;
}
ASSERT( cam);