chromium/content/browser/renderer_host/media/video_capture_manager.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/renderer_host/media/video_capture_manager.h"

#include <memory>
#include <set>
#include <utility>

#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/task/bind_post_task.h"
#include "base/task/single_thread_task_runner.h"
#include "base/timer/elapsed_timer.h"
#include "build/android_buildflags.h"
#include "build/build_config.h"
#include "content/browser/media/media_internals.h"
#include "content/browser/renderer_host/media/video_capture_controller.h"
#include "content/browser/screenlock_monitor/screenlock_monitor.h"
#include "content/common/features.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/desktop_media_id.h"
#include "content/public/common/content_client.h"
#include "media/base/media_switches.h"
#include "media/base/video_facing.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "media/capture/video/video_capture_device.h"
#include "services/video_effects/public/mojom/video_effects_processor.mojom-forward.h"
#include "third_party/blink/public/common/mediastream/media_stream_request.h"

namespace {

void LogVideoCaptureError(media::VideoCaptureError error) {}

const base::UnguessableToken& FakeSessionId() {}

}  // namespace

namespace content {

// Class used for queuing request for starting a device.
class VideoCaptureManager::CaptureDeviceStartRequest {};

VideoCaptureManager::CaptureDeviceStartRequest::CaptureDeviceStartRequest(
    VideoCaptureController* controller,
    const media::VideoCaptureSessionId& session_id,
    const media::VideoCaptureParams& params,
    mojo::PendingRemote<video_effects::mojom::VideoEffectsProcessor>
        video_effects_processor)
    :{}

VideoCaptureManager::VideoCaptureManager(
    std::unique_ptr<VideoCaptureProvider> video_capture_provider,
    base::RepeatingCallback<void(const std::string&)> emit_log_message_cb)
    :{}

VideoCaptureManager::~VideoCaptureManager() {}

void VideoCaptureManager::AddVideoCaptureObserver(
    media::VideoCaptureObserver* observer) {}

void VideoCaptureManager::RemoveAllVideoCaptureObservers() {}

void VideoCaptureManager::RegisterListener(
    MediaStreamProviderListener* listener) {}

void VideoCaptureManager::UnregisterListener(
    MediaStreamProviderListener* listener) {}

void VideoCaptureManager::EnumerateDevices(
    EnumerationCallback client_callback) {}

base::UnguessableToken VideoCaptureManager::Open(
    const blink::MediaStreamDevice& device) {}

void VideoCaptureManager::Close(
    const base::UnguessableToken& capture_session_id) {}

void VideoCaptureManager::ApplySubCaptureTarget(
    const base::UnguessableToken& session_id,
    media::mojom::SubCaptureTargetType type,
    const base::Token& target,
    uint32_t sub_capture_target_version,
    base::OnceCallback<void(media::mojom::ApplySubCaptureTargetResult)>
        callback) {}

void VideoCaptureManager::QueueStartDevice(
    const media::VideoCaptureSessionId& session_id,
    VideoCaptureController* controller,
    const media::VideoCaptureParams& params,
    mojo::PendingRemote<video_effects::mojom::VideoEffectsProcessor>
        video_effects_processor) {}

void VideoCaptureManager::DoStopDevice(VideoCaptureController* controller) {}

void VideoCaptureManager::ProcessDeviceStartRequestQueue() {}

void VideoCaptureManager::OnDeviceLaunched(VideoCaptureController* controller) {}

void VideoCaptureManager::OnDeviceLaunchFailed(
    VideoCaptureController* controller,
    media::VideoCaptureError error) {}

void VideoCaptureManager::OnDeviceLaunchAborted() {}

void VideoCaptureManager::OnDeviceConnectionLost(
    VideoCaptureController* controller) {}

void VideoCaptureManager::OpenNativeScreenCapturePicker(
    DesktopMediaID::Type type,
    base::OnceCallback<void(webrtc::DesktopCapturer::Source)> picker_callback,
    base::OnceCallback<void()> cancel_callback,
    base::OnceCallback<void()> error_callback) {}

void VideoCaptureManager::CloseNativeScreenCapturePicker(
    DesktopMediaID device_id) {}

void VideoCaptureManager::ConnectClient(
    const media::VideoCaptureSessionId& session_id,
    const media::VideoCaptureParams& params,
    VideoCaptureControllerID client_id,
    VideoCaptureControllerEventHandler* client_handler,
    std::optional<url::Origin> origin,
    DoneCB done_cb,
    BrowserContext* browser_context) {}

void VideoCaptureManager::DisconnectClient(
    VideoCaptureController* controller,
    VideoCaptureControllerID client_id,
    VideoCaptureControllerEventHandler* client_handler,
    media::VideoCaptureError error) {}

void VideoCaptureManager::PauseCaptureForClient(
    VideoCaptureController* controller,
    VideoCaptureControllerID client_id,
    VideoCaptureControllerEventHandler* client_handler) {}

void VideoCaptureManager::ResumeCaptureForClient(
    const media::VideoCaptureSessionId& session_id,
    const media::VideoCaptureParams& params,
    VideoCaptureController* controller,
    VideoCaptureControllerID client_id,
    VideoCaptureControllerEventHandler* client_handler) {}

void VideoCaptureManager::RequestRefreshFrameForClient(
    VideoCaptureController* controller) {}

bool VideoCaptureManager::GetDeviceSupportedFormats(
    const media::VideoCaptureSessionId& capture_session_id,
    media::VideoCaptureFormats* supported_formats) {}

bool VideoCaptureManager::GetDeviceSupportedFormats(
    const std::string& device_id,
    media::VideoCaptureFormats* supported_formats) {}

bool VideoCaptureManager::GetDeviceFormatsInUse(
    const media::VideoCaptureSessionId& capture_session_id,
    media::VideoCaptureFormats* formats_in_use) {}

std::optional<media::VideoCaptureFormat>
VideoCaptureManager::GetDeviceFormatInUse(
    blink::mojom::MediaStreamType stream_type,
    const std::string& device_id) {}

GlobalRenderFrameHostId VideoCaptureManager::GetGlobalRenderFrameHostId(
    const base::UnguessableToken& session_id) const {}

void VideoCaptureManager::SetDesktopCaptureWindowId(
    const media::VideoCaptureSessionId& session_id,
    gfx::NativeViewId window_id) {}

void VideoCaptureManager::MaybePostDesktopCaptureWindowId(
    const media::VideoCaptureSessionId& session_id) {}

void VideoCaptureManager::GetPhotoState(
    const base::UnguessableToken& session_id,
    media::VideoCaptureDevice::GetPhotoStateCallback callback) {}

void VideoCaptureManager::SetPhotoOptions(
    const base::UnguessableToken& session_id,
    media::mojom::PhotoSettingsPtr settings,
    media::VideoCaptureDevice::SetPhotoOptionsCallback callback) {}

void VideoCaptureManager::TakePhoto(
    const base::UnguessableToken& session_id,
    media::VideoCaptureDevice::TakePhotoCallback callback) {}

void VideoCaptureManager::OnOpened(
    blink::mojom::MediaStreamType stream_type,
    const media::VideoCaptureSessionId& capture_session_id) {}

void VideoCaptureManager::OnClosed(
    blink::mojom::MediaStreamType stream_type,
    const media::VideoCaptureSessionId& capture_session_id) {}

void VideoCaptureManager::OnDeviceInfosReceived(
    base::ElapsedTimer timer,
    EnumerationCallback client_callback,
    media::mojom::DeviceEnumerationResult error_code,
    const std::vector<media::VideoCaptureDeviceInfo>& device_infos) {}

void VideoCaptureManager::DestroyControllerIfNoClients(
    const base::UnguessableToken& capture_session_id,
    VideoCaptureController* controller) {}

VideoCaptureController* VideoCaptureManager::LookupControllerBySessionId(
    const base::UnguessableToken& session_id) const {}

VideoCaptureController*
VideoCaptureManager::LookupControllerByMediaTypeAndDeviceId(
    blink::mojom::MediaStreamType type,
    const std::string& device_id) const {}

bool VideoCaptureManager::IsControllerPointerValid(
    const VideoCaptureController* controller) const {}

scoped_refptr<VideoCaptureController>
VideoCaptureManager::GetControllerSharedRef(
    VideoCaptureController* controller) const {}

media::VideoCaptureDeviceInfo* VideoCaptureManager::GetDeviceInfoById(
    const std::string& id) {}

VideoCaptureController* VideoCaptureManager::GetOrCreateController(
    const media::VideoCaptureSessionId& capture_session_id,
    const media::VideoCaptureParams& params) {}

#if BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_DESKTOP_ANDROID)
void VideoCaptureManager::OnApplicationStateChange(
    base::android::ApplicationState state) {
  DCHECK_CURRENTLY_ON(BrowserThread::IO);

  // Only release/resume devices when the Application state changes from
  // RUNNING->STOPPED->RUNNING.
  if (state == base::android::APPLICATION_STATE_HAS_RUNNING_ACTIVITIES &&
      !application_state_has_running_activities_) {
    ResumeDevices();
    application_state_has_running_activities_ = true;
  } else if (state == base::android::APPLICATION_STATE_HAS_STOPPED_ACTIVITIES) {
    ReleaseDevices();
    application_state_has_running_activities_ = false;
  }
}
#endif

void VideoCaptureManager::ReleaseDevices() {}

void VideoCaptureManager::ResumeDevices() {}

void VideoCaptureManager::OnScreenLocked() {}

void VideoCaptureManager::OnScreenUnlocked() {}

void VideoCaptureManager::EmitLogMessage(const std::string& message,
                                         int verbose_log_level) {}

}  // namespace content