| 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 <cstdlib> | 5 #include <cstdlib> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/synchronization/condition_variable.h" | 9 #include "base/synchronization/condition_variable.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "media/cast/cast_config.h" | 12 #include "media/cast/cast_config.h" |
| 13 #include "media/cast/receiver/video_decoder.h" | 13 #include "media/cast/receiver/video_decoder.h" |
| 14 #include "media/cast/sender/vp8_encoder.h" | 14 #include "media/cast/sender/vp8_encoder.h" |
| 15 #include "media/cast/test/utility/default_config.h" |
| 15 #include "media/cast/test/utility/standalone_cast_environment.h" | 16 #include "media/cast/test/utility/standalone_cast_environment.h" |
| 16 #include "media/cast/test/utility/video_utility.h" | 17 #include "media/cast/test/utility/video_utility.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 namespace cast { | 21 namespace cast { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const int kWidth = 360; | 25 const int kWidth = 360; |
| 25 const int kHeight = 240; | 26 const int kHeight = 240; |
| 26 const int kFrameRate = 10; | 27 const int kFrameRate = 10; |
| 27 | 28 |
| 28 VideoSenderConfig GetVideoSenderConfigForTest() { | 29 VideoSenderConfig GetVideoSenderConfigForTest() { |
| 29 VideoSenderConfig config; | 30 VideoSenderConfig config = GetDefaultVideoSenderConfig(); |
| 30 config.width = kWidth; | 31 config.width = kWidth; |
| 31 config.height = kHeight; | 32 config.height = kHeight; |
| 32 config.max_frame_rate = kFrameRate; | 33 config.max_frame_rate = kFrameRate; |
| 33 return config; | 34 return config; |
| 34 } | 35 } |
| 35 | 36 |
| 36 } // namespace | 37 } // namespace |
| 37 | 38 |
| 38 class VideoDecoderTest : public ::testing::TestWithParam<Codec> { | 39 class VideoDecoderTest : public ::testing::TestWithParam<Codec> { |
| 39 public: | 40 public: |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 next_frame_timestamp_); | 77 next_frame_timestamp_); |
| 77 next_frame_timestamp_ += base::TimeDelta::FromSeconds(1) / kFrameRate; | 78 next_frame_timestamp_ += base::TimeDelta::FromSeconds(1) / kFrameRate; |
| 78 PopulateVideoFrame(video_frame.get(), 0); | 79 PopulateVideoFrame(video_frame.get(), 0); |
| 79 | 80 |
| 80 // Encode |frame| into |encoded_frame->data|. | 81 // Encode |frame| into |encoded_frame->data|. |
| 81 scoped_ptr<EncodedFrame> encoded_frame( | 82 scoped_ptr<EncodedFrame> encoded_frame( |
| 82 new EncodedFrame()); | 83 new EncodedFrame()); |
| 83 // Test only supports VP8, currently. | 84 // Test only supports VP8, currently. |
| 84 CHECK_EQ(CODEC_VIDEO_VP8, GetParam()); | 85 CHECK_EQ(CODEC_VIDEO_VP8, GetParam()); |
| 85 vp8_encoder_.Encode(video_frame, encoded_frame.get()); | 86 vp8_encoder_.Encode(video_frame, encoded_frame.get()); |
| 87 // Rewrite frame IDs for testing purposes. |
| 86 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; | 88 encoded_frame->frame_id = last_frame_id_ + 1 + num_dropped_frames; |
| 89 if (last_frame_id_ == 0) |
| 90 encoded_frame->referenced_frame_id = encoded_frame->frame_id; |
| 91 else |
| 92 encoded_frame->referenced_frame_id = encoded_frame->frame_id - 1; |
| 87 last_frame_id_ = encoded_frame->frame_id; | 93 last_frame_id_ = encoded_frame->frame_id; |
| 88 | 94 |
| 89 { | 95 { |
| 90 base::AutoLock auto_lock(lock_); | 96 base::AutoLock auto_lock(lock_); |
| 91 ++total_video_frames_feed_in_; | 97 ++total_video_frames_feed_in_; |
| 92 } | 98 } |
| 93 | 99 |
| 94 cast_environment_->PostTask( | 100 cast_environment_->PostTask( |
| 95 CastEnvironment::MAIN, | 101 CastEnvironment::MAIN, |
| 96 FROM_HERE, | 102 FROM_HERE, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 185 } |
| 180 WaitForAllVideoToBeDecoded(); | 186 WaitForAllVideoToBeDecoded(); |
| 181 } | 187 } |
| 182 | 188 |
| 183 INSTANTIATE_TEST_CASE_P(VideoDecoderTestScenarios, | 189 INSTANTIATE_TEST_CASE_P(VideoDecoderTestScenarios, |
| 184 VideoDecoderTest, | 190 VideoDecoderTest, |
| 185 ::testing::Values(CODEC_VIDEO_VP8)); | 191 ::testing::Values(CODEC_VIDEO_VP8)); |
| 186 | 192 |
| 187 } // namespace cast | 193 } // namespace cast |
| 188 } // namespace media | 194 } // namespace media |
| OLD | NEW |