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

Side by Side Diff: remoting/protocol/connection_to_client.cc

Issue 577473002: Simplify VideoReader and VideoWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/protocol/connection_to_client.h" 5 #include "remoting/protocol/connection_to_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
11 #include "remoting/protocol/clipboard_stub.h" 11 #include "remoting/protocol/clipboard_stub.h"
12 #include "remoting/protocol/host_control_dispatcher.h" 12 #include "remoting/protocol/host_control_dispatcher.h"
13 #include "remoting/protocol/host_event_dispatcher.h" 13 #include "remoting/protocol/host_event_dispatcher.h"
14 #include "remoting/protocol/host_stub.h" 14 #include "remoting/protocol/host_stub.h"
15 #include "remoting/protocol/host_video_dispatcher.h"
15 #include "remoting/protocol/input_stub.h" 16 #include "remoting/protocol/input_stub.h"
16 17
17 namespace remoting { 18 namespace remoting {
18 namespace protocol { 19 namespace protocol {
19 20
20 ConnectionToClient::ConnectionToClient(protocol::Session* session) 21 ConnectionToClient::ConnectionToClient(protocol::Session* session)
21 : handler_(NULL), 22 : handler_(NULL),
22 clipboard_stub_(NULL), 23 clipboard_stub_(NULL),
23 host_stub_(NULL), 24 host_stub_(NULL),
24 input_stub_(NULL), 25 input_stub_(NULL),
(...skipping 24 matching lines...) Expand all
49 session_->Close(); 50 session_->Close();
50 } 51 }
51 52
52 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) { 53 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
53 DCHECK(CalledOnValidThread()); 54 DCHECK(CalledOnValidThread());
54 handler_->OnSequenceNumberUpdated(this, sequence_number); 55 handler_->OnSequenceNumberUpdated(this, sequence_number);
55 } 56 }
56 57
57 VideoStub* ConnectionToClient::video_stub() { 58 VideoStub* ConnectionToClient::video_stub() {
58 DCHECK(CalledOnValidThread()); 59 DCHECK(CalledOnValidThread());
59 return video_writer_.get(); 60 return video_dispatcher_.get();
60 } 61 }
61 62
62 AudioStub* ConnectionToClient::audio_stub() { 63 AudioStub* ConnectionToClient::audio_stub() {
63 DCHECK(CalledOnValidThread()); 64 DCHECK(CalledOnValidThread());
64 return audio_writer_.get(); 65 return audio_writer_.get();
65 } 66 }
66 67
67 // Return pointer to ClientStub. 68 // Return pointer to ClientStub.
68 ClientStub* ConnectionToClient::client_stub() { 69 ClientStub* ConnectionToClient::client_stub() {
69 DCHECK(CalledOnValidThread()); 70 DCHECK(CalledOnValidThread());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 128
128 event_dispatcher_.reset(new HostEventDispatcher()); 129 event_dispatcher_.reset(new HostEventDispatcher());
129 event_dispatcher_->Init( 130 event_dispatcher_->Init(
130 session_.get(), session_->config().event_config(), 131 session_.get(), session_->config().event_config(),
131 base::Bind(&ConnectionToClient::OnChannelInitialized, 132 base::Bind(&ConnectionToClient::OnChannelInitialized,
132 base::Unretained(this))); 133 base::Unretained(this)));
133 event_dispatcher_->set_input_stub(input_stub_); 134 event_dispatcher_->set_input_stub(input_stub_);
134 event_dispatcher_->set_sequence_number_callback(base::Bind( 135 event_dispatcher_->set_sequence_number_callback(base::Bind(
135 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); 136 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
136 137
137 video_writer_ = VideoWriter::Create(session_->config()); 138 video_dispatcher_.reset(new HostVideoDispatcher());
138 video_writer_->Init(session_.get(), base::Bind( 139 video_dispatcher_->Init(
139 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 140 session_.get(), session_->config().video_config(),
141 base::Bind(&ConnectionToClient::OnChannelInitialized,
142 base::Unretained(this)));
140 143
141 audio_writer_ = AudioWriter::Create(session_->config()); 144 audio_writer_ = AudioWriter::Create(session_->config());
142 if (audio_writer_.get()) { 145 if (audio_writer_.get()) {
143 audio_writer_->Init( 146 audio_writer_->Init(
144 session_.get(), session_->config().audio_config(), 147 session_.get(), session_->config().audio_config(),
145 base::Bind(&ConnectionToClient::OnChannelInitialized, 148 base::Bind(&ConnectionToClient::OnChannelInitialized,
146 base::Unretained(this))); 149 base::Unretained(this)));
147 } 150 }
148 151
149 // Notify the handler after initializing the channels, so that 152 // Notify the handler after initializing the channels, so that
(...skipping 29 matching lines...) Expand all
179 NotifyIfChannelsReady(); 182 NotifyIfChannelsReady();
180 } 183 }
181 184
182 void ConnectionToClient::NotifyIfChannelsReady() { 185 void ConnectionToClient::NotifyIfChannelsReady() {
183 DCHECK(CalledOnValidThread()); 186 DCHECK(CalledOnValidThread());
184 187
185 if (!control_dispatcher_.get() || !control_dispatcher_->is_connected()) 188 if (!control_dispatcher_.get() || !control_dispatcher_->is_connected())
186 return; 189 return;
187 if (!event_dispatcher_.get() || !event_dispatcher_->is_connected()) 190 if (!event_dispatcher_.get() || !event_dispatcher_->is_connected())
188 return; 191 return;
189 if (!video_writer_.get() || !video_writer_->is_connected()) 192 if (!video_dispatcher_.get() || !video_dispatcher_->is_connected())
190 return; 193 return;
191 if ((!audio_writer_.get() || !audio_writer_->is_connected()) && 194 if ((!audio_writer_.get() || !audio_writer_->is_connected()) &&
192 session_->config().is_audio_enabled()) { 195 session_->config().is_audio_enabled()) {
193 return; 196 return;
194 } 197 }
195 handler_->OnConnectionChannelsConnected(this); 198 handler_->OnConnectionChannelsConnected(this);
196 } 199 }
197 200
198 void ConnectionToClient::Close(ErrorCode error) { 201 void ConnectionToClient::Close(ErrorCode error) {
199 CloseChannels(); 202 CloseChannels();
200 handler_->OnConnectionClosed(this, error); 203 handler_->OnConnectionClosed(this, error);
201 } 204 }
202 205
203 void ConnectionToClient::CloseChannels() { 206 void ConnectionToClient::CloseChannels() {
204 control_dispatcher_.reset(); 207 control_dispatcher_.reset();
205 event_dispatcher_.reset(); 208 event_dispatcher_.reset();
206 video_writer_.reset(); 209 video_dispatcher_.reset();
207 audio_writer_.reset(); 210 audio_writer_.reset();
208 } 211 }
209 212
210 } // namespace protocol 213 } // namespace protocol
211 } // namespace remoting 214 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698