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 | import ISoundTriggerHwCallback; |
| 22 | |
| 23 | interface ISoundTriggerHw { |
| 24 | |
| 25 | /* |
| 26 | * Sound trigger implementation descriptor read by the framework via |
| 27 | * getProperties(). Used by SoundTrigger service to report to applications |
| 28 | * and manage concurrency and policy. |
| 29 | */ |
| 30 | struct Properties { |
| 31 | /* Implementor name */ |
| 32 | string implementor; |
| 33 | /* Implementation description */ |
| 34 | string description; |
| 35 | /* Implementation version */ |
| 36 | uint32_t version; |
| 37 | /* Unique implementation ID. The UUID must change with each version of |
| 38 | the engine implementation */ |
| 39 | Uuid uuid; |
| 40 | /* Maximum number of concurrent sound models loaded */ |
| 41 | uint32_t maxSoundModels; |
| 42 | /* Maximum number of key phrases */ |
| 43 | uint32_t maxKeyPhrases; |
| 44 | /* Maximum number of concurrent users detected */ |
| 45 | uint32_t maxUsers; |
| 46 | /* All supported modes. e.g RecognitionMode.VOICE_TRIGGER */ |
| 47 | uint32_t recognitionModes; |
| 48 | /* Supports seamless transition from detection to capture */ |
| 49 | bool captureTransition; |
| 50 | /* Maximum buffering capacity in ms if captureTransition is true */ |
| 51 | uint32_t maxBufferMs; |
| 52 | /* Supports capture by other use cases while detection is active */ |
| 53 | bool concurrentCapture; |
| 54 | /* Returns the trigger capture in event */ |
| 55 | bool triggerInEvent; |
| 56 | /* Rated power consumption when detection is active with TDB |
| 57 | * silence/sound/speech ratio */ |
| 58 | uint32_t powerConsumptionMw; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | /* |
| 63 | * Base sound model descriptor. This struct is the header of a larger block |
| 64 | * passed to loadSoundModel() and contains the binary data of the |
| 65 | * sound model. |
| 66 | */ |
| 67 | struct SoundModel { |
| 68 | /* Model type. e.g. SoundModelType.KEYPHRASE */ |
| 69 | SoundModelType type; |
| 70 | /* Unique sound model ID. */ |
| 71 | Uuid uuid; |
| 72 | /* Unique vendor ID. Identifies the engine the sound model |
| 73 | * was build for */ |
| 74 | Uuid vendorUuid; |
| 75 | /* Opaque data transparent to Android framework */ |
| 76 | vec<uint8_t> data; |
| 77 | }; |
| 78 | |
| 79 | /* Key phrase descriptor */ |
| 80 | struct Phrase { |
| 81 | /* Unique keyphrase ID assigned at enrollment time */ |
| 82 | uint32_t id; |
| 83 | /* Recognition modes supported by this key phrase */ |
| 84 | uint32_t recognitionModes; |
| 85 | /* List of users IDs associated with this key phrase */ |
| 86 | vec<uint32_t> users; |
| 87 | /* Locale - Java Locale style (e.g. en_US) */ |
| 88 | string locale; |
| 89 | /* Phrase text in UTF-8 format. */ |
| 90 | string text; |
| 91 | }; |
| 92 | |
| 93 | /* |
| 94 | * Specialized sound model for key phrase detection. |
| 95 | * Proprietary representation of key phrases in binary data must match |
| 96 | * information indicated by phrases field |
| 97 | */ |
| 98 | struct PhraseSoundModel { |
| 99 | /* Common part of sound model descriptor */ |
| 100 | SoundModel common; |
| 101 | /* List of descriptors for key phrases supported by this sound model */ |
| 102 | vec<Phrase> phrases; |
| 103 | }; |
| 104 | |
| 105 | /* |
| 106 | * Configuration for sound trigger capture session passed to |
| 107 | * startRecognition() method |
| 108 | */ |
| 109 | struct RecognitionConfig { |
| 110 | /* IO handle that will be used for capture. N/A if captureRequested |
| 111 | * is false */ |
| 112 | AudioIoHandle captureHandle; |
| 113 | /* Input device requested for detection capture */ |
| 114 | AudioDevice captureDevice; |
| 115 | /* Capture and buffer audio for this recognition instance */ |
| 116 | bool captureRequested; |
| 117 | /* Configuration for each key phrase */ |
| 118 | vec<PhraseRecognitionExtra> phrases; |
| 119 | /* Opaque capture configuration data transparent to the framework */ |
| 120 | vec<uint8_t> data; |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | /* |
| 125 | * Retrieve implementation properties. |
| 126 | * @return retval Operation completion status: 0 in case of success, |
| 127 | * -ENODEV in case of initialization error. |
| 128 | * @return properties A Properties structure containing implementation |
| 129 | * description and capabilities. |
| 130 | */ |
| 131 | getProperties() generates (int32_t retval, Properties properties); |
| 132 | |
| 133 | /* |
| 134 | * Load a sound model. Once loaded, recognition of this model can be |
| 135 | * started and stopped. Only one active recognition per model at a time. |
| 136 | * The SoundTrigger service must handle concurrent recognition requests by |
| 137 | * different users/applications on the same model. |
| 138 | * The implementation returns a unique handle used by other functions |
| 139 | * (unloadSoundModel(), startRecognition(), etc... |
| 140 | * @param soundModel A SoundModel structure describing the sound model to |
| 141 | * load. |
| 142 | * @param callback The callback interface on which the soundmodelCallback() |
| 143 | * method will be called upon completion. |
| 144 | * @param cookie The value of the cookie argument passed to the completion |
| 145 | * callback. This unique context information is assigned and |
| 146 | * used only by the framework. |
| 147 | * @return retval Operation completion status: 0 in case of success, |
| 148 | * -EINVAL in case of invalid sound model (e.g 0 data size), |
| 149 | * -ENOSYS in case of invalid operation (e.g max number of |
| 150 | * models exceeded), |
| 151 | * -ENOMEM in case of memory allocation failure, |
| 152 | * -ENODEV in case of initialization error. |
| 153 | * @return modelHandle A unique handle assigned by the HAL for use by the |
| 154 | * framework when controlling activity for this sound model. |
| 155 | */ |
| 156 | loadSoundModel(SoundModel soundModel, |
| 157 | ISoundTriggerHwCallback callback, |
| 158 | CallbackCookie cookie) |
| 159 | generates (int32_t retval, SoundModelHandle modelHandle); |
| 160 | |
| 161 | /* |
| 162 | * Unload a sound model. A sound model may be unloaded to make room for a |
| 163 | * new one to overcome implementation limitations. |
| 164 | * @param modelHandle the handle of the sound model to unload |
| 165 | * @return retval Operation completion status: 0 in case of success, |
| 166 | * -ENOSYS if the model is not loaded, |
| 167 | * -ENODEV in case of initialization error. |
| 168 | */ |
| 169 | unloadSoundModel(SoundModelHandle modelHandle) |
| 170 | generates (int32_t retval); |
| 171 | |
| 172 | /* |
| 173 | * Start recognition on a given model. Only one recognition active |
| 174 | * at a time per model. Once recognition succeeds of fails, the callback |
| 175 | * is called. |
| 176 | * @param modelHandle the handle of the sound model to use for recognition |
| 177 | * @param config A RecognitionConfig structure containing attributes of the |
| 178 | * recognition to perform |
| 179 | * @param callback The callback interface on which the recognitionCallback() |
| 180 | * method must be called upon recognition. |
| 181 | * @param cookie The value of the cookie argument passed to the recognition |
| 182 | * callback. This unique context information is assigned and |
| 183 | * used only by the framework. |
| 184 | * @return retval Operation completion status: 0 in case of success, |
| 185 | * -EINVAL in case of invalid recognition attributes, |
| 186 | * -ENOSYS in case of invalid model handle, |
| 187 | * -ENOMEM in case of memory allocation failure, |
| 188 | * -ENODEV in case of initialization error. |
| 189 | */ |
| 190 | startRecognition(SoundModelHandle modelHandle, |
| 191 | RecognitionConfig config, |
| 192 | ISoundTriggerHwCallback callback, |
| 193 | CallbackCookie cookie) |
| 194 | generates (int32_t retval); |
| 195 | |
| 196 | /* |
| 197 | * Stop recognition on a given model. |
| 198 | * The implementation must not call the recognition callback when stopped |
| 199 | * via this method. |
| 200 | * @param modelHandle The handle of the sound model to use for recognition |
| 201 | * @return retval Operation completion status: 0 in case of success, |
| 202 | * -ENOSYS in case of invalid model handle, |
| 203 | * -ENODEV in case of initialization error. |
| 204 | */ |
| 205 | stopRecognition(SoundModelHandle modelHandle) |
| 206 | generates (int32_t retval); |
| 207 | |
| 208 | /* |
| 209 | * Stop recognition on all models. |
| 210 | * @return retval Operation completion status: 0 in case of success, |
| 211 | * -ENODEV in case of initialization error. |
| 212 | */ |
| 213 | stopAllRecognitions() |
| 214 | generates (int32_t retval); |
| 215 | }; |