tor-browser

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

video_capture_linux.cc (1861B)


      1 /*
      2 *  Copyright (c) 2012 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 #include "api/make_ref_counted.h"
     12 #include "api/scoped_refptr.h"
     13 #include "modules/video_capture/linux/video_capture_v4l2.h"
     14 #include "modules/video_capture/video_capture.h"
     15 #include "modules/video_capture/video_capture_impl.h"
     16 #include "modules/video_capture/video_capture_options.h"
     17 #include "system_wrappers/include/clock.h"
     18 
     19 #if defined(WEBRTC_USE_PIPEWIRE)
     20 #include "modules/video_capture/linux/video_capture_pipewire.h"
     21 #endif
     22 
     23 namespace webrtc {
     24 namespace videocapturemodule {
     25 scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
     26    Clock* clock,
     27    const char* deviceUniqueId) {
     28  auto implementation = make_ref_counted<VideoCaptureModuleV4L2>(clock);
     29 
     30  if (implementation->Init(deviceUniqueId) != 0)
     31    return nullptr;
     32 
     33  return implementation;
     34 }
     35 
     36 scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
     37    Clock* clock,
     38    VideoCaptureOptions* options,
     39    const char* deviceUniqueId) {
     40 #if defined(WEBRTC_USE_PIPEWIRE)
     41  if (options->allow_pipewire()) {
     42    auto implementation =
     43        webrtc::make_ref_counted<VideoCaptureModulePipeWire>(clock, options);
     44 
     45    if (implementation->Init(deviceUniqueId) == 0)
     46      return implementation;
     47  }
     48 #endif
     49  if (options->allow_v4l2()) {
     50    auto implementation = make_ref_counted<VideoCaptureModuleV4L2>(clock);
     51 
     52    if (implementation->Init(deviceUniqueId) == 0)
     53      return implementation;
     54  }
     55  return nullptr;
     56 }
     57 }  // namespace videocapturemodule
     58 }  // namespace webrtc