IWMEncDeviceControlPlugin::put_StopLatency
The put_StopLatency method specifies the number of frames to play after encoding.
Syntax
HRESULT put_StopLatency(
long lLatency
);
Parameters
lLatency
[in] A long that indicates the stop latency value in frames.
Return Values
If the method succeeds, it returns S_OK. If it fails, it supports the IErrorInfo interface and returns an HRESULT error code.
Remarks
This value specifies the number of frames, relative to the mark-out time, that you want encoding to continue, which ensures that the last frame of your clip is captured before shutting down the device. For example, sometimes on certain systems, the device stops a little earlier than the mark-out time, so you can indicate a stop latency value to compensate and ensure that all frames are captured.
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"
// Declare variables.
HRESULT hr;
IWMEncoder2* pEncoder;
IWMEncSource* pSrcAud;
IWMEncSource* pSrcVid;
IWMEncDeviceControlCollection* pDCColl;
IWMEncDeviceControl* pDControl;
IWMEncDeviceControlPlugin* pDCPlugin;
// 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")); // Replace the device name
}
// 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);
}
if ( SUCCEEDED( hr ) )
{
hr = pDCPlugin->put_StopLatency(3);
}
// 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 ( pEncoder )
{
pEncoder->Release();
pEncoder = NULL;
}
Requirements
Header: wmdevctl.h
Library: wmdevctl.dll
See Also