1# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2# 3# Use of this source code is governed by a BSD-style license 4# that can be found in the LICENSE file in the root of the source 5# tree. An additional intellectual property rights grant can be found 6# in the file PATENTS. All contributing project authors may 7# be found in the AUTHORS file in the root of the source tree. 8 9import("../../webrtc.gni") 10 11if (is_android) { 12 import("//build/config/android/config.gni") 13 import("//build/config/android/rules.gni") 14} 15 16config("audio_device_warnings_config") { 17 if (is_win && is_clang) { 18 cflags = [ 19 # Disable warnings failing when compiling with Clang on Windows. 20 # https://bugs.chromium.org/p/webrtc/issues/detail?id=5366 21 "-Wno-microsoft-goto", 22 ] 23 } 24} 25 26rtc_source_set("audio_device_default") { 27 visibility = [ "*" ] 28 sources = [ "include/audio_device_default.h" ] 29 deps = [ ":audio_device_api" ] 30} 31 32rtc_source_set("audio_device") { 33 visibility = [ "*" ] 34 public_deps = [ 35 ":audio_device_api", 36 37 # Deprecated. 38 # TODO(webrtc:7452): Remove this public dep. audio_device_impl should 39 # be depended on directly if needed. 40 ":audio_device_impl", 41 ] 42} 43 44rtc_source_set("audio_device_api") { 45 visibility = [ "*" ] 46 sources = [ 47 "include/audio_device.h", 48 "include/audio_device_defines.h", 49 ] 50 deps = [ 51 "../../api:scoped_refptr", 52 "../../api/task_queue", 53 "../../rtc_base:checks", 54 "../../rtc_base:deprecation", 55 "../../rtc_base:rtc_base_approved", 56 "../../rtc_base:stringutils", 57 ] 58} 59 60rtc_library("audio_device_buffer") { 61 sources = [ 62 "audio_device_buffer.cc", 63 "audio_device_buffer.h", 64 "audio_device_config.h", 65 "fine_audio_buffer.cc", 66 "fine_audio_buffer.h", 67 ] 68 deps = [ 69 ":audio_device_api", 70 "../../api:array_view", 71 "../../api/task_queue", 72 "../../common_audio:common_audio_c", 73 "../../rtc_base:checks", 74 "../../rtc_base:rtc_base_approved", 75 "../../rtc_base:rtc_task_queue", 76 "../../rtc_base/synchronization:mutex", 77 "../../system_wrappers", 78 "../../system_wrappers:metrics", 79 ] 80} 81 82rtc_library("audio_device_generic") { 83 sources = [ 84 "audio_device_generic.cc", 85 "audio_device_generic.h", 86 ] 87 deps = [ 88 ":audio_device_api", 89 ":audio_device_buffer", 90 "../../rtc_base:rtc_base_approved", 91 ] 92} 93 94rtc_library("audio_device_name") { 95 sources = [ 96 "audio_device_name.cc", 97 "audio_device_name.h", 98 ] 99} 100 101rtc_source_set("windows_core_audio_utility") { 102 if (is_win && !build_with_chromium) { 103 sources = [ 104 "win/core_audio_utility_win.cc", 105 "win/core_audio_utility_win.h", 106 ] 107 108 deps = [ 109 ":audio_device_api", 110 ":audio_device_name", 111 "../../api/units:time_delta", 112 "../../rtc_base:checks", 113 "../../rtc_base:rtc_base_approved", 114 ] 115 } 116} 117 118# An ADM with a dedicated factory method which does not depend on the 119# audio_device_impl target. The goal is to use this new structure and 120# gradually phase out the old design. 121# TODO(henrika): currently only supported on Windows. 122rtc_source_set("audio_device_module_from_input_and_output") { 123 visibility = [ "*" ] 124 if (is_win && !build_with_chromium) { 125 sources = [ 126 "include/audio_device_factory.cc", 127 "include/audio_device_factory.h", 128 ] 129 sources += [ 130 "win/audio_device_module_win.cc", 131 "win/audio_device_module_win.h", 132 "win/core_audio_base_win.cc", 133 "win/core_audio_base_win.h", 134 "win/core_audio_input_win.cc", 135 "win/core_audio_input_win.h", 136 "win/core_audio_output_win.cc", 137 "win/core_audio_output_win.h", 138 ] 139 140 deps = [ 141 ":audio_device_api", 142 ":audio_device_buffer", 143 ":windows_core_audio_utility", 144 "../../api:scoped_refptr", 145 "../../api/task_queue", 146 "../../rtc_base:checks", 147 "../../rtc_base:rtc_base_approved", 148 ] 149 absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] 150 } 151} 152 153# Contains default implementations of webrtc::AudioDeviceModule for Windows, 154# Linux, Mac, iOS and Android. 155rtc_library("audio_device_impl") { 156 visibility = [ "*" ] 157 deps = [ 158 ":audio_device_api", 159 ":audio_device_buffer", 160 ":audio_device_default", 161 ":audio_device_generic", 162 "../../api:array_view", 163 "../../api:refcountedbase", 164 "../../api:scoped_refptr", 165 "../../api/task_queue", 166 "../../common_audio", 167 "../../common_audio:common_audio_c", 168 "../../rtc_base", 169 "../../rtc_base:checks", 170 "../../rtc_base:deprecation", 171 "../../rtc_base:rtc_base_approved", 172 "../../rtc_base:rtc_task_queue", 173 "../../rtc_base/synchronization:mutex", 174 "../../rtc_base/system:arch", 175 "../../rtc_base/system:file_wrapper", 176 "../../rtc_base/task_utils:repeating_task", 177 "../../system_wrappers", 178 "../../system_wrappers:field_trial", 179 "../../system_wrappers:metrics", 180 "../utility", 181 ] 182 if (rtc_include_internal_audio_device && is_ios) { 183 deps += [ "../../sdk:audio_device" ] 184 } 185 186 sources = [ 187 "dummy/audio_device_dummy.cc", 188 "dummy/audio_device_dummy.h", 189 "dummy/file_audio_device.cc", 190 "dummy/file_audio_device.h", 191 "include/fake_audio_device.h", 192 "include/test_audio_device.cc", 193 "include/test_audio_device.h", 194 ] 195 196 if (build_with_mozilla) { 197 sources += [ 198 "opensl/single_rw_fifo.cc", 199 "opensl/single_rw_fifo.h", 200 ] 201 } 202 203 defines = [] 204 cflags = [] 205 if (rtc_audio_device_plays_sinus_tone) { 206 defines += [ "AUDIO_DEVICE_PLAYS_SINUS_TONE" ] 207 } 208 if (rtc_enable_android_aaudio) { 209 defines += [ "WEBRTC_AUDIO_DEVICE_INCLUDE_ANDROID_AAUDIO" ] 210 } 211 if (rtc_include_internal_audio_device) { 212 sources += [ 213 "audio_device_data_observer.cc", 214 "audio_device_impl.cc", 215 "audio_device_impl.h", 216 "include/audio_device_data_observer.h", 217 ] 218 if (is_android) { 219 sources += [ 220 "android/audio_common.h", 221 "android/audio_device_template.h", 222 "android/audio_manager.cc", 223 "android/audio_manager.h", 224 "android/audio_record_jni.cc", 225 "android/audio_record_jni.h", 226 "android/audio_track_jni.cc", 227 "android/audio_track_jni.h", 228 "android/build_info.cc", 229 "android/build_info.h", 230 "android/opensles_common.cc", 231 "android/opensles_common.h", 232 "android/opensles_player.cc", 233 "android/opensles_player.h", 234 "android/opensles_recorder.cc", 235 "android/opensles_recorder.h", 236 ] 237 libs = [ 238 "log", 239 "OpenSLES", 240 ] 241 if (rtc_enable_android_aaudio) { 242 sources += [ 243 "android/aaudio_player.cc", 244 "android/aaudio_player.h", 245 "android/aaudio_recorder.cc", 246 "android/aaudio_recorder.h", 247 "android/aaudio_wrapper.cc", 248 "android/aaudio_wrapper.h", 249 ] 250 libs += [ "aaudio" ] 251 } 252 253 if (build_with_mozilla) { 254 include_dirs += [ 255 "/config/external/nspr", 256 "/nsprpub/lib/ds", 257 "/nsprpub/pr/include", 258 ] 259 } 260 } 261 if (rtc_use_dummy_audio_file_devices) { 262 defines += [ "WEBRTC_DUMMY_FILE_DEVICES" ] 263 } else { 264 if (is_linux) { 265 sources += [ 266 "linux/alsasymboltable_linux.cc", 267 "linux/alsasymboltable_linux.h", 268 "linux/audio_device_alsa_linux.cc", 269 "linux/audio_device_alsa_linux.h", 270 "linux/audio_mixer_manager_alsa_linux.cc", 271 "linux/audio_mixer_manager_alsa_linux.h", 272 "linux/latebindingsymboltable_linux.cc", 273 "linux/latebindingsymboltable_linux.h", 274 ] 275 defines += [ "WEBRTC_ENABLE_LINUX_ALSA" ] 276 libs = [ "dl" ] 277 if (rtc_use_x11) { 278 libs += [ "X11" ] 279 defines += [ "WEBRTC_USE_X11" ] 280 } 281 if (rtc_include_pulse_audio) { 282 defines += [ "WEBRTC_ENABLE_LINUX_PULSE" ] 283 } 284 sources += [ 285 "linux/audio_device_pulse_linux.cc", 286 "linux/audio_device_pulse_linux.h", 287 "linux/audio_mixer_manager_pulse_linux.cc", 288 "linux/audio_mixer_manager_pulse_linux.h", 289 "linux/pulseaudiosymboltable_linux.cc", 290 "linux/pulseaudiosymboltable_linux.h", 291 ] 292 } 293 if (is_mac) { 294 sources += [ 295 "mac/audio_device_mac.cc", 296 "mac/audio_device_mac.h", 297 "mac/audio_mixer_manager_mac.cc", 298 "mac/audio_mixer_manager_mac.h", 299 ] 300 deps += [ 301 ":audio_device_impl_frameworks", 302 "../third_party/portaudio:mac_portaudio", 303 ] 304 } 305 if (is_win) { 306 sources += [ 307 "win/audio_device_core_win.cc", 308 "win/audio_device_core_win.h", 309 ] 310 libs = [ 311 # Required for the built-in WASAPI AEC. 312 "dmoguids.lib", 313 "wmcodecdspuuid.lib", 314 "amstrmid.lib", 315 "msdmo.lib", 316 ] 317 } 318 configs += [ ":audio_device_warnings_config" ] 319 } 320 } else { 321 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ] 322 } 323 324 if (!build_with_chromium) { 325 sources += [ 326 # Do not link these into Chrome since they contain static data. 327 "dummy/file_audio_device_factory.cc", 328 "dummy/file_audio_device_factory.h", 329 ] 330 } 331} 332 333if (is_mac) { 334 rtc_source_set("audio_device_impl_frameworks") { 335 visibility = [ ":*" ] 336 frameworks = [ 337 # Needed for CoreGraphics: 338 "ApplicationServices.framework", 339 340 "AudioToolbox.framework", 341 "CoreAudio.framework", 342 343 # Needed for CGEventSourceKeyState in audio_device_mac.cc: 344 "CoreGraphics.framework", 345 ] 346 } 347} 348 349rtc_source_set("mock_audio_device") { 350 testonly = true 351 sources = [ 352 "include/mock_audio_device.h", 353 "include/mock_audio_transport.h", 354 "mock_audio_device_buffer.h", 355 ] 356 deps = [ 357 ":audio_device", 358 ":audio_device_buffer", 359 ":audio_device_impl", 360 "../../rtc_base:refcount", 361 "../../test:test_support", 362 ] 363} 364 365if (rtc_include_tests) { 366 rtc_library("audio_device_unittests") { 367 testonly = true 368 369 sources = [ 370 "fine_audio_buffer_unittest.cc", 371 "include/test_audio_device_unittest.cc", 372 ] 373 deps = [ 374 ":audio_device", 375 ":audio_device_buffer", 376 ":audio_device_impl", 377 ":mock_audio_device", 378 "../../api:array_view", 379 "../../api:scoped_refptr", 380 "../../api/task_queue", 381 "../../api/task_queue:default_task_queue_factory", 382 "../../common_audio", 383 "../../rtc_base:checks", 384 "../../rtc_base:ignore_wundef", 385 "../../rtc_base:rtc_base_approved", 386 "../../rtc_base/synchronization:mutex", 387 "../../system_wrappers", 388 "../../test:fileutils", 389 "../../test:test_support", 390 "../utility", 391 ] 392 absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ] 393 if (is_linux || is_mac || is_win) { 394 sources += [ "audio_device_unittest.cc" ] 395 } 396 if (is_win) { 397 sources += [ "win/core_audio_utility_win_unittest.cc" ] 398 deps += [ 399 ":audio_device_module_from_input_and_output", 400 ":windows_core_audio_utility", 401 ] 402 } 403 if (is_android) { 404 # Need to disable error due to the line in 405 # base/android/jni_android.h triggering it: 406 # const BASE_EXPORT jobject GetApplicationContext() 407 # error: type qualifiers ignored on function return type 408 cflags = [ "-Wno-ignored-qualifiers" ] 409 sources += [ 410 "android/audio_device_unittest.cc", 411 "android/audio_manager_unittest.cc", 412 "android/ensure_initialized.cc", 413 "android/ensure_initialized.h", 414 ] 415 deps += [ 416 "../../base", 417 "../../sdk/android:libjingle_peerconnection_java", 418 ] 419 } 420 if (!rtc_include_internal_audio_device) { 421 defines = [ "WEBRTC_DUMMY_AUDIO_BUILD" ] 422 } 423 } 424} 425 426if (!build_with_chromium && is_android) { 427 rtc_android_library("audio_device_java") { 428 sources = [ 429 "android/java/src/org/webrtc/voiceengine/BuildInfo.java", 430 "android/java/src/org/webrtc/voiceengine/WebRtcAudioEffects.java", 431 "android/java/src/org/webrtc/voiceengine/WebRtcAudioManager.java", 432 "android/java/src/org/webrtc/voiceengine/WebRtcAudioRecord.java", 433 "android/java/src/org/webrtc/voiceengine/WebRtcAudioTrack.java", 434 "android/java/src/org/webrtc/voiceengine/WebRtcAudioUtils.java", 435 ] 436 deps = [ 437 "../../rtc_base:base_java", 438 "//third_party/android_deps:com_android_support_support_annotations_java", 439 ] 440 } 441} 442