1 /* 2 * Copyright (C) 2018 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.media; 18 19 import android.annotation.CallbackExecutor; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 23 import java.util.concurrent.Executor; 24 25 /** 26 * AudioRecordingMonitor defines an interface implemented by {@link AudioRecord} and 27 * {@link MediaRecorder} allowing applications to install a callback and be notified of changes 28 * in the capture path while recoding is active. 29 */ 30 public interface AudioRecordingMonitor { 31 /** 32 * Register a callback to be notified of audio capture changes via a 33 * {@link AudioManager.AudioRecordingCallback}. A callback is received when the capture path 34 * configuration changes (pre-processing, format, sampling rate...) or capture is 35 * silenced/unsilenced by the system. 36 * @param executor {@link Executor} to handle the callbacks. 37 * @param cb non-null callback to register 38 */ registerAudioRecordingCallback(@onNull @allbackExecutor Executor executor, @NonNull AudioManager.AudioRecordingCallback cb)39 void registerAudioRecordingCallback(@NonNull @CallbackExecutor Executor executor, 40 @NonNull AudioManager.AudioRecordingCallback cb); 41 42 /** 43 * Unregister an audio recording callback previously registered with 44 * {@link #registerAudioRecordingCallback(Executor, AudioManager.AudioRecordingCallback)}. 45 * @param cb non-null callback to unregister 46 */ unregisterAudioRecordingCallback(@onNull AudioManager.AudioRecordingCallback cb)47 void unregisterAudioRecordingCallback(@NonNull AudioManager.AudioRecordingCallback cb); 48 49 /** 50 * Returns the current active audio recording for this audio recorder. 51 * @return a valid {@link AudioRecordingConfiguration} if this recorder is active 52 * or null otherwise. 53 * @see AudioRecordingConfiguration 54 */ getActiveRecordingConfiguration()55 @Nullable AudioRecordingConfiguration getActiveRecordingConfiguration(); 56 } 57