| OLD | NEW | 
|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/client/software_video_renderer.h" | 5 #include "remoting/client/software_video_renderer.h" | 
| 6 | 6 | 
| 7 #include <stdint.h> | 7 #include <stdint.h> | 
| 8 | 8 | 
| 9 #include <utility> | 9 #include <utility> | 
| 10 #include <vector> | 10 #include <vector> | 
| 11 | 11 | 
| 12 #include "base/bind.h" | 12 #include "base/bind.h" | 
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" | 
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" | 
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" | 
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" | 
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" | 
|  | 18 #include "remoting/client/client_context.h" | 
| 18 #include "remoting/codec/video_encoder_verbatim.h" | 19 #include "remoting/codec/video_encoder_verbatim.h" | 
| 19 #include "remoting/proto/video.pb.h" | 20 #include "remoting/proto/video.pb.h" | 
| 20 #include "remoting/protocol/frame_consumer.h" | 21 #include "remoting/protocol/frame_consumer.h" | 
| 21 #include "remoting/protocol/session_config.h" | 22 #include "remoting/protocol/session_config.h" | 
| 22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" | 
| 23 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 24 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 
| 24 | 25 | 
| 25 using webrtc::DesktopFrame; | 26 using webrtc::DesktopFrame; | 
| 26 | 27 | 
| 27 namespace remoting { | 28 namespace remoting { | 
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 127 | 128 | 
| 128 // Helper to set value at |out| to 1. | 129 // Helper to set value at |out| to 1. | 
| 129 void SetTrue(int* out) { | 130 void SetTrue(int* out) { | 
| 130   *out = 1; | 131   *out = 1; | 
| 131 } | 132 } | 
| 132 | 133 | 
| 133 }  // namespace | 134 }  // namespace | 
| 134 | 135 | 
| 135 class SoftwareVideoRendererTest : public ::testing::Test { | 136 class SoftwareVideoRendererTest : public ::testing::Test { | 
| 136  public: | 137  public: | 
| 137   SoftwareVideoRendererTest() : decode_thread_("TestDecodeThread") { | 138   SoftwareVideoRendererTest() : context_(nullptr) { | 
| 138     decode_thread_.Start(); | 139     context_.Start(); | 
| 139     renderer_.reset(new SoftwareVideoRenderer(decode_thread_.task_runner(), | 140     renderer_.reset(new SoftwareVideoRenderer(&frame_consumer_)); | 
| 140                                               &frame_consumer_, nullptr)); | 141     renderer_->Initialize(context_, nullptr); | 
| 141     renderer_->OnSessionConfig( | 142     renderer_->OnSessionConfig( | 
| 142         *protocol::SessionConfig::ForTestWithVerbatimVideo()); | 143         *protocol::SessionConfig::ForTestWithVerbatimVideo()); | 
| 143   } | 144   } | 
| 144 | 145 | 
| 145  protected: | 146  protected: | 
| 146   base::MessageLoop message_loop_; | 147   base::MessageLoop message_loop_; | 
| 147   base::Thread decode_thread_; | 148   ClientContext context_; | 
| 148 | 149 | 
| 149   TestFrameConsumer frame_consumer_; | 150   TestFrameConsumer frame_consumer_; | 
| 150   std::unique_ptr<SoftwareVideoRenderer> renderer_; | 151   std::unique_ptr<SoftwareVideoRenderer> renderer_; | 
| 151 | 152 | 
| 152   VideoEncoderVerbatim encoder_; | 153   VideoEncoderVerbatim encoder_; | 
| 153 }; | 154 }; | 
| 154 | 155 | 
| 155 TEST_F(SoftwareVideoRendererTest, DecodeFrame) { | 156 TEST_F(SoftwareVideoRendererTest, DecodeFrame) { | 
| 156   const int kFrameCount = 5; | 157   const int kFrameCount = 5; | 
| 157 | 158 | 
| (...skipping 19 matching lines...) Expand all  Loading... | 
| 177 | 178 | 
| 178     EXPECT_FALSE(callback_called[frame_index]); | 179     EXPECT_FALSE(callback_called[frame_index]); | 
| 179     done_callback.Run(); | 180     done_callback.Run(); | 
| 180     EXPECT_TRUE(callback_called[frame_index]); | 181     EXPECT_TRUE(callback_called[frame_index]); | 
| 181 | 182 | 
| 182     EXPECT_TRUE(CompareFrames(*test_frames[frame_index], *decoded_frame)); | 183     EXPECT_TRUE(CompareFrames(*test_frames[frame_index], *decoded_frame)); | 
| 183   } | 184   } | 
| 184 } | 185 } | 
| 185 | 186 | 
| 186 }  // namespace remoting | 187 }  // namespace remoting | 
| OLD | NEW | 
|---|