#include "content/browser/renderer_host/media/video_capture_host.h"
#include <memory>
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/token.h"
#include "base/unguessable_token.h"
#include "content/browser/browser_main_loop.h"
#include "content/browser/renderer_host/media/media_stream_manager.h"
#include "content/browser/renderer_host/media/video_capture_manager.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/common/content_client.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "media/capture/mojom/video_effects_manager.mojom.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
namespace content {
namespace {
BrowserContext* GetBrowserContext(
GlobalRenderFrameHostId render_frame_host_id) { … }
}
VideoCaptureHost::RenderFrameHostDelegate::~RenderFrameHostDelegate() = default;
class VideoCaptureHost::RenderFrameHostDelegateImpl
: public VideoCaptureHost::RenderFrameHostDelegate { … };
VideoCaptureHost::VideoCaptureHost(GlobalRenderFrameHostId render_frame_host_id,
MediaStreamManager* media_stream_manager)
: … { … }
VideoCaptureHost::VideoCaptureHost(
std::unique_ptr<RenderFrameHostDelegate> delegate,
MediaStreamManager* media_stream_manager)
: … { … }
void VideoCaptureHost::Create(
GlobalRenderFrameHostId render_frame_host_id,
MediaStreamManager* media_stream_manager,
mojo::PendingReceiver<media::mojom::VideoCaptureHost> receiver) { … }
VideoCaptureHost::~VideoCaptureHost() { … }
void VideoCaptureHost::OnError(const VideoCaptureControllerID& controller_id,
media::VideoCaptureError error) { … }
void VideoCaptureHost::OnCaptureConfigurationChanged(
const VideoCaptureControllerID& controller_id) { … }
void VideoCaptureHost::OnNewBuffer(
const VideoCaptureControllerID& controller_id,
media::mojom::VideoBufferHandlePtr buffer_handle,
int buffer_id) { … }
void VideoCaptureHost::OnBufferDestroyed(
const VideoCaptureControllerID& controller_id,
int buffer_id) { … }
void VideoCaptureHost::OnBufferReady(
const VideoCaptureControllerID& controller_id,
const ReadyBuffer& buffer) { … }
void VideoCaptureHost::OnFrameDropped(
const VideoCaptureControllerID& controller_id,
media::VideoCaptureFrameDropReason reason) { … }
void VideoCaptureHost::OnFrameWithEmptyRegionCapture(
const VideoCaptureControllerID& controller_id) { … }
void VideoCaptureHost::OnEnded(const VideoCaptureControllerID& controller_id) { … }
void VideoCaptureHost::OnStarted(
const VideoCaptureControllerID& controller_id) { … }
void VideoCaptureHost::OnStartedUsingGpuDecode(
const VideoCaptureControllerID& id) { … }
void VideoCaptureHost::Start(
const base::UnguessableToken& device_id,
const base::UnguessableToken& session_id,
const media::VideoCaptureParams& params,
mojo::PendingRemote<media::mojom::VideoCaptureObserver> observer) { … }
void VideoCaptureHost::Stop(const base::UnguessableToken& device_id) { … }
void VideoCaptureHost::Pause(const base::UnguessableToken& device_id) { … }
void VideoCaptureHost::Resume(const base::UnguessableToken& device_id,
const base::UnguessableToken& session_id,
const media::VideoCaptureParams& params) { … }
void VideoCaptureHost::RequestRefreshFrame(
const base::UnguessableToken& device_id) { … }
void VideoCaptureHost::ReleaseBuffer(
const base::UnguessableToken& device_id,
int32_t buffer_id,
const media::VideoCaptureFeedback& feedback) { … }
void VideoCaptureHost::GetDeviceSupportedFormats(
const base::UnguessableToken& device_id,
const base::UnguessableToken& session_id,
GetDeviceSupportedFormatsCallback callback) { … }
void VideoCaptureHost::GetDeviceFormatsInUse(
const base::UnguessableToken& device_id,
const base::UnguessableToken& session_id,
GetDeviceFormatsInUseCallback callback) { … }
void VideoCaptureHost::OnNewSubCaptureTargetVersion(
const base::UnguessableToken& device_id,
uint32_t sub_capture_target_version) { … }
void VideoCaptureHost::OnLog(const base::UnguessableToken& device_id,
const std::string& message) { … }
void VideoCaptureHost::DoError(const VideoCaptureControllerID& controller_id,
media::VideoCaptureError error) { … }
void VideoCaptureHost::DoEnded(const VideoCaptureControllerID& controller_id) { … }
void VideoCaptureHost::OnControllerAdded(
const base::UnguessableToken& device_id,
const base::WeakPtr<VideoCaptureController>& controller) { … }
void VideoCaptureHost::DeleteVideoCaptureController(
const VideoCaptureControllerID& controller_id,
media::VideoCaptureError error) { … }
void VideoCaptureHost::NotifyStreamAdded() { … }
void VideoCaptureHost::NotifyStreamRemoved() { … }
void VideoCaptureHost::NotifyAllStreamsRemoved() { … }
void VideoCaptureHost::ConnectClient(const base::UnguessableToken session_id,
const media::VideoCaptureParams& params,
VideoCaptureControllerID controller_id,
VideoCaptureManager::DoneCB done_cb,
BrowserContext* browser_context) { … }
}