OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ |
12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 12 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
18 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/common.h" | |
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" | 19 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" |
21 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" | 20 #include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h" |
22 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" | 21 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" |
23 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" | 22 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" |
24 #include "webrtc/video_frame.h" | 23 #include "webrtc/video_frame.h" |
25 | 24 |
26 #include "gtest/gtest.h" | 25 #include "gtest/gtest.h" |
27 | 26 |
28 using ::testing::_; | 27 using ::testing::_; |
29 using ::testing::AllOf; | 28 using ::testing::AllOf; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 139 |
141 private: | 140 private: |
142 int decoded_frames_; | 141 int decoded_frames_; |
143 }; | 142 }; |
144 | 143 |
145 class SkipEncodingUnusedStreamsTest { | 144 class SkipEncodingUnusedStreamsTest { |
146 public: | 145 public: |
147 std::vector<unsigned int> RunTest(VP8Encoder* encoder, | 146 std::vector<unsigned int> RunTest(VP8Encoder* encoder, |
148 VideoCodec* settings, | 147 VideoCodec* settings, |
149 uint32_t target_bitrate) { | 148 uint32_t target_bitrate) { |
150 Config options; | 149 SpyingTemporalLayersFactory spy_factory; |
151 SpyingTemporalLayersFactory* spy_factory = | 150 settings->codecSpecific.VP8.tl_factory = &spy_factory; |
152 new SpyingTemporalLayersFactory(); | |
153 options.Set<TemporalLayers::Factory>(spy_factory); | |
154 settings->extra_options = &options; | |
155 EXPECT_EQ(0, encoder->InitEncode(settings, 1, 1200)); | 151 EXPECT_EQ(0, encoder->InitEncode(settings, 1, 1200)); |
156 | 152 |
157 encoder->SetRates(target_bitrate, 30); | 153 encoder->SetRates(target_bitrate, 30); |
158 | 154 |
159 std::vector<unsigned int> configured_bitrates; | 155 std::vector<unsigned int> configured_bitrates; |
160 for (std::vector<TemporalLayers*>::const_iterator it = | 156 for (std::vector<TemporalLayers*>::const_iterator it = |
161 spy_factory->spying_layers_.begin(); | 157 spy_factory.spying_layers_.begin(); |
162 it != spy_factory->spying_layers_.end(); ++it) { | 158 it != spy_factory.spying_layers_.end(); ++it) { |
163 configured_bitrates.push_back( | 159 configured_bitrates.push_back( |
164 static_cast<SpyingTemporalLayers*>(*it)->configured_bitrate_); | 160 static_cast<SpyingTemporalLayers*>(*it)->configured_bitrate_); |
165 } | 161 } |
166 return configured_bitrates; | 162 return configured_bitrates; |
167 } | 163 } |
168 | 164 |
169 class SpyingTemporalLayers : public TemporalLayers { | 165 class SpyingTemporalLayers : public TemporalLayers { |
170 public: | 166 public: |
171 explicit SpyingTemporalLayers(TemporalLayers* layers) | 167 explicit SpyingTemporalLayers(TemporalLayers* layers) |
172 : configured_bitrate_(0), layers_(layers) {} | 168 : configured_bitrate_(0), layers_(layers) {} |
(...skipping 26 matching lines...) Expand all Loading... |
199 int CurrentLayerId() const override { return layers_->CurrentLayerId(); } | 195 int CurrentLayerId() const override { return layers_->CurrentLayerId(); } |
200 | 196 |
201 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { | 197 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { |
202 return false; | 198 return false; |
203 } | 199 } |
204 | 200 |
205 int configured_bitrate_; | 201 int configured_bitrate_; |
206 TemporalLayers* layers_; | 202 TemporalLayers* layers_; |
207 }; | 203 }; |
208 | 204 |
209 class SpyingTemporalLayersFactory : public TemporalLayers::Factory { | 205 class SpyingTemporalLayersFactory : public TemporalLayersFactory { |
210 public: | 206 public: |
211 virtual ~SpyingTemporalLayersFactory() {} | 207 virtual ~SpyingTemporalLayersFactory() {} |
212 TemporalLayers* Create(int temporal_layers, | 208 TemporalLayers* Create(int temporal_layers, |
213 uint8_t initial_tl0_pic_idx) const override { | 209 uint8_t initial_tl0_pic_idx) const override { |
214 SpyingTemporalLayers* layers = | 210 SpyingTemporalLayers* layers = |
215 new SpyingTemporalLayers(TemporalLayers::Factory::Create( | 211 new SpyingTemporalLayers(TemporalLayersFactory::Create( |
216 temporal_layers, initial_tl0_pic_idx)); | 212 temporal_layers, initial_tl0_pic_idx)); |
217 spying_layers_.push_back(layers); | 213 spying_layers_.push_back(layers); |
218 return layers; | 214 return layers; |
219 } | 215 } |
220 | 216 |
221 mutable std::vector<TemporalLayers*> spying_layers_; | 217 mutable std::vector<TemporalLayers*> spying_layers_; |
222 }; | 218 }; |
223 }; | 219 }; |
224 | 220 |
225 class TestVp8Simulcast : public ::testing::Test { | 221 class TestVp8Simulcast : public ::testing::Test { |
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 rtc::scoped_ptr<VP8Decoder> decoder_; | 947 rtc::scoped_ptr<VP8Decoder> decoder_; |
952 MockDecodedImageCallback decoder_callback_; | 948 MockDecodedImageCallback decoder_callback_; |
953 VideoCodec settings_; | 949 VideoCodec settings_; |
954 VideoFrame input_frame_; | 950 VideoFrame input_frame_; |
955 }; | 951 }; |
956 | 952 |
957 } // namespace testing | 953 } // namespace testing |
958 } // namespace webrtc | 954 } // namespace webrtc |
959 | 955 |
960 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ | 956 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_VP8_SIMULCAST_UNITTEST_H_ |
OLD | NEW |