@@ -185,48 +185,77 @@ public class AlwaysOnHotwordDetector {
185185 * Additional payload for {@link Callback#onDetected}.
186186 */
187187 public static class EventPayload {
188+ private final boolean mTriggerAvailable ;
189+ // Indicates if {@code captureSession} can be used to continue capturing more audio
190+ // from the DSP hardware.
191+ private final boolean mCaptureAvailable ;
192+ // The session to use when attempting to capture more audio from the DSP hardware.
193+ private final int mCaptureSession ;
194+ private final AudioFormat mAudioFormat ;
195+ // Raw data associated with the event.
196+ // This is the audio that triggered the keyphrase if {@code isTriggerAudio} is true.
197+ private final byte [] mData ;
198+
199+ private EventPayload (boolean triggerAvailable , boolean captureAvailable ,
200+ AudioFormat audioFormat , int captureSession , byte [] data ) {
201+ mTriggerAvailable = triggerAvailable ;
202+ mCaptureAvailable = captureAvailable ;
203+ mCaptureSession = captureSession ;
204+ mAudioFormat = audioFormat ;
205+ mData = data ;
206+ }
207+
188208 /**
189- * Indicates if {@code data} is the audio that triggered the keyphrase.
209+ * Gets the format of the audio obtained using {@link #getTriggerAudio()}.
210+ * May be null if there's no audio present.
190211 */
191- public final boolean triggerAvailable ;
212+ @ Nullable
213+ public AudioFormat getCaptureAudioFormat () {
214+ return mAudioFormat ;
215+ }
216+
192217 /**
193- * Indicates if {@code captureSession} can be used to continue capturing more audio from
194- * the DSP hardware.
218+ * Gets the raw audio that triggered the keyphrase.
219+ * This may be null if the trigger audio isn't available.
220+ * If non-null, the format of the audio can be obtained by calling
221+ * {@link #getCaptureAudioFormat()}.
195222 *
196- * Candidate for public API
197- * @hide
223+ * @see AlwaysOnHotwordDetector#RECOGNITION_FLAG_CAPTURE_TRIGGER_AUDIO
198224 */
199- public final boolean captureAvailable ;
225+ @ Nullable
226+ public byte [] getTriggerAudio () {
227+ if (mTriggerAvailable ) {
228+ return mData ;
229+ } else {
230+ return null ;
231+ }
232+ }
233+
200234 /**
201- * The session to use when attempting to capture more audio from the DSP hardware.
235+ * Gets the session ID to start a capture from the DSP.
236+ * This may be null if streaming capture isn't possible.
237+ * If non-null, the format of the audio that can be captured can be
238+ * obtained using {@link #getCaptureAudioFormat()}.
239+ *
240+ * TODO: Candidate for Public API when the API to start capture with a session ID
241+ * is made public.
242+ *
243+ * TODO: Add this to {@link #getCaptureAudioFormat()}:
244+ * "Gets the format of the audio obtained using {@link #getTriggerAudio()}
245+ * or {@link #getCaptureSession()}. May be null if no audio can be obtained
246+ * for either the trigger or a streaming session."
247+ *
248+ * TODO: Should this return a known invalid value instead?
202249 *
203- * Candidate for public API
204- * TODO: When unhiding, change javadoc of audioFormat to -
205- * "Format of {@code data} or the audio that may be captured using {@code captureSession}.
206- * May be null if {@code triggerAvailable} and {@code captureAvailable} are false."
207250 * @hide
208251 */
209- public final int captureSession ;
210- /**
211- * Format of {@code data}.
212- * May be null if {@code triggerAvailable} is false.
213- */
214252 @ Nullable
215- public final AudioFormat audioFormat ;
216- /**
217- * Raw data associated with the event.
218- * This is the audio that triggered the keyphrase if {@code isTriggerAudio} is true.
219- */
220- @ Nullable
221- public final byte [] data ;
222-
223- private EventPayload (boolean _triggerAvailable , boolean _captureAvailable ,
224- AudioFormat _audioFormat , int _captureSession , byte [] _data ) {
225- triggerAvailable = _triggerAvailable ;
226- captureAvailable = _captureAvailable ;
227- captureSession = _captureSession ;
228- audioFormat = _audioFormat ;
229- data = _data ;
253+ public Integer getCaptureSession () {
254+ if (mCaptureAvailable ) {
255+ return mCaptureSession ;
256+ } else {
257+ return null ;
258+ }
230259 }
231260 }
232261
0 commit comments