#include "content/browser/media/capture/web_contents_frame_tracker.h"
#include <algorithm>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/strcat.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "components/viz/common/surfaces/video_capture_target.h"
#include "content/browser/media/capture/web_contents_video_capture_device.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_media_capture_id.h"
#include "content/public/browser/web_contents_observer.h"
#include "media/base/media_switches.h"
#include "media/base/video_util.h"
#include "media/capture/mojom/video_capture_types.mojom.h"
#include "media/capture/video_capture_types.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/native_widget_types.h"
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS)
#include "content/browser/media/capture/mouse_cursor_overlay_controller.h"
#endif
namespace content {
namespace {
static constexpr float kMinCaptureScaleOverride = …;
class WebContentsContext : public WebContentsFrameTracker::Context { … };
}
const float WebContentsFrameTracker::kMaxCaptureScaleOverride = …;
WebContentsFrameTracker::WebContentsFrameTracker(
scoped_refptr<base::SequencedTaskRunner> device_task_runner,
base::WeakPtr<WebContentsVideoCaptureDevice> device,
MouseCursorOverlayController* cursor_controller)
: … { … }
WebContentsFrameTracker::~WebContentsFrameTracker() { … }
void WebContentsFrameTracker::WillStartCapturingWebContents(
const gfx::Size& capture_size,
bool is_high_dpi_enabled) { … }
void WebContentsFrameTracker::DidStopCapturingWebContents() { … }
void WebContentsFrameTracker::SetCapturedContentSize(
const gfx::Size& content_size) { … }
gfx::Size WebContentsFrameTracker::CalculatePreferredSize(
const gfx::Size& capture_size) { … }
float WebContentsFrameTracker::CalculatePreferredScaleFactor(
const gfx::Size& current_content_size,
const gfx::Size& unscaled_current_content_size) { … }
void WebContentsFrameTracker::OnUtilizationReport(
media::VideoCaptureFeedback feedback) { … }
void WebContentsFrameTracker::RenderFrameCreated(
RenderFrameHost* render_frame_host) { … }
void WebContentsFrameTracker::RenderFrameDeleted(
RenderFrameHost* render_frame_host) { … }
void WebContentsFrameTracker::RenderFrameHostChanged(
RenderFrameHost* old_host,
RenderFrameHost* new_host) { … }
void WebContentsFrameTracker::WebContentsDestroyed() { … }
void WebContentsFrameTracker::CaptureTargetChanged() { … }
void WebContentsFrameTracker::SetWebContentsAndContextFromRoutingId(
const GlobalRenderFrameHostId& id) { … }
void WebContentsFrameTracker::ApplySubCaptureTarget(
media::mojom::SubCaptureTargetType type,
const base::Token& target_token,
uint32_t sub_capture_target_version,
base::OnceCallback<void(media::mojom::ApplySubCaptureTargetResult)>
callback) { … }
void WebContentsFrameTracker::SetWebContentsAndContextForTesting(
WebContents* web_contents,
std::unique_ptr<WebContentsFrameTracker::Context> context) { … }
void WebContentsFrameTracker::OnPossibleTargetChange() { … }
void WebContentsFrameTracker::SetTargetView(gfx::NativeView view) { … }
void WebContentsFrameTracker::SetCaptureScaleOverride(float new_value) { … }
float WebContentsFrameTracker::DetermineMaxScaleOverride() { … }
viz::VideoCaptureSubTarget WebContentsFrameTracker::DeriveSubTarget() const { … }
}