#include "third_party/blink/renderer/platform/peerconnection/webrtc_video_track_source.h"
#include <optional>
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "base/types/optional_util.h"
#include "media/base/media_switches.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/platform/webrtc/convert_to_webrtc_video_frame_buffer.h"
#include "third_party/blink/renderer/platform/webrtc/webrtc_video_utils.h"
#include "third_party/webrtc/rtc_base/ref_counted_object.h"
namespace {
gfx::Rect CropRectangle(const gfx::Rect& input_rect,
const gfx::Rect& cropping_rect) { … }
gfx::Rect ScaleRectangle(const gfx::Rect& input_rect,
gfx::Size original,
gfx::Size scaled) { … }
webrtc::VideoRotation GetFrameRotation(const media::VideoFrame* frame) { … }
}
namespace blink {
WebRtcVideoTrackSource::WebRtcVideoTrackSource(
bool is_screencast,
std::optional<bool> needs_denoising,
media::VideoCaptureFeedbackCB feedback_callback,
base::RepeatingClosure request_refresh_frame_callback,
media::GpuVideoAcceleratorFactories* gpu_factories)
: … { … }
WebRtcVideoTrackSource::~WebRtcVideoTrackSource() = default;
void WebRtcVideoTrackSource::SetCustomFrameAdaptationParamsForTesting(
const FrameAdaptationParams& params) { … }
void WebRtcVideoTrackSource::SetSinkWantsForTesting(
const rtc::VideoSinkWants& sink_wants) { … }
WebRtcVideoTrackSource::SourceState WebRtcVideoTrackSource::state() const { … }
bool WebRtcVideoTrackSource::remote() const { … }
bool WebRtcVideoTrackSource::is_screencast() const { … }
std::optional<bool> WebRtcVideoTrackSource::needs_denoising() const { … }
void WebRtcVideoTrackSource::RequestRefreshFrame() { … }
void WebRtcVideoTrackSource::SendFeedback() { … }
void WebRtcVideoTrackSource::OnFrameCaptured(
scoped_refptr<media::VideoFrame> frame) { … }
void WebRtcVideoTrackSource::OnNotifyFrameDropped() { … }
WebRtcVideoTrackSource::FrameAdaptationParams
WebRtcVideoTrackSource::ComputeAdaptationParams(int width,
int height,
int64_t time_us) { … }
void WebRtcVideoTrackSource::DeliverFrame(
scoped_refptr<media::VideoFrame> frame,
gfx::Rect* update_rect,
int64_t timestamp_us,
std::optional<webrtc::Timestamp> capture_time_identifier,
std::optional<webrtc::Timestamp> reference_time) { … }
bool WebRtcVideoTrackSource::ShouldSetColorSpace(
const gfx::ColorSpace& color_space) { … }
}