BUILD.gn (19831B)
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 9 import("//chromium/build/config/linux/gtk/gtk.gni") 10 import("//chromium/build/config/ui.gni") 11 import("../../webrtc.gni") 12 13 use_desktop_capture_differ_sse2 = target_cpu == "x86" || target_cpu == "x64" 14 15 config("x11_config") { 16 if (rtc_use_x11_extensions) { 17 defines = [ "WEBRTC_USE_X11" ] 18 } 19 } 20 21 rtc_library("primitives") { 22 visibility = [ "*" ] 23 sources = [ 24 "desktop_capture_types.h", 25 "desktop_frame.cc", 26 "desktop_frame.h", 27 "desktop_geometry.cc", 28 "desktop_geometry.h", 29 "desktop_region.cc", 30 "desktop_region.h", 31 "shared_desktop_frame.cc", 32 "shared_desktop_frame.h", 33 "shared_memory.cc", 34 "shared_memory.h", 35 ] 36 37 deps = [ 38 "../../api:scoped_refptr", 39 "../../media:video_common", 40 "../../rtc_base:checks", 41 "../../rtc_base:refcount", 42 "../../rtc_base:stringutils", 43 "../../rtc_base/system:rtc_export", 44 "//third_party/libyuv", 45 ] 46 } 47 48 if (rtc_include_tests) { 49 rtc_library("desktop_capture_modules_tests") { 50 testonly = true 51 52 defines = [] 53 sources = [] 54 deps = [ 55 ":desktop_capture", 56 "../../api:function_view", 57 "../../api:scoped_refptr", 58 "../../rtc_base:checks", 59 "../../rtc_base:logging", 60 "../../rtc_base:platform_thread", 61 "../../rtc_base:random", 62 "../../rtc_base:timeutils", 63 ] 64 if (rtc_desktop_capture_supported) { 65 deps += [ 66 ":desktop_capture_mock", 67 ":primitives", 68 ":screen_drawer", 69 "../../api:array_view", 70 "../../rtc_base:base64", 71 "../../rtc_base:threading", 72 "../../test:test_support", 73 ] 74 sources += [ 75 "screen_capturer_integration_test.cc", 76 "screen_drawer_unittest.cc", 77 "window_finder_unittest.cc", 78 ] 79 80 if ((is_linux || is_chromeos) && rtc_use_pipewire) { 81 configs += [ "../portal:gio" ] 82 } 83 84 public_configs = [ ":x11_config" ] 85 86 if (is_win) { 87 deps += [ "../../rtc_base/win:windows_version" ] 88 } 89 } 90 } 91 92 if ((is_linux || is_chromeos) && rtc_use_pipewire) { 93 rtc_test("shared_screencast_stream_test") { 94 testonly = true 95 96 sources = [ 97 "linux/wayland/shared_screencast_stream_unittest.cc", 98 "linux/wayland/test/test_screencast_stream_provider.cc", 99 "linux/wayland/test/test_screencast_stream_provider.h", 100 ] 101 102 configs += [ "../portal:pipewire_all" ] 103 104 deps = [ 105 ":desktop_capture", 106 ":desktop_capture_mock", 107 ":primitives", 108 "../../api:scoped_refptr", 109 "../../rtc_base:checks", 110 "../../rtc_base:logging", 111 "../../rtc_base:random", 112 "../../rtc_base:timeutils", 113 "../portal", 114 115 # TODO(bugs.webrtc.org/9987): Remove this dep on rtc_base:rtc_base once 116 # rtc_base:threading is fully defined. 117 "../../rtc_base:task_queue_for_test", 118 "../../rtc_base:threading", 119 "../../system_wrappers", 120 "../../test:test_main", 121 "../../test:test_support", 122 "//api/units:time_delta", 123 "//rtc_base:rtc_event", 124 ] 125 126 data = [ "../../third_party/pipewire" ] 127 public_configs = [ "../portal:pipewire_config" ] 128 } 129 } 130 131 rtc_library("desktop_capture_unittests") { 132 testonly = true 133 134 defines = [] 135 sources = [ 136 "blank_detector_desktop_capturer_wrapper_unittest.cc", 137 "cropped_desktop_frame_unittest.cc", 138 "desktop_and_cursor_composer_unittest.cc", 139 "desktop_capturer_differ_wrapper_unittest.cc", 140 "desktop_frame_rotation_unittest.cc", 141 "desktop_frame_unittest.cc", 142 "desktop_geometry_unittest.cc", 143 "desktop_region_unittest.cc", 144 "differ_block_unittest.cc", 145 "fallback_desktop_capturer_wrapper_unittest.cc", 146 "rgba_color_unittest.cc", 147 "test_utils.cc", 148 "test_utils.h", 149 "test_utils_unittest.cc", 150 ] 151 152 if ((is_linux || is_chromeos) && rtc_use_pipewire) { 153 configs += [ "../portal:gio" ] 154 } 155 156 deps = [ 157 ":desktop_capture", 158 ":desktop_capture_mock", 159 ":primitives", 160 "../../api:array_view", 161 "../../api/units:time_delta", 162 "../../api/units:timestamp", 163 "../../rtc_base:checks", 164 "../../rtc_base:logging", 165 "../../rtc_base:random", 166 "../../rtc_base:task_queue_for_test", 167 "../../rtc_base:threading", 168 "../../rtc_base:timeutils", 169 "../../system_wrappers", 170 "../../test:test_support", 171 ] 172 173 if (is_win) { 174 sources += [ 175 "win/cursor_unittest.cc", 176 "win/cursor_unittest_resources.h", 177 "win/cursor_unittest_resources.rc", 178 "win/full_screen_win_application_handler_unittest.cc", 179 "win/screen_capture_utils_unittest.cc", 180 "win/screen_capturer_win_directx_unittest.cc", 181 "win/test_support/test_window.cc", 182 "win/test_support/test_window.h", 183 "win/window_capture_utils_unittest.cc", 184 ] 185 deps += [ 186 "../../rtc_base/win:scoped_com_initializer", 187 "../../rtc_base/win:windows_version", 188 ] 189 } 190 191 if (rtc_desktop_capture_supported) { 192 sources += [ 193 "screen_capturer_helper_unittest.cc", 194 "screen_capturer_unittest.cc", 195 "window_capturer_unittest.cc", 196 ] 197 if (is_mac) { 198 sources += [ "screen_capturer_mac_unittest.cc" ] 199 } 200 if (rtc_enable_win_wgc) { 201 sources += [ 202 "win/wgc_capture_source_unittest.cc", 203 "win/wgc_capturer_win_unittest.cc", 204 ] 205 } 206 deps += [ 207 ":desktop_capture_mock", 208 "../../system_wrappers:metrics", 209 ] 210 public_configs = [ ":x11_config" ] 211 } 212 } 213 214 rtc_library("screen_drawer") { 215 testonly = true 216 217 sources = [ 218 "screen_drawer.cc", 219 "screen_drawer.h", 220 ] 221 222 if (is_linux || is_chromeos) { 223 sources += [ "screen_drawer_linux.cc" ] 224 libs = [ "X11" ] 225 } 226 227 if (is_mac) { 228 sources += [ "screen_drawer_mac.cc" ] 229 } 230 231 if (is_win) { 232 sources += [ "screen_drawer_win.cc" ] 233 } 234 235 deps = [ 236 ":desktop_capture", 237 ":primitives", 238 "../../api:scoped_refptr", 239 "../../rtc_base:checks", 240 "../../rtc_base:logging", 241 "../../rtc_base:threading", 242 "//third_party/abseil-cpp/absl/strings:string_view", 243 ] 244 245 if (is_posix || is_fuchsia) { 246 sources += [ 247 "screen_drawer_lock_posix.cc", 248 "screen_drawer_lock_posix.h", 249 ] 250 } 251 } 252 253 rtc_library("desktop_capture_mock") { 254 testonly = true 255 256 sources = [ 257 "mock_desktop_capturer_callback.cc", 258 "mock_desktop_capturer_callback.h", 259 ] 260 261 if ((is_linux || is_chromeos) && rtc_use_pipewire) { 262 configs += [ "../portal:gio" ] 263 } 264 265 deps = [ 266 ":desktop_capture", 267 ":primitives", 268 "../../test:test_support", 269 ] 270 } 271 } 272 273 # TODO(bugs.webrtc.org/14187): remove when all users are gone 274 if ((is_linux || is_chromeos) && rtc_use_pipewire) { 275 config("pipewire_config") { 276 configs = [ "../portal:pipewire_config" ] 277 } 278 } 279 280 rtc_library("desktop_capture") { 281 visibility = [ "*" ] 282 defines = [] 283 deps = [ 284 "//third_party/abseil-cpp/absl/memory", 285 "//third_party/abseil-cpp/absl/strings", 286 "//third_party/abseil-cpp/absl/strings:string_view", 287 ] 288 public_configs = [ ":x11_config" ] 289 sources = [ 290 "blank_detector_desktop_capturer_wrapper.cc", 291 "blank_detector_desktop_capturer_wrapper.h", 292 "cropped_desktop_frame.cc", 293 "cropped_desktop_frame.h", 294 "cropping_window_capturer.cc", 295 "cropping_window_capturer.h", 296 "delegated_source_list_controller.h", 297 "desktop_and_cursor_composer.cc", 298 "desktop_and_cursor_composer.h", 299 "desktop_capture_metadata.h", 300 "desktop_capture_metrics_helper.cc", 301 "desktop_capture_metrics_helper.h", 302 "desktop_capture_options.cc", 303 "desktop_capture_options.h", 304 "desktop_capturer.cc", 305 "desktop_capturer.h", 306 "desktop_capturer_differ_wrapper.cc", 307 "desktop_capturer_differ_wrapper.h", 308 "desktop_capturer_wrapper.cc", 309 "desktop_capturer_wrapper.h", 310 "desktop_frame_generator.cc", 311 "desktop_frame_generator.h", 312 "desktop_frame_rotation.cc", 313 "desktop_frame_rotation.h", 314 "differ_block.cc", 315 "differ_block.h", 316 "fake_desktop_capturer.cc", 317 "fake_desktop_capturer.h", 318 "fallback_desktop_capturer_wrapper.cc", 319 "fallback_desktop_capturer_wrapper.h", 320 "full_screen_application_handler.cc", 321 "full_screen_application_handler.h", 322 "full_screen_window_detector.cc", 323 "full_screen_window_detector.h", 324 "mouse_cursor.cc", 325 "mouse_cursor.h", 326 "mouse_cursor_monitor.h", 327 "resolution_tracker.cc", 328 "resolution_tracker.h", 329 "rgba_color.cc", 330 "rgba_color.h", 331 "screen_capture_frame_queue.h", 332 "screen_capturer_helper.cc", 333 "screen_capturer_helper.h", 334 "window_finder.cc", 335 "window_finder.h", 336 ] 337 if (is_mac) { 338 sources += [ 339 "mac/desktop_configuration.h", 340 "mac/desktop_configuration_monitor.cc", 341 "mac/desktop_configuration_monitor.h", 342 "mac/desktop_frame_utils.cc", 343 "mac/desktop_frame_utils.h", 344 "mac/full_screen_mac_application_handler.cc", 345 "mac/full_screen_mac_application_handler.h", 346 "mac/window_list_utils.cc", 347 "mac/window_list_utils.h", 348 ] 349 deps += [ ":desktop_capture_objc" ] 350 } 351 if (rtc_use_x11_extensions || rtc_use_pipewire) { 352 sources += [ 353 "mouse_cursor_monitor_linux.cc", 354 "screen_capturer_linux.cc", 355 "window_capturer_linux.cc", 356 ] 357 } 358 359 if (rtc_use_x11_extensions) { 360 sources += [ 361 "linux/x11/mouse_cursor_monitor_x11.cc", 362 "linux/x11/mouse_cursor_monitor_x11.h", 363 "linux/x11/screen_capturer_x11.cc", 364 "linux/x11/screen_capturer_x11.h", 365 "linux/x11/shared_x_display.cc", 366 "linux/x11/shared_x_display.h", 367 "linux/x11/window_capturer_x11.cc", 368 "linux/x11/window_capturer_x11.h", 369 "linux/x11/window_finder_x11.cc", 370 "linux/x11/window_finder_x11.h", 371 "linux/x11/window_list_utils.cc", 372 "linux/x11/window_list_utils.h", 373 "linux/x11/x_atom_cache.cc", 374 "linux/x11/x_atom_cache.h", 375 "linux/x11/x_error_trap.cc", 376 "linux/x11/x_error_trap.h", 377 "linux/x11/x_server_pixel_buffer.cc", 378 "linux/x11/x_server_pixel_buffer.h", 379 "linux/x11/x_window_property.cc", 380 "linux/x11/x_window_property.h", 381 ] 382 libs = [ 383 "X11", 384 "Xcomposite", 385 "Xdamage", 386 "Xext", 387 "Xfixes", 388 389 # Xrandr depends on Xrender and needs to be listed before its dependency. 390 "Xrandr", 391 392 "Xrender", 393 "Xtst", 394 ] 395 if (build_with_mozilla) { 396 libs -= [ "Xtst" ] 397 # Mozilla provides custom impl of x_error_trap.* 398 sources -= [ 399 "linux/x11/x_error_trap.cc", 400 "linux/x11/x_error_trap.h", 401 ] 402 } 403 } 404 405 if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire && 406 !is_fuchsia) { 407 sources += [ 408 "mouse_cursor_monitor_null.cc", 409 "screen_capturer_null.cc", 410 "window_capturer_null.cc", 411 ] 412 } 413 414 deps += [ 415 ":primitives", 416 "../../api:function_view", 417 "../../api:make_ref_counted", 418 "../../api:refcountedbase", 419 "../../api:scoped_refptr", 420 "../../api:sequence_checker", 421 "../../rtc_base:checks", 422 "../../rtc_base:cpu_info", 423 "../../rtc_base:event_tracer", 424 "../../rtc_base:logging", 425 "../../rtc_base:macromagic", 426 "../../rtc_base:random", 427 "../../rtc_base:stringutils", 428 "../../rtc_base:timeutils", 429 "../../rtc_base/synchronization:mutex", 430 "../../rtc_base/system:arch", 431 "../../rtc_base/system:no_unique_address", 432 "../../rtc_base/system:rtc_export", 433 "../../system_wrappers:metrics", 434 ] 435 436 if (is_fuchsia) { 437 sources += [ 438 "mouse_cursor_monitor_null.cc", 439 "screen_capturer_fuchsia.cc", 440 "screen_capturer_fuchsia.h", 441 "window_capturer_null.cc", 442 ] 443 deps += [ 444 "../../rtc_base:divide_round", 445 "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sysmem", 446 "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.composition", 447 "//third_party/fuchsia-sdk/sdk/fidl/fuchsia.ui.display.singleton", 448 "//third_party/fuchsia-sdk/sdk/pkg/sys_cpp", 449 ] 450 } 451 452 if (is_win) { 453 sources += [ 454 "cropping_window_capturer_win.cc", 455 "desktop_frame_win.cc", 456 "desktop_frame_win.h", 457 "mouse_cursor_monitor_win.cc", 458 "screen_capturer_win.cc", 459 "win/cursor.cc", 460 "win/cursor.h", 461 "win/d3d_device.cc", 462 "win/d3d_device.h", 463 "win/desktop.cc", 464 "win/desktop.h", 465 "win/desktop_capture_utils.cc", 466 "win/desktop_capture_utils.h", 467 "win/display_configuration_monitor.cc", 468 "win/display_configuration_monitor.h", 469 "win/dxgi_adapter_duplicator.cc", 470 "win/dxgi_adapter_duplicator.h", 471 "win/dxgi_context.cc", 472 "win/dxgi_context.h", 473 "win/dxgi_duplicator_controller.cc", 474 "win/dxgi_duplicator_controller.h", 475 "win/dxgi_frame.cc", 476 "win/dxgi_frame.h", 477 "win/dxgi_output_duplicator.cc", 478 "win/dxgi_output_duplicator.h", 479 "win/dxgi_texture.cc", 480 "win/dxgi_texture.h", 481 "win/dxgi_texture_mapping.cc", 482 "win/dxgi_texture_mapping.h", 483 "win/dxgi_texture_staging.cc", 484 "win/dxgi_texture_staging.h", 485 "win/full_screen_win_application_handler.cc", 486 "win/full_screen_win_application_handler.h", 487 "win/scoped_gdi_object.h", 488 "win/scoped_thread_desktop.cc", 489 "win/scoped_thread_desktop.h", 490 "win/screen_capture_utils.cc", 491 "win/screen_capture_utils.h", 492 "win/screen_capturer_win_directx.cc", 493 "win/screen_capturer_win_directx.h", 494 "win/screen_capturer_win_gdi.cc", 495 "win/screen_capturer_win_gdi.h", 496 "win/screen_capturer_win_magnifier.cc", 497 "win/screen_capturer_win_magnifier.h", 498 "win/selected_window_context.cc", 499 "win/selected_window_context.h", 500 "win/window_capture_utils.cc", 501 "win/window_capture_utils.h", 502 "win/window_capturer_win_gdi.cc", 503 "win/window_capturer_win_gdi.h", 504 "window_capturer_win.cc", 505 "window_finder_win.cc", 506 "window_finder_win.h", 507 ] 508 libs = [ 509 "d3d11.lib", 510 "dxgi.lib", 511 "shcore.lib", 512 ] 513 deps += [ 514 "../../rtc_base:threading", 515 "../../rtc_base:win32", 516 "../../rtc_base/containers:flat_map", 517 "../../rtc_base/win:create_direct3d_device", 518 "../../rtc_base/win:get_activation_factory", 519 "../../rtc_base/win:windows_version", 520 ] 521 } 522 523 if (rtc_use_x11_extensions) { 524 deps += [ "../../rtc_base:sanitizer" ] 525 } 526 527 deps += [ "//third_party/libyuv" ] 528 529 if (use_desktop_capture_differ_sse2) { 530 deps += [ ":desktop_capture_differ_sse2" ] 531 } 532 533 if (rtc_use_pipewire) { 534 sources += [ 535 "linux/wayland/base_capturer_pipewire.cc", 536 "linux/wayland/base_capturer_pipewire.h", 537 "linux/wayland/egl_dmabuf.cc", 538 "linux/wayland/egl_dmabuf.h", 539 "linux/wayland/mouse_cursor_monitor_pipewire.cc", 540 "linux/wayland/mouse_cursor_monitor_pipewire.h", 541 "linux/wayland/portal_request_response.h", 542 "linux/wayland/restore_token_manager.cc", 543 "linux/wayland/restore_token_manager.h", 544 "linux/wayland/scoped_glib.h", 545 "linux/wayland/screen_capture_portal_interface.cc", 546 "linux/wayland/screen_capture_portal_interface.h", 547 "linux/wayland/screencast_portal.cc", 548 "linux/wayland/screencast_portal.h", 549 "linux/wayland/screencast_stream_utils.cc", 550 "linux/wayland/screencast_stream_utils.h", 551 "linux/wayland/shared_screencast_stream.cc", 552 "linux/wayland/shared_screencast_stream.h", 553 "linux/wayland/xdg_desktop_portal_utils.h", 554 "linux/wayland/xdg_session_details.h", 555 ] 556 557 configs += [ "../portal:pipewire_all" ] 558 559 public_configs += [ "../portal:pipewire_config" ] 560 561 deps += [ 562 "../../rtc_base:sanitizer", 563 "../portal", 564 ] 565 566 if (build_with_mozilla) { 567 defines += [ "WEBRTC_USE_PIPEWIRE" ] 568 } 569 } 570 571 if (rtc_enable_win_wgc) { 572 sources += [ 573 "win/wgc_capture_session.cc", 574 "win/wgc_capture_session.h", 575 "win/wgc_capture_source.cc", 576 "win/wgc_capture_source.h", 577 "win/wgc_capturer_win.cc", 578 "win/wgc_capturer_win.h", 579 "win/wgc_desktop_frame.cc", 580 "win/wgc_desktop_frame.h", 581 ] 582 libs += [ "dwmapi.lib" ] 583 deps += [ 584 "../../api/units:time_delta", 585 "../../rtc_base:rtc_event", 586 "../../rtc_base:threading", 587 "../../rtc_base/win:hstring", 588 ] 589 } 590 } 591 592 if (is_mac) { 593 rtc_library("desktop_capture_objc") { 594 # This target, needs to be separated from ":desktop_capture" because 595 # that is the C++ part of the target while this one is the Obj-C++ part. 596 # Aside from this, both represent a "desktop_capture" target. 597 # This target separation based on programming languages introduces a 598 # dependency cycle between ":desktop_capture" and 599 # ":desktop_capture_objc". 600 # To break this, ":desktop_capture_objc" shares some .h files with 601 # ":desktop_capture" but when external targets need one of these 602 # headers, they should depend on ":desktop_capture" and consider 603 # this target as private. 604 visibility = [ ":desktop_capture" ] 605 sources = [ 606 "delegated_source_list_controller.h", 607 "desktop_capture_metadata.h", 608 "desktop_capture_options.h", 609 "desktop_capturer.h", 610 "full_screen_application_handler.h", 611 "full_screen_window_detector.h", 612 "mac/desktop_configuration.h", 613 "mac/desktop_configuration.mm", 614 "mac/desktop_configuration_monitor.h", 615 "mac/desktop_frame_cgimage.h", 616 "mac/desktop_frame_cgimage.mm", 617 "mac/desktop_frame_iosurface.h", 618 "mac/desktop_frame_iosurface.mm", 619 "mac/desktop_frame_provider.h", 620 "mac/desktop_frame_provider.mm", 621 "mac/sck_picker_handle.h", 622 "mac/sck_picker_handle.mm", 623 "mac/screen_capturer_mac.h", 624 "mac/screen_capturer_mac.mm", 625 "mac/screen_capturer_sck.h", 626 "mac/screen_capturer_sck.mm", 627 "mac/window_list_utils.h", 628 "mouse_cursor.h", 629 "mouse_cursor_monitor.h", 630 "mouse_cursor_monitor_mac.mm", 631 "screen_capture_frame_queue.h", 632 "screen_capturer_darwin.mm", 633 "screen_capturer_helper.h", 634 "window_capturer_mac.mm", 635 "window_finder.h", 636 "window_finder_mac.h", 637 "window_finder_mac.mm", 638 ] 639 deps = [ 640 ":primitives", 641 "../../api:function_view", 642 "../../api:refcountedbase", 643 "../../api:scoped_refptr", 644 "../../api:sequence_checker", 645 "../../rtc_base:checks", 646 "../../rtc_base:event_tracer", 647 "../../rtc_base:logging", 648 "../../rtc_base:macromagic", 649 "../../rtc_base:safe_conversions", 650 "../../rtc_base:timeutils", 651 "../../rtc_base/synchronization:mutex", 652 "../../rtc_base/system:rtc_export", 653 "../../sdk:helpers_objc", 654 "//third_party/abseil-cpp/absl/base:core_headers", 655 "//third_party/abseil-cpp/absl/strings:str_format", 656 ] 657 frameworks = [ 658 "AppKit.framework", 659 "CoreVideo.framework", 660 "IOKit.framework", 661 "IOSurface.framework", 662 ] 663 weak_frameworks = [ "ScreenCaptureKit.framework" ] # macOS 12.3 664 } 665 } 666 667 if (use_desktop_capture_differ_sse2) { 668 # Have to be compiled as a separate target because it needs to be compiled 669 # with SSE2 enabled. 670 rtc_library("desktop_capture_differ_sse2") { 671 visibility = [ ":*" ] 672 sources = [ 673 "differ_vector_sse2.cc", 674 "differ_vector_sse2.h", 675 ] 676 677 if (is_posix || is_fuchsia) { 678 cflags = [ "-msse2" ] 679 } 680 } 681 }