Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1143)

Unified Diff: remoting/host/client_session.cc

Issue 1472873005: Add VideoStream interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_video_pump
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/client_session.cc
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index d12a5ed2b0238e60e0105a5590b333ab0af57a27..0b1e0b2fed1fd4fa3a0a5fa5cf722e714045cb6c 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -14,9 +14,6 @@
#include "remoting/codec/audio_encoder.h"
#include "remoting/codec/audio_encoder_opus.h"
#include "remoting/codec/audio_encoder_verbatim.h"
-#include "remoting/codec/video_encoder.h"
-#include "remoting/codec/video_encoder_verbatim.h"
-#include "remoting/codec/video_encoder_vpx.h"
#include "remoting/host/audio_capturer.h"
#include "remoting/host/audio_pump.h"
#include "remoting/host/desktop_capturer_proxy.h"
@@ -47,22 +44,6 @@ namespace {
// Name of command-line flag to disable use of I444 by default.
const char kDisableI444SwitchName[] = "disable-i444";
-scoped_ptr<VideoEncoder> CreateVideoEncoder(
- const protocol::SessionConfig& config) {
- const protocol::ChannelConfig& video_config = config.video_config();
-
- if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
- return VideoEncoderVpx::CreateForVP8().Pass();
- } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) {
- return VideoEncoderVpx::CreateForVP9().Pass();
- } else if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
- return make_scoped_ptr(new VideoEncoderVerbatim());
- }
-
- NOTREACHED();
- return nullptr;
-}
-
scoped_ptr<AudioEncoder> CreateAudioEncoder(
const protocol::SessionConfig& config) {
const protocol::ChannelConfig& audio_config = config.audio_config();
@@ -99,7 +80,7 @@ ClientSession::ClientSession(
input_tracker_(&host_input_filter_),
remote_input_filter_(&input_tracker_),
mouse_clamping_filter_(&remote_input_filter_),
- disable_input_filter_(mouse_clamping_filter_.input_filter()),
+ disable_input_filter_(&mouse_clamping_filter_),
disable_clipboard_filter_(clipboard_echo_filter_.host_filter()),
client_clipboard_factory_(clipboard_echo_filter_.client_filter()),
max_duration_(max_duration),
@@ -136,7 +117,6 @@ ClientSession::~ClientSession() {
DCHECK(!desktop_environment_);
DCHECK(!input_injector_);
DCHECK(!screen_controls_);
Jamie 2015/11/25 01:32:46 No DCHECK for video_stream_?
Sergey Ulanov 2015/11/27 22:11:34 Done.
- DCHECK(!video_frame_pump_);
connection_.reset();
}
@@ -171,28 +151,28 @@ void ClientSession::NotifyClientResolution(
void ClientSession::ControlVideo(const protocol::VideoControl& video_control) {
DCHECK(CalledOnValidThread());
- // Note that |video_frame_pump_| may be null, depending upon whether
+ // Note that |video_stream_| may be null, depending upon whether
// extensions choose to wrap or "steal" the video capturer or encoder.
if (video_control.has_enable()) {
VLOG(1) << "Received VideoControl (enable="
<< video_control.enable() << ")";
pause_video_ = !video_control.enable();
- if (video_frame_pump_)
- video_frame_pump_->Pause(pause_video_);
+ if (video_stream_)
+ video_stream_->Pause(pause_video_);
}
if (video_control.has_lossless_encode()) {
VLOG(1) << "Received VideoControl (lossless_encode="
<< video_control.lossless_encode() << ")";
lossless_video_encode_ = video_control.lossless_encode();
- if (video_frame_pump_)
- video_frame_pump_->SetLosslessEncode(lossless_video_encode_);
+ if (video_stream_)
+ video_stream_->SetLosslessEncode(lossless_video_encode_);
}
if (video_control.has_lossless_color()) {
VLOG(1) << "Received VideoControl (lossless_color="
<< video_control.lossless_color() << ")";
lossless_video_color_ = video_control.lossless_color();
- if (video_frame_pump_)
- video_frame_pump_->SetLosslessColor(lossless_video_color_);
+ if (video_stream_)
+ video_stream_->SetLosslessColor(lossless_video_color_);
}
}
@@ -285,7 +265,7 @@ void ClientSession::OnConnectionAuthenticated(
DCHECK(!desktop_environment_);
DCHECK(!input_injector_);
DCHECK(!screen_controls_);
- DCHECK(!video_frame_pump_);
+ DCHECK(!video_stream_);
is_authenticated_ = true;
@@ -311,9 +291,6 @@ void ClientSession::OnConnectionAuthenticated(
// Connect host stub.
connection_->set_host_stub(this);
- // Connect video stub.
- mouse_clamping_filter_.set_video_stub(connection_->video_stub());
-
// Collate the set of capabilities to offer the client, if it supports them.
host_capabilities_ = desktop_environment_->GetCapabilities();
if (!host_capabilities_.empty())
@@ -392,7 +369,7 @@ void ClientSession::OnConnectionClosed(
// Stop components access the client, audio or video stubs, which are no
// longer valid once ConnectionToClient calls OnConnectionClosed().
audio_pump_.reset();
- video_frame_pump_.reset();
+ video_stream_.reset();
mouse_shape_pump_.reset();
client_clipboard_factory_.InvalidateWeakPtrs();
input_injector_.reset();
@@ -403,14 +380,19 @@ void ClientSession::OnConnectionClosed(
event_handler_->OnSessionClosed(this);
}
+void ClientSession::OnCreateVideoEncoder(scoped_ptr<VideoEncoder>* encoder) {
+ DCHECK(CalledOnValidThread());
+ extension_manager_->OnCreateVideoEncoder(encoder);
+}
+
void ClientSession::OnInputEventReceived(
protocol::ConnectionToClient* connection,
int64_t event_timestamp) {
DCHECK(CalledOnValidThread());
DCHECK_EQ(connection_.get(), connection);
- if (video_frame_pump_.get())
- video_frame_pump_->OnInputEventReceived(event_timestamp);
+ if (video_stream_.get())
+ video_stream_->OnInputEventReceived(event_timestamp);
}
void ClientSession::OnRouteChange(
@@ -455,21 +437,18 @@ void ClientSession::SetDisableInputs(bool disable_inputs) {
void ClientSession::ResetVideoPipeline() {
DCHECK(CalledOnValidThread());
+ video_stream_.reset();
mouse_shape_pump_.reset();
- connection_->set_video_feedback_stub(nullptr);
- video_frame_pump_.reset();
// Create VideoEncoder and DesktopCapturer to match the session's video
// channel configuration.
scoped_ptr<webrtc::DesktopCapturer> video_capturer =
desktop_environment_->CreateVideoCapturer();
extension_manager_->OnCreateVideoCapturer(&video_capturer);
- scoped_ptr<VideoEncoder> video_encoder =
- CreateVideoEncoder(connection_->session()->config());
- extension_manager_->OnCreateVideoEncoder(&video_encoder);
- // Don't start the VideoFramePump if either capturer or encoder are missing.
- if (!video_capturer || !video_encoder)
+ // Don't start the video stream if the extension took ownership of the
+ // capturer.
+ if (!video_capturer)
return;
// Create MouseShapePump to send mouse cursor shape.
@@ -478,25 +457,23 @@ void ClientSession::ResetVideoPipeline() {
desktop_environment_->CreateMouseCursorMonitor(),
connection_->client_stub()));
- // Create a VideoFramePump to pump frames from the capturer to the client.'
- //
+ // Create a VideoStream to pump frames from the capturer to the client.
+
// TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment.
// When using IpcDesktopCapturer the capture thread is not useful.
- scoped_ptr<DesktopCapturerProxy> capturer_proxy(new DesktopCapturerProxy(
+ scoped_ptr<webrtc::DesktopCapturer> capturer_proxy(new DesktopCapturerProxy(
video_capture_task_runner_, video_capturer.Pass()));
- video_frame_pump_.reset(new protocol::VideoFramePump(
- video_encode_task_runner_, capturer_proxy.Pass(), video_encoder.Pass(),
- &mouse_clamping_filter_));
- // Apply video-control parameters to the new scheduler.
- video_frame_pump_->SetLosslessEncode(lossless_video_encode_);
- video_frame_pump_->SetLosslessColor(lossless_video_color_);
+ video_stream_ = connection_->StartVideoStream(capturer_proxy.Pass());
+ video_stream_->SetSizeCallback(
+ base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this)));
- // Pause capturing if necessary.
- video_frame_pump_->Pause(pause_video_);
+ // Apply video-control parameters to the new stream.
+ video_stream_->SetLosslessEncode(lossless_video_encode_);
+ video_stream_->SetLosslessColor(lossless_video_color_);
- connection_->set_video_feedback_stub(
- video_frame_pump_->video_feedback_stub());
+ // Pause capturing if necessary.
+ video_stream_->Pause(pause_video_);
}
void ClientSession::SetGnubbyAuthHandlerForTesting(
@@ -513,4 +490,10 @@ scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() {
base::ThreadTaskRunnerHandle::Get()));
}
+void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) {
+ DCHECK(CalledOnValidThread());
+ mouse_clamping_filter_.set_input_size(size);
+ mouse_clamping_filter_.set_output_size(size);
+}
+
} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698