| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/fake_video_renderer.h" | 5 #include "remoting/protocol/fake_video_renderer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "remoting/proto/video.pb.h" | 12 #include "remoting/proto/video.pb.h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 13 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 13 | 14 |
| 14 namespace remoting { | 15 namespace remoting { |
| 15 namespace protocol { | 16 namespace protocol { |
| 16 | 17 |
| 17 FakeVideoStub::FakeVideoStub() {} | 18 FakeVideoStub::FakeVideoStub() {} |
| 18 FakeVideoStub::~FakeVideoStub() {} | 19 FakeVideoStub::~FakeVideoStub() {} |
| 19 | 20 |
| 20 void FakeVideoStub::set_on_frame_callback(base::Closure on_frame_callback) { | 21 void FakeVideoStub::set_on_frame_callback(base::Closure on_frame_callback) { |
| 21 CHECK(thread_checker_.CalledOnValidThread()); | 22 CHECK(thread_checker_.CalledOnValidThread()); |
| 22 on_frame_callback_ = on_frame_callback; | 23 on_frame_callback_ = on_frame_callback; |
| 23 } | 24 } |
| 24 | 25 |
| 25 void FakeVideoStub::ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 26 void FakeVideoStub::ProcessVideoPacket( |
| 26 const base::Closure& done) { | 27 std::unique_ptr<VideoPacket> video_packet, |
| 28 const base::Closure& done) { |
| 27 CHECK(thread_checker_.CalledOnValidThread()); | 29 CHECK(thread_checker_.CalledOnValidThread()); |
| 28 received_packets_.push_back(std::move(video_packet)); | 30 received_packets_.push_back(std::move(video_packet)); |
| 29 if (!done.is_null()) | 31 if (!done.is_null()) |
| 30 done.Run(); | 32 done.Run(); |
| 31 if (!on_frame_callback_.is_null()) | 33 if (!on_frame_callback_.is_null()) |
| 32 on_frame_callback_.Run(); | 34 on_frame_callback_.Run(); |
| 33 } | 35 } |
| 34 | 36 |
| 35 FakeFrameConsumer::FakeFrameConsumer() {} | 37 FakeFrameConsumer::FakeFrameConsumer() {} |
| 36 FakeFrameConsumer::~FakeFrameConsumer() {} | 38 FakeFrameConsumer::~FakeFrameConsumer() {} |
| 37 | 39 |
| 38 void FakeFrameConsumer::set_on_frame_callback(base::Closure on_frame_callback) { | 40 void FakeFrameConsumer::set_on_frame_callback(base::Closure on_frame_callback) { |
| 39 CHECK(thread_checker_.CalledOnValidThread()); | 41 CHECK(thread_checker_.CalledOnValidThread()); |
| 40 on_frame_callback_ = on_frame_callback; | 42 on_frame_callback_ = on_frame_callback; |
| 41 } | 43 } |
| 42 | 44 |
| 43 scoped_ptr<webrtc::DesktopFrame> FakeFrameConsumer::AllocateFrame( | 45 std::unique_ptr<webrtc::DesktopFrame> FakeFrameConsumer::AllocateFrame( |
| 44 const webrtc::DesktopSize& size) { | 46 const webrtc::DesktopSize& size) { |
| 45 CHECK(thread_checker_.CalledOnValidThread()); | 47 CHECK(thread_checker_.CalledOnValidThread()); |
| 46 return make_scoped_ptr(new webrtc::BasicDesktopFrame(size)); | 48 return base::WrapUnique(new webrtc::BasicDesktopFrame(size)); |
| 47 } | 49 } |
| 48 | 50 |
| 49 void FakeFrameConsumer::DrawFrame(scoped_ptr<webrtc::DesktopFrame> frame, | 51 void FakeFrameConsumer::DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame, |
| 50 const base::Closure& done) { | 52 const base::Closure& done) { |
| 51 CHECK(thread_checker_.CalledOnValidThread()); | 53 CHECK(thread_checker_.CalledOnValidThread()); |
| 52 received_frames_.push_back(std::move(frame)); | 54 received_frames_.push_back(std::move(frame)); |
| 53 if (!done.is_null()) | 55 if (!done.is_null()) |
| 54 done.Run(); | 56 done.Run(); |
| 55 if (!on_frame_callback_.is_null()) | 57 if (!on_frame_callback_.is_null()) |
| 56 on_frame_callback_.Run(); | 58 on_frame_callback_.Run(); |
| 57 } | 59 } |
| 58 | 60 |
| 59 FrameConsumer::PixelFormat FakeFrameConsumer::GetPixelFormat() { | 61 FrameConsumer::PixelFormat FakeFrameConsumer::GetPixelFormat() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 71 return &video_stub_; | 73 return &video_stub_; |
| 72 } | 74 } |
| 73 | 75 |
| 74 FakeFrameConsumer* FakeVideoRenderer::GetFrameConsumer() { | 76 FakeFrameConsumer* FakeVideoRenderer::GetFrameConsumer() { |
| 75 CHECK(thread_checker_.CalledOnValidThread()); | 77 CHECK(thread_checker_.CalledOnValidThread()); |
| 76 return &frame_consumer_; | 78 return &frame_consumer_; |
| 77 } | 79 } |
| 78 | 80 |
| 79 } // namespace protocol | 81 } // namespace protocol |
| 80 } // namespace remoting | 82 } // namespace remoting |
| OLD | NEW |