IWMEncDeviceControlCollection::Add
![]() |
The Add method adds a device control object to the collection.
Syntax
HRESULT Add(
IWMEncDeviceControl** ppDeviceControl
);
Parameters
ppDeviceControl
[out] Pointer to a pointer to an IWMEncDeviceControl object.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
| Return code | Number | Description |
| E_POINTER | 0x80004003 | The indirect pointer to the device control object is NULL. |
Remarks
Once you retrieve an IWMEncDeviceControl interface, use the IWMEncDeviceControl::SetInput method to specify the device to use.
Example Code
// Include libraries.#include <windows.h>
#include <atlbase.h>
#include <comdef.h>
#include "C:\WMSDK\WMEncSDK9\include\wmencode.h"
#include "C:\WMSDK\WMEncSDK9\include\wmdevctl.h"
#include <conio.h> // for kbhit()
// Declare variables.
HRESULT hr;
IWMEncoder2* pEncoder;
IWMEncSource* pSrcAud;
IWMEncSource* pSrcVid;
IWMEncDeviceControlCollection* pDCColl;
IWMEncDeviceControl* pDControl;
IWMEncDeviceControlPlugin* pDCPlugin;
IWMEncEditDecisionList* pEDList;
IWMEncEditDecisionData* pEDData;
CComBSTR bstrName = NULL;
long lCount;
int i;
// Initialize the COM library and retrieve a pointer
// to an IWMEncoder interface.
hr = CoInitialize(NULL);
if ( SUCCEEDED( hr ) )
{
hr = CoCreateInstance(CLSID_WMEncoder,
NULL,
CLSCTX_INPROC_SERVER,
IID_IWMEncoder2,
(void**) &pEncoder);
}
// Configure the encoding session, including the sources, profile,
// and output file.
// Add the device as the audio source and video source.
if ( SUCCEEDED( hr ) )
{
hr = pSrcAud->SetInput(CComBSTR("Device://DEVICENAME"));
}
if ( SUCCEEDED( hr ) )
{
hr = pSrcVid->SetInput(CComBSTR("Device://DEVICENAME"));
}
// Retrieve the device control collection, then add a device to it.
if ( SUCCEEDED( hr ) )
{
hr = pSrcGrp2->get_DeviceControlCollection(&pDCColl);
}
if ( SUCCEEDED( hr ) )
{
hr = pDCColl->Add(&pDControl);
}
if ( SUCCEEDED( hr ) )
{
hr = pDControl->SetInput(CComBSTR("DeviceControl://DEVICENAME"));
}
// Initialize the encoding session. if ( SUCCEEDED( hr ) )
{
hr = pEncoder->PrepareToEncode(VARIANT_TRUE);
}
// Get the plug-in from the device. if ( SUCCEEDED( hr ) )
{
hr = pDControl->GetDeviceControlPlugin((IUnknown**)&pDCPlugin);
}
// Retrieve a IWMEncEditDecisionList interface from the device control plug-in.
if ( SUCCEEDED( hr ) )
{
hr = pDCPlugin->get_EditDecisionList(&pEDList);
}
// Create an EDL entry.
if ( SUCCEEDED( hr ) )
{
hr = pEDList->Add(&pEDData);
}
// Add attributes to the EDL entry specifying mark-in, mark-out,
// tape ID, and description information.
if ( SUCCEEDED( hr ) )
{
hr = pEDData->Add(CComBSTR("MarkIn"), CComVariant(262295));
}
if ( SUCCEEDED( hr ) )
{
hr = pEDData->Add(CComBSTR("MarkOut"), CComVariant(267268));
}
if ( SUCCEEDED( hr ) )
{
hr = pEDData->Add(CComBSTR("TapeID"), CComVariant("A"));
}
if ( SUCCEEDED( hr ) )
{
hr = pEDData->Add(CComBSTR("Description"), CComVariant("Scene 1"));
}
// Wait for the user to press a key to start encoding.
printf("Press a key to start encoding.");
// Wait for a key press.
while(!kbhit())
_asm nop;
// Start encoding.
if ( SUCCEEDED( hr ) )
{
hr = pEncoder->Start();
}
// Wait for the user to press a key to stop encoding.
printf("Press a key to stop encoding.");
// Wait for a key press.
while(!kbhit())
_asm nop;
// Stop encoding.
if ( SUCCEEDED( hr ) )
{
hr = pEncoder->Stop();
}
// Release pointers.
if ( pSrcAud )
{
pSrcAud->Release();
pSrcAud = NULL;
}
if ( pSrcVid )
{
pSrcVid->Release();
pSrcVid = NULL;
}
if ( pDCColl )
{
pDCColl->Release();
pDCColl = NULL;
}
if ( pDControl )
{
pDControl->Release();
pDControl = NULL;
}
if ( pDCPlugin )
{
pDCPlugin->Release();
pDCPlugin = NULL;
}
if ( pEDList )
{
pEDList->Release();
pEDList = NULL;
}
if ( pEDData )
{
pEDData->Release();
pEDData = NULL;
}
if ( pEncoder )
{
pEncoder->Release();
pEncoder = NULL;
}
Requirements
Header: wmdevctl.h
Library: wmdevctl.dll
See Also
.gif)