PIBIO_SENSOR_FINISH_CAPTURE_FN função de retorno de chamada (winbio_adapter.h)

Chamado pela Estrutura Biométrica do Windows para aguardar a conclusão de uma operação de captura iniciada pela função SensorAdapterStartCapture .

Sintaxe

PIBIO_SENSOR_FINISH_CAPTURE_FN PibioSensorFinishCaptureFn;

HRESULT PibioSensorFinishCaptureFn(
  [in, out] PWINBIO_PIPELINE Pipeline,
  [out]     PWINBIO_REJECT_DETAIL RejectDetail
)
{...}

Parâmetros

[in, out] Pipeline

Ponteiro para uma estrutura WINBIO_PIPELINE associada à unidade biométrica que executa a operação.

[out] RejectDetail

Ponteiro para um valor WINBIO_REJECT_DETAIL que recebe informações adicionais sobre a falha ao capturar uma amostra biométrica. Se a operação for bem-sucedida, esse parâmetro será definido como zero. Os seguintes valores são definidos para amostras de impressão digital:

  • WINBIO_FP_TOO_HIGH
  • WINBIO_FP_TOO_LOW
  • WINBIO_FP_TOO_LEFT
  • WINBIO_FP_TOO_RIGHT
  • WINBIO_FP_TOO_FAST
  • WINBIO_FP_TOO_SLOW
  • WINBIO_FP_POOR_QUALITY
  • WINBIO_FP_TOO_SKEWED
  • WINBIO_FP_TOO_SHORT
  • WINBIO_FP_MERGE_FAILURE

Retornar valor

Se a função for bem-sucedida, ela retornará S_OK. Se a função falhar, ela retornará um valor HRESULT que indica o erro. Os valores a seguir serão reconhecidos pela Estrutura Biométrica do Windows.

Código de retorno Descrição
WINBIO_E_BAD_CAPTURE
Não foi possível capturar o exemplo. Se você retornar esse código de erro, também deverá especificar um valor no parâmetro RejectDetail que indique a natureza do problema.
WINBIO_E_CAPTURE_CANCELED
O driver do sensor retornou ERROR_CANCELLED ou ERROR_OPERATION_ABORTED.
WINBIO_E_DEVICE_FAILURE
Houve uma falha no dispositivo.
WINBIO_E_INVALID_DEVICE_STATE
O membro SensorContext da estrutura WINBIO_PIPELINE apontada pelo argumento Pipeline é NULL ou o membro SensorHandle está definido como INVALID_HANDLE_VALUE.

Comentários

A Estrutura Biométrica do Windows chama essa função depois de chamar SensorAdapterStartCapture com êxito ou chamar SensorAdapterCancel. Ele não chamará essa função se a chamada para SensorAdapterStartCapture falhar.

Quando a implementação dessa função retorna, os dados no pipeline devem estar prontos para chamadas subsequentes para funções como SensorAdapterPushDataToEngine ou SensorAdapterExportSensorData.

Essa é uma função de bloqueio que deve retornar somente depois que a operação de E/S do sensor tiver sido bem-sucedida, com falha ou cancelada. Normalmente, você fará esse bloco de função passando a estrutura OVERLAPPED no contexto do adaptador do sensor para a função GetOverlappedResult . O identificador hEvent na estrutura OVERLAPPED deve ser sinalizado quando SensorAdapterFinishCapture retorna. A função GetOverlappedResult define esse identificador automaticamente quando detecta o fim de uma operação de E/S do sensor. Se o adaptador usar algum outro mecanismo para detectar a conclusão de E/S, você deverá sinalizar o evento por conta própria.

Exemplos

O pseudocódigo a seguir mostra uma implementação possível dessa função. O exemplo não é compilado. Você deve adaptá-lo para se adequar ao seu propósito.

