tor-browser

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

placeholder_device_info.cc (2081B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set sw=2 ts=8 et ft=cpp : */
      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 #include "placeholder_device_info.h"
      8 
      9 #include "modules/video_capture/video_capture_factory.h"
     10 
     11 namespace mozilla {
     12 
     13 PlaceholderDeviceInfo::PlaceholderDeviceInfo(bool aCameraPresent)
     14    : mCameraPresent(aCameraPresent) {}
     15 
     16 PlaceholderDeviceInfo::~PlaceholderDeviceInfo() = default;
     17 
     18 uint32_t PlaceholderDeviceInfo::NumberOfDevices() { return mCameraPresent; }
     19 
     20 int32_t PlaceholderDeviceInfo::Init() { return 0; }
     21 
     22 int32_t PlaceholderDeviceInfo::GetDeviceName(
     23    uint32_t aDeviceNumber, char* aDeviceNameUTF8, uint32_t aDeviceNameLength,
     24    char* aDeviceUniqueIdUTF8, uint32_t aDeviceUniqueIdUTF8Length,
     25    char* aProductUniqueIdUTF8, uint32_t aProductUniqueIdUTF8Length,
     26    pid_t* aPid, bool* aDeviceIsPlaceholder) {
     27  // Check whether there is camera device reported by the Camera portal
     28  // When the promise is resolved, it means there is a camera available
     29  // but we have to use a placeholder device.
     30  if (!mCameraPresent) {
     31    return -1;
     32  }
     33 
     34  // Making these empty to follow the specs for non-legacy enumeration:
     35  // https://w3c.github.io/mediacapture-main/#access-control-model
     36  memset(aDeviceNameUTF8, 0, aDeviceNameLength);
     37  memset(aDeviceUniqueIdUTF8, 0, aDeviceUniqueIdUTF8Length);
     38 
     39  if (aProductUniqueIdUTF8) {
     40    memset(aProductUniqueIdUTF8, 0, aProductUniqueIdUTF8Length);
     41  }
     42 
     43  if (aDeviceIsPlaceholder) {
     44    *aDeviceIsPlaceholder = true;
     45  }
     46 
     47  return 0;
     48 }
     49 
     50 int32_t PlaceholderDeviceInfo::CreateCapabilityMap(
     51    const char* /*aDeviceUniqueIdUTF8*/) {
     52  return -1;
     53 }
     54 
     55 int32_t PlaceholderDeviceInfo::DisplayCaptureSettingsDialogBox(
     56    const char* /*deviceUniqueIdUTF8*/, const char* /*dialogTitleUTF8*/,
     57    void* /*parentWindow*/, uint32_t /*positionX*/, uint32_t /*positionY*/) {
     58  return -1;
     59 }
     60 
     61 }  // namespace mozilla