blob: 84b11c82b324b92bedb5c4732905582e83c28cd4 [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
Andreas Huber40d3a9b2017-03-28 16:19:16 -070032 /**
Eric Laurentfc496a22016-08-05 12:13:45 -070033 * Generic recognition event sent via recognition callback
34 */
35 struct RecognitionEvent {
Andreas Huber40d3a9b2017-03-28 16:19:16 -070036 /** Recognition status e.g. SUCCESS */
Eric Laurentfc496a22016-08-05 12:13:45 -070037 RecognitionStatus status;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070038 /** Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */
Eric Laurentfc496a22016-08-05 12:13:45 -070039 SoundModelType type;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070040 /** Handle of loaded sound model which triggered the event */
Eric Laurentfc496a22016-08-05 12:13:45 -070041 SoundModelHandle model;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070042 /** It is possible to capture audio from this */
43 /** utterance buffered by the implementation */
Eric Laurentfc496a22016-08-05 12:13:45 -070044 bool captureAvailable;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070045 /** Audio session ID. framework use */
Eric Laurentfc496a22016-08-05 12:13:45 -070046 int32_t captureSession;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070047 /**
48 * Delay in ms between end of model detection and start of audio
Andreas Huber40d3a9b2017-03-28 16:19:16 -070049 * available for capture. A negative value is possible
Eric Laurentfc496a22016-08-05 12:13:45 -070050 * (e.g. if key phrase is also available for capture */
51 int32_t captureDelayMs;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070052 /**
53 * Duration in ms of audio captured before the start of the trigger.
Eric Laurentfc496a22016-08-05 12:13:45 -070054 * 0 if none. */
55 int32_t capturePreambleMs;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070056 /** The opaque data is the capture of the trigger sound */
Eric Laurentfc496a22016-08-05 12:13:45 -070057 bool triggerInData;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070058 /**
59 * Audio format of either the trigger in event data or to use for
Eric Laurentfc496a22016-08-05 12:13:45 -070060 * capture of the rest of the utterance */
61 AudioConfig audioConfig;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070062 /** Opaque event data */
Eric Laurentfc496a22016-08-05 12:13:45 -070063 vec<uint8_t> data;
64 };
65
Andreas Huber40d3a9b2017-03-28 16:19:16 -070066 /**
Eric Laurentfc496a22016-08-05 12:13:45 -070067 * Specialized recognition event for key phrase recognitions
68 */
69 struct PhraseRecognitionEvent {
Andreas Huber40d3a9b2017-03-28 16:19:16 -070070 /** Common part of the recognition event */
Eric Laurentfc496a22016-08-05 12:13:45 -070071 RecognitionEvent common;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070072 /** List of descriptors for each recognized key phrase */
Eric Laurentfc496a22016-08-05 12:13:45 -070073 vec<PhraseRecognitionExtra> phraseExtras;
74 };
75
Andreas Huber40d3a9b2017-03-28 16:19:16 -070076 /**
Eric Laurentfc496a22016-08-05 12:13:45 -070077 * Event sent via load sound model callback
78 */
79 struct ModelEvent {
Andreas Huber40d3a9b2017-03-28 16:19:16 -070080 /** Sound model status e.g. SoundModelStatus.UPDATED */
Eric Laurentfc496a22016-08-05 12:13:45 -070081 SoundModelStatus status;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070082 /** Loaded sound model that triggered the event */
Eric Laurentfc496a22016-08-05 12:13:45 -070083 SoundModelHandle model;
Andreas Huber40d3a9b2017-03-28 16:19:16 -070084 /** Opaque event data, passed transparently by the framework */
Eric Laurentfc496a22016-08-05 12:13:45 -070085 vec<uint8_t> data;
86 };
87
88 typedef int32_t CallbackCookie;
89
Andreas Huber40d3a9b2017-03-28 16:19:16 -070090 /**
Eric Laurentfc496a22016-08-05 12:13:45 -070091 * Callback method called by the HAL when the sound recognition triggers
92 * @param event A RecognitionEvent structure containing detailed results
93 * of the recognition triggered
94 * @param cookie The cookie passed by the framework when recognition was
95 * started (see ISoundtriggerHw.startRecognition()
96 */
97 recognitionCallback(RecognitionEvent event, CallbackCookie cookie);
Eric Laurenta4b776c2016-10-13 15:11:24 -070098
Andreas Huber40d3a9b2017-03-28 16:19:16 -070099 /**
Eric Laurenta4b776c2016-10-13 15:11:24 -0700100 * Callback method called by the HAL when the sound recognition triggers
101 * for a key phrase sound model.
102 * @param event A RecognitionEvent structure containing detailed results
103 * of the recognition triggered
104 * @param cookie The cookie passed by the framework when recognition was
105 * started (see ISoundtriggerHw.startRecognition()
106 */
107 phraseRecognitionCallback(PhraseRecognitionEvent event,
108 CallbackCookie cookie);
Andreas Huber40d3a9b2017-03-28 16:19:16 -0700109 /**
Eric Laurentfc496a22016-08-05 12:13:45 -0700110 * Callback method called by the HAL when the sound model loading completes
111 * @param event A ModelEvent structure containing detailed results of the
112 * model loading operation
113 * @param cookie The cookie passed by the framework when loading was
114 * initiated (see ISoundtriggerHw.loadSoundModel()
115 */
116 soundModelCallback(ModelEvent event, CallbackCookie cookie);
117};