OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 10 #include "base/logging.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 261 |
262 bool last = (packet->flags() & VideoPacket::LAST_PARTITION) != 0; | 262 bool last = (packet->flags() & VideoPacket::LAST_PARTITION) != 0; |
263 | 263 |
264 if (network_stopped_ || connections_.empty()) { | 264 if (network_stopped_ || connections_.empty()) { |
265 delete packet; | 265 delete packet; |
266 return; | 266 return; |
267 } | 267 } |
268 | 268 |
269 for (ConnectionToClientList::const_iterator i = connections_.begin(); | 269 for (ConnectionToClientList::const_iterator i = connections_.begin(); |
270 i < connections_.end(); ++i) { | 270 i < connections_.end(); ++i) { |
271 Task* done_task = NULL; | 271 base::Closure done_task; |
272 | 272 |
273 // Call FrameSentCallback() only for the last packet in the first | 273 // Call FrameSentCallback() only for the last packet in the first |
274 // connection. | 274 // connection. |
275 if (last && i == connections_.begin()) { | 275 if (last && i == connections_.begin()) { |
276 done_task = NewRunnableMethod(this, &ScreenRecorder::FrameSentCallback, | 276 done_task = base::Bind(&ScreenRecorder::FrameSentCallback, this, packet); |
277 packet); | |
278 } else { | 277 } else { |
279 // TODO(hclam): Fix this code since it causes multiple deletion if there's | 278 // TODO(hclam): Fix this code since it causes multiple deletion if there's |
280 // more than one connection. | 279 // more than one connection. |
281 done_task = new DeleteTask<VideoPacket>(packet); | 280 done_task = base::Bind(&DeletePointer<VideoPacket>, packet); |
282 } | 281 } |
283 | 282 |
284 (*i)->video_stub()->ProcessVideoPacket(packet, done_task); | 283 (*i)->video_stub()->ProcessVideoPacket(packet, done_task); |
285 } | 284 } |
286 } | 285 } |
287 | 286 |
288 void ScreenRecorder::FrameSentCallback(VideoPacket* packet) { | 287 void ScreenRecorder::FrameSentCallback(VideoPacket* packet) { |
289 delete packet; | 288 delete packet; |
290 | 289 |
291 if (network_stopped_) | 290 if (network_stopped_) |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 (base::Time::Now() - encode_start_time_).InMilliseconds()); | 385 (base::Time::Now() - encode_start_time_).InMilliseconds()); |
387 packet->set_encode_time_ms(encode_time); | 386 packet->set_encode_time_ms(encode_time); |
388 } | 387 } |
389 | 388 |
390 network_loop_->PostTask( | 389 network_loop_->PostTask( |
391 FROM_HERE, | 390 FROM_HERE, |
392 NewRunnableMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); | 391 NewRunnableMethod(this, &ScreenRecorder::DoSendVideoPacket, packet)); |
393 } | 392 } |
394 | 393 |
395 } // namespace remoting | 394 } // namespace remoting |
OLD | NEW |