summaryrefslogtreecommitdiffstats
path: root/remoting/client/chromoting_client.cc
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 23:22:20 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-09 23:22:20 +0000
commit3adf1b2a65a85ff7d4b55cd57a4e400f104d27dd (patch)
tree235aee1f595583297e057b058a29d2ed24d9da92 /remoting/client/chromoting_client.cc
parent9db9173baebf27623ce30770696f84a3fec74259 (diff)
downloadchromium_src-3adf1b2a65a85ff7d4b55cd57a4e400f104d27dd.zip
chromium_src-3adf1b2a65a85ff7d4b55cd57a4e400f104d27dd.tar.gz
chromium_src-3adf1b2a65a85ff7d4b55cd57a4e400f104d27dd.tar.bz2
Add VideoPacket struct for video packets. Refactor Decode interface to use it.
Various cleanups. BUG=None TEST=Unittests. Review URL: http://codereview.chromium.org/4476003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client/chromoting_client.cc')
-rw-r--r--remoting/client/chromoting_client.cc54
1 files changed, 23 insertions, 31 deletions
diff --git a/remoting/client/chromoting_client.cc b/remoting/client/chromoting_client.cc
index 4400d4f..1a0192c 100644
--- a/remoting/client/chromoting_client.cc
+++ b/remoting/client/chromoting_client.cc
@@ -12,6 +12,7 @@
#include "remoting/client/rectangle_update_decoder.h"
#include "remoting/proto/internal.pb.h"
#include "remoting/protocol/connection_to_host.h"
+#include "remoting/protocol/session_config.h"
namespace remoting {
@@ -94,27 +95,6 @@ void ChromotingClient::SetViewport(int x, int y, int width, int height) {
view_->SetViewport(x, y, width, height);
}
-void ChromotingClient::HandleMessage(protocol::ConnectionToHost* conn,
- ChromotingHostMessage* msg) {
- if (message_loop() != MessageLoop::current()) {
- message_loop()->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &ChromotingClient::HandleMessage,
- conn, msg));
- return;
- }
-
- // TODO(ajwong): Consider creating a macro similar to the IPC message
- // mappings. Also reconsider the lifetime of the message object.
- if (msg->has_init_client()) {
- ScopedTracer tracer("Handle Init Client");
- InitClient(msg->init_client());
- delete msg;
- } else {
- NOTREACHED() << "Unknown message received";
- }
-}
-
void ChromotingClient::ProcessVideoPacket(const VideoPacket* packet,
Task* done) {
if (message_loop() != MessageLoop::current()) {
@@ -144,12 +124,13 @@ void ChromotingClient::DispatchPacket() {
ScopedTracer tracer("Handle video packet");
rectangle_decoder_->DecodePacket(
- *packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone));
+ packet, NewTracedMethod(this, &ChromotingClient::OnPacketDone));
}
void ChromotingClient::OnConnectionOpened(protocol::ConnectionToHost* conn) {
VLOG(1) << "ChromotingClient::OnConnectionOpened";
SetConnectionState(CONNECTED);
+ Initialize();
}
void ChromotingClient::OnConnectionClosed(protocol::ConnectionToHost* conn) {
@@ -201,20 +182,31 @@ void ChromotingClient::OnPacketDone() {
DispatchPacket();
}
-void ChromotingClient::InitClient(const InitClientMessage& init_client) {
- DCHECK_EQ(message_loop(), MessageLoop::current());
- TraceContext::tracer()->PrintString("Init received");
+void ChromotingClient::Initialize() {
+ if (message_loop() != MessageLoop::current()) {
+ message_loop()->PostTask(
+ FROM_HERE,
+ NewTracedMethod(this, &ChromotingClient::Initialize));
+ return;
+ }
+
+ TraceContext::tracer()->PrintString("Initializing client.");
+
+ const protocol::SessionConfig* config = connection_->config();
// Resize the window.
- int width = init_client.width();
- int height = init_client.height();
- VLOG(1) << "Init client received geometry: " << width << "x" << height;
+ int width = config->initial_resolution().width;
+ int height = config->initial_resolution().height;
+ VLOG(1) << "Initial screen geometry: " << width << "x" << height;
-// TODO(ajwong): What to do here? Does the decoder actually need to request
-// the right frame size? This is mainly an optimization right?
-// rectangle_decoder_->SetOutputFrameSize(width, height);
+ // TODO(ajwong): What to do here? Does the decoder actually need to request
+ // the right frame size? This is mainly an optimization right?
+ // rectangle_decoder_->SetOutputFrameSize(width, height);
view_->SetViewport(0, 0, width, height);
+ // Initialize the decoder.
+ rectangle_decoder_->Initialize(config);
+
// Schedule the input handler to process the event queue.
input_handler_->Initialize();
}