tor-browser

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

device_info_avfoundation.h (3025B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_MEDIA_SYSTEMSERVICES_OBJC_VIDEO_CAPTURE_DEVICE_INFO_AVFOUNDATION_H_
      8 #define DOM_MEDIA_SYSTEMSERVICES_OBJC_VIDEO_CAPTURE_DEVICE_INFO_AVFOUNDATION_H_
      9 
     10 #include <string>
     11 
     12 #include "api/sequence_checker.h"
     13 #include "device_info_objc.h"
     14 #include "modules/video_capture/device_info_impl.h"
     15 
     16 namespace webrtc::videocapturemodule {
     17 
     18 /**
     19 * DeviceInfo implementation for the libwebrtc ios/mac sdk camera backend.
     20 * Single threaded except for DeviceChange() that happens on a platform callback
     21 * thread.
     22 */
     23 class DeviceInfoAvFoundation : public DeviceInfoImpl {
     24 public:
     25  static int32_t ConvertAVFrameRateToCapabilityFPS(Float64 aRate);
     26  static webrtc::VideoType ConvertFourCCToVideoType(FourCharCode aCode);
     27 
     28  DeviceInfoAvFoundation();
     29  virtual ~DeviceInfoAvFoundation();
     30 
     31  // Implementation of DeviceInfoImpl.
     32  int32_t Init() override { return 0; }
     33  void DeviceChange() override;
     34  uint32_t NumberOfDevices() override;
     35  int32_t GetDeviceName(uint32_t aDeviceNumber, char* aDeviceNameUTF8,
     36                        uint32_t aDeviceNameLength, char* aDeviceUniqueIdUTF8,
     37                        uint32_t aDeviceUniqueIdUTF8Length,
     38                        char* aProductUniqueIdUTF8 = nullptr,
     39                        uint32_t aProductUniqueIdUTF8Length = 0,
     40                        pid_t* aPid = nullptr,
     41                        bool* deviceIsPlaceholder = 0) override;
     42  int32_t NumberOfCapabilities(const char* aDeviceUniqueIdUTF8) override;
     43  int32_t GetCapability(const char* aDeviceUniqueIdUTF8,
     44                        const uint32_t aDeviceCapabilityNumber,
     45                        VideoCaptureCapability& aCapability) override;
     46  int32_t DisplayCaptureSettingsDialogBox(const char* aDeviceUniqueIdUTF8,
     47                                          const char* aDialogTitleUTF8,
     48                                          void* aParentWindow,
     49                                          uint32_t aPositionX,
     50                                          uint32_t aPositionY) override {
     51    return -1;
     52  }
     53  int32_t CreateCapabilityMap(const char* aDeviceUniqueIdUTF8) override
     54      RTC_EXCLUSIVE_LOCKS_REQUIRED(_apiLock);
     55 
     56 private:
     57  const std::tuple<std::string, std::string, VideoCaptureCapabilities>*
     58  FindDeviceAndCapabilities(const std::string& aDeviceUniqueId) const;
     59  void EnsureCapabilitiesMap();
     60 
     61  SequenceChecker mChecker;
     62  std::atomic<bool> mInvalidateCapabilities;
     63  // [{uniqueId, name, capabilities}]
     64  std::vector<std::tuple<std::string, std::string, VideoCaptureCapabilities>>
     65      mDevicesAndCapabilities RTC_GUARDED_BY(mChecker);
     66  const DeviceInfoIosObjC* mDeviceChangeCaptureInfo RTC_GUARDED_BY(mChecker);
     67 };
     68 
     69 }  // namespace webrtc::videocapturemodule
     70 
     71 #endif