OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/cast/cast_defines.h" | 10 #include "media/cast/cast_defines.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 void DeliverEncodedVideoFrame(scoped_ptr<EncodedVideoFrame> encoded_frame, | 40 void DeliverEncodedVideoFrame(scoped_ptr<EncodedVideoFrame> encoded_frame, |
41 const base::TimeTicks& capture_time) { | 41 const base::TimeTicks& capture_time) { |
42 EXPECT_EQ(expected_key_frame_, encoded_frame->key_frame); | 42 EXPECT_EQ(expected_key_frame_, encoded_frame->key_frame); |
43 EXPECT_EQ(expected_frame_id_, encoded_frame->frame_id); | 43 EXPECT_EQ(expected_frame_id_, encoded_frame->frame_id); |
44 EXPECT_EQ(expected_last_referenced_frame_id_, | 44 EXPECT_EQ(expected_last_referenced_frame_id_, |
45 encoded_frame->last_referenced_frame_id); | 45 encoded_frame->last_referenced_frame_id); |
46 EXPECT_EQ(expected_capture_time_, capture_time); | 46 EXPECT_EQ(expected_capture_time_, capture_time); |
47 } | 47 } |
48 | 48 |
49 protected: | |
50 virtual ~TestVideoEncoderCallback() {} | |
51 | |
52 private: | 49 private: |
53 friend class base::RefCountedThreadSafe<TestVideoEncoderCallback>; | |
54 | |
55 bool expected_key_frame_; | 50 bool expected_key_frame_; |
56 uint8 expected_frame_id_; | 51 uint8 expected_frame_id_; |
57 uint8 expected_last_referenced_frame_id_; | 52 uint8 expected_last_referenced_frame_id_; |
58 base::TimeTicks expected_capture_time_; | 53 base::TimeTicks expected_capture_time_; |
59 }; | 54 }; |
60 | 55 |
61 class VideoEncoderTest : public ::testing::Test { | 56 class VideoEncoderTest : public ::testing::Test { |
62 protected: | 57 protected: |
63 VideoEncoderTest() | 58 VideoEncoderTest() |
64 : pixels_(320 * 240, 123), | 59 : pixels_(320 * 240, 123), |
(...skipping 18 matching lines...) Expand all Loading... |
83 video_frame_.y_plane.length = video_frame_.width; | 78 video_frame_.y_plane.length = video_frame_.width; |
84 video_frame_.y_plane.data = &(pixels_[0]); | 79 video_frame_.y_plane.data = &(pixels_[0]); |
85 video_frame_.u_plane.stride = video_frame_.width / 2; | 80 video_frame_.u_plane.stride = video_frame_.width / 2; |
86 video_frame_.u_plane.length = video_frame_.width / 2; | 81 video_frame_.u_plane.length = video_frame_.width / 2; |
87 video_frame_.u_plane.data = &(pixels_[0]); | 82 video_frame_.u_plane.data = &(pixels_[0]); |
88 video_frame_.v_plane.stride = video_frame_.width / 2; | 83 video_frame_.v_plane.stride = video_frame_.width / 2; |
89 video_frame_.v_plane.length = video_frame_.width / 2; | 84 video_frame_.v_plane.length = video_frame_.width / 2; |
90 video_frame_.v_plane.data = &(pixels_[0]); | 85 video_frame_.v_plane.data = &(pixels_[0]); |
91 } | 86 } |
92 | 87 |
93 virtual ~VideoEncoderTest() {} | 88 ~VideoEncoderTest() {} |
94 | 89 |
95 virtual void SetUp() { | 90 virtual void SetUp() { |
96 task_runner_ = new test::FakeTaskRunner(&testing_clock_); | 91 task_runner_ = new test::FakeTaskRunner(&testing_clock_); |
97 cast_thread_ = new CastThread(task_runner_, task_runner_, task_runner_, | 92 cast_thread_ = new CastThread(task_runner_, task_runner_, task_runner_, |
98 task_runner_, task_runner_); | 93 task_runner_, task_runner_); |
99 } | 94 } |
100 | 95 |
101 void Configure(uint8 max_unacked_frames) { | 96 void Configure(uint8 max_unacked_frames) { |
102 video_encoder_= new VideoEncoder(cast_thread_, video_config_, | 97 video_encoder_= new VideoEncoder(cast_thread_, video_config_, |
103 max_unacked_frames); | 98 max_unacked_frames); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 for (int i = 5; i < 17; ++i) { | 236 for (int i = 5; i < 17; ++i) { |
242 test_video_encoder_callback_->SetExpectedResult(false, i, 4, capture_time); | 237 test_video_encoder_callback_->SetExpectedResult(false, i, 4, capture_time); |
243 EXPECT_TRUE(video_encoder_->EncodeVideoFrame(&video_frame_, capture_time, | 238 EXPECT_TRUE(video_encoder_->EncodeVideoFrame(&video_frame_, capture_time, |
244 frame_encoded_callback, base::Bind(ReleaseFrame, &video_frame_))); | 239 frame_encoded_callback, base::Bind(ReleaseFrame, &video_frame_))); |
245 task_runner_->RunTasks(); | 240 task_runner_->RunTasks(); |
246 } | 241 } |
247 } | 242 } |
248 | 243 |
249 } // namespace cast | 244 } // namespace cast |
250 } // namespace media | 245 } // namespace media |
OLD | NEW |