tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

screen_capturer_fuchsia.h (2103B)


      1 /*
      2 *  Copyright 2022 The WebRTC project authors. All Rights Reserved.
      3 *
      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
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_FUCHSIA_H_
     12 #define MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_FUCHSIA_H_
     13 
     14 #include <fuchsia/sysmem2/cpp/fidl.h>
     15 #include <fuchsia/ui/composition/cpp/fidl.h>
     16 #include <lib/sys/cpp/component_context.h>
     17 
     18 #include <memory>
     19 #include <unordered_map>
     20 
     21 #include "modules/desktop_capture/desktop_capture_options.h"
     22 #include "modules/desktop_capture/desktop_capturer.h"
     23 #include "modules/desktop_capture/desktop_frame.h"
     24 
     25 namespace webrtc {
     26 
     27 class ScreenCapturerFuchsia final : public DesktopCapturer {
     28 public:
     29  ScreenCapturerFuchsia();
     30  ~ScreenCapturerFuchsia() override;
     31 
     32  // DesktopCapturer interface.
     33  void Start(Callback* callback) override;
     34  void CaptureFrame() override;
     35  bool GetSourceList(SourceList* screens) override;
     36  bool SelectSource(SourceId id) override;
     37 
     38 private:
     39  fuchsia::sysmem2::BufferCollectionConstraints GetBufferConstraints();
     40  void SetupBuffers();
     41  uint32_t GetPixelsPerRow(
     42      const fuchsia::sysmem2::ImageFormatConstraints& constraints);
     43 
     44  Callback* callback_ = nullptr;
     45 
     46  std::unique_ptr<sys::ComponentContext> component_context_;
     47  fuchsia::sysmem2::AllocatorSyncPtr sysmem_allocator_;
     48  fuchsia::ui::composition::AllocatorSyncPtr flatland_allocator_;
     49  fuchsia::ui::composition::ScreenCaptureSyncPtr screen_capture_;
     50  fuchsia::sysmem2::BufferCollectionSyncPtr collection_;
     51  fuchsia::sysmem2::BufferCollectionInfo buffer_collection_info_;
     52  std::unordered_map<uint32_t, uint8_t*> virtual_memory_mapped_addrs_;
     53 
     54  bool fatal_error_;
     55 
     56  // Dimensions of the screen we are capturing
     57  uint32_t width_;
     58  uint32_t height_;
     59 };
     60 
     61 }  // namespace webrtc
     62 
     63 #endif  // MODULES_DESKTOP_CAPTURE_SCREEN_CAPTURER_FUCHSIA_H_