AcousticEchoCanceler.java revision 0f7f4ece1b6b73caf608d533d833a8cdc11c8131
1/*
2 * Copyright (C) 2011 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
17package android.media.audiofx;
18
19/**
20 * Acoustic Echo Canceler (AEC).
21 * <p>Acoustic Echo Canceler (AEC) is an audio pre-processing which removes the contribution of the
22 * signal received from the remote party from the captured audio signal.
23 * <p>AEC is used by voice communication applications (voice chat, video conferencing, SIP calls)
24 * where the presence of echo with significant delay in the signal received from the remote party
25 * is highly disturbing. AEC is often used in conjunction with noise suppression (NS).
26 * <p>An application creates an AcousticEchoCanceler object to instantiate and control an AEC
27 * engine in the audio capture path.
28 * <p>To attach the AcousticEchoCanceler to a particular {@link android.media.AudioRecord},
29 * specify the audio session ID of this AudioRecord when constructing the AcousticEchoCanceler.
30 * The audio session is retrieved by calling
31 * {@link android.media.AudioRecord#getAudioSessionId()} on the AudioRecord instance.
32 * <p>On some devices, an AEC can be inserted by default in the capture path by the platform
33 * according to the {@link android.media.MediaRecorder.AudioSource} used. The application can
34 * query which pre-processings are currently applied to an AudioRecord instance by calling
35 * {@link android.media.audiofx.AudioEffect#queryPreProcessings(int)} with the audio session of the
36 * AudioRecord.
37 * <p>See {@link android.media.audiofx.AudioEffect} class for more details on
38 * controlling audio effects.
39 * @hide
40 */
41
42public class AcousticEchoCanceler extends AudioEffect {
43
44    private final static String TAG = "AcousticEchoCanceler";
45
46    /**
47     * Class constructor.
48     * <p> The application must catch exceptions when creating an AcousticEchoCanceler as the
49     * constructor is not guarantied to succeed:
50     * <ul>
51     *  <li>IllegalArgumentException is thrown if the device does not implement an AEC</li>
52     *  <li>UnsupportedOperationException is thrown is the resources allocated to audio
53     *  pre-procesing are currently exceeded.</li>
54     * </ul>
55     *
56     * @param audioSession system wide unique audio session identifier. The AcousticEchoCanceler
57     * will be applied to the AudioRecord with the same audio session.
58     *
59     * @throws java.lang.IllegalArgumentException
60     * @throws java.lang.UnsupportedOperationException
61     * @throws java.lang.RuntimeException
62     */
63    public AcousticEchoCanceler(int audioSession)
64            throws IllegalArgumentException, UnsupportedOperationException, RuntimeException {
65        super(EFFECT_TYPE_AEC, EFFECT_TYPE_NULL, 0, audioSession);
66    }
67}
68