Condividi tramite


EVT_ACX_KEYWORDSPOTTER_ASSIGN_PATTERNS funzione di callback (acxelements.h)

Il callback EVT_ACX_KEYWORDSPOTTER_ASSIGN_PATTERNS assegna modelli di rilevamento per il rilevamento delle parole chiave da usare dal rilevatore di parole chiave.

Sintassi

EVT_ACX_KEYWORDSPOTTER_ASSIGN_PATTERNS EvtAcxKeywordspotterAssignPatterns;

NTSTATUS EvtAcxKeywordspotterAssignPatterns(
  ACXKEYWORDSPOTTER KeywordSpotter,
  GUID *EventId,
  PVOID Pattern,
  ULONG PatternSize
)
{...}

Parametri

KeywordSpotter

Oggetto ACXKEYWORDSPOTTER esistente inizializzato. Per altre informazioni sugli oggetti ACX, vedere Riepilogo degli oggetti ACX. Vedere anche la funzione AcxKeywordSpotterCreate.

EventId

Puntatore a un GUID che rappresenta l'EventId.

Pattern

GUID che identifica il modello di rilevamento del rilevatore di parole chiave.

PatternSize

Lunghezza, in byte, del modello di rilevamento delle parole chiave.

Valore restituito

Restituisce STATUS_SUCCESS se la chiamata ha avuto esito positivo. In caso contrario, restituisce un codice di errore appropriato. Per altre informazioni, vedere Uso di valori NTSTATUS.

Osservazioni

Per informazioni generali sul rilevamento delle parole chiave, vedere attivazione vocale e multiple Voice Assistant.

Esempio

Di seguito è riportato un esempio di utilizzo.

EVT_ACX_KEYWORDSPOTTER_ASSIGN_PATTERNS  CodecC_EvtAcxKeywordSpotterAssignPatterns;

NTSTATUS
NTAPI
CodecC_EvtAcxKeywordSpotterAssignPatterns(
    _In_    ACXKEYWORDSPOTTER   KeywordSpotter,
    _In_    GUID *              EventId,
    _In_    PVOID               Pattern,
    _In_    ULONG               PatternSize
    )
{
    KSMULTIPLE_ITEM *               itemsHeader = nullptr;
    SOUNDDETECTOR_PATTERNHEADER *   patternHeader;
    CONTOSO_KEYWORDCONFIGURATION *  pattern;
    ULONG                           cbRemaining = 0;
    PCODEC_KEYWORDSPOTTER_CONTEXT   keywordSpotterCtx;
    CKeywordDetector *              keywordDetector = NULL;

    PAGED_CODE();

    keywordSpotterCtx = GetCodecKeywordSpotterContext(KeywordSpotter);

    keywordDetector = (CKeywordDetector*)keywordSpotterCtx->KeywordDetector;

    cbRemaining = PatternSize;

    // The SYSVADPROPERTY_ITEM for this property ensures the value size is at
    // least sizeof KSMULTIPLE_ITEM.
    if (cbRemaining < sizeof(KSMULTIPLE_ITEM))
    {
        return STATUS_INVALID_PARAMETER;
    }

    itemsHeader = (KSMULTIPLE_ITEM*)Pattern;

    // Verify property value is large enough to include the items
    if (itemsHeader->Size > cbRemaining)
    {
        return STATUS_INVALID_PARAMETER;
    }

    // No items so clear the configuration.
    if (itemsHeader->Count == 0)
    {
        keywordDetector->ResetDetector(*EventId);
        return STATUS_SUCCESS;
    }

    // This sample supports only 1 pattern type.
    if (itemsHeader->Count > 1)
    {
        return STATUS_NOT_SUPPORTED;
    }

    // Bytes remaining after the items header
    cbRemaining = itemsHeader->Size - sizeof(*itemsHeader);

    // Verify the property value is large enough to include the pattern header.
    if (cbRemaining < sizeof(SOUNDDETECTOR_PATTERNHEADER))
    {
        return STATUS_INVALID_PARAMETER;
    }

    patternHeader = (SOUNDDETECTOR_PATTERNHEADER*)(itemsHeader + 1);

    // Verify the pattern type is supported.
    if (patternHeader->PatternType != CONTOSO_KEYWORDCONFIGURATION_IDENTIFIER2)
    {
        return STATUS_NOT_SUPPORTED;
    }

    // Verify the property value is large enough for the pattern.
    if (cbRemaining < patternHeader->Size)
    {
        return STATUS_INVALID_PARAMETER;
    }

    // Verify the pattern is large enough.
    if (patternHeader->Size != sizeof(CONTOSO_KEYWORDCONFIGURATION))
    {
        return STATUS_INVALID_PARAMETER;
    }

    pattern = (CONTOSO_KEYWORDCONFIGURATION*)(patternHeader);

    return keywordDetector->DownloadDetectorData(*EventId, pattern->ContosoDetectorConfigurationData);
}

Requisiti ACX

versione minima di ACX: 1.0

Per altre informazioni sulle versioni di ACX, vedere panoramica della versione ACX.

Fabbisogno

Requisito Valore
intestazione acxelements.h
IRQL PASSIVE_LEVEL

Vedere anche

  • intestazione acxelements.h