webrtc/modules/video_capture/video_capture_options.cc
Jan Grulich 56d126074e PipeWire video capture: split portal and PipeWire implementations
Allows to use camera portal separately in implementations where each
implementation needs to be called in different places.

This is targeted for Firefox support, where we need to ask for camera
access in the FF frontend code, otherwise making camera access requests
in the backend WebRTC code might result into presenting portal dialogs
asking for access from the javascript API.

Bug: webrtc:15202
Change-Id: Ida8b010bb93e08a9e5ddd9dd8a2a3549ee7fde8b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305222
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Commit-Queue: Jan Grulich <grulja@gmail.com>
Cr-Commit-Position: refs/heads/main@{#40148}
2023-05-25 17:04:53 +00:00

55 lines
1.7 KiB
C++

/*
* Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "modules/video_capture/video_capture_options.h"
#if defined(WEBRTC_USE_PIPEWIRE)
#include "modules/video_capture/linux/pipewire_session.h"
#endif
namespace webrtc {
VideoCaptureOptions::VideoCaptureOptions() {}
VideoCaptureOptions::VideoCaptureOptions(const VideoCaptureOptions& options) =
default;
VideoCaptureOptions::VideoCaptureOptions(VideoCaptureOptions&& options) =
default;
VideoCaptureOptions::~VideoCaptureOptions() {}
VideoCaptureOptions& VideoCaptureOptions::operator=(
const VideoCaptureOptions& options) = default;
VideoCaptureOptions& VideoCaptureOptions::operator=(
VideoCaptureOptions&& options) = default;
void VideoCaptureOptions::Init(Callback* callback) {
#if defined(WEBRTC_USE_PIPEWIRE)
if (allow_pipewire_) {
pipewire_session_ =
rtc::make_ref_counted<videocapturemodule::PipeWireSession>();
pipewire_session_->Init(callback, pipewire_fd_);
return;
}
#endif
#if defined(WEBRTC_LINUX)
if (!allow_v4l2_)
callback->OnInitialized(Status::UNAVAILABLE);
else
#endif
callback->OnInitialized(Status::SUCCESS);
}
#if defined(WEBRTC_USE_PIPEWIRE)
rtc::scoped_refptr<videocapturemodule::PipeWireSession>
VideoCaptureOptions::pipewire_session() {
return pipewire_session_;
}
#endif
} // namespace webrtc