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/host/screen_recorder.h" | 5 #include "remoting/host/screen_recorder.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 void ScreenRecorder::VideoFrameSentCallback() { | 273 void ScreenRecorder::VideoFrameSentCallback() { |
274 DCHECK(network_loop_->BelongsToCurrentThread()); | 274 DCHECK(network_loop_->BelongsToCurrentThread()); |
275 | 275 |
276 if (network_stopped_) | 276 if (network_stopped_) |
277 return; | 277 return; |
278 | 278 |
279 capture_loop_->PostTask( | 279 capture_loop_->PostTask( |
280 FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this)); | 280 FROM_HERE, base::Bind(&ScreenRecorder::DoFinishOneRecording, this)); |
281 } | 281 } |
282 | 282 |
| 283 void ScreenRecorder::DoSendAudioPacket(scoped_ptr<AudioPacket> packet) { |
| 284 DCHECK(network_loop_->BelongsToCurrentThread()); |
| 285 |
| 286 if (network_stopped_ || connections_.empty()) |
| 287 return; |
| 288 |
| 289 base::Closure callback = base::Bind( |
| 290 &ScreenRecorder::AudioSamplesSentCallback, this); |
| 291 |
| 292 connections_.front()->audio_stub()->ProcessAudioPacket( |
| 293 packet.Pass(), callback); |
| 294 } |
| 295 |
| 296 void ScreenRecorder::AudioSamplesSentCallback() { |
| 297 // TODO(kxing): continue sending audio packets |
| 298 } |
| 299 |
283 void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) { | 300 void ScreenRecorder::DoStopOnNetworkThread(const base::Closure& done_task) { |
284 DCHECK(network_loop_->BelongsToCurrentThread()); | 301 DCHECK(network_loop_->BelongsToCurrentThread()); |
285 | 302 |
286 // There could be tasks on the network thread when this method is being | 303 // There could be tasks on the network thread when this method is being |
287 // executed. By setting the flag we'll not post anymore tasks from network | 304 // executed. By setting the flag we'll not post anymore tasks from network |
288 // thread. | 305 // thread. |
289 // | 306 // |
290 // After that a task is posted on encode thread to continue the stop | 307 // After that a task is posted on encode thread to continue the stop |
291 // sequence. | 308 // sequence. |
292 network_stopped_ = true; | 309 network_stopped_ = true; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 packet->set_encode_time_ms(encode_time_ms); | 377 packet->set_encode_time_ms(encode_time_ms); |
361 scheduler_.RecordEncodeTime(encode_time); | 378 scheduler_.RecordEncodeTime(encode_time); |
362 } | 379 } |
363 | 380 |
364 network_loop_->PostTask( | 381 network_loop_->PostTask( |
365 FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, | 382 FROM_HERE, base::Bind(&ScreenRecorder::DoSendVideoPacket, this, |
366 base::Passed(packet.Pass()))); | 383 base::Passed(packet.Pass()))); |
367 } | 384 } |
368 | 385 |
369 } // namespace remoting | 386 } // namespace remoting |
OLD | NEW |