OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
11 #include "media/cast/cast_defines.h" | 11 #include "media/cast/cast_defines.h" |
12 #include "media/cast/cast_environment.h" | 12 #include "media/cast/cast_environment.h" |
| 13 #include "media/cast/sender/video_encoder_impl.h" |
13 #include "media/cast/test/fake_single_thread_task_runner.h" | 14 #include "media/cast/test/fake_single_thread_task_runner.h" |
14 #include "media/cast/test/utility/video_utility.h" | 15 #include "media/cast/test/utility/video_utility.h" |
15 #include "media/cast/video_sender/video_encoder_impl.h" | |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 | 17 |
18 namespace media { | 18 namespace media { |
19 namespace cast { | 19 namespace cast { |
20 | 20 |
21 using testing::_; | 21 using testing::_; |
22 | 22 |
23 namespace { | 23 namespace { |
24 class TestVideoEncoderCallback | 24 class TestVideoEncoderCallback |
25 : public base::RefCountedThreadSafe<TestVideoEncoderCallback> { | 25 : public base::RefCountedThreadSafe<TestVideoEncoderCallback> { |
26 public: | 26 public: |
27 TestVideoEncoderCallback() {} | 27 TestVideoEncoderCallback() {} |
28 | 28 |
29 void SetExpectedResult(uint32 expected_frame_id, | 29 void SetExpectedResult(uint32 expected_frame_id, |
30 uint32 expected_last_referenced_frame_id, | 30 uint32 expected_last_referenced_frame_id, |
31 const base::TimeTicks& expected_capture_time) { | 31 const base::TimeTicks& expected_capture_time) { |
32 expected_frame_id_ = expected_frame_id; | 32 expected_frame_id_ = expected_frame_id; |
33 expected_last_referenced_frame_id_ = expected_last_referenced_frame_id; | 33 expected_last_referenced_frame_id_ = expected_last_referenced_frame_id; |
34 expected_capture_time_ = expected_capture_time; | 34 expected_capture_time_ = expected_capture_time; |
35 } | 35 } |
36 | 36 |
37 void DeliverEncodedVideoFrame( | 37 void DeliverEncodedVideoFrame( |
38 scoped_ptr<transport::EncodedFrame> encoded_frame) { | 38 scoped_ptr<EncodedFrame> encoded_frame) { |
39 if (expected_frame_id_ == expected_last_referenced_frame_id_) { | 39 if (expected_frame_id_ == expected_last_referenced_frame_id_) { |
40 EXPECT_EQ(transport::EncodedFrame::KEY, encoded_frame->dependency); | 40 EXPECT_EQ(EncodedFrame::KEY, encoded_frame->dependency); |
41 } else { | 41 } else { |
42 EXPECT_EQ(transport::EncodedFrame::DEPENDENT, | 42 EXPECT_EQ(EncodedFrame::DEPENDENT, |
43 encoded_frame->dependency); | 43 encoded_frame->dependency); |
44 } | 44 } |
45 EXPECT_EQ(expected_frame_id_, encoded_frame->frame_id); | 45 EXPECT_EQ(expected_frame_id_, encoded_frame->frame_id); |
46 EXPECT_EQ(expected_last_referenced_frame_id_, | 46 EXPECT_EQ(expected_last_referenced_frame_id_, |
47 encoded_frame->referenced_frame_id); | 47 encoded_frame->referenced_frame_id); |
48 EXPECT_EQ(expected_capture_time_, encoded_frame->reference_time); | 48 EXPECT_EQ(expected_capture_time_, encoded_frame->reference_time); |
49 } | 49 } |
50 | 50 |
51 protected: | 51 protected: |
52 virtual ~TestVideoEncoderCallback() {} | 52 virtual ~TestVideoEncoderCallback() {} |
(...skipping 19 matching lines...) Expand all Loading... |
72 video_config_.use_external_encoder = false; | 72 video_config_.use_external_encoder = false; |
73 video_config_.width = 320; | 73 video_config_.width = 320; |
74 video_config_.height = 240; | 74 video_config_.height = 240; |
75 video_config_.max_bitrate = 5000000; | 75 video_config_.max_bitrate = 5000000; |
76 video_config_.min_bitrate = 1000000; | 76 video_config_.min_bitrate = 1000000; |
77 video_config_.start_bitrate = 2000000; | 77 video_config_.start_bitrate = 2000000; |
78 video_config_.max_qp = 56; | 78 video_config_.max_qp = 56; |
79 video_config_.min_qp = 0; | 79 video_config_.min_qp = 0; |
80 video_config_.max_frame_rate = 30; | 80 video_config_.max_frame_rate = 30; |
81 video_config_.max_number_of_video_buffers_used = 3; | 81 video_config_.max_number_of_video_buffers_used = 3; |
82 video_config_.codec = transport::CODEC_VIDEO_VP8; | 82 video_config_.codec = CODEC_VIDEO_VP8; |
83 gfx::Size size(video_config_.width, video_config_.height); | 83 gfx::Size size(video_config_.width, video_config_.height); |
84 video_frame_ = media::VideoFrame::CreateFrame( | 84 video_frame_ = media::VideoFrame::CreateFrame( |
85 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); | 85 VideoFrame::I420, size, gfx::Rect(size), size, base::TimeDelta()); |
86 PopulateVideoFrame(video_frame_, 123); | 86 PopulateVideoFrame(video_frame_, 123); |
87 } | 87 } |
88 | 88 |
89 virtual ~VideoEncoderImplTest() {} | 89 virtual ~VideoEncoderImplTest() {} |
90 | 90 |
91 virtual void SetUp() OVERRIDE { | 91 virtual void SetUp() OVERRIDE { |
92 testing_clock_ = new base::SimpleTestTickClock(); | 92 testing_clock_ = new base::SimpleTestTickClock(); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 for (int i = 5; i < 17; ++i) { | 251 for (int i = 5; i < 17; ++i) { |
252 test_video_encoder_callback_->SetExpectedResult(i, 4, capture_time); | 252 test_video_encoder_callback_->SetExpectedResult(i, 4, capture_time); |
253 EXPECT_TRUE(video_encoder_->EncodeVideoFrame( | 253 EXPECT_TRUE(video_encoder_->EncodeVideoFrame( |
254 video_frame_, capture_time, frame_encoded_callback)); | 254 video_frame_, capture_time, frame_encoded_callback)); |
255 task_runner_->RunTasks(); | 255 task_runner_->RunTasks(); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 } // namespace cast | 259 } // namespace cast |
260 } // namespace media | 260 } // namespace media |
OLD | NEW |