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

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

Issue 10843031: Piping for audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changed an #include to a forward declaration Created 8 years, 4 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
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/client/chromoting_client.h" 5 #include "remoting/client/chromoting_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "remoting/client/audio_decode_scheduler.h"
8 #include "remoting/client/audio_player.h" 9 #include "remoting/client/audio_player.h"
9 #include "remoting/client/client_context.h" 10 #include "remoting/client/client_context.h"
10 #include "remoting/client/client_user_interface.h" 11 #include "remoting/client/client_user_interface.h"
11 #include "remoting/client/rectangle_update_decoder.h" 12 #include "remoting/client/rectangle_update_decoder.h"
12 #include "remoting/proto/audio.pb.h" 13 #include "remoting/proto/audio.pb.h"
13 #include "remoting/proto/video.pb.h" 14 #include "remoting/proto/video.pb.h"
14 #include "remoting/protocol/authentication_method.h" 15 #include "remoting/protocol/authentication_method.h"
15 #include "remoting/protocol/connection_to_host.h" 16 #include "remoting/protocol/connection_to_host.h"
16 #include "remoting/protocol/negotiating_authenticator.h" 17 #include "remoting/protocol/negotiating_authenticator.h"
17 #include "remoting/protocol/session_config.h" 18 #include "remoting/protocol/session_config.h"
18 #include "remoting/protocol/transport.h" 19 #include "remoting/protocol/transport.h"
19 20
20 namespace remoting { 21 namespace remoting {
21 22
22 using protocol::AuthenticationMethod; 23 using protocol::AuthenticationMethod;
23 24
24 ChromotingClient::QueuedVideoPacket::QueuedVideoPacket( 25 ChromotingClient::QueuedVideoPacket::QueuedVideoPacket(
25 scoped_ptr<VideoPacket> packet, const base::Closure& done) 26 scoped_ptr<VideoPacket> packet, const base::Closure& done)
26 : packet(packet.release()), done(done) { 27 : packet(packet.release()), done(done) {
27 } 28 }
28 29
29 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() { 30 ChromotingClient::QueuedVideoPacket::~QueuedVideoPacket() {
30 } 31 }
31 32
32 ChromotingClient::ChromotingClient( 33 ChromotingClient::ChromotingClient(
33 const ClientConfig& config, 34 const ClientConfig& config,
34 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 35 const ClientContext& client_context,
35 protocol::ConnectionToHost* connection, 36 protocol::ConnectionToHost* connection,
36 ClientUserInterface* user_interface, 37 ClientUserInterface* user_interface,
37 RectangleUpdateDecoder* rectangle_decoder, 38 RectangleUpdateDecoder* rectangle_decoder,
38 AudioPlayer* audio_player) 39 scoped_ptr<AudioPlayer> audio_player)
39 : config_(config), 40 : config_(config),
40 task_runner_(task_runner), 41 task_runner_(client_context.main_task_runner()),
41 connection_(connection), 42 connection_(connection),
42 user_interface_(user_interface), 43 user_interface_(user_interface),
43 rectangle_decoder_(rectangle_decoder), 44 rectangle_decoder_(rectangle_decoder),
44 audio_player_(audio_player),
45 packet_being_processed_(false), 45 packet_being_processed_(false),
46 last_sequence_number_(0), 46 last_sequence_number_(0),
47 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 47 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
48 audio_decode_scheduler_.reset(new AudioDecodeScheduler(
49 client_context.main_task_runner(),
50 client_context.audio_decode_task_runner(),
51 audio_player.Pass()));
48 } 52 }
49 53
50 ChromotingClient::~ChromotingClient() { 54 ChromotingClient::~ChromotingClient() {
51 } 55 }
52 56
53 void ChromotingClient::Start( 57 void ChromotingClient::Start(
54 scoped_refptr<XmppProxy> xmpp_proxy, 58 scoped_refptr<XmppProxy> xmpp_proxy,
55 scoped_ptr<protocol::TransportFactory> transport_factory) { 59 scoped_ptr<protocol::TransportFactory> transport_factory) {
56 DCHECK(task_runner_->BelongsToCurrentThread()); 60 DCHECK(task_runner_->BelongsToCurrentThread());
57 61
58 scoped_ptr<protocol::Authenticator> authenticator( 62 scoped_ptr<protocol::Authenticator> authenticator(
59 protocol::NegotiatingAuthenticator::CreateForClient( 63 protocol::NegotiatingAuthenticator::CreateForClient(
60 config_.authentication_tag, 64 config_.authentication_tag,
61 config_.shared_secret, config_.authentication_methods)); 65 config_.shared_secret, config_.authentication_methods));
62 66
63 // Create a WeakPtr to ourself for to use for all posted tasks. 67 // Create a WeakPtr to ourself for to use for all posted tasks.
64 weak_ptr_ = weak_factory_.GetWeakPtr(); 68 weak_ptr_ = weak_factory_.GetWeakPtr();
65 69
66 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid, 70 connection_->Connect(xmpp_proxy, config_.local_jid, config_.host_jid,
67 config_.host_public_key, transport_factory.Pass(), 71 config_.host_public_key, transport_factory.Pass(),
68 authenticator.Pass(), this, this, this, this, this); 72 authenticator.Pass(), this, this, this, this,
73 audio_decode_scheduler_.get());
69 } 74 }
70 75
71 void ChromotingClient::Stop(const base::Closure& shutdown_task) { 76 void ChromotingClient::Stop(const base::Closure& shutdown_task) {
72 DCHECK(task_runner_->BelongsToCurrentThread()); 77 DCHECK(task_runner_->BelongsToCurrentThread());
73 78
74 // Drop all pending packets. 79 // Drop all pending packets.
75 while(!received_packets_.empty()) { 80 while(!received_packets_.empty()) {
76 delete received_packets_.front().packet; 81 delete received_packets_.front().packet;
77 received_packets_.front().done.Run(); 82 received_packets_.front().done.Run();
78 received_packets_.pop_front(); 83 received_packets_.pop_front();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done)); 139 received_packets_.push_back(QueuedVideoPacket(packet.Pass(), done));
135 if (!packet_being_processed_) 140 if (!packet_being_processed_)
136 DispatchPacket(); 141 DispatchPacket();
137 } 142 }
138 143
139 int ChromotingClient::GetPendingVideoPackets() { 144 int ChromotingClient::GetPendingVideoPackets() {
140 DCHECK(task_runner_->BelongsToCurrentThread()); 145 DCHECK(task_runner_->BelongsToCurrentThread());
141 return received_packets_.size(); 146 return received_packets_.size();
142 } 147 }
143 148
144 void ChromotingClient::ProcessAudioPacket(scoped_ptr<AudioPacket> packet,
145 const base::Closure& done) {
146 audio_player_->ProcessAudioPacket(packet.Pass());
147 done.Run();
148 }
149
150 void ChromotingClient::DispatchPacket() { 149 void ChromotingClient::DispatchPacket() {
151 DCHECK(task_runner_->BelongsToCurrentThread()); 150 DCHECK(task_runner_->BelongsToCurrentThread());
152 CHECK(!packet_being_processed_); 151 CHECK(!packet_being_processed_);
153 152
154 if (received_packets_.empty()) { 153 if (received_packets_.empty()) {
155 // Nothing to do! 154 // Nothing to do!
156 return; 155 return;
157 } 156 }
158 157
159 scoped_ptr<VideoPacket> packet(received_packets_.front().packet); 158 scoped_ptr<VideoPacket> packet(received_packets_.front().packet);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 209
211 // Process the next video packet. 210 // Process the next video packet.
212 DispatchPacket(); 211 DispatchPacket();
213 } 212 }
214 213
215 void ChromotingClient::Initialize() { 214 void ChromotingClient::Initialize() {
216 DCHECK(task_runner_->BelongsToCurrentThread()); 215 DCHECK(task_runner_->BelongsToCurrentThread());
217 216
218 // Initialize the decoder. 217 // Initialize the decoder.
219 rectangle_decoder_->Initialize(connection_->config()); 218 rectangle_decoder_->Initialize(connection_->config());
219 if (connection_->config().is_audio_enabled()) {
Sergey Ulanov 2012/08/03 17:59:55 remove brackets for consistency with other one-lin
kxing 2012/08/03 20:55:13 Done.
220 audio_decode_scheduler_->Initialize(connection_->config());
221 }
220 } 222 }
221 223
222 } // namespace remoting 224 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698