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

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

Issue 10532211: Added piping for sending audio packets from host to client. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unittests Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_host.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "google/protobuf/message.h" 10 #include "google/protobuf/message.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) { 61 void ConnectionToClient::UpdateSequenceNumber(int64 sequence_number) {
62 DCHECK(CalledOnValidThread()); 62 DCHECK(CalledOnValidThread());
63 handler_->OnSequenceNumberUpdated(this, sequence_number); 63 handler_->OnSequenceNumberUpdated(this, sequence_number);
64 } 64 }
65 65
66 VideoStub* ConnectionToClient::video_stub() { 66 VideoStub* ConnectionToClient::video_stub() {
67 DCHECK(CalledOnValidThread()); 67 DCHECK(CalledOnValidThread());
68 return video_writer_.get(); 68 return video_writer_.get();
69 } 69 }
70 70
71 AudioStub* ConnectionToClient::audio_stub() {
72 DCHECK(CalledOnValidThread());
73 return audio_writer_.get();
74 }
75
71 // Return pointer to ClientStub. 76 // Return pointer to ClientStub.
72 ClientStub* ConnectionToClient::client_stub() { 77 ClientStub* ConnectionToClient::client_stub() {
73 DCHECK(CalledOnValidThread()); 78 DCHECK(CalledOnValidThread());
74 return control_dispatcher_.get(); 79 return control_dispatcher_.get();
75 } 80 }
76 81
77 void ConnectionToClient::set_clipboard_stub( 82 void ConnectionToClient::set_clipboard_stub(
78 protocol::ClipboardStub* clipboard_stub) { 83 protocol::ClipboardStub* clipboard_stub) {
79 DCHECK(CalledOnValidThread()); 84 DCHECK(CalledOnValidThread());
80 clipboard_stub_ = clipboard_stub; 85 clipboard_stub_ = clipboard_stub;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 event_dispatcher_->Init(session_.get(), base::Bind( 118 event_dispatcher_->Init(session_.get(), base::Bind(
114 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 119 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
115 event_dispatcher_->set_input_stub(input_stub_); 120 event_dispatcher_->set_input_stub(input_stub_);
116 event_dispatcher_->set_sequence_number_callback(base::Bind( 121 event_dispatcher_->set_sequence_number_callback(base::Bind(
117 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this))); 122 &ConnectionToClient::UpdateSequenceNumber, base::Unretained(this)));
118 123
119 video_writer_ = VideoWriter::Create(session_->config()); 124 video_writer_ = VideoWriter::Create(session_->config());
120 video_writer_->Init(session_.get(), base::Bind( 125 video_writer_->Init(session_.get(), base::Bind(
121 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); 126 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
122 127
128 audio_writer_ = AudioWriter::Create(session_->config());
129 if (audio_writer_.get()) {
130 audio_writer_->Init(session_.get(), base::Bind(
131 &ConnectionToClient::OnChannelInitialized, base::Unretained(this)));
132 }
133
123 // Notify the handler after initializing the channels, so that 134 // Notify the handler after initializing the channels, so that
124 // ClientSession can get a client clipboard stub. 135 // ClientSession can get a client clipboard stub.
125 handler_->OnConnectionAuthenticated(this); 136 handler_->OnConnectionAuthenticated(this);
126 break; 137 break;
127 138
128 case Session::CLOSED: 139 case Session::CLOSED:
129 Close(OK); 140 Close(OK);
130 break; 141 break;
131 142
132 case Session::FAILED: 143 case Session::FAILED:
(...skipping 16 matching lines...) Expand all
149 Close(CHANNEL_CONNECTION_ERROR); 160 Close(CHANNEL_CONNECTION_ERROR);
150 return; 161 return;
151 } 162 }
152 163
153 NotifyIfChannelsReady(); 164 NotifyIfChannelsReady();
154 } 165 }
155 166
156 void ConnectionToClient::NotifyIfChannelsReady() { 167 void ConnectionToClient::NotifyIfChannelsReady() {
157 DCHECK(CalledOnValidThread()); 168 DCHECK(CalledOnValidThread());
158 169
159 if (control_dispatcher_.get() && control_dispatcher_->is_connected() && 170 if (!control_dispatcher_.get() || !control_dispatcher_->is_connected())
160 event_dispatcher_.get() && event_dispatcher_->is_connected() && 171 return;
161 video_writer_.get() && video_writer_->is_connected()) { 172 if (!event_dispatcher_.get() || !event_dispatcher_->is_connected())
162 handler_->OnConnectionChannelsConnected(this); 173 return;
174 if (!video_writer_.get() || !video_writer_->is_connected())
175 return;
176 if ((!audio_writer_.get() || !audio_writer_->is_connected()) &&
177 session_->config().is_audio_enabled()) {
178 return;
163 } 179 }
180 handler_->OnConnectionChannelsConnected(this);
164 } 181 }
165 182
166 void ConnectionToClient::Close(ErrorCode error) { 183 void ConnectionToClient::Close(ErrorCode error) {
167 CloseChannels(); 184 CloseChannels();
168 handler_->OnConnectionClosed(this, error); 185 handler_->OnConnectionClosed(this, error);
169 } 186 }
170 187
171 void ConnectionToClient::CloseChannels() { 188 void ConnectionToClient::CloseChannels() {
172 control_dispatcher_.reset(); 189 control_dispatcher_.reset();
173 event_dispatcher_.reset(); 190 event_dispatcher_.reset();
174 video_writer_.reset(); 191 video_writer_.reset();
192 audio_writer_.reset();
175 } 193 }
176 194
177 } // namespace protocol 195 } // namespace protocol
178 } // namespace remoting 196 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/connection_to_client.h ('k') | remoting/protocol/connection_to_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698