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.FloatRange;
20 import android.annotation.IntDef;
21 
22 import java.lang.annotation.Retention;
23 import java.lang.annotation.RetentionPolicy;
24 
25 /**
26  * Interface defining mechanism for controlling the directionality and field width of
27  * audio capture.
28  */
29 public interface MicrophoneDirection {
30     /**
31      * Don't do any directionality processing of the activated microphone(s).
32      */
33     int MIC_DIRECTION_UNSPECIFIED = 0;
34     /**
35      * Optimize capture for audio coming from the side of the device facing the user.
36      * In the typical case, a device with a single screen, screen-side camera/microphone and
37      * non-screen-side camera/microphone, this will be the screen side (as in a "selfie").
38      * For a different device geometry, it is the side for which the expectation is to be
39      * facing the user.
40      */
41     int MIC_DIRECTION_TOWARDS_USER = 1;
42     /**
43      * Optimize capture for audio coming from the side of the device pointing away from the user.
44      * In the typical case, a device with a single screen, screen-side camera/microphone and
45      * non-screen-side camera/microphone, this will be the non-screen side.
46      * For a different device geometry, it is the side for which the expectation is to be
47      * facing away from the user. This is the "taking a video of something else" case.
48      */
49     int MIC_DIRECTION_AWAY_FROM_USER = 2;
50     /**
51      * Optimize capture for audio coming from an off-device microphone.
52      */
53     int MIC_DIRECTION_EXTERNAL = 3;
54 
55     /** @hide */
56     /*public*/ @IntDef({
57             MIC_DIRECTION_UNSPECIFIED,
58             MIC_DIRECTION_TOWARDS_USER,
59             MIC_DIRECTION_AWAY_FROM_USER,
60             MIC_DIRECTION_EXTERNAL
61     })
62     @Retention(RetentionPolicy.SOURCE)
63     @interface DirectionMode{};
64     /**
65      * Specifies the logical microphone (for processing). Applications can use this to specify
66      * which side of the device to optimize capture from. Typically used in conjunction with
67      * the camera capturing video.
68      *
69      * Usage would include specifying the audio capture to follow camera being used to capture
70      * video.
71      * @param direction Direction constant.
72      * @return true if sucessful.
73      */
setPreferredMicrophoneDirection(@irectionMode int direction)74     boolean setPreferredMicrophoneDirection(@DirectionMode int direction);
75 
76     /**
77      * Specifies the zoom factor (i.e. the field dimension) for the selected microphone
78      * (for processing). The selected microphone is determined by the use-case for the stream.
79      *
80      * Usage would include specifying the audio focus to follow the zoom specified for the camera
81      * being used to capture video.
82      *
83      * @param zoom the desired field dimension of microphone capture. Range is from -1 (wide angle),
84      * though 0 (no zoom) to 1 (maximum zoom).
85      * @return true if sucessful.
86      */
setPreferredMicrophoneFieldDimension(@loatRangefrom = -1.0, to = 1.0) float zoom)87     boolean setPreferredMicrophoneFieldDimension(@FloatRange(from = -1.0, to = 1.0) float zoom);
88 }
89