Create an instance of the ltmmCapture class. This is accomplished using the Win32 CoCreateInstance function, as follows:
IltmmCapture* pCapture;
CoCreateInstance(&CLSID_ltmmCapture, NULL, CLSCTX_INPROC_SERVER,&IID_IltmmCapture,(void**) &pCapture);
IltmmCapture* pCapture;
CoCreateInstance(&CLSID_ltmmCapture, NULL, CLSCTX_INPROC_SERVER,&IID_IltmmCapture, (void**) &pCapture);
Define the notification window, which receives the capture status notifications:
HWND hwndNotify;
#define WM_CAPTURENOTIFY (WM_USER + 1000)
IltmmCapture_SetNotifyWindow(pCapture, (long) hwndNotify, WM_CAPTURENOTIFY);
HWND hwndNotify;
#define WM_CAPTURENOTIFY (WM_USER + 1000)
pCapture->SetNotifyWindow((long) hwndNotify, WM_CAPTURENOTIFY);
The above code instructs the capture object to send WM_CAPTURENOTIFY messages to the window procedure of hwndNotify. The wParam parameter of the window message will contain the notification code.
Note
A capture can be accomplished without using a notification window, but the user would be required to poll the objects state to determine when the capture has finished.
Define a frame window for the video preview:
HWND hwndFrame;
IltmmCapture_put_VideoWindowFrame(pCapture, (long) hwndFrame);
HWND hwndFrame;
pCapture->put_VideoWindowFrame((long) hwndFrame);
The user is required to create the window that serves as the video frame. ltmmCapture will subclass this window, so there is no need to forward any messages to the ltmmCapture object. By default, ltmmCapture will automatically maximize the video within the frame window. The video will automatically resize when the frame window size changes.
Note
The notification window and the video frame window can be the same.
Set the Target file:
BSTR bstr;
bstr = SysAllocString(L"c:\\captured.asf");
IltmmCapture_put_TargetFile(pCapture, bstr);
SysFreeString(bstr);
BSTR bstr;
::SysAllocString(L"c:\\captured.asf");
pCapture->put_TargetFile(bstr);
::SysFreeString(bstr);
Set the video device:
IltmmDevices* devices;
IltmmCapture_get_VideoDevices(pCapture, &devices);
IltmmDevices_put_Selection(devices, 0);
IltmmDevices_Release(devices);
IltmmDevices* devices;
pCapture->get_VideoDevices(&devices);
devices->put_Selection(0);
devices->Release();
Set the audio device:
HIltmmDevices* devices;
IltmmCapture_get_AudioDevices(pCapture, &devices);
IltmmDevices_put_Selection(devices, 0);
IltmmDevices_Release(devices);
IltmmDevices* devices;
pCapture->get_AudioDevices(&devices);
devices->put_Selection(0);
devices->Release();
Set the target format:
IltmmCapture_put_TargetFormat(pCapture, ltmmCapture_TargetFormat_Asf);
pCapture->put_TargetFormat(ltmmCapture_TargetFormat_Asf);
When you want to start capturing, call the StartCapture function as follows:
IltmmCapture_StartCapture(pCapture, ltmmCapture_Mode_VideoAndAudio)
pCapture->StartCapture(ltmmCapture_Mode_VideoAndAudio);
When you want to stop capturing, call the StopCapture function as follows:
IltmmCapture_StopCapture(pCapture);
pCapture->StopCapture();
Release the capture object (and all active objects) when you are done.
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document