summaryrefslogtreecommitdiffstats
path: root/soundtrigger/2.0/ISoundTriggerHwCallback.hal
blob: 90132d9a8b0b172e091caac5bb07da029076403a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
 * Copyright 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.soundtrigger@2.0;

import android.hardware.audio.common@2.0;

interface ISoundTriggerHwCallback {
    enum RecognitionStatus : uint32_t {
        SUCCESS  = 0,
        ABORT    = 1,
        FAILURE  = 2,
    };

    enum SoundModelStatus : uint32_t {
        UPDATED  = 0,
    };

    /**
     * Generic recognition event sent via recognition callback
     */
    struct RecognitionEvent {
        /** Recognition status e.g. SUCCESS */
        RecognitionStatus status;
        /** Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */
        SoundModelType    type;
        /** Handle of loaded sound model which triggered the event */
        SoundModelHandle  model;
        /** It is possible to capture audio from this */
        /** utterance buffered by the implementation */
        bool              captureAvailable;
        /** Audio session ID. framework use */
        int32_t           captureSession;
        /**
         * Delay in ms between end of model detection and start of audio
        /**
         * available for capture. A negative value is possible
         * (e.g. if key phrase is also available for capture */
        int32_t           captureDelayMs;
        /**
         * Duration in ms of audio captured before the start of the trigger.
         * 0 if none. */
        int32_t           capturePreambleMs;
        /** The opaque data is the capture of the trigger sound */
        bool              triggerInData;
        /**
         * Audio format of either the trigger in event data or to use for
         * capture of the rest of the utterance */
        AudioConfig       audioConfig;
        /** Opaque event data */
        vec<uint8_t>      data;
    };

    /**
     * Specialized recognition event for key phrase recognitions
     */
    struct PhraseRecognitionEvent {
        /** Common part of the recognition event */
        RecognitionEvent common;
        /** List of descriptors for each recognized key phrase */
        vec<PhraseRecognitionExtra> phraseExtras;
    };

    /**
     * Event sent via load sound model callback
     */
    struct ModelEvent {
         /** Sound model status e.g. SoundModelStatus.UPDATED */
        SoundModelStatus status;
        /** Loaded sound model that triggered the event */
        SoundModelHandle model;
        /** Opaque event data, passed transparently by the framework */
        vec<uint8_t>     data;
    };

    typedef int32_t CallbackCookie;

    /**
     * Callback method called by the HAL when the sound recognition triggers
     * @param event A RecognitionEvent structure containing detailed results
     *              of the recognition triggered
     * @param cookie The cookie passed by the framework when recognition was
     *               started (see ISoundtriggerHw.startRecognition()
     */
    recognitionCallback(RecognitionEvent event, CallbackCookie cookie);

    /**
     * Callback method called by the HAL when the sound recognition triggers
     * for a key phrase sound model.
     * @param event A RecognitionEvent structure containing detailed results
     *              of the recognition triggered
     * @param cookie The cookie passed by the framework when recognition was
     *               started (see ISoundtriggerHw.startRecognition()
     */
    phraseRecognitionCallback(PhraseRecognitionEvent event,
                              CallbackCookie cookie);
    /**
     * Callback method called by the HAL when the sound model loading completes
     * @param event A ModelEvent structure containing detailed results of the
     *              model loading operation
     * @param cookie The cookie passed by the framework when loading was
     *               initiated (see ISoundtriggerHw.loadSoundModel()
     */
    soundModelCallback(ModelEvent event, CallbackCookie cookie);
};