blob: c6555f6c55b1709ff10d47126297084e65cb8b78 [file] [log] [blame]
Eric Laurentfc496a22016-08-05 12:13:45 -07001/*
2 * Copyright 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.soundtrigger@2.0;
18
19import android.hardware.audio.common@2.0;
20
21interface ISoundTriggerHwCallback {
22 enum RecognitionStatus : uint32_t {
23 SUCCESS = 0,
24 ABORT = 1,
25 FAILURE = 2,
26 };
27
28 enum SoundModelStatus : uint32_t {
29 UPDATED = 0,
30 };
31
32 /*
33 * Generic recognition event sent via recognition callback
34 */
35 struct RecognitionEvent {
36 /* Recognition status e.g. SUCCESS */
37 RecognitionStatus status;
38 /* Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */
39 SoundModelType type;
40 /* Handle of loaded sound model which triggered the event */
41 SoundModelHandle model;
42 /* It is possible to capture audio from this */
43 /* utterance buffered by the implementation */
44 bool captureAvailable;
45 /* Audio session ID. framework use */
46 int32_t captureSession;
47 /* Delay in ms between end of model detection and start of audio
48 /* available for capture. A negative value is possible
49 * (e.g. if key phrase is also available for capture */
50 int32_t captureDelayMs;
51 /* Duration in ms of audio captured before the start of the trigger.
52 * 0 if none. */
53 int32_t capturePreambleMs;
54 /* The opaque data is the capture of the trigger sound */
55 bool triggerInData;
56 /* Audio format of either the trigger in event data or to use for
57 * capture of the rest of the utterance */
58 AudioConfig audioConfig;
59 /* Opaque event data */
60 vec<uint8_t> data;
61 };
62
63 /*
64 * Specialized recognition event for key phrase recognitions
65 */
66 struct PhraseRecognitionEvent {
67 /* Common part of the recognition event */
68 RecognitionEvent common;
69 /* List of descriptors for each recognized key phrase */
70 vec<PhraseRecognitionExtra> phraseExtras;
71 };
72
73 /*
74 * Event sent via load sound model callback
75 */
76 struct ModelEvent {
77 /* Sound model status e.g. SoundModelStatus.UPDATED */
78 SoundModelStatus status;
79 /* Loaded sound model that triggered the event */
80 SoundModelHandle model;
81 /* Opaque event data, passed transparently by the framework */
82 vec<uint8_t> data;
83 };
84
85 typedef int32_t CallbackCookie;
86
87 /*
88 * Callback method called by the HAL when the sound recognition triggers
89 * @param event A RecognitionEvent structure containing detailed results
90 * of the recognition triggered
91 * @param cookie The cookie passed by the framework when recognition was
92 * started (see ISoundtriggerHw.startRecognition()
93 */
94 recognitionCallback(RecognitionEvent event, CallbackCookie cookie);
Eric Laurenta4b776c2016-10-13 15:11:24 -070095
96 /*
97 * Callback method called by the HAL when the sound recognition triggers
98 * for a key phrase sound model.
99 * @param event A RecognitionEvent structure containing detailed results
100 * of the recognition triggered
101 * @param cookie The cookie passed by the framework when recognition was
102 * started (see ISoundtriggerHw.startRecognition()
103 */
104 phraseRecognitionCallback(PhraseRecognitionEvent event,
105 CallbackCookie cookie);
Eric Laurentfc496a22016-08-05 12:13:45 -0700106 /*
107 * Callback method called by the HAL when the sound model loading completes
108 * @param event A ModelEvent structure containing detailed results of the
109 * model loading operation
110 * @param cookie The cookie passed by the framework when loading was
111 * initiated (see ISoundtriggerHw.loadSoundModel()
112 */
113 soundModelCallback(ModelEvent event, CallbackCookie cookie);
114};