Commit 54624e1a authored by sergeyu's avatar sergeyu Committed by Commit bot

Use only DIPs size in ClientResolution.

ClientResolution message contains DIPs and device size fields. DIPs
size was marked as legacy, but it was actually used by the host. It's
best to use DIPs for consistency with other messages, particularly
VideoTrackLayout. marked device-pixel size as deprecated and the host
now works when width/height fields are not specified.

Review-Url: https://codereview.chromium.org/2021773002
Cr-Commit-Position: refs/heads/master@{#397102}
parent 062c8f5c
......@@ -811,15 +811,16 @@ void ChromotingInstance::HandleNotifyClientResolution(
}
protocol::ClientResolution client_resolution;
client_resolution.set_width(width);
client_resolution.set_height(height);
client_resolution.set_x_dpi(x_dpi);
client_resolution.set_y_dpi(y_dpi);
// Include the legacy width & height in DIPs for use by older hosts.
client_resolution.set_dips_width((width * kDefaultDPI) / x_dpi);
client_resolution.set_dips_height((height * kDefaultDPI) / y_dpi);
// Include the legacy width & height in physical pixels for use by older
// hosts.
client_resolution.set_width_deprecated(width);
client_resolution.set_height_deprecated(height);
client_->host_stub()->NotifyClientResolution(client_resolution);
}
......
......@@ -111,14 +111,7 @@ ClientSession::~ClientSession() {
void ClientSession::NotifyClientResolution(
const protocol::ClientResolution& resolution) {
DCHECK(CalledOnValidThread());
// TODO(sergeyu): Move these checks to protocol layer.
if (!resolution.has_dips_width() || !resolution.has_dips_height() ||
resolution.dips_width() < 0 || resolution.dips_height() < 0 ||
resolution.width() <= 0 || resolution.height() <= 0) {
LOG(ERROR) << "Received invalid ClientResolution message.";
return;
}
DCHECK(resolution.dips_width() > 0 && resolution.dips_height() > 0);
VLOG(1) << "Received ClientResolution (dips_width="
<< resolution.dips_width() << ", dips_height="
......
......@@ -11,13 +11,13 @@ option optimize_for = LITE_RUNTIME;
package remoting.protocol;
message ClientResolution {
// Legacy width and height of the client in Density-Independent Pixels
// Width and height of the client in Density-Independent Pixels
optional int32 dips_width = 1;
optional int32 dips_height = 2;
// Width and height of the client in device pixels.
optional int32 width = 3;
optional int32 height = 4;
// Deprecated width and height of the client in device pixels.
optional int32 width_deprecated = 3;
optional int32 height_deprecated = 4;
// Horizontal and vertical DPI of the screen. If either of these is zero or
// unset, the corresponding DPI should be assumed to be 96 (Windows' default)
......
......@@ -72,10 +72,17 @@ void HostControlDispatcher::OnIncomingMessage(
if (!message)
return;
// TODO(sergeyu): Move message valudation from the message handlers here.
if (message->has_clipboard_event()) {
clipboard_stub_->InjectClipboardEvent(message->clipboard_event());
} else if (message->has_client_resolution()) {
host_stub_->NotifyClientResolution(message->client_resolution());
const ClientResolution& resolution = message->client_resolution();
if (!resolution.has_dips_width() || !resolution.has_dips_height() ||
resolution.dips_width() <= 0 || resolution.dips_height() <= 0) {
LOG(ERROR) << "Received invalid ClientResolution message.";
return;
}
host_stub_->NotifyClientResolution(resolution);
} else if (message->has_video_control()) {
host_stub_->ControlVideo(message->video_control());
} else if (message->has_audio_control()) {
......
......@@ -61,16 +61,21 @@ void WebrtcVideoRendererAdapter::OnFrame(const cricket::VideoFrame& frame) {
std::unique_ptr<webrtc::DesktopFrame> rgb_frame(new webrtc::BasicDesktopFrame(
webrtc::DesktopSize(frame.width(), frame.height())));
base::TimeDelta render_delay = std::max(
base::TimeDelta(), base::TimeDelta::FromMicroseconds(static_cast<float>(
frame.timestamp_us() - rtc::TimeMicros())));
frame.ConvertToRgbBuffer(
output_format_fourcc_, rgb_frame->data(),
std::abs(rgb_frame->stride()) * rgb_frame->size().height(),
rgb_frame->stride());
rgb_frame->mutable_updated_region()->AddRect(
webrtc::DesktopRect::MakeSize(rgb_frame->size()));
task_runner_->PostTask(
task_runner_->PostDelayedTask(
FROM_HERE,
base::Bind(&WebrtcVideoRendererAdapter::DrawFrame,
weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame)));
weak_factory_.GetWeakPtr(), base::Passed(&rgb_frame)),
render_delay);
}
void WebrtcVideoRendererAdapter::DrawFrame(
......
......@@ -161,8 +161,8 @@ void AppRemotingConnectionHelper::SendClientConnectionDetailsToHost() {
// Next send the host a description of the client screen size.
protocol::ClientResolution client_resolution;
client_resolution.set_width(kDefaultWidth);
client_resolution.set_height(kDefaultHeight);
client_resolution.set_width_deprecated(kDefaultWidth);
client_resolution.set_height_deprecated(kDefaultHeight);
client_resolution.set_x_dpi(kDefaultDPI);
client_resolution.set_y_dpi(kDefaultDPI);
client_resolution.set_dips_width(kDefaultWidth);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment