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