#include "remoting/protocol/webrtc_video_stream.h"
#include <memory>
#include <utility>
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/thread_pool.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "remoting/base/constants.h"
#include "remoting/protocol/desktop_capturer.h"
#include "remoting/protocol/frame_stats.h"
#include "remoting/protocol/host_video_stats_dispatcher.h"
#include "remoting/protocol/no_op_webrtc_frame_scheduler.h"
#include "remoting/protocol/webrtc_frame_scheduler_constant_rate.h"
#include "remoting/protocol/webrtc_transport.h"
#include "remoting/protocol/webrtc_video_encoder_factory.h"
#include "remoting/protocol/webrtc_video_frame_adapter.h"
#include "remoting/protocol/webrtc_video_track_source.h"
#include "third_party/webrtc/api/media_stream_interface.h"
#include "third_party/webrtc/api/notifier.h"
#include "third_party/webrtc/api/peer_connection_interface.h"
namespace remoting::protocol {
class ScopedAllowSyncPrimitivesForWebRtcVideoStream
: public base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope { … };
FrameStatsMessage::VideoCodec VideoCodecToProtoEnum(
webrtc::VideoCodecType codec) { … }
struct WebrtcVideoStream::FrameStats : public WebrtcVideoEncoder::FrameStats { … };
class WebrtcVideoStream::Core : public webrtc::DesktopCapturer::Callback { … };
WebrtcVideoStream::Core::Core(webrtc::ScreenId screen_id,
std::unique_ptr<DesktopCapturer> capturer,
base::WeakPtr<WebrtcVideoStream> video_stream)
: … { … }
WebrtcVideoStream::Core::~Core() = default;
void WebrtcVideoStream::Core::Start() { … }
void WebrtcVideoStream::Core::OnFrameCaptureStart() { … }
void WebrtcVideoStream::Core::OnCaptureResult(
webrtc::DesktopCapturer::Result result,
std::unique_ptr<webrtc::DesktopFrame> frame) { … }
void WebrtcVideoStream::Core::SetEventTimestampsSource(
scoped_refptr<InputEventTimestampsSource> event_timestamps_source) { … }
void WebrtcVideoStream::Core::Pause(bool pause) { … }
void WebrtcVideoStream::Core::SelectSource(webrtc::ScreenId id) { … }
void WebrtcVideoStream::Core::SetComposeEnabled(bool enabled) { … }
void WebrtcVideoStream::Core::SetMouseCursor(
std::unique_ptr<webrtc::MouseCursor> mouse_cursor) { … }
void WebrtcVideoStream::Core::SetMouseCursorPosition(
const webrtc::DesktopVector& position) { … }
void WebrtcVideoStream::Core::BoostFramerate(base::TimeDelta capture_interval,
base::TimeDelta boost_duration) { … }
void WebrtcVideoStream::Core::SetMaxFramerateFps(int max_framerate_fps) { … }
void WebrtcVideoStream::Core::CaptureNextFrame() { … }
WebrtcVideoStream::WebrtcVideoStream(const SessionOptions& session_options)
: … { … }
WebrtcVideoStream::~WebrtcVideoStream() { … }
void WebrtcVideoStream::Start(
webrtc::ScreenId screen_id,
std::unique_ptr<DesktopCapturer> desktop_capturer,
WebrtcTransport* webrtc_transport,
WebrtcVideoEncoderFactory* video_encoder_factory) { … }
void WebrtcVideoStream::SelectSource(webrtc::ScreenId id) { … }
void WebrtcVideoStream::SetEventTimestampsSource(
scoped_refptr<InputEventTimestampsSource> event_timestamps_source) { … }
void WebrtcVideoStream::Pause(bool pause) { … }
void WebrtcVideoStream::SetObserver(Observer* observer) { … }
void WebrtcVideoStream::SetComposeEnabled(bool enabled) { … }
void WebrtcVideoStream::SetMouseCursor(
std::unique_ptr<webrtc::MouseCursor> mouse_cursor) { … }
void WebrtcVideoStream::SetMouseCursorPosition(
const webrtc::DesktopVector& position) { … }
void WebrtcVideoStream::BoostFramerate(base::TimeDelta capture_interval,
base::TimeDelta boost_duration) { … }
void WebrtcVideoStream::SetTargetFramerate(int framerate) { … }
std::string WebrtcVideoStream::StreamNameForId(webrtc::ScreenId id) { … }
void WebrtcVideoStream::OnEncodedFrameSent(
webrtc::EncodedImageCallback::Result result,
const WebrtcVideoEncoder::EncodedFrame& frame) { … }
void WebrtcVideoStream::OnSinkAddedOrUpdated(const rtc::VideoSinkWants& wants) { … }
void WebrtcVideoStream::OnVideoSizeChanged(webrtc::DesktopSize frame_size,
webrtc::DesktopVector frame_dpi) { … }
void WebrtcVideoStream::SendCapturedFrame(
std::unique_ptr<webrtc::DesktopFrame> desktop_frame,
std::unique_ptr<WebrtcVideoEncoder::FrameStats> frame_stats) { … }
}