PIBIO_SENSOR_EXPORT_SENSOR_DATA_FN回调函数 (winbio_adapter.h)

由 Windows 生物识别框架调用,以检索格式为标准 WINBIO_BIR 结构的最新捕获生物识别示例的副本。

语法

PIBIO_SENSOR_EXPORT_SENSOR_DATA_FN PibioSensorExportSensorDataFn;

HRESULT PibioSensorExportSensorDataFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PWINBIO_BIR *SampleBuffer,
  [out]     PSIZE_T SampleSize
)
{...}

参数

[in, out] Pipeline

指向与执行操作的生物识别单元关联的 WINBIO_PIPELINE 结构的指针。

[out] SampleBuffer

接收指向包含示例的 WINBIO_BIR 结构的指针的变量的地址。

[out] SampleSize

指向一个变量的指针,该变量接收 SampleBuffer 参数指定的缓冲区的大小(以字节为单位)。

返回值

如果函数成功,则返回S_OK。 如果函数失败,它必须返回以下 HRESULT 值之一来指示错误。

返回代码 说明
E_OUTOFMEMORY
没有足够的内存可用于创建 WINBIO_BIR 结构。
E_POINTER
强制指针参数为 NULL
WINBIO_E_INVALID_DEVICE_STATE
Pipeline 参数指向的 WINBIO_PIPELINE 结构的 SensorContext 成员为 NULL
WINBIO_E_NO_CAPTURE_DATA
不存在捕获数据。
E_NOTIMPL
目前未实现此方法。

注解

必须使用 HeapAlloc 函数从进程堆分配要在 SampleBuffer 参数中返回的缓冲区。 创建后,此缓冲区将成为 Windows 生物识别框架的 属性。 由于框架在完成使用此内存后会解除分配此内存,因此此函数的实现不得尝试解除分配缓冲区或保存指向它的指针。 通过不保存指针,可以阻止引擎适配器的其他部分在此函数返回后尝试使用该缓冲区。

示例

以下伪代码演示了此函数的一种可能实现。 该示例不编译。 必须根据自己的目的调整它。

//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterExportSensorData
//
// Purpose:
//      Retrieves a copy of the most recently captured biometric sample.
//      
// Parameters:
//      Pipeline     -  Pointer to a WINBIO_PIPELINE structure associated with 
//                      the biometric unit.
//      SampleBuffer -  Address of a variable that receives a pointer to a 
//                      WINBIO_BIR structure that contains the sample.
//      SampleSize   -  Pointer to a variable that receives the size, in bytes, 
//                      of the buffer specified by the SampleBuffer parameter.
//
static HRESULT
WINAPI
SensorAdapterExportSensorData(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PWINBIO_BIR *SampleBuffer,
    __out SIZE_T *SampleSize
    )
{
    PWINBIO_BIR sampleBuffer = NULL;

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(SampleBuffer) ||
        !ARGUMENT_PRESENT(SampleSize))
    {
        hr = E_POINTER;
        goto cleanup;
    }

    // Retrieve the context from the pipeline.
    PWINBIO_SENSOR_CONTEXT sensorContext = 
                 (PWINBIO_SENSOR_CONTEXT)Pipeline->SensorContext;

    // Verify the state of the pipeline.
    if (sensorContext == NULL)
    {
        return WINBIO_E_INVALID_DEVICE_STATE;
    }

    // Determine whether there is capture data to return.
    if (sensorContext->CaptureBuffer == NULL ||
        sensorContext->CaptureBuffer->CaptureData.Size == 0)
    {
        return WINBIO_E_NO_CAPTURE_DATA;
    }

    // Allocate a buffer, copy the data into it, and return
    // the buffer and buffer size to the caller.
    sampleBuffer = _AdapterAlloc(sensorContext->CaptureBuffer->CaptureData.Size);
    if (sampleBuffer == NULL)
    {
        return E_OUTOFMEMORY;
    }
    RtlCopyMemory(
        sampleBuffer, 
        sensorContext->CaptureBuffer->CaptureData.Data,
        sensorContext->CaptureBuffer->CaptureData.Size
        );

    *SampleBuffer = sampleBuffer;
    sampleBuffer = NULL;

    *SampleSize = Pipeline->SensorContext->CaptureBuffer->CaptureData.Size;  

    return S_OK;
}

要求

   
最低受支持的客户端 Windows 7 [仅限桌面应用]
最低受支持的服务器 Windows Server 2008 R2 [仅限桌面应用]
目标平台 Windows
标头 winbio_adapter.h (包括 Winbio_adapter.h)

另请参阅

插件函数