#include "content/browser/renderer_host/media/service_video_capture_device_launcher.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "build/build_config.h"
#include "content/browser/renderer_host/media/service_launched_video_capture_device.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "media/capture/capture_switches.h"
#include "media/capture/video/video_capture_device.h"
#include "media/capture/video/video_frame_receiver_on_task_runner.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "services/video_capture/public/cpp/receiver_media_to_mojo_adapter.h"
#include "services/video_capture/public/mojom/video_frame_handler.mojom.h"
#include "services/video_effects/public/mojom/video_effects_processor.mojom-forward.h"
#if BUILDFLAG(IS_WIN)
#include "media/base/media_switches.h"
#endif
#if BUILDFLAG(IS_LINUX)
#include "content/browser/gpu/gpu_data_manager_impl.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "media/capture/video/apple/video_capture_device_factory_apple.h"
#endif
namespace content {
namespace {
void ConcludeLaunchDeviceWithSuccess(
mojo::Remote<video_capture::mojom::VideoSource> source,
mojo::Remote<video_capture::mojom::PushVideoStreamSubscription>
subscription,
base::OnceClosure connection_lost_cb,
VideoCaptureDeviceLauncher::Callbacks* callbacks,
base::OnceClosure done_cb) { … }
void ConcludeLaunchDeviceWithFailure(
bool abort_requested,
media::VideoCaptureError error,
scoped_refptr<RefCountedVideoSourceProvider> service_connection,
VideoCaptureDeviceLauncher::Callbacks* callbacks,
base::OnceClosure done_cb) { … }
}
ServiceVideoCaptureDeviceLauncher::ServiceVideoCaptureDeviceLauncher(
ConnectToDeviceFactoryCB connect_to_source_provider_cb)
: … { … }
ServiceVideoCaptureDeviceLauncher::~ServiceVideoCaptureDeviceLauncher() { … }
void ServiceVideoCaptureDeviceLauncher::LaunchDeviceAsync(
const std::string& device_id,
blink::mojom::MediaStreamType stream_type,
const media::VideoCaptureParams& params,
base::WeakPtr<media::VideoFrameReceiver> receiver,
base::OnceClosure connection_lost_cb,
Callbacks* callbacks,
base::OnceClosure done_cb,
mojo::PendingRemote<video_effects::mojom::VideoEffectsProcessor>
video_effects_processor) { … }
void ServiceVideoCaptureDeviceLauncher::AbortLaunch() { … }
void ServiceVideoCaptureDeviceLauncher::OnCreatePushSubscriptionCallback(
mojo::Remote<video_capture::mojom::VideoSource> source,
mojo::Remote<video_capture::mojom::PushVideoStreamSubscription>
subscription,
base::OnceClosure connection_lost_cb,
std::unique_ptr<ScopedCaptureTrace> scoped_trace,
video_capture::mojom::CreatePushSubscriptionResultCodePtr result_code,
const media::VideoCaptureParams& params) { … }
void ServiceVideoCaptureDeviceLauncher::
OnConnectionLostWhileWaitingForCallback() { … }
}