summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/client/plugin/chromoting_instance.cc18
-rw-r--r--remoting/client/plugin/chromoting_instance.h1
-rw-r--r--remoting/host/client_session.cc14
-rw-r--r--remoting/host/client_session.h2
-rw-r--r--remoting/proto/control.proto5
-rw-r--r--remoting/proto/internal.proto1
-rw-r--r--remoting/protocol/client_control_dispatcher.cc6
-rw-r--r--remoting/protocol/client_control_dispatcher.h1
-rw-r--r--remoting/protocol/host_control_dispatcher.cc2
-rw-r--r--remoting/protocol/host_stub.h5
-rw-r--r--remoting/protocol/protocol_mock_objects.h2
-rw-r--r--remoting/webapp/client_plugin.js9
-rw-r--r--remoting/webapp/client_plugin_async.js13
-rw-r--r--remoting/webapp/client_plugin_v1.js8
14 files changed, 86 insertions, 1 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index b3c28d3..b8f2cce 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -103,7 +103,7 @@ static base::LazyInstance<base::Lock>::Leaky
// String sent in the "hello" message to the plugin to describe features.
const char ChromotingInstance::kApiFeatures[] =
"highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey "
- "notifyClientDimensions";
+ "notifyClientDimensions pauseVideo";
bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str,
ClientConfig* config) {
@@ -309,6 +309,13 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
return;
}
NotifyClientDimensions(width, height);
+ } else if (method == "pauseVideo") {
+ bool pause = false;
+ if (!data->GetBoolean("pause", &pause)) {
+ LOG(ERROR) << "Invalid pauseVideo.";
+ return;
+ }
+ PauseVideo(pause);
}
}
@@ -492,6 +499,15 @@ void ChromotingInstance::NotifyClientDimensions(int width, int height) {
host_connection_->host_stub()->NotifyClientDimensions(client_dimensions);
}
+void ChromotingInstance::PauseVideo(bool pause) {
+ if (!IsConnected()) {
+ return;
+ }
+ protocol::VideoControl video_control;
+ video_control.set_enable(!pause);
+ host_connection_->host_stub()->ControlVideo(video_control);
+}
+
ChromotingStats* ChromotingInstance::GetStats() {
if (!client_.get())
return NULL;
diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h
index a223382..cece07e 100644
--- a/remoting/client/plugin/chromoting_instance.h
+++ b/remoting/client/plugin/chromoting_instance.h
@@ -146,6 +146,7 @@ class ChromotingInstance :
void TrapKey(uint32 usb_keycode, bool trap);
void SendClipboardItem(const std::string& mime_type, const std::string& item);
void NotifyClientDimensions(int width, int height);
+ void PauseVideo(bool pause);
// Return statistics record by ChromotingClient.
// If no connection is currently active then NULL will be returned.
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 04a0ac9..7db5498 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -8,6 +8,7 @@
#include "base/message_loop_proxy.h"
#include "remoting/host/capturer.h"
+#include "remoting/proto/control.pb.h"
#include "remoting/proto/event.pb.h"
namespace remoting {
@@ -70,6 +71,19 @@ void ClientSession::InjectMouseEvent(const protocol::MouseEvent& event) {
void ClientSession::NotifyClientDimensions(
const protocol::ClientDimensions& dimensions) {
// TODO(wez): Use the dimensions, e.g. to resize the host desktop to match.
+ if (dimensions.has_width() && dimensions.has_height()) {
+ VLOG(1) << "Received ClientDimensions (width="
+ << dimensions.width() << ", height=" << dimensions.height() << ")";
+ }
+}
+
+void ClientSession::ControlVideo(const protocol::VideoControl& video_control) {
+ // TODO(wez): Pause/resume video updates, being careful not to let clients
+ // override any host-initiated pause of the video channel.
+ if (video_control.has_enable()) {
+ VLOG(1) << "Received VideoControl (enable="
+ << video_control.enable() << ")";
+ }
}
void ClientSession::OnConnectionAuthenticated(
diff --git a/remoting/host/client_session.h b/remoting/host/client_session.h
index de307f1b..084d153 100644
--- a/remoting/host/client_session.h
+++ b/remoting/host/client_session.h
@@ -80,6 +80,8 @@ class ClientSession : public protocol::HostEventStub,
// protocol::HostStub interface.
virtual void NotifyClientDimensions(
const protocol::ClientDimensions& dimensions) OVERRIDE;
+ virtual void ControlVideo(
+ const protocol::VideoControl& video_control) OVERRIDE;
// protocol::ConnectionToClient::EventHandler interface.
virtual void OnConnectionAuthenticated(
diff --git a/remoting/proto/control.proto b/remoting/proto/control.proto
index 861005a..6c00389 100644
--- a/remoting/proto/control.proto
+++ b/remoting/proto/control.proto
@@ -15,3 +15,8 @@ message ClientDimensions {
optional int32 width = 1;
optional int32 height = 2;
}
+
+message VideoControl {
+ // Enables the video channel if true, pauses if false.
+ optional bool enable = 1;
+}
diff --git a/remoting/proto/internal.proto b/remoting/proto/internal.proto
index b5c77a6..06f9585 100644
--- a/remoting/proto/internal.proto
+++ b/remoting/proto/internal.proto
@@ -18,6 +18,7 @@ package remoting.protocol;
message ControlMessage {
optional ClipboardEvent clipboard_event = 1;
optional ClientDimensions client_dimensions = 2;
+ optional VideoControl video_control = 3;
}
// Defines an event message on the event channel.
diff --git a/remoting/protocol/client_control_dispatcher.cc b/remoting/protocol/client_control_dispatcher.cc
index 12bc795..73bff85 100644
--- a/remoting/protocol/client_control_dispatcher.cc
+++ b/remoting/protocol/client_control_dispatcher.cc
@@ -50,6 +50,12 @@ void ClientControlDispatcher::NotifyClientDimensions(
writer_->Write(SerializeAndFrameMessage(message), base::Closure());
}
+void ClientControlDispatcher::ControlVideo(const VideoControl& video_control) {
+ ControlMessage message;
+ message.mutable_video_control()->CopyFrom(video_control);
+ writer_->Write(SerializeAndFrameMessage(message), base::Closure());
+}
+
void ClientControlDispatcher::OnMessageReceived(
scoped_ptr<ControlMessage> message, const base::Closure& done_task) {
DCHECK(client_stub_);
diff --git a/remoting/protocol/client_control_dispatcher.h b/remoting/protocol/client_control_dispatcher.h
index 422f518..a867e13 100644
--- a/remoting/protocol/client_control_dispatcher.h
+++ b/remoting/protocol/client_control_dispatcher.h
@@ -35,6 +35,7 @@ class ClientControlDispatcher : public ChannelDispatcherBase,
// HostStub implementation.
virtual void NotifyClientDimensions(
const ClientDimensions& dimensions) OVERRIDE;
+ virtual void ControlVideo(const VideoControl& video_control) OVERRIDE;
// Sets the ClientStub that will be called for each incoming control
// message. |client_stub| must outlive this object.
diff --git a/remoting/protocol/host_control_dispatcher.cc b/remoting/protocol/host_control_dispatcher.cc
index ec7d4a6..1932cac 100644
--- a/remoting/protocol/host_control_dispatcher.cc
+++ b/remoting/protocol/host_control_dispatcher.cc
@@ -51,6 +51,8 @@ void HostControlDispatcher::OnMessageReceived(
clipboard_stub_->InjectClipboardEvent(message->clipboard_event());
} else if (message->has_client_dimensions()) {
host_stub_->NotifyClientDimensions(message->client_dimensions());
+ } else if (message->has_video_control()) {
+ host_stub_->ControlVideo(message->video_control());
} else {
LOG(WARNING) << "Unknown control message received.";
}
diff --git a/remoting/protocol/host_stub.h b/remoting/protocol/host_stub.h
index a1b3b30..e712146 100644
--- a/remoting/protocol/host_stub.h
+++ b/remoting/protocol/host_stub.h
@@ -15,6 +15,7 @@ namespace remoting {
namespace protocol {
class ClientDimensions;
+class VideoControl;
class HostStub {
public:
@@ -25,6 +26,10 @@ class HostStub {
// This may be used to resize the host display to match the client area.
virtual void NotifyClientDimensions(const ClientDimensions& dimensions) = 0;
+ // Configures video update properties. Currently only pausing & resuming the
+ // video channel is supported.
+ virtual void ControlVideo(const VideoControl& video_control) = 0;
+
private:
DISALLOW_COPY_AND_ASSIGN(HostStub);
};
diff --git a/remoting/protocol/protocol_mock_objects.h b/remoting/protocol/protocol_mock_objects.h
index 63bb730..592f199 100644
--- a/remoting/protocol/protocol_mock_objects.h
+++ b/remoting/protocol/protocol_mock_objects.h
@@ -105,6 +105,8 @@ class MockHostStub : public HostStub {
MOCK_METHOD1(NotifyClientDimensions,
void(const ClientDimensions& dimensions));
+ MOCK_METHOD1(ControlVideo,
+ void(const VideoControl& video_control));
private:
DISALLOW_COPY_AND_ASSIGN(MockHostStub);
diff --git a/remoting/webapp/client_plugin.js b/remoting/webapp/client_plugin.js
index 826419e..f496f63 100644
--- a/remoting/webapp/client_plugin.js
+++ b/remoting/webapp/client_plugin.js
@@ -50,6 +50,7 @@ remoting.ClientPlugin.Feature = {
HIGH_QUALITY_SCALING: 'highQualityScaling',
INJECT_KEY_EVENT: 'injectKeyEvent',
NOTIFY_CLIENT_DIMENSIONS: 'notifyClientDimensions',
+ PAUSE_VIDEO: 'pauseVideo',
REMAP_KEY: 'remapKey',
SEND_CLIPBOARD_ITEM: 'sendClipboardItem'
};
@@ -144,3 +145,11 @@ remoting.ClientPlugin.prototype.sendClipboardItem = function(mimeType, item) {};
*/
remoting.ClientPlugin.prototype.notifyClientDimensions =
function(width, height) {};
+
+/**
+ * Requests that the host pause or resume sending video updates.
+ *
+ * @param {boolean} pause True to suspend video updates, false otherwise.
+ */
+remoting.ClientPlugin.prototype.pauseVideo =
+ function(pause) {};
diff --git a/remoting/webapp/client_plugin_async.js b/remoting/webapp/client_plugin_async.js
index ff93e19..1a8433e 100644
--- a/remoting/webapp/client_plugin_async.js
+++ b/remoting/webapp/client_plugin_async.js
@@ -380,6 +380,19 @@ remoting.ClientPluginAsync.prototype.notifyClientDimensions =
};
/**
+ * Requests that the host pause or resume sending video updates.
+ *
+ * @param {boolean} pause True to suspend video updates, false otherwise.
+ */
+remoting.ClientPluginAsync.prototype.pauseVideo =
+ function(pause) {
+ if (!this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_VIDEO))
+ return;
+ this.plugin.postMessage(JSON.stringify(
+ { method: 'pauseVideo', data: { pause: pause }}));
+};
+
+/**
* If we haven't yet received a "hello" message from the plugin, change its
* size so that the user can confirm it if click-to-play is enabled, or can
* see the "this plugin is disabled" message if it is actually disabled.
diff --git a/remoting/webapp/client_plugin_v1.js b/remoting/webapp/client_plugin_v1.js
index 8b51eb1..9f9efce 100644
--- a/remoting/webapp/client_plugin_v1.js
+++ b/remoting/webapp/client_plugin_v1.js
@@ -267,3 +267,11 @@ remoting.ClientPluginV1.prototype.notifyClientDimensions =
function(width, height) {
return;
};
+
+/**
+ * @param {boolean} pause
+ */
+remoting.ClientPluginV1.prototype.pauseVideo =
+ function(pause) {
+ return;
+};