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

Side by Side Diff: remoting/client/chromoting_view.cc

Issue 3305001: Move decoder into separate thread, clean up API layering, and redo update protocl (Closed)
Patch Set: Fix compile error. Created 10 years, 2 months 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 unified diff | Download patch
« no previous file with comments | « remoting/client/chromoting_view.h ('k') | remoting/client/chromoting_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/client/chromoting_view.h" 5 #include "remoting/client/chromoting_view.h"
6 6
7 #include "remoting/base/decoder_verbatim.h" 7 #include "base/message_loop.h"
8 #include "remoting/base/decoder_zlib.h" 8 #include "base/waitable_event.h"
9 #include "remoting/base/tracer.h"
9 10
10 namespace remoting { 11 namespace remoting {
11 12
12 ChromotingView::ChromotingView() 13 ChromotingView::ChromotingView()
13 : frame_width_(0), 14 : frame_width_(0),
14 frame_height_(0) { 15 frame_height_(0) {
15 } 16 }
16 17
17
18 // TODO(garykac): This assumes a single screen. This will need to be adjusted 18 // TODO(garykac): This assumes a single screen. This will need to be adjusted
19 // to add support for mulitple monitors. 19 // to add support for mulitple monitors.
20 void ChromotingView::GetScreenSize(int* width, int* height) { 20 void ChromotingView::GetScreenSize(int* width, int* height) {
21 *width = frame_width_; 21 *width = frame_width_;
22 *height = frame_height_; 22 *height = frame_height_;
23 } 23 }
24 24
25 bool ChromotingView::SetupDecoder(UpdateStreamEncoding encoding) {
26 if (encoding == EncodingInvalid) {
27 LOG(ERROR) << "Cannot create encoder for EncodingInvalid";
28 return false;
29 }
30
31 // If we're in the middle of decoding a stream, then we need to make sure
32 // that that all packets in that stream match the encoding of the first
33 // packet.
34 //
35 // If we decide to relax this constraint in the future, we'll need to
36 // update this to keep a set of decoders around.
37 if (decoder_.get() && decoder_->IsStarted()) {
38 // Verify that the encoding matches the decoder. Once we've started
39 // decoding, we can't switch to another decoder.
40 if (decoder_->Encoding() != encoding) {
41 LOG(ERROR) << "Encoding mismatch: Set up to handle "
42 << "UpdateStreamEncoding=" << decoder_->Encoding()
43 << " but received request for "
44 << encoding;
45 return false;
46 }
47 return true;
48 }
49
50 // Lazily initialize a new decoder.
51 // We create a new decoder if we don't currently have a decoder or if the
52 // decoder doesn't match the desired encoding.
53 if (!decoder_.get() || decoder_->Encoding() != encoding) {
54 // Initialize a new decoder based on this message encoding.
55 if (encoding == EncodingNone) {
56 decoder_.reset(new DecoderVerbatim());
57 } else if (encoding == EncodingZlib) {
58 decoder_.reset(new DecoderZlib());
59 }
60 // Make sure we successfully allocated a decoder of the correct type.
61 DCHECK(decoder_.get());
62 DCHECK(decoder_->Encoding() == encoding);
63 }
64
65 return true;
66 }
67
68 bool ChromotingView::BeginDecoding(Task* partial_decode_done,
69 Task* decode_done) {
70 if (decoder_->IsStarted()) {
71 LOG(ERROR) << "BeginDecoding called without ending previous decode.";
72 return false;
73 }
74
75 decoder_->BeginDecode(frame_, &update_rects_,
76 partial_decode_done, decode_done);
77
78 if (!decoder_->IsStarted()) {
79 LOG(ERROR) << "Unable to start decoding.";
80 return false;
81 }
82
83 return true;
84 }
85
86 bool ChromotingView::Decode(ChromotingHostMessage* msg) {
87 if (!decoder_->IsStarted()) {
88 LOG(ERROR) << "Attempt to decode payload before calling BeginDecode.";
89 return false;
90 }
91
92 return decoder_->PartialDecode(msg);
93 }
94
95 bool ChromotingView::EndDecoding() {
96 if (!decoder_->IsStarted()) {
97 LOG(ERROR) << "Attempt to end decode when none has been started.";
98 return false;
99 }
100
101 decoder_->EndDecode();
102
103 if (decoder_->IsStarted()) {
104 LOG(ERROR) << "Unable to properly end decoding.\n";
105 return false;
106 }
107
108 return true;
109 }
110
111 } // namespace remoting 25 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/chromoting_view.h ('k') | remoting/client/chromoting_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698