1 /* 2 * Copyright 2022 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 androidx.camera.view.video; 18 19 import android.Manifest; 20 21 import androidx.annotation.RequiresPermission; 22 23 import org.jspecify.annotations.NonNull; 24 25 /** 26 * A class providing configuration for audio settings in the video recording. 27 */ 28 public class AudioConfig { 29 30 /** 31 * The audio configuration with audio disabled. 32 */ 33 public static final @NonNull AudioConfig AUDIO_DISABLED = new AudioConfig(false); 34 35 private final boolean mIsAudioEnabled; 36 AudioConfig(boolean audioEnabled)37 AudioConfig(boolean audioEnabled) { 38 mIsAudioEnabled = audioEnabled; 39 } 40 41 /** 42 * Creates a default {@link AudioConfig} with the given audio enabled state. 43 * 44 * <p> The {@link android.Manifest.permission#RECORD_AUDIO} permission is required to 45 * enable audio in video recording; for the use cases where audio is always disabled, please 46 * use {@link AudioConfig#AUDIO_DISABLED} instead, which has no permission requirements. 47 */ 48 @RequiresPermission(Manifest.permission.RECORD_AUDIO) create(boolean enableAudio)49 public static @NonNull AudioConfig create(boolean enableAudio) { 50 return new AudioConfig(enableAudio); 51 } 52 53 /** 54 * Get the audio enabled state. 55 */ getAudioEnabled()56 public boolean getAudioEnabled() { 57 return mIsAudioEnabled; 58 } 59 } 60