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/desktop_session_proxy.h" | 5 #include "remoting/host/desktop_session_proxy.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 464 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
465 | 465 |
466 // Drop the cached reference to the buffer. | 466 // Drop the cached reference to the buffer. |
467 shared_buffers_.erase(id); | 467 shared_buffers_.erase(id); |
468 } | 468 } |
469 | 469 |
470 void DesktopSessionProxy::OnCaptureCompleted( | 470 void DesktopSessionProxy::OnCaptureCompleted( |
471 const SerializedDesktopFrame& serialized_frame) { | 471 const SerializedDesktopFrame& serialized_frame) { |
472 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 472 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
473 | 473 |
| 474 --pending_capture_frame_requests_; |
| 475 |
| 476 // If the input serialized_frame does not have a screen size, it means the |
| 477 // capturer returns a nullptr for OnCaptureCompleted call. |
| 478 if (serialized_frame.dimensions.is_empty()) { |
| 479 video_capturer_->OnCaptureCompleted(nullptr); |
| 480 return; |
| 481 } |
| 482 |
474 // Assume that |serialized_frame| is well-formed because it was received from | 483 // Assume that |serialized_frame| is well-formed because it was received from |
475 // a more privileged process. | 484 // a more privileged process. |
476 scoped_refptr<IpcSharedBufferCore> shared_buffer_core = | 485 scoped_refptr<IpcSharedBufferCore> shared_buffer_core = |
477 GetSharedBufferCore(serialized_frame.shared_buffer_id); | 486 GetSharedBufferCore(serialized_frame.shared_buffer_id); |
478 CHECK(shared_buffer_core.get()); | 487 CHECK(shared_buffer_core.get()); |
479 | 488 |
480 std::unique_ptr<webrtc::DesktopFrame> frame( | 489 std::unique_ptr<webrtc::DesktopFrame> frame( |
481 new webrtc::SharedMemoryDesktopFrame( | 490 new webrtc::SharedMemoryDesktopFrame( |
482 serialized_frame.dimensions, serialized_frame.bytes_per_row, | 491 serialized_frame.dimensions, serialized_frame.bytes_per_row, |
483 new IpcSharedBuffer(shared_buffer_core))); | 492 new IpcSharedBuffer(shared_buffer_core))); |
484 frame->set_capture_time_ms(serialized_frame.capture_time_ms); | 493 frame->set_capture_time_ms(serialized_frame.capture_time_ms); |
485 frame->set_dpi(serialized_frame.dpi); | 494 frame->set_dpi(serialized_frame.dpi); |
486 | 495 |
487 for (size_t i = 0; i < serialized_frame.dirty_region.size(); ++i) { | 496 for (size_t i = 0; i < serialized_frame.dirty_region.size(); ++i) { |
488 frame->mutable_updated_region()->AddRect(serialized_frame.dirty_region[i]); | 497 frame->mutable_updated_region()->AddRect(serialized_frame.dirty_region[i]); |
489 } | 498 } |
490 | 499 |
491 --pending_capture_frame_requests_; | |
492 video_capturer_->OnCaptureCompleted(std::move(frame)); | 500 video_capturer_->OnCaptureCompleted(std::move(frame)); |
493 } | 501 } |
494 | 502 |
495 void DesktopSessionProxy::OnMouseCursor( | 503 void DesktopSessionProxy::OnMouseCursor( |
496 const webrtc::MouseCursor& mouse_cursor) { | 504 const webrtc::MouseCursor& mouse_cursor) { |
497 DCHECK(caller_task_runner_->BelongsToCurrentThread()); | 505 DCHECK(caller_task_runner_->BelongsToCurrentThread()); |
498 | 506 |
499 if (mouse_cursor_monitor_) { | 507 if (mouse_cursor_monitor_) { |
500 mouse_cursor_monitor_->OnMouseCursor( | 508 mouse_cursor_monitor_->OnMouseCursor( |
501 base::WrapUnique(webrtc::MouseCursor::CopyOf(mouse_cursor))); | 509 base::WrapUnique(webrtc::MouseCursor::CopyOf(mouse_cursor))); |
(...skipping 26 matching lines...) Expand all Loading... |
528 } | 536 } |
529 | 537 |
530 // static | 538 // static |
531 void DesktopSessionProxyTraits::Destruct( | 539 void DesktopSessionProxyTraits::Destruct( |
532 const DesktopSessionProxy* desktop_session_proxy) { | 540 const DesktopSessionProxy* desktop_session_proxy) { |
533 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, | 541 desktop_session_proxy->caller_task_runner_->DeleteSoon(FROM_HERE, |
534 desktop_session_proxy); | 542 desktop_session_proxy); |
535 } | 543 } |
536 | 544 |
537 } // namespace remoting | 545 } // namespace remoting |
OLD | NEW |