Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package android.hardware.soundtrigger@2.0; |
| 18 | |
| 19 | import android.hardware.audio.common@2.0; |
| 20 | |
| 21 | interface 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 Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 32 | /** |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 33 | * Generic recognition event sent via recognition callback |
| 34 | */ |
| 35 | struct RecognitionEvent { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 36 | /** Recognition status e.g. SUCCESS */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 37 | RecognitionStatus status; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 38 | /** Sound model type for this event. e.g SoundModelType.TYPE_KEYPHRASE */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 39 | SoundModelType type; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 40 | /** Handle of loaded sound model which triggered the event */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 41 | SoundModelHandle model; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 42 | /** It is possible to capture audio from this */ |
| 43 | /** utterance buffered by the implementation */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 44 | bool captureAvailable; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 45 | /** Audio session ID. framework use */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 46 | int32_t captureSession; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 47 | /** |
| 48 | * Delay in ms between end of model detection and start of audio |
| 49 | /** |
| 50 | * available for capture. A negative value is possible |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 51 | * (e.g. if key phrase is also available for capture */ |
| 52 | int32_t captureDelayMs; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 53 | /** |
| 54 | * Duration in ms of audio captured before the start of the trigger. |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 55 | * 0 if none. */ |
| 56 | int32_t capturePreambleMs; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 57 | /** The opaque data is the capture of the trigger sound */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 58 | bool triggerInData; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Audio format of either the trigger in event data or to use for |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 61 | * capture of the rest of the utterance */ |
| 62 | AudioConfig audioConfig; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 63 | /** Opaque event data */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 64 | vec<uint8_t> data; |
| 65 | }; |
| 66 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 67 | /** |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 68 | * Specialized recognition event for key phrase recognitions |
| 69 | */ |
| 70 | struct PhraseRecognitionEvent { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 71 | /** Common part of the recognition event */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 72 | RecognitionEvent common; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 73 | /** List of descriptors for each recognized key phrase */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 74 | vec<PhraseRecognitionExtra> phraseExtras; |
| 75 | }; |
| 76 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 77 | /** |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 78 | * Event sent via load sound model callback |
| 79 | */ |
| 80 | struct ModelEvent { |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 81 | /** Sound model status e.g. SoundModelStatus.UPDATED */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 82 | SoundModelStatus status; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 83 | /** Loaded sound model that triggered the event */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 84 | SoundModelHandle model; |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 85 | /** Opaque event data, passed transparently by the framework */ |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 86 | vec<uint8_t> data; |
| 87 | }; |
| 88 | |
| 89 | typedef int32_t CallbackCookie; |
| 90 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 91 | /** |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 92 | * Callback method called by the HAL when the sound recognition triggers |
| 93 | * @param event A RecognitionEvent structure containing detailed results |
| 94 | * of the recognition triggered |
| 95 | * @param cookie The cookie passed by the framework when recognition was |
| 96 | * started (see ISoundtriggerHw.startRecognition() |
| 97 | */ |
| 98 | recognitionCallback(RecognitionEvent event, CallbackCookie cookie); |
Eric Laurent | a4b776c | 2016-10-13 15:11:24 -0700 | [diff] [blame] | 99 | |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 100 | /** |
Eric Laurent | a4b776c | 2016-10-13 15:11:24 -0700 | [diff] [blame] | 101 | * Callback method called by the HAL when the sound recognition triggers |
| 102 | * for a key phrase sound model. |
| 103 | * @param event A RecognitionEvent structure containing detailed results |
| 104 | * of the recognition triggered |
| 105 | * @param cookie The cookie passed by the framework when recognition was |
| 106 | * started (see ISoundtriggerHw.startRecognition() |
| 107 | */ |
| 108 | phraseRecognitionCallback(PhraseRecognitionEvent event, |
| 109 | CallbackCookie cookie); |
Andreas Huber | 40d3a9b | 2017-03-28 16:19:16 -0700 | [diff] [blame] | 110 | /** |
Eric Laurent | fc496a2 | 2016-08-05 12:13:45 -0700 | [diff] [blame] | 111 | * Callback method called by the HAL when the sound model loading completes |
| 112 | * @param event A ModelEvent structure containing detailed results of the |
| 113 | * model loading operation |
| 114 | * @param cookie The cookie passed by the framework when loading was |
| 115 | * initiated (see ISoundtriggerHw.loadSoundModel() |
| 116 | */ |
| 117 | soundModelCallback(ModelEvent event, CallbackCookie cookie); |
| 118 | }; |