| 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 "remoting/proto/video.pb.h" | 11 #include "remoting/proto/video.pb.h" |
| 12 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 12 | 13 |
| 13 namespace remoting { | 14 namespace remoting { |
| 14 namespace protocol { | 15 namespace protocol { |
| 15 | 16 |
| 16 FakeVideoStub::FakeVideoStub() {} | 17 FakeVideoStub::FakeVideoStub() {} |
| 17 FakeVideoStub::~FakeVideoStub() {} | 18 FakeVideoStub::~FakeVideoStub() {} |
| 18 | 19 |
| 20 void FakeVideoStub::set_on_frame_callback(base::Closure on_frame_callback) { |
| 21 CHECK(thread_checker_.CalledOnValidThread()); |
| 22 on_frame_callback_ = on_frame_callback; |
| 23 } |
| 24 |
| 19 void FakeVideoStub::ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 25 void FakeVideoStub::ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 20 const base::Closure& done) { | 26 const base::Closure& done) { |
| 27 CHECK(thread_checker_.CalledOnValidThread()); |
| 21 received_packets_.push_back(std::move(video_packet)); | 28 received_packets_.push_back(std::move(video_packet)); |
| 22 done.Run(); | 29 if (!done.is_null()) |
| 30 done.Run(); |
| 31 if (!on_frame_callback_.is_null()) |
| 32 on_frame_callback_.Run(); |
| 33 } |
| 34 |
| 35 FakeFrameConsumer::FakeFrameConsumer() {} |
| 36 FakeFrameConsumer::~FakeFrameConsumer() {} |
| 37 |
| 38 void FakeFrameConsumer::set_on_frame_callback(base::Closure on_frame_callback) { |
| 39 CHECK(thread_checker_.CalledOnValidThread()); |
| 40 on_frame_callback_ = on_frame_callback; |
| 41 } |
| 42 |
| 43 scoped_ptr<webrtc::DesktopFrame> FakeFrameConsumer::AllocateFrame( |
| 44 const webrtc::DesktopSize& size) { |
| 45 CHECK(thread_checker_.CalledOnValidThread()); |
| 46 return make_scoped_ptr(new webrtc::BasicDesktopFrame(size)); |
| 47 } |
| 48 |
| 49 void FakeFrameConsumer::DrawFrame(scoped_ptr<webrtc::DesktopFrame> frame, |
| 50 const base::Closure& done) { |
| 51 CHECK(thread_checker_.CalledOnValidThread()); |
| 52 received_frames_.push_back(std::move(frame)); |
| 53 if (!done.is_null()) |
| 54 done.Run(); |
| 55 if (!on_frame_callback_.is_null()) |
| 56 on_frame_callback_.Run(); |
| 57 } |
| 58 |
| 59 FrameConsumer::PixelFormat FakeFrameConsumer::GetPixelFormat() { |
| 60 CHECK(thread_checker_.CalledOnValidThread()); |
| 61 return FORMAT_BGRA; |
| 23 } | 62 } |
| 24 | 63 |
| 25 FakeVideoRenderer::FakeVideoRenderer() {} | 64 FakeVideoRenderer::FakeVideoRenderer() {} |
| 26 FakeVideoRenderer::~FakeVideoRenderer() {} | 65 FakeVideoRenderer::~FakeVideoRenderer() {} |
| 27 | 66 |
| 28 void FakeVideoRenderer::OnSessionConfig(const SessionConfig& config) {} | 67 void FakeVideoRenderer::OnSessionConfig(const SessionConfig& config) {} |
| 29 | 68 |
| 30 FakeVideoStub* FakeVideoRenderer::GetVideoStub() { | 69 FakeVideoStub* FakeVideoRenderer::GetVideoStub() { |
| 70 CHECK(thread_checker_.CalledOnValidThread()); |
| 31 return &video_stub_; | 71 return &video_stub_; |
| 32 } | 72 } |
| 33 | 73 |
| 34 FrameConsumer* FakeVideoRenderer::GetFrameConsumer() { | 74 FakeFrameConsumer* FakeVideoRenderer::GetFrameConsumer() { |
| 35 NOTIMPLEMENTED(); | 75 CHECK(thread_checker_.CalledOnValidThread()); |
| 36 return nullptr; | 76 return &frame_consumer_; |
| 37 } | 77 } |
| 38 | 78 |
| 39 } // namespace protocol | 79 } // namespace protocol |
| 40 } // namespace remoting | 80 } // namespace remoting |
| OLD | NEW |