//////////////////////////////////////////////////////////////////////////////////////////
//
// SensorAdapterFinishCapture
//
// Purpose:
//      Waits for the completion of a capture operation initiated by the 
//      SensorAdapterStartCapture function.
//      
// Parameters:
//      Pipeline     -  Pointer to a WINBIO_PIPELINE structure associated with 
//                      the biometric unit.
//      RejectDetail -  Pointer to a WINBIO_REJECT_DETAIL value that receives 
//                      additional information about the failure to capture a 
//                      biometric sample.
//
static HRESULT
WINAPI
SensorAdapterFinishCapture(
    __inout PWINBIO_PIPELINE Pipeline,
    __out PWINBIO_REJECT_DETAIL RejectDetail
    )
{
    HRESULT hr = S_OK;
    WINBIO_SENSOR_STATUS sensorStatus = WINBIO_SENSOR_FAILURE;
    WINBIO_CAPTURE_PARAMETERS captureParameters = {0};
    BOOL result = TRUE;
    DWORD bytesReturned = 0;

    // Verify that pointer arguments are not NULL.
    if (!ARGUMENT_PRESENT(Pipeline) ||
        !ARGUMENT_PRESENT(RejectDetail))
    {
        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 || 
        Pipeline->SensorHandle == INVALID_HANDLE_VALUE)
    {
        return WINBIO_E_INVALID_DEVICE_STATE;
    }

    // Initialize the RejectDetail argument.
    *RejectDetail = 0;

    // Wait for I/O completion. This sample assumes that the I/O operation was 
    // started using the code example shown in the SensorAdapterStartCapture
    // documentation.
    SetLastError(ERROR_SUCCESS);

    result = GetOverlappedResult(
                Pipeline->SensorHandle,
                &sensorContext->Overlapped,
                &bytesReturned,
                TRUE
                );
    if (!result)
    {
        // There was an I/O error.
        return _AdapterGetHresultFromWin32(GetLastError());
    }

    if (bytesReturned == sizeof (DWORD))
    {
        // The buffer is not large enough.  This can happen if a device needs a 
        // bigger buffer depending on the purpose. Allocate a larger buffer and 
        // force the caller to reissue their I/O request.
        DWORD allocationSize = sensorContext->CaptureBuffer->PayloadSize;

        // Allocate at least the minimum buffer size needed to retrieve the 
        // payload structure.
        if (allocationSize < sizeof(WINBIO_CAPTURE_DATA))
        {
            allocationSize = sizeof(WINBIO_CAPTURE_DATA);
        }

        // Free the old buffer and allocate a new one.
        _AdapterRelease(sensorContext->CaptureBuffer);
        sensorContext->CaptureBuffer = NULL;

        sensorContext->CaptureBuffer = 
            (PWINBIO_CAPTURE_DATA)_AdapterAlloc(allocationSize);
        if (sensorContext->CaptureBuffer == NULL)
        {
            sensorContext->CaptureBufferSize = 0;
            return E_OUTOFMEMORY;
        }
        sensorContext->CaptureBufferSize = allocationSize;
        return WINBIO_E_BAD_CAPTURE;
    }

    // Normalize the status value before sending it back to the biometric service.
    if (sensorContext->CaptureBuffer != NULL &&
        sensorContext->CaptureBufferSize >= sizeof (WINBIO_CAPTURE_DATA))
    {
        switch (sensorContext->CaptureBuffer->SensorStatus)
        {
            case WINBIO_SENSOR_ACCEPT:
                // The capture was acceptable.
                break;

            case WINBIO_SENSOR_REJECT:
                // The capture was not acceptable. Overwrite the WinBioHresult value
                // in case it has not been properly set.
                sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_BAD_CAPTURE;
                break;

            case WINBIO_SENSOR_BUSY:
                // The device is busy. Reset the WinBioHresult value in case it 
                // has not been properly set.
                sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_DEVICE_BUSY;
                break;

            case WINBIO_SENSOR_READY:
            case WINBIO_SENSOR_NOT_CALIBRATED:
            case WINBIO_SENSOR_FAILURE:
            default:
                // There has been a device failure. Reset the WinBioHresult value
                // in case it has not been properly set.
                sensorContext->CaptureBuffer->WinBioHresult = WINBIO_E_INVALID_DEVICE_STATE;
                break;
        }

        *RejectDetail = sensorContext->CaptureBuffer->RejectDetail;
        hr = sensorContext->CaptureBuffer->WinBioHresult;
    }
    else
    {
        // The buffer is not large enough or the buffer pointer is NULL.
        hr = WINBIO_E_INVALID_DEVICE_STATE;
    }
    return hr;
}

Requisitos

Requisito Valor
Cliente mínimo com suporte Windows 7 [somente aplicativos da área de trabalho]
Servidor mínimo com suporte Windows Server 2008 R2 [somente aplicativos da área de trabalho]
Plataforma de Destino Windows
Cabeçalho winbio_adapter.h (inclua Winbio_adapter.h)

Confira também

Funções de plug-in

SensorAdapterCancel

SensorAdapterExportSensorData

SensorAdapterPushDataToEngine

SensorAdapterStartCapture