0

Remove shaped desktop support from remoting host and client.

We no longer need to support shaped desktop, so the corresponding
code can be removed.

Review URL: https://codereview.chromium.org/1827043004

Cr-Commit-Position: refs/heads/master@{#383340}
This commit is contained in:
sergeyu
2016-03-25 13:27:21 -07:00
committed by Commit bot
parent 97ddb5c86d
commit 24ed25b8af
27 changed files with 6 additions and 589 deletions

@ -56,6 +56,7 @@
#include "remoting/protocol/host_stub.h"
#include "remoting/protocol/transport_context.h"
#include "third_party/webrtc/base/helpers.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
#include "url/gurl.h"
namespace remoting {
@ -355,31 +356,6 @@ void ChromotingInstance::OnVideoSize(const webrtc::DesktopSize& size,
PostLegacyJsonMessage("onDesktopSize", std::move(data));
}
void ChromotingInstance::OnVideoShape(const webrtc::DesktopRegion* shape) {
if ((shape && desktop_shape_ && shape->Equals(*desktop_shape_)) ||
(!shape && !desktop_shape_)) {
return;
}
scoped_ptr<base::DictionaryValue> shape_message(new base::DictionaryValue());
if (shape) {
desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape));
scoped_ptr<base::ListValue> rects_value(new base::ListValue());
for (webrtc::DesktopRegion::Iterator i(*shape); !i.IsAtEnd(); i.Advance()) {
const webrtc::DesktopRect& rect = i.rect();
scoped_ptr<base::ListValue> rect_value(new base::ListValue());
rect_value->AppendInteger(rect.left());
rect_value->AppendInteger(rect.top());
rect_value->AppendInteger(rect.width());
rect_value->AppendInteger(rect.height());
rects_value->Append(rect_value.release());
}
shape_message->Set("rects", rects_value.release());
}
PostLegacyJsonMessage("onDesktopShape", std::move(shape_message));
}
void ChromotingInstance::OnVideoFrameDirtyRegion(
const webrtc::DesktopRegion& dirty_region) {
scoped_ptr<base::ListValue> rects_value(new base::ListValue());

@ -132,7 +132,6 @@ class ChromotingInstance : public ClientUserInterface,
void OnVideoFirstFrameReceived() override;
void OnVideoSize(const webrtc::DesktopSize& size,
const webrtc::DesktopVector& dpi) override;
void OnVideoShape(const webrtc::DesktopRegion* shape) override;
void OnVideoFrameDirtyRegion(
const webrtc::DesktopRegion& dirty_region) override;

@ -44,10 +44,6 @@ class PepperVideoRenderer : public protocol::VideoRenderer {
virtual void OnVideoSize(const webrtc::DesktopSize& size,
const webrtc::DesktopVector& dpi) = 0;
// Called when desktop shape changes. |shape| should be NULL if frames are
// un-shaped.
virtual void OnVideoShape(const webrtc::DesktopRegion* shape) = 0;
// Called with each frame's updated region, if EnableDebugDirtyRegion(true)
// was called.
virtual void OnVideoFrameDirtyRegion(

@ -159,17 +159,6 @@ void PepperVideoRenderer2D::DrawFrame(scoped_ptr<webrtc::DesktopFrame> frame,
event_handler_->OnVideoSize(source_size_, source_dpi_);
}
const webrtc::DesktopRegion* shape = frame->shape();
if (shape) {
if (!source_shape_ || !source_shape_->Equals(*shape)) {
source_shape_ = make_scoped_ptr(new webrtc::DesktopRegion(*shape));
event_handler_->OnVideoShape(source_shape_.get());
}
} else if (source_shape_) {
source_shape_ = nullptr;
event_handler_->OnVideoShape(nullptr);
}
// If Debug dirty region is enabled then emit it.
if (debug_dirty_region_)
event_handler_->OnVideoFrameDirtyRegion(frame->updated_region());

@ -21,7 +21,6 @@
#include "remoting/client/plugin/pepper_video_renderer.h"
#include "remoting/protocol/frame_consumer.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace base {
class ScopedClosureRunner;
@ -86,9 +85,6 @@ class PepperVideoRenderer2D : public PepperVideoRenderer,
// Resolution of the most recent source frame dots-per-inch.
webrtc::DesktopVector source_dpi_;
// Shape of the most recent source frame.
scoped_ptr<webrtc::DesktopRegion> source_shape_;
// Done callbacks for the frames that have been painted but not flushed.
ScopedVector<base::ScopedClosureRunner> pending_frames_done_callbacks_;

@ -19,6 +19,7 @@
#include "remoting/proto/video.pb.h"
#include "remoting/protocol/performance_tracker.h"
#include "remoting/protocol/session_config.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
@ -220,26 +221,6 @@ void PepperVideoRenderer3D::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
if (resolution_changed)
event_handler_->OnVideoSize(frame_size_, frame_dpi_);
// Process the frame shape, if supplied.
if (packet->has_use_desktop_shape()) {
if (packet->use_desktop_shape()) {
scoped_ptr<webrtc::DesktopRegion> shape(new webrtc::DesktopRegion);
for (int i = 0; i < packet->desktop_shape_rects_size(); ++i) {
Rect remoting_rect = packet->desktop_shape_rects(i);
shape->AddRect(webrtc::DesktopRect::MakeXYWH(
remoting_rect.x(), remoting_rect.y(), remoting_rect.width(),
remoting_rect.height()));
}
if (!frame_shape_ || !frame_shape_->Equals(*shape)) {
frame_shape_ = std::move(shape);
event_handler_->OnVideoShape(frame_shape_.get());
}
} else if (frame_shape_) {
frame_shape_ = nullptr;
event_handler_->OnVideoShape(nullptr);
}
}
// Report the dirty region, for debugging, if requested.
if (debug_dirty_region_) {
webrtc::DesktopRegion dirty_region;

@ -20,7 +20,6 @@
#include "remoting/client/plugin/pepper_video_renderer.h"
#include "remoting/protocol/video_stub.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
struct PPB_OpenGLES2;
@ -99,7 +98,6 @@ class PepperVideoRenderer3D : public PepperVideoRenderer,
webrtc::DesktopSize frame_size_;
webrtc::DesktopVector frame_dpi_;
scoped_ptr<webrtc::DesktopRegion> frame_shape_;
webrtc::DesktopSize view_size_;

@ -117,26 +117,6 @@ bool VideoDecoderVpx::DecodePacket(const VideoPacket& packet,
RenderRect(image, rect, frame);
}
// Process the frame shape, if supplied.
if (packet.has_use_desktop_shape()) {
if (packet.use_desktop_shape()) {
if (!desktop_shape_)
desktop_shape_ = make_scoped_ptr(new webrtc::DesktopRegion);
desktop_shape_->Clear();
for (int i = 0; i < packet.desktop_shape_rects_size(); ++i) {
Rect proto_rect = packet.desktop_shape_rects(i);
desktop_shape_->AddRect(webrtc::DesktopRect::MakeXYWH(
proto_rect.x(), proto_rect.y(), proto_rect.width(),
proto_rect.height()));
}
} else {
desktop_shape_.reset();
}
}
if (desktop_shape_)
frame->set_shape(new webrtc::DesktopRegion(*desktop_shape_));
return true;
}

@ -14,11 +14,6 @@
typedef const struct vpx_codec_iface vpx_codec_iface_t;
typedef struct vpx_image vpx_image_t;
namespace webrtc {
class DesktopRect;
class DesktopRegion;
} // namespace webrtc
namespace remoting {
class VideoDecoderVpx : public VideoDecoder {
@ -38,9 +33,6 @@ class VideoDecoderVpx : public VideoDecoder {
ScopedVpxCodec codec_;
// The shape of the most-recent frame, if any.
scoped_ptr<webrtc::DesktopRegion> desktop_shape_;
DISALLOW_COPY_AND_ASSIGN(VideoDecoderVpx);
};

@ -44,19 +44,6 @@ VideoEncoderHelper::CreateVideoPacketWithUpdatedRegion(
dirty_rect->set_height(rect.height());
}
// Record the shape of the frame, if specified.
if (frame.shape()) {
packet->set_use_desktop_shape(true);
for (webrtc::DesktopRegion::Iterator r(*frame.shape());
!r.IsAtEnd(); r.Advance()) {
Rect* rect = packet->add_desktop_shape_rects();
rect->set_x(r.rect().left());
rect->set_y(r.rect().top());
rect->set_width(r.rect().width());
rect->set_height(r.rect().height());
}
}
// Store frame DPI.
if (!frame.dpi().is_zero()) {
packet->mutable_format()->set_x_dpi(frame.dpi().x());

@ -22,9 +22,6 @@ TEST(VideoEncoderHelperTest, PropagatesCommonFields) {
frame.set_dpi(DesktopVector(96, 97));
frame.set_capture_time_ms(20);
frame.mutable_updated_region()->SetRect(DesktopRect::MakeLTRB(0, 0, 16, 16));
scoped_ptr<DesktopRegion> shape(
new DesktopRegion(DesktopRect::MakeLTRB(16, 0, 32, 16)));
frame.set_shape(shape.release());
VideoEncoderHelper helper;
scoped_ptr<VideoPacket> packet(helper.CreateVideoPacket(frame));
@ -37,11 +34,6 @@ TEST(VideoEncoderHelperTest, PropagatesCommonFields) {
EXPECT_TRUE(packet->format().has_y_dpi());
EXPECT_EQ(1, packet->dirty_rects().size());
ASSERT_TRUE(packet->has_use_desktop_shape());
EXPECT_TRUE(packet->use_desktop_shape());
EXPECT_EQ(1, packet->desktop_shape_rects().size());
}
TEST(VideoEncoderHelperTest, ZeroDpi) {
@ -59,16 +51,6 @@ TEST(VideoEncoderHelperTest, ZeroDpi) {
EXPECT_FALSE(packet->format().has_y_dpi());
}
TEST(VideoEncoderHelperTest, NoShape) {
BasicDesktopFrame frame(DesktopSize(32, 32));
VideoEncoderHelper helper;
scoped_ptr<VideoPacket> packet(helper.CreateVideoPacket(frame));
EXPECT_FALSE(packet->use_desktop_shape());
EXPECT_EQ(0, packet->desktop_shape_rects().size());
}
TEST(VideoEncoderHelperTest, NoScreenSizeIfUnchanged) {
BasicDesktopFrame frame(DesktopSize(32, 32));
// Set DPI so that the packet will have a format, with DPI but no size.

@ -261,7 +261,6 @@ if (is_mac) { # TODO(GYP) Mac build of remoting host.
"config_file_watcher_unittest.cc",
"daemon_process_unittest.cc",
"desktop_process_unittest.cc",
"desktop_shape_tracker_unittest.cc",
"gcd_rest_client_unittest.cc",
"gcd_state_updater_unittest.cc",
"heartbeat_sender_unittest.cc",
@ -298,7 +297,6 @@ if (is_mac) { # TODO(GYP) Mac build of remoting host.
"setup/me2me_native_messaging_host_unittest.cc",
"setup/oauth_helper_unittest.cc",
"setup/pin_validator_unittest.cc",
"shaped_desktop_capturer_unittest.cc",
"third_party_auth_config_unittest.cc",
"token_validator_factory_impl_unittest.cc",
"touch_injector_win_unittest.cc",

@ -1,39 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_DESKTOP_SHAPE_TRACKER_H_
#define REMOTING_HOST_DESKTOP_SHAPE_TRACKER_H_
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
namespace webrtc {
class DesktopCaptureOptions;
class DesktopRegion;
} // namespace webrtc
namespace remoting {
// Tracks changes in the area of the desktop that is occupied by windows.
class DesktopShapeTracker {
public:
static scoped_ptr<DesktopShapeTracker> Create(
webrtc::DesktopCaptureOptions options);
DesktopShapeTracker() {}
virtual ~DesktopShapeTracker() {}
// Recalculates the desktop shape, as returned by desktop_shape();
virtual void RefreshDesktopShape() = 0;
// Returns a reference to the most recently capture desktop shape.
virtual const webrtc::DesktopRegion& desktop_shape() = 0;
private:
DISALLOW_COPY_AND_ASSIGN(DesktopShapeTracker);
};
} // namespace remoting
#endif // REMOTING_HOST_DESKTOP_SHAPE_TRACKER_H_

@ -1,17 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/desktop_shape_tracker.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
namespace remoting {
scoped_ptr<DesktopShapeTracker> DesktopShapeTracker::Create(
webrtc::DesktopCaptureOptions options) {
return nullptr;
}
} // namespace remoting

@ -1,17 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/desktop_shape_tracker.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
namespace remoting {
scoped_ptr<DesktopShapeTracker> DesktopShapeTracker::Create(
webrtc::DesktopCaptureOptions options) {
return nullptr;
}
} // namespace remoting

@ -1,33 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// DesktopShapeTracker tests assume that there is at least one top-level
// window on-screen. Currently we assume the presence of the Explorer
// task bar window.
#include "remoting/host/desktop_shape_tracker.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
// Verify that the desktop shape tracker returns a non-empty region.
TEST(DesktopShapeTrackerTest, Basic) {
scoped_ptr<DesktopShapeTracker> shape_tracker = DesktopShapeTracker::Create(
webrtc::DesktopCaptureOptions::CreateDefault());
// Shape tracker is not supported on all platforms yet.
#if defined(OS_WIN)
shape_tracker->RefreshDesktopShape();
EXPECT_FALSE(shape_tracker->desktop_shape().is_empty());
#else
EXPECT_FALSE(shape_tracker);
#endif
}
} // namespace remoting

@ -1,146 +0,0 @@
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/desktop_shape_tracker.h"
#include <stddef.h>
#include <vector>
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/win/scoped_gdi_object.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
namespace {
struct EnumDesktopShapeData {
EnumDesktopShapeData()
: window_region(CreateRectRgn(0, 0, 0, 0)),
desktop_region(CreateRectRgn(0, 0, 0, 0)) {
}
base::win::ScopedRegion window_region;
base::win::ScopedRegion desktop_region;
};
class DesktopShapeTrackerWin : public DesktopShapeTracker {
public:
DesktopShapeTrackerWin();
~DesktopShapeTrackerWin() override;
void RefreshDesktopShape() override;
const webrtc::DesktopRegion& desktop_shape() override;
private:
// Callback passed to EnumWindows() to enumerate windows.
static BOOL CALLBACK EnumWindowsCallback(HWND window, LPARAM lparam);
// The most recently calculated desktop region.
webrtc::DesktopRegion desktop_shape_;
// Stored to compare with newly calculated desktop shapes, to avoid converting
// to an DesktopRegion unless the shape has actually changed.
base::win::ScopedRegion old_desktop_region_;
DISALLOW_COPY_AND_ASSIGN(DesktopShapeTrackerWin);
};
DesktopShapeTrackerWin::DesktopShapeTrackerWin()
: old_desktop_region_(CreateRectRgn(0, 0, 0, 0)) {
}
DesktopShapeTrackerWin::~DesktopShapeTrackerWin() {
}
void DesktopShapeTrackerWin::RefreshDesktopShape() {
// Accumulate a new desktop shape from current window positions.
scoped_ptr<EnumDesktopShapeData> shape_data(new EnumDesktopShapeData);
if (!EnumWindows(EnumWindowsCallback, (LPARAM)shape_data.get())) {
PLOG(ERROR) << "Failed to enumerate windows";
desktop_shape_.Clear();
return;
}
// If the shape has changed, refresh |desktop_shape_|.
if (!EqualRgn(shape_data->desktop_region.get(), old_desktop_region_.get())) {
old_desktop_region_ = std::move(shape_data->desktop_region);
// Determine the size of output buffer required to receive the region.
DWORD bytes_size = GetRegionData(old_desktop_region_.get(), 0, nullptr);
CHECK(bytes_size != 0);
// Fetch the Windows RECTs that comprise the region.
std::vector<char> buffer(bytes_size);
LPRGNDATA region_data = reinterpret_cast<LPRGNDATA>(buffer.data());
DWORD result =
GetRegionData(old_desktop_region_.get(), bytes_size, region_data);
CHECK(result == bytes_size);
const LPRECT rects = reinterpret_cast<LPRECT>(&region_data->Buffer[0]);
// Reset |desktop_shape_| and add new rectangles into it.
desktop_shape_.Clear();
for (size_t i = 0; i < region_data->rdh.nCount; ++i) {
desktop_shape_.AddRect(webrtc::DesktopRect::MakeLTRB(
rects[i].left, rects[i].top, rects[i].right, rects[i].bottom));
}
}
}
const webrtc::DesktopRegion& DesktopShapeTrackerWin::desktop_shape() {
return desktop_shape_;
}
// static
BOOL DesktopShapeTrackerWin::EnumWindowsCallback(HWND window, LPARAM lparam) {
EnumDesktopShapeData* data = reinterpret_cast<EnumDesktopShapeData*>(lparam);
HRGN desktop_region = data->desktop_region.get();
HRGN window_region = data->window_region.get();
// Is the window visible?
if (!IsWindow(window) || !IsWindowVisible(window) || IsIconic(window))
return TRUE;
// Find the desktop position of the window (including non-client-area).
RECT window_rect;
if (!GetWindowRect(window, &window_rect))
return TRUE;
// Find the shape of the window, in window coords.
// GetWindowRgn will overwrite the current contents of |window_region|.
if (GetWindowRgn(window, window_region) != ERROR) {
// Translate the window region into desktop coordinates.
OffsetRgn(window_region, window_rect.left, window_rect.top);
} else {
// Window has no shape, or an error occurred, so assume it's rectangular.
SetRectRgn(window_region, window_rect.left, window_rect.top,
window_rect.right, window_rect.bottom);
}
// TODO(wez): If the window is maximized then we should clip it to the
// display on which it is maximized.
// if (IsZoomed(window))
// CombineRgn(window_region, window_region, screen_region, RGN_AND);
// Merge the window region into the accumulated desktop region. Window
// regions are combined together before converting the result to
// DesktopRegion. It assumed that this approach is more efficient than
// converting each window region individually.
CombineRgn(desktop_region, desktop_region, window_region, RGN_OR);
return TRUE;
}
} // namespace
// static
scoped_ptr<DesktopShapeTracker> DesktopShapeTracker::Create(
webrtc::DesktopCaptureOptions options) {
return make_scoped_ptr(new DesktopShapeTrackerWin());
}
} // namespace remoting

@ -1,44 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/shaped_desktop_capturer.h"
#include <utility>
#include "base/logging.h"
#include "remoting/host/desktop_shape_tracker.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
namespace remoting {
ShapedDesktopCapturer::ShapedDesktopCapturer(
scoped_ptr<webrtc::DesktopCapturer> desktop_capturer,
scoped_ptr<DesktopShapeTracker> shape_tracker)
: desktop_capturer_(std::move(desktop_capturer)),
shape_tracker_(std::move(shape_tracker)),
callback_(nullptr) {}
ShapedDesktopCapturer::~ShapedDesktopCapturer() {}
void ShapedDesktopCapturer::Start(webrtc::DesktopCapturer::Callback* callback) {
callback_ = callback;
desktop_capturer_->Start(this);
}
void ShapedDesktopCapturer::Capture(const webrtc::DesktopRegion& region) {
desktop_capturer_->Capture(region);
}
void ShapedDesktopCapturer::SetSharedMemoryFactory(
rtc::scoped_ptr<webrtc::SharedMemoryFactory> shared_memory_factory) {
desktop_capturer_->SetSharedMemoryFactory(std::move(shared_memory_factory));
}
void ShapedDesktopCapturer::OnCaptureCompleted(webrtc::DesktopFrame* frame) {
shape_tracker_->RefreshDesktopShape();
frame->set_shape(new webrtc::DesktopRegion(shape_tracker_->desktop_shape()));
callback_->OnCaptureCompleted(frame);
}
} // namespace remoting

@ -1,45 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_SHAPED_DESKTOP_CAPTURER_H_
#define REMOTING_HOST_SHAPED_DESKTOP_CAPTURER_H_
#include <stddef.h>
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
namespace remoting {
class DesktopShapeTracker;
// Screen capturer that also captures desktop shape.
class ShapedDesktopCapturer : public webrtc::DesktopCapturer,
public webrtc::DesktopCapturer::Callback {
public:
ShapedDesktopCapturer(scoped_ptr<webrtc::DesktopCapturer> screen_capturer,
scoped_ptr<DesktopShapeTracker> shape_tracker);
~ShapedDesktopCapturer() override;
// webrtc::DesktopCapturer interface.
void Start(webrtc::DesktopCapturer::Callback* callback) override;
void SetSharedMemoryFactory(rtc::scoped_ptr<webrtc::SharedMemoryFactory>
shared_memory_factory) override;
void Capture(const webrtc::DesktopRegion& region) override;
private:
// webrtc::DesktopCapturer::Callback interface.
void OnCaptureCompleted(webrtc::DesktopFrame* frame) override;
scoped_ptr<webrtc::DesktopCapturer> desktop_capturer_;
scoped_ptr<DesktopShapeTracker> shape_tracker_;
webrtc::DesktopCapturer::Callback* callback_;
DISALLOW_COPY_AND_ASSIGN(ShapedDesktopCapturer);
};
} // namespace remoting
#endif // REMOTING_HOST_SHAPED_DESKTOP_CAPTURER_H_

@ -1,66 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/shaped_desktop_capturer.h"
#include <stddef.h>
#include "remoting/host/desktop_shape_tracker.h"
#include "remoting/protocol/fake_desktop_capturer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
namespace remoting {
class FakeDesktopShapeTracker : public DesktopShapeTracker {
public:
FakeDesktopShapeTracker() {}
~FakeDesktopShapeTracker() override {}
static webrtc::DesktopRegion CreateShape() {
webrtc::DesktopRegion result;
result.AddRect(webrtc::DesktopRect::MakeXYWH(0, 0, 5, 5));
result.AddRect(webrtc::DesktopRect::MakeXYWH(5, 5, 5, 5));
return result;
}
void RefreshDesktopShape() override { shape_ = CreateShape(); }
const webrtc::DesktopRegion& desktop_shape() override {
// desktop_shape() can't be called before RefreshDesktopShape().
EXPECT_FALSE(shape_.is_empty());
return shape_;
}
private:
webrtc::DesktopRegion shape_;
};
class ShapedDesktopCapturerTest : public testing::Test,
public webrtc::DesktopCapturer::Callback {
public:
// webrtc::DesktopCapturer::Callback interface
void OnCaptureCompleted(webrtc::DesktopFrame* frame) override {
last_frame_.reset(frame);
}
scoped_ptr<webrtc::DesktopFrame> last_frame_;
};
// Verify that captured frame have shape.
TEST_F(ShapedDesktopCapturerTest, Basic) {
ShapedDesktopCapturer capturer(
make_scoped_ptr(new protocol::FakeDesktopCapturer()),
make_scoped_ptr(new FakeDesktopShapeTracker()));
capturer.Start(this);
capturer.Capture(webrtc::DesktopRegion());
ASSERT_TRUE(last_frame_.get());
ASSERT_TRUE(last_frame_->shape());
EXPECT_TRUE(
FakeDesktopShapeTracker::CreateShape().Equals(*last_frame_->shape()));
}
} // namespace remoting

@ -11,6 +11,8 @@ option optimize_for = LITE_RUNTIME;
package remoting;
message VideoPacketFormat {
// Reserved fields IDs used for removed fields: 1 to 4.
// Identifies how the image was encoded.
enum Encoding {
ENCODING_INVALID = -1;
@ -41,6 +43,8 @@ message Rect {
}
message VideoPacket {
// Reserved fields IDs used for removed fields: 1 to 3, 10, 11.
optional VideoPacketFormat format = 4;
optional bytes data = 5;
@ -58,14 +62,6 @@ message VideoPacket {
// starting to capture this video frame.
optional int64 latest_event_timestamp = 9;
// Provides the new shape for this frame, iff |use_desktop_shape| is true.
repeated Rect desktop_shape_rects = 10;
// True when |desktop_shape_rects| should be used, false to indicate that
// the frame is un-shaped. If the shape has not changed since the preceding
// frame then this field should be omitted.
optional bool use_desktop_shape = 11;
// Optional frame timestamp. Used in tests to estimate frame latency.
optional int64 timestamp = 12;

@ -86,10 +86,6 @@
'host/desktop_session_proxy.h',
'host/desktop_session_win.cc',
'host/desktop_session_win.h',
'host/desktop_shape_tracker.h',
'host/desktop_shape_tracker_linux.cc',
'host/desktop_shape_tracker_mac.cc',
'host/desktop_shape_tracker_win.cc',
'host/disconnect_window_chromeos.cc',
'host/disconnect_window_linux.cc',
'host/disconnect_window_mac.h',
@ -234,8 +230,6 @@
'host/server_log_entry_host.h',
'host/service_urls.cc',
'host/service_urls.h',
'host/shaped_desktop_capturer.cc',
'host/shaped_desktop_capturer.h',
'host/shutdown_watchdog.cc',
'host/shutdown_watchdog.h',
'host/signaling_connector.cc',

@ -267,7 +267,6 @@
'host/config_file_watcher_unittest.cc',
'host/daemon_process_unittest.cc',
'host/desktop_process_unittest.cc',
'host/desktop_shape_tracker_unittest.cc',
'host/gcd_rest_client_unittest.cc',
'host/gcd_state_updater_unittest.cc',
'host/heartbeat_sender_unittest.cc',
@ -309,7 +308,6 @@
'host/setup/mock_oauth_client.h',
'host/setup/oauth_helper_unittest.cc',
'host/setup/pin_validator_unittest.cc',
'host/shaped_desktop_capturer_unittest.cc',
'host/third_party_auth_config_unittest.cc',
'host/token_validator_factory_impl_unittest.cc',
'host/touch_injector_win_unittest.cc',

@ -177,9 +177,6 @@ void TestVideoRenderer::Core::ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
}
}
// To make life easier, assume that the desktop shape is a single rectangle.
packet->clear_use_desktop_shape();
// Render the result into a new DesktopFrame instance that shares buffer with
// |frame_|. updated_region() will be updated for |new_frame|, but not for
// |frame_|.

@ -86,33 +86,4 @@ remoting.ClientPlugin.HostDesktopImpl.prototype.onSizeUpdated = function(
this.getDimensions());
};
/**
* This function is called by |this.plugin_| when the shape of the host
* desktop is changed.
*
* @param {remoting.ClientPluginMessage} message
* @return {Array<{left:number, top:number, width:number, height:number}>}
* rectangles of the desktop shape.
*/
remoting.ClientPlugin.HostDesktopImpl.prototype.onShapeUpdated =
function(message) {
var shapes = base.getArrayAttr(message.data, 'rects');
var rects = shapes.map(
/** @param {Array<number>} shape */
function(shape) {
if (!Array.isArray(shape) || shape.length != 4) {
throw 'Received invalid onDesktopShape message';
}
var rect = {};
rect.left = shape[0];
rect.top = shape[1];
rect.width = shape[2];
rect.height = shape[3];
return rect;
});
this.raiseEvent(remoting.HostDesktop.Events.shapeChanged, rects);
return rects;
};
}());

@ -264,8 +264,6 @@ remoting.ClientPluginImpl.prototype.handleMessageMethod_ = function(message) {
this.onInitializedDeferred_.resolve();
} else if (message.method == 'onDesktopSize') {
this.hostDesktop_.onSizeUpdated(message);
} else if (message.method == 'onDesktopShape') {
this.hostDesktop_.onShapeUpdated(message);
} else if (message.method == 'onPerfStats') {
// Return value is ignored. These calls will throw an error if the value
// is not a number.

@ -24,10 +24,6 @@ remoting.HostDesktop.Events = {
// Fired when the size of the host desktop changes with the desktop dimensions
// {{width:number, height:number, xDpi:number, yDpi:number}}
sizeChanged: 'sizeChanged',
// Fired when the shape of the host desktop changes with an array of
// rectangles of desktop shapes as the event data.
// Array<{left:number, top:number, width:number, height:number}>
shapeChanged: 'shapeChanged'
};
/**