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 "media/remoting/courier_renderer.h" | 5 #include "media/remoting/courier_renderer.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "media/base/pipeline_status.h" | 10 #include "media/base/pipeline_status.h" |
11 #include "media/base/renderer_client.h" | 11 #include "media/base/renderer_client.h" |
12 #include "media/base/test_helpers.h" | 12 #include "media/base/test_helpers.h" |
13 #include "media/remoting/fake_demuxer_stream_provider.h" | 13 #include "media/remoting/fake_media_resource.h" |
14 #include "media/remoting/fake_remoter.h" | 14 #include "media/remoting/fake_remoter.h" |
15 #include "media/remoting/renderer_controller.h" | 15 #include "media/remoting/renderer_controller.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
19 using testing::_; | 19 using testing::_; |
20 using testing::Invoke; | 20 using testing::Invoke; |
21 using testing::Return; | 21 using testing::Return; |
22 | 22 |
23 namespace media { | 23 namespace media { |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 void OnSendMessageToSink(std::unique_ptr<std::vector<uint8_t>> message) { | 204 void OnSendMessageToSink(std::unique_ptr<std::vector<uint8_t>> message) { |
205 std::unique_ptr<pb::RpcMessage> rpc(new pb::RpcMessage()); | 205 std::unique_ptr<pb::RpcMessage> rpc(new pb::RpcMessage()); |
206 ASSERT_TRUE(rpc->ParseFromArray(message->data(), message->size())); | 206 ASSERT_TRUE(rpc->ParseFromArray(message->data(), message->size())); |
207 received_rpc_.push_back(std::move(rpc)); | 207 received_rpc_.push_back(std::move(rpc)); |
208 } | 208 } |
209 | 209 |
210 protected: | 210 protected: |
211 void InitializeRenderer() { | 211 void InitializeRenderer() { |
212 // Register media::RendererClient implementation. | 212 // Register media::RendererClient implementation. |
213 render_client_.reset(new RendererClientImpl()); | 213 render_client_.reset(new RendererClientImpl()); |
214 demuxer_stream_provider_.reset(new FakeDemuxerStreamProvider()); | 214 media_resource_.reset(new FakeMediaResource()); |
215 EXPECT_CALL(*render_client_, OnPipelineStatus(_)).Times(1); | 215 EXPECT_CALL(*render_client_, OnPipelineStatus(_)).Times(1); |
216 DCHECK(renderer_); | 216 DCHECK(renderer_); |
217 // Redirect RPC message for simulate receiver scenario | 217 // Redirect RPC message for simulate receiver scenario |
218 controller_->GetRpcBroker()->SetMessageCallbackForTesting(base::Bind( | 218 controller_->GetRpcBroker()->SetMessageCallbackForTesting(base::Bind( |
219 &CourierRendererTest::RpcMessageResponseBot, base::Unretained(this))); | 219 &CourierRendererTest::RpcMessageResponseBot, base::Unretained(this))); |
220 RunPendingTasks(); | 220 RunPendingTasks(); |
221 renderer_->Initialize(demuxer_stream_provider_.get(), render_client_.get(), | 221 renderer_->Initialize(media_resource_.get(), render_client_.get(), |
222 base::Bind(&RendererClientImpl::OnPipelineStatus, | 222 base::Bind(&RendererClientImpl::OnPipelineStatus, |
223 base::Unretained(render_client_.get()))); | 223 base::Unretained(render_client_.get()))); |
224 RunPendingTasks(); | 224 RunPendingTasks(); |
225 // Redirect RPC message back to save for later check. | 225 // Redirect RPC message back to save for later check. |
226 controller_->GetRpcBroker()->SetMessageCallbackForTesting(base::Bind( | 226 controller_->GetRpcBroker()->SetMessageCallbackForTesting(base::Bind( |
227 &CourierRendererTest::OnSendMessageToSink, base::Unretained(this))); | 227 &CourierRendererTest::OnSendMessageToSink, base::Unretained(this))); |
228 RunPendingTasks(); | 228 RunPendingTasks(); |
229 } | 229 } |
230 | 230 |
231 bool IsRendererInitialized() const { | 231 bool IsRendererInitialized() const { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 267 |
268 void ValidateCurrentTime(base::TimeDelta current, | 268 void ValidateCurrentTime(base::TimeDelta current, |
269 base::TimeDelta current_max) const { | 269 base::TimeDelta current_max) const { |
270 ASSERT_EQ(renderer_->current_media_time_, current); | 270 ASSERT_EQ(renderer_->current_media_time_, current); |
271 ASSERT_EQ(renderer_->current_max_time_, current_max); | 271 ASSERT_EQ(renderer_->current_max_time_, current_max); |
272 } | 272 } |
273 | 273 |
274 base::MessageLoop message_loop_; | 274 base::MessageLoop message_loop_; |
275 std::unique_ptr<RendererController> controller_; | 275 std::unique_ptr<RendererController> controller_; |
276 std::unique_ptr<RendererClientImpl> render_client_; | 276 std::unique_ptr<RendererClientImpl> render_client_; |
277 std::unique_ptr<FakeDemuxerStreamProvider> demuxer_stream_provider_; | 277 std::unique_ptr<FakeMediaResource> media_resource_; |
278 std::unique_ptr<CourierRenderer> renderer_; | 278 std::unique_ptr<CourierRenderer> renderer_; |
279 | 279 |
280 // RPC handles. | 280 // RPC handles. |
281 const int receiver_renderer_handle_; | 281 const int receiver_renderer_handle_; |
282 const int receiver_audio_demuxer_callback_handle_; | 282 const int receiver_audio_demuxer_callback_handle_; |
283 const int receiver_video_demuxer_callback_handle_; | 283 const int receiver_video_demuxer_callback_handle_; |
284 int sender_client_handle_; | 284 int sender_client_handle_; |
285 int sender_renderer_callback_handle_; | 285 int sender_renderer_callback_handle_; |
286 int sender_audio_demuxer_handle_; | 286 int sender_audio_demuxer_handle_; |
287 int sender_video_demuxer_handle_; | 287 int sender_video_demuxer_handle_; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 rpc->set_proc(pb::RpcMessage::RPC_RC_ONDURATIONCHANGE); | 535 rpc->set_proc(pb::RpcMessage::RPC_RC_ONDURATIONCHANGE); |
536 rpc->set_integer64_value(-345); | 536 rpc->set_integer64_value(-345); |
537 OnReceivedRpc(std::move(rpc)); | 537 OnReceivedRpc(std::move(rpc)); |
538 RunPendingTasks(); | 538 RunPendingTasks(); |
539 } | 539 } |
540 | 540 |
541 // TODO(xjz): Tests for detecting PACING_TOO_SLOWLY and FRAME_DROP_RATE_HIGH. | 541 // TODO(xjz): Tests for detecting PACING_TOO_SLOWLY and FRAME_DROP_RATE_HIGH. |
542 | 542 |
543 } // namespace remoting | 543 } // namespace remoting |
544 } // namespace media | 544 } // namespace media |
OLD | NEW |