Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 audio_writer_->Init(session_.get(), base::Bind( | |
| 130 &ConnectionToClient::OnChannelInitialized, base::Unretained(this))); | |
| 131 | |
| 123 // Notify the handler after initializing the channels, so that | 132 // Notify the handler after initializing the channels, so that |
| 124 // ClientSession can get a client clipboard stub. | 133 // ClientSession can get a client clipboard stub. |
| 125 handler_->OnConnectionAuthenticated(this); | 134 handler_->OnConnectionAuthenticated(this); |
| 126 break; | 135 break; |
| 127 | 136 |
| 128 case Session::CLOSED: | 137 case Session::CLOSED: |
| 129 Close(OK); | 138 Close(OK); |
| 130 break; | 139 break; |
| 131 | 140 |
| 132 case Session::FAILED: | 141 case Session::FAILED: |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 151 } | 160 } |
| 152 | 161 |
| 153 NotifyIfChannelsReady(); | 162 NotifyIfChannelsReady(); |
| 154 } | 163 } |
| 155 | 164 |
| 156 void ConnectionToClient::NotifyIfChannelsReady() { | 165 void ConnectionToClient::NotifyIfChannelsReady() { |
| 157 DCHECK(CalledOnValidThread()); | 166 DCHECK(CalledOnValidThread()); |
| 158 | 167 |
| 159 if (control_dispatcher_.get() && control_dispatcher_->is_connected() && | 168 if (control_dispatcher_.get() && control_dispatcher_->is_connected() && |
| 160 event_dispatcher_.get() && event_dispatcher_->is_connected() && | 169 event_dispatcher_.get() && event_dispatcher_->is_connected() && |
| 161 video_writer_.get() && video_writer_->is_connected()) { | 170 video_writer_.get() && video_writer_->is_connected() && |
| 171 audio_writer_.get() && audio_writer_->is_connected()) { | |
|
Wez
2012/06/19 03:29:31
This assumes that the remote party also wants an a
kxing
2012/06/20 22:30:06
Done.
| |
| 162 handler_->OnConnectionChannelsConnected(this); | 172 handler_->OnConnectionChannelsConnected(this); |
| 163 } | 173 } |
| 164 } | 174 } |
| 165 | 175 |
| 166 void ConnectionToClient::Close(ErrorCode error) { | 176 void ConnectionToClient::Close(ErrorCode error) { |
| 167 CloseChannels(); | 177 CloseChannels(); |
| 168 handler_->OnConnectionClosed(this, error); | 178 handler_->OnConnectionClosed(this, error); |
| 169 } | 179 } |
| 170 | 180 |
| 171 void ConnectionToClient::CloseChannels() { | 181 void ConnectionToClient::CloseChannels() { |
| 172 control_dispatcher_.reset(); | 182 control_dispatcher_.reset(); |
| 173 event_dispatcher_.reset(); | 183 event_dispatcher_.reset(); |
| 174 video_writer_.reset(); | 184 video_writer_.reset(); |
| 185 audio_writer_.reset(); | |
| 175 } | 186 } |
| 176 | 187 |
| 177 } // namespace protocol | 188 } // namespace protocol |
| 178 } // namespace remoting | 189 } // namespace remoting |
| OLD | NEW |