• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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("//build/config/linux/pkg_config.gni")
10import("//build/config/ui.gni")
11import("//tools/generate_stubs/rules.gni")
12import("../../webrtc.gni")
13
14use_desktop_capture_differ_sse2 = current_cpu == "x86" || current_cpu == "x64"
15
16config("x11_config") {
17  if (rtc_use_x11_extensions) {
18    defines = [ "WEBRTC_USE_X11" ]
19  }
20}
21
22rtc_library("primitives") {
23  visibility = [ "*" ]
24  sources = [
25    "desktop_capture_types.h",
26    "desktop_frame.cc",
27    "desktop_frame.h",
28    "desktop_geometry.cc",
29    "desktop_geometry.h",
30    "desktop_region.cc",
31    "desktop_region.h",
32    "shared_desktop_frame.cc",
33    "shared_desktop_frame.h",
34    "shared_memory.cc",
35    "shared_memory.h",
36  ]
37
38  deps = [
39    "../../api:scoped_refptr",
40    "../../rtc_base:checks",
41    "../../rtc_base/system:rtc_export",
42  ]
43
44  if (!build_with_mozilla) {
45    deps += [ "../../rtc_base" ]  # TODO(kjellander): Cleanup in
46                                  # bugs.webrtc.org/3806.
47  }
48}
49
50if (rtc_include_tests) {
51  rtc_library("desktop_capture_modules_tests") {
52    testonly = true
53
54    defines = []
55    sources = []
56    deps = [
57      "../../api:function_view",
58      "../../api:scoped_refptr",
59      "../../rtc_base:checks",
60    ]
61    if (rtc_desktop_capture_supported) {
62      deps += [
63        ":desktop_capture_mock",
64        ":primitives",
65        ":screen_drawer",
66        "../../rtc_base",
67        "../../rtc_base:rtc_base_approved",
68        "../../rtc_base/third_party/base64",
69        "../../system_wrappers",
70        "../../test:test_support",
71        "../../test:video_test_support",
72      ]
73      sources += [
74        "screen_capturer_integration_test.cc",
75        "screen_drawer_unittest.cc",
76        "window_finder_unittest.cc",
77      ]
78      public_configs = [ ":x11_config" ]
79    }
80  }
81
82  rtc_library("desktop_capture_unittests") {
83    testonly = true
84
85    defines = []
86    sources = [
87      "blank_detector_desktop_capturer_wrapper_unittest.cc",
88      "cropped_desktop_frame_unittest.cc",
89      "desktop_and_cursor_composer_unittest.cc",
90      "desktop_capturer_differ_wrapper_unittest.cc",
91      "desktop_frame_rotation_unittest.cc",
92      "desktop_frame_unittest.cc",
93      "desktop_geometry_unittest.cc",
94      "desktop_region_unittest.cc",
95      "differ_block_unittest.cc",
96      "fallback_desktop_capturer_wrapper_unittest.cc",
97      "mouse_cursor_monitor_unittest.cc",
98      "rgba_color_unittest.cc",
99      "test_utils.cc",
100      "test_utils.h",
101      "test_utils_unittest.cc",
102    ]
103    if (is_win) {
104      sources += [
105        "win/cursor_unittest.cc",
106        "win/cursor_unittest_resources.h",
107        "win/cursor_unittest_resources.rc",
108        "win/screen_capture_utils_unittest.cc",
109        "win/screen_capturer_win_directx_unittest.cc",
110      ]
111    }
112    deps = [
113      ":desktop_capture",
114      ":desktop_capture_mock",
115      ":primitives",
116      "../../rtc_base:checks",
117      "../../rtc_base:rtc_base_approved",
118      "../../system_wrappers:cpu_features_api",
119      "../../test:test_support",
120    ]
121    if (rtc_desktop_capture_supported) {
122      sources += [
123        "screen_capturer_helper_unittest.cc",
124        "screen_capturer_mac_unittest.cc",
125        "screen_capturer_unittest.cc",
126        "window_capturer_unittest.cc",
127      ]
128      deps += [ ":desktop_capture_mock" ]
129      public_configs = [ ":x11_config" ]
130    }
131  }
132
133  rtc_library("screen_drawer") {
134    testonly = true
135
136    public_deps = [ ":desktop_capture" ]  # no-presubmit-check TODO(webrtc:8603)
137
138    sources = [
139      "screen_drawer.cc",
140      "screen_drawer.h",
141    ]
142
143    if (is_linux) {
144      sources += [ "screen_drawer_linux.cc" ]
145    }
146
147    if (is_mac) {
148      sources += [ "screen_drawer_mac.cc" ]
149    }
150
151    if (is_win) {
152      sources += [ "screen_drawer_win.cc" ]
153    }
154
155    deps = [
156      ":primitives",
157      "../../api:scoped_refptr",
158      "../../rtc_base:checks",
159      "../../rtc_base:rtc_base_approved",
160      "../../system_wrappers",
161    ]
162
163    if (is_posix || is_fuchsia) {
164      sources += [
165        "screen_drawer_lock_posix.cc",
166        "screen_drawer_lock_posix.h",
167      ]
168    }
169  }
170
171  rtc_library("desktop_capture_mock") {
172    testonly = true
173
174    public_deps = [ ":desktop_capture" ]  # no-presubmit-check TODO(webrtc:8603)
175
176    sources = [
177      "mock_desktop_capturer_callback.cc",
178      "mock_desktop_capturer_callback.h",
179    ]
180
181    deps = [
182      ":primitives",
183      "../../rtc_base:rtc_base_approved",
184      "../../test:test_support",
185    ]
186  }
187}
188
189if (is_linux) {
190  if (rtc_use_pipewire) {
191    pkg_config("gio") {
192      packages = [
193        "gio-2.0",
194        "gio-unix-2.0",
195      ]
196    }
197
198    if (rtc_link_pipewire) {
199      pkg_config("pipewire") {
200        packages = [ "libpipewire-0.2" ]
201      }
202    } else {
203      # When libpipewire is not directly linked, use stubs to allow for dlopening of
204      # the binary.
205      generate_stubs("pipewire_stubs") {
206        configs = [ "../../:common_config" ]
207        deps = [ "../../rtc_base" ]
208        extra_header = "linux/pipewire_stub_header.fragment"
209        logging_function = "RTC_LOG(LS_VERBOSE)"
210        logging_include = "rtc_base/logging.h"
211        output_name = "linux/pipewire_stubs"
212        path_from_source = "modules/desktop_capture/linux"
213        sigs = [ "linux/pipewire.sigs" ]
214      }
215    }
216
217    config("pipewire_config") {
218      defines = [ "WEBRTC_USE_PIPEWIRE" ]
219      if (!rtc_link_pipewire) {
220        defines += [ "WEBRTC_DLOPEN_PIPEWIRE" ]
221      }
222    }
223  }
224}
225
226rtc_source_set("desktop_capture") {
227  visibility = [ "*" ]
228  public_deps =  # no-presubmit-check TODO(webrtc:8603)
229      [ ":desktop_capture_generic" ]
230  if (is_mac) {
231    public_deps += [ ":desktop_capture_objc" ]
232  }
233}
234
235if (is_mac) {
236  rtc_library("desktop_capture_objc") {
237    visibility = [ ":desktop_capture" ]
238    sources = [
239      "mac/desktop_configuration.mm",
240      "mac/desktop_frame_cgimage.h",
241      "mac/desktop_frame_cgimage.mm",
242      "mac/desktop_frame_iosurface.h",
243      "mac/desktop_frame_iosurface.mm",
244      "mac/desktop_frame_provider.h",
245      "mac/desktop_frame_provider.mm",
246      "mac/screen_capturer_mac.h",
247      "mac/screen_capturer_mac.mm",
248      "mouse_cursor_monitor_mac.mm",
249      "screen_capturer_darwin.mm",
250      "window_capturer_mac.mm",
251      "window_finder_mac.h",
252      "window_finder_mac.mm",
253    ]
254    deps = [
255      ":desktop_capture_generic",
256      ":primitives",
257      "../../api:scoped_refptr",
258      "../../rtc_base",
259      "../../rtc_base:checks",
260      "../../rtc_base:rtc_base_approved",
261      "../../rtc_base/synchronization:rw_lock_wrapper",
262      "../../rtc_base/system:rtc_export",
263      "../../sdk:helpers_objc",
264    ]
265    frameworks = [
266      "AppKit.framework",
267      "IOKit.framework",
268      "IOSurface.framework",
269    ]
270  }
271}
272
273rtc_library("desktop_capture_generic") {
274  defines = []
275  public_configs = [ ":x11_config" ]
276  visibility = [
277    ":desktop_capture",
278    ":desktop_capture_objc",
279  ]
280  sources = [
281    "blank_detector_desktop_capturer_wrapper.cc",
282    "blank_detector_desktop_capturer_wrapper.h",
283    "capture_result_desktop_capturer_wrapper.cc",
284    "capture_result_desktop_capturer_wrapper.h",
285    "cropped_desktop_frame.cc",
286    "cropped_desktop_frame.h",
287    "cropping_window_capturer.cc",
288    "cropping_window_capturer.h",
289    "desktop_and_cursor_composer.cc",
290    "desktop_and_cursor_composer.h",
291    "desktop_capture_options.cc",
292    "desktop_capture_options.h",
293    "desktop_capturer.cc",
294    "desktop_capturer.h",
295    "desktop_capturer_differ_wrapper.cc",
296    "desktop_capturer_differ_wrapper.h",
297    "desktop_capturer_wrapper.cc",
298    "desktop_capturer_wrapper.h",
299    "desktop_frame_generator.cc",
300    "desktop_frame_generator.h",
301    "desktop_frame_rotation.cc",
302    "desktop_frame_rotation.h",
303    "differ_block.cc",
304    "differ_block.h",
305    "fake_desktop_capturer.cc",
306    "fake_desktop_capturer.h",
307    "fallback_desktop_capturer_wrapper.cc",
308    "fallback_desktop_capturer_wrapper.h",
309    "full_screen_application_handler.cc",
310    "full_screen_application_handler.h",
311    "full_screen_window_detector.cc",
312    "full_screen_window_detector.h",
313    "mouse_cursor.cc",
314    "mouse_cursor.h",
315    "mouse_cursor_monitor.h",
316    "resolution_tracker.cc",
317    "resolution_tracker.h",
318    "rgba_color.cc",
319    "rgba_color.h",
320    "screen_capture_frame_queue.h",
321    "screen_capturer_helper.cc",
322    "screen_capturer_helper.h",
323    "window_finder.cc",
324    "window_finder.h",
325  ]
326
327  if (is_mac) {
328    sources += [
329      "mac/desktop_configuration.h",
330      "mac/desktop_configuration_monitor.cc",
331      "mac/desktop_configuration_monitor.h",
332      "mac/full_screen_mac_application_handler.cc",
333      "mac/full_screen_mac_application_handler.h",
334      "mac/window_list_utils.cc",
335      "mac/window_list_utils.h",
336    ]
337  }
338
339  if (build_with_mozilla) {
340    sources += [
341      "desktop_device_info.cc",
342      "desktop_device_info.h",
343    ]
344    if (is_win) {
345      sources += [
346        "app_capturer_win.cc",
347        "win/desktop_device_info_win.cc",
348        "win/win_shared.cc",
349      ]
350    }
351  }
352
353  if (rtc_use_x11_extensions || rtc_use_pipewire) {
354    sources += [
355      "mouse_cursor_monitor_linux.cc",
356      "screen_capturer_linux.cc",
357      "window_capturer_linux.cc",
358    ]
359
360    if (build_with_mozilla && is_linux) {
361      sources += [
362        "app_capturer_linux.cc",
363        "linux/app_capturer_x11.cc",
364        "linux/desktop_device_info_linux.cc",
365        "linux/desktop_device_info_linux.h",
366        "linux/shared_x_util.cc",
367        "linux/shared_x_util.h",
368      ]
369    }
370  }
371
372  if (rtc_use_x11_extensions) {
373    sources += [
374      "linux/mouse_cursor_monitor_x11.cc",
375      "linux/mouse_cursor_monitor_x11.h",
376      "linux/screen_capturer_x11.cc",
377      "linux/screen_capturer_x11.h",
378      "linux/shared_x_display.cc",
379      "linux/shared_x_display.h",
380      "linux/window_capturer_x11.cc",
381      "linux/window_capturer_x11.h",
382      "linux/window_finder_x11.cc",
383      "linux/window_finder_x11.h",
384      "linux/window_list_utils.cc",
385      "linux/window_list_utils.h",
386      "linux/x_atom_cache.cc",
387      "linux/x_atom_cache.h",
388      "linux/x_error_trap.cc",
389      "linux/x_error_trap.h",
390      "linux/x_server_pixel_buffer.cc",
391      "linux/x_server_pixel_buffer.h",
392      "linux/x_window_property.cc",
393      "linux/x_window_property.h",
394    ]
395    libs = [
396      "X11",
397      "Xcomposite",
398      "Xdamage",
399      "Xext",
400      "Xfixes",
401      "Xrender",
402      "Xrandr",
403    ]
404  }
405
406  if (!is_win && !is_mac && !rtc_use_x11_extensions && !rtc_use_pipewire) {
407    sources += [
408      "mouse_cursor_monitor_null.cc",
409      "screen_capturer_null.cc",
410      "window_capturer_null.cc",
411    ]
412  }
413
414  if (is_win) {
415    sources += [
416      "cropping_window_capturer_win.cc",
417      "desktop_frame_win.cc",
418      "desktop_frame_win.h",
419      "mouse_cursor_monitor_win.cc",
420      "screen_capturer_win.cc",
421      "win/cursor.cc",
422      "win/cursor.h",
423      "win/d3d_device.cc",
424      "win/d3d_device.h",
425      "win/desktop.cc",
426      "win/desktop.h",
427      "win/display_configuration_monitor.cc",
428      "win/display_configuration_monitor.h",
429      "win/dxgi_adapter_duplicator.cc",
430      "win/dxgi_adapter_duplicator.h",
431      "win/dxgi_context.cc",
432      "win/dxgi_context.h",
433      "win/dxgi_duplicator_controller.cc",
434      "win/dxgi_duplicator_controller.h",
435      "win/dxgi_frame.cc",
436      "win/dxgi_frame.h",
437      "win/dxgi_output_duplicator.cc",
438      "win/dxgi_output_duplicator.h",
439      "win/dxgi_texture.cc",
440      "win/dxgi_texture.h",
441      "win/dxgi_texture_mapping.cc",
442      "win/dxgi_texture_mapping.h",
443      "win/dxgi_texture_staging.cc",
444      "win/dxgi_texture_staging.h",
445      "win/full_screen_win_application_handler.cc",
446      "win/full_screen_win_application_handler.h",
447      "win/scoped_gdi_object.h",
448      "win/scoped_thread_desktop.cc",
449      "win/scoped_thread_desktop.h",
450      "win/screen_capture_utils.cc",
451      "win/screen_capture_utils.h",
452      "win/screen_capturer_win_directx.cc",
453      "win/screen_capturer_win_directx.h",
454      "win/screen_capturer_win_gdi.cc",
455      "win/screen_capturer_win_gdi.h",
456      "win/screen_capturer_win_magnifier.cc",
457      "win/screen_capturer_win_magnifier.h",
458      "win/selected_window_context.cc",
459      "win/selected_window_context.h",
460      "win/window_capture_utils.cc",
461      "win/window_capture_utils.h",
462      "win/window_capturer_win_gdi.cc",
463      "win/window_capturer_win_gdi.h",
464      "win/window_capturer_win_wgc.cc",
465      "win/window_capturer_win_wgc.h",
466      "window_capturer_win.cc",
467      "window_finder_win.cc",
468      "window_finder_win.h",
469    ]
470    libs = [
471      "d3d11.lib",
472      "dxgi.lib",
473    ]
474  }
475
476  deps = [
477    ":primitives",
478    "../../api:function_view",
479    "../../api:refcountedbase",
480    "../../api:scoped_refptr",
481    "../../rtc_base",  # TODO(kjellander): Cleanup in bugs.webrtc.org/3806.
482    "../../rtc_base:checks",
483    "../../rtc_base/synchronization:mutex",
484    "../../rtc_base/synchronization:rw_lock_wrapper",
485    "../../rtc_base/system:arch",
486    "../../rtc_base/system:rtc_export",
487    "../../system_wrappers",
488    "../../system_wrappers:cpu_features_api",
489    "../../system_wrappers:metrics",
490  ]
491  absl_deps = [
492    "//third_party/abseil-cpp/absl/memory",
493    "//third_party/abseil-cpp/absl/strings",
494  ]
495
496  if (rtc_use_x11_extensions) {
497    deps += [ "../../rtc_base:sanitizer" ]
498  }
499
500  if (build_with_mozilla) {
501    deps += [ "../../rtc_base:rtc_base_approved" ]
502  } else {
503    deps += [ "//third_party/libyuv" ]
504  }
505
506  if (use_desktop_capture_differ_sse2) {
507    deps += [ ":desktop_capture_differ_sse2" ]
508  }
509
510  if (rtc_use_pipewire) {
511    sources += [
512      "linux/base_capturer_pipewire.cc",
513      "linux/base_capturer_pipewire.h",
514      "linux/screen_capturer_pipewire.cc",
515      "linux/screen_capturer_pipewire.h",
516      "linux/window_capturer_pipewire.cc",
517      "linux/window_capturer_pipewire.h",
518    ]
519
520    configs += [
521      ":pipewire_config",
522      ":gio",
523    ]
524
525    if (rtc_link_pipewire) {
526      configs += [ ":pipewire" ]
527    } else {
528      deps += [ ":pipewire_stubs" ]
529    }
530  }
531}
532
533if (use_desktop_capture_differ_sse2) {
534  # Have to be compiled as a separate target because it needs to be compiled
535  # with SSE2 enabled.
536  rtc_library("desktop_capture_differ_sse2") {
537    visibility = [ ":*" ]
538    sources = [
539      "differ_vector_sse2.cc",
540      "differ_vector_sse2.h",
541    ]
542
543    if (is_posix || is_fuchsia) {
544      cflags = [ "-msse2" ]
545    }
546  }
547}
548