| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // allows calls like JavaAudioManager::Close() while hiding the Java/JNI | 40 // allows calls like JavaAudioManager::Close() while hiding the Java/JNI |
| 41 // parts that are associated with this call. | 41 // parts that are associated with this call. |
| 42 class JavaAudioManager { | 42 class JavaAudioManager { |
| 43 public: | 43 public: |
| 44 JavaAudioManager(NativeRegistration* native_registration, | 44 JavaAudioManager(NativeRegistration* native_registration, |
| 45 std::unique_ptr<GlobalRef> audio_manager); | 45 std::unique_ptr<GlobalRef> audio_manager); |
| 46 ~JavaAudioManager(); | 46 ~JavaAudioManager(); |
| 47 | 47 |
| 48 bool Init(); | 48 bool Init(); |
| 49 void Close(); | 49 void Close(); |
| 50 void SetCommunicationMode(bool enable); |
| 50 bool IsCommunicationModeEnabled(); | 51 bool IsCommunicationModeEnabled(); |
| 51 bool IsDeviceBlacklistedForOpenSLESUsage(); | 52 bool IsDeviceBlacklistedForOpenSLESUsage(); |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 std::unique_ptr<GlobalRef> audio_manager_; | 55 std::unique_ptr<GlobalRef> audio_manager_; |
| 55 jmethodID init_; | 56 jmethodID init_; |
| 56 jmethodID dispose_; | 57 jmethodID dispose_; |
| 58 jmethodID set_communication_mode_; |
| 57 jmethodID is_communication_mode_enabled_; | 59 jmethodID is_communication_mode_enabled_; |
| 58 jmethodID is_device_blacklisted_for_open_sles_usage_; | 60 jmethodID is_device_blacklisted_for_open_sles_usage_; |
| 59 }; | 61 }; |
| 60 | 62 |
| 61 AudioManager(); | 63 AudioManager(); |
| 62 ~AudioManager(); | 64 ~AudioManager(); |
| 63 | 65 |
| 64 // Sets the currently active audio layer combination. Must be called before | 66 // Sets the currently active audio layer combination. Must be called before |
| 65 // Init(). | 67 // Init(). |
| 66 void SetActiveAudioLayer(AudioDeviceModule::AudioLayer audio_layer); | 68 void SetActiveAudioLayer(AudioDeviceModule::AudioLayer audio_layer); |
| 67 | 69 |
| 68 // Creates and realizes the main (global) Open SL engine object and returns | 70 // Creates and realizes the main (global) Open SL engine object and returns |
| 69 // a reference to it. The engine object is only created at the first call | 71 // a reference to it. The engine object is only created at the first call |
| 70 // since OpenSL ES for Android only supports a single engine per application. | 72 // since OpenSL ES for Android only supports a single engine per application. |
| 71 // Subsequent calls returns the already created engine. The SL engine object | 73 // Subsequent calls returns the already created engine. The SL engine object |
| 72 // is destroyed when the AudioManager object is deleted. It means that the | 74 // is destroyed when the AudioManager object is deleted. It means that the |
| 73 // engine object will be the first OpenSL ES object to be created and last | 75 // engine object will be the first OpenSL ES object to be created and last |
| 74 // object to be destroyed. | 76 // object to be destroyed. |
| 75 // Note that NULL will be returned unless the audio layer is specified as | 77 // Note that NULL will be returned unless the audio layer is specified as |
| 76 // AudioDeviceModule::kAndroidOpenSLESAudio or | 78 // AudioDeviceModule::kAndroidOpenSLESAudio or |
| 77 // AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio. | 79 // AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio. |
| 78 SLObjectItf GetOpenSLEngine(); | 80 SLObjectItf GetOpenSLEngine(); |
| 79 | 81 |
| 80 // Initializes the audio manager and stores the current audio mode. | 82 // Initializes the audio manager and stores the current audio mode. |
| 81 bool Init(); | 83 bool Init(); |
| 82 // Revert any setting done by Init(). | 84 // Revert any setting done by Init(). |
| 83 bool Close(); | 85 bool Close(); |
| 84 | 86 |
| 87 // Set audio mode to AudioManager.MODE_IN_COMMUNICATION if |enable| is true |
| 88 // and AudioManager.MODE_NORMAL otherwise. |
| 89 void SetCommunicationMode(bool enable); |
| 85 // Returns true if current audio mode is AudioManager.MODE_IN_COMMUNICATION. | 90 // Returns true if current audio mode is AudioManager.MODE_IN_COMMUNICATION. |
| 86 bool IsCommunicationModeEnabled() const; | 91 bool IsCommunicationModeEnabled() const; |
| 87 | 92 |
| 88 // Native audio parameters stored during construction. | 93 // Native audio parameters stored during construction. |
| 89 const AudioParameters& GetPlayoutAudioParameters(); | 94 const AudioParameters& GetPlayoutAudioParameters(); |
| 90 const AudioParameters& GetRecordAudioParameters(); | 95 const AudioParameters& GetRecordAudioParameters(); |
| 91 | 96 |
| 92 // Returns true if the device supports built-in audio effects for AEC, AGC | 97 // Returns true if the device supports built-in audio effects for AEC, AGC |
| 93 // and NS. Some devices can also be blacklisted for use in combination with | 98 // and NS. Some devices can also be blacklisted for use in combination with |
| 94 // platform effects and these devices will return false. | 99 // platform effects and these devices will return false. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Contains native parameters (e.g. sample rate, channel configuration). | 202 // Contains native parameters (e.g. sample rate, channel configuration). |
| 198 // Set at construction in OnCacheAudioParameters() which is called from | 203 // Set at construction in OnCacheAudioParameters() which is called from |
| 199 // Java on the same thread as this object is created on. | 204 // Java on the same thread as this object is created on. |
| 200 AudioParameters playout_parameters_; | 205 AudioParameters playout_parameters_; |
| 201 AudioParameters record_parameters_; | 206 AudioParameters record_parameters_; |
| 202 }; | 207 }; |
| 203 | 208 |
| 204 } // namespace webrtc | 209 } // namespace webrtc |
| 205 | 210 |
| 206 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ | 211 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_MANAGER_H_ |
| OLD | NEW |