OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 using ::testing::NiceMock; | 34 using ::testing::NiceMock; |
35 using ::testing::Pointee; | 35 using ::testing::Pointee; |
36 using ::testing::Return; | 36 using ::testing::Return; |
37 using ::testing::FloatEq; | 37 using ::testing::FloatEq; |
38 using std::vector; | 38 using std::vector; |
39 using webrtc::test::FrameGenerator; | 39 using webrtc::test::FrameGenerator; |
40 | 40 |
41 namespace webrtc { | 41 namespace webrtc { |
42 namespace vcm { | 42 namespace vcm { |
43 namespace { | 43 namespace { |
44 enum { | 44 enum { kMaxNumberOfTemporalLayers = 3 }; |
45 kMaxNumberOfTemporalLayers = 3 | |
46 }; | |
47 | 45 |
48 struct Vp8StreamInfo { | 46 struct Vp8StreamInfo { |
49 float framerate_fps[kMaxNumberOfTemporalLayers]; | 47 float framerate_fps[kMaxNumberOfTemporalLayers]; |
50 int bitrate_kbps[kMaxNumberOfTemporalLayers]; | 48 int bitrate_kbps[kMaxNumberOfTemporalLayers]; |
51 }; | 49 }; |
52 | 50 |
53 MATCHER_P(MatchesVp8StreamInfo, expected, "") { | 51 MATCHER_P(MatchesVp8StreamInfo, expected, "") { |
54 bool res = true; | 52 bool res = true; |
55 for (int tl = 0; tl < kMaxNumberOfTemporalLayers; ++tl) { | 53 for (int tl = 0; tl < kMaxNumberOfTemporalLayers; ++tl) { |
56 if (fabs(expected.framerate_fps[tl] - arg.framerate_fps[tl]) > 0.5) { | 54 if (fabs(expected.framerate_fps[tl] - arg.framerate_fps[tl]) > 0.5) { |
(...skipping 23 matching lines...) Expand all Loading... |
80 } | 78 } |
81 | 79 |
82 private: | 80 private: |
83 const int width_; | 81 const int width_; |
84 const int height_; | 82 const int height_; |
85 rtc::scoped_ptr<VideoFrame> frame_; | 83 rtc::scoped_ptr<VideoFrame> frame_; |
86 }; | 84 }; |
87 | 85 |
88 class PacketizationCallback : public VCMPacketizationCallback { | 86 class PacketizationCallback : public VCMPacketizationCallback { |
89 public: | 87 public: |
90 PacketizationCallback(Clock* clock) | 88 explicit PacketizationCallback(Clock* clock) |
91 : clock_(clock), start_time_ms_(clock_->TimeInMilliseconds()) {} | 89 : clock_(clock), start_time_ms_(clock_->TimeInMilliseconds()) {} |
92 | 90 |
93 virtual ~PacketizationCallback() {} | 91 virtual ~PacketizationCallback() {} |
94 | 92 |
95 int32_t SendData(uint8_t payload_type, | 93 int32_t SendData(uint8_t payload_type, |
96 const EncodedImage& encoded_image, | 94 const EncodedImage& encoded_image, |
97 const RTPFragmentationHeader& fragmentation_header, | 95 const RTPFragmentationHeader& fragmentation_header, |
98 const RTPVideoHeader* rtp_video_header) override { | 96 const RTPVideoHeader* rtp_video_header) override { |
99 assert(rtp_video_header); | 97 assert(rtp_video_header); |
100 frame_data_.push_back(FrameData(encoded_image._length, *rtp_video_header)); | 98 frame_data_.push_back(FrameData(encoded_image._length, *rtp_video_header)); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 static const int kNumberOfStreams = 3; | 202 static const int kNumberOfStreams = 3; |
205 static const int kNumberOfLayers = 3; | 203 static const int kNumberOfLayers = 3; |
206 static const int kUnusedPayloadType = 10; | 204 static const int kUnusedPayloadType = 10; |
207 | 205 |
208 void SetUp() override { | 206 void SetUp() override { |
209 TestVideoSender::SetUp(); | 207 TestVideoSender::SetUp(); |
210 sender_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType, false); | 208 sender_->RegisterExternalEncoder(&encoder_, kUnusedPayloadType, false); |
211 memset(&settings_, 0, sizeof(settings_)); | 209 memset(&settings_, 0, sizeof(settings_)); |
212 EXPECT_EQ(0, VideoCodingModule::Codec(kVideoCodecVP8, &settings_)); | 210 EXPECT_EQ(0, VideoCodingModule::Codec(kVideoCodecVP8, &settings_)); |
213 settings_.numberOfSimulcastStreams = kNumberOfStreams; | 211 settings_.numberOfSimulcastStreams = kNumberOfStreams; |
214 ConfigureStream(kDefaultWidth / 4, | 212 ConfigureStream(kDefaultWidth / 4, kDefaultHeight / 4, 100, |
215 kDefaultHeight / 4, | |
216 100, | |
217 &settings_.simulcastStream[0]); | 213 &settings_.simulcastStream[0]); |
218 ConfigureStream(kDefaultWidth / 2, | 214 ConfigureStream(kDefaultWidth / 2, kDefaultHeight / 2, 500, |
219 kDefaultHeight / 2, | |
220 500, | |
221 &settings_.simulcastStream[1]); | 215 &settings_.simulcastStream[1]); |
222 ConfigureStream( | 216 ConfigureStream(kDefaultWidth, kDefaultHeight, 1200, |
223 kDefaultWidth, kDefaultHeight, 1200, &settings_.simulcastStream[2]); | 217 &settings_.simulcastStream[2]); |
224 settings_.plType = kUnusedPayloadType; // Use the mocked encoder. | 218 settings_.plType = kUnusedPayloadType; // Use the mocked encoder. |
225 generator_.reset( | 219 generator_.reset( |
226 new EmptyFrameGenerator(settings_.width, settings_.height)); | 220 new EmptyFrameGenerator(settings_.width, settings_.height)); |
227 EXPECT_EQ(0, sender_->RegisterSendCodec(&settings_, 1, 1200)); | 221 EXPECT_EQ(0, sender_->RegisterSendCodec(&settings_, 1, 1200)); |
228 } | 222 } |
229 | 223 |
230 void TearDown() override { sender_.reset(); } | 224 void TearDown() override { sender_.reset(); } |
231 | 225 |
232 void ExpectIntraRequest(int stream) { | 226 void ExpectIntraRequest(int stream) { |
233 if (stream == -1) { | 227 if (stream == -1) { |
234 // No intra request expected. | 228 // No intra request expected. |
235 EXPECT_CALL( | 229 EXPECT_CALL( |
236 encoder_, | 230 encoder_, |
237 Encode(_, _, Pointee(ElementsAre(kVideoFrameDelta, kVideoFrameDelta, | 231 Encode(_, _, Pointee(ElementsAre(kVideoFrameDelta, kVideoFrameDelta, |
238 kVideoFrameDelta)))) | 232 kVideoFrameDelta)))) |
239 .Times(1) | 233 .Times(1) |
240 .WillRepeatedly(Return(0)); | 234 .WillRepeatedly(Return(0)); |
241 return; | 235 return; |
242 } | 236 } |
243 assert(stream >= 0); | 237 assert(stream >= 0); |
244 assert(stream < kNumberOfStreams); | 238 assert(stream < kNumberOfStreams); |
245 std::vector<FrameType> frame_types(kNumberOfStreams, kVideoFrameDelta); | 239 std::vector<FrameType> frame_types(kNumberOfStreams, kVideoFrameDelta); |
246 frame_types[stream] = kVideoFrameKey; | 240 frame_types[stream] = kVideoFrameKey; |
247 EXPECT_CALL( | 241 EXPECT_CALL(encoder_, |
248 encoder_, | 242 Encode(_, _, Pointee(ElementsAreArray(&frame_types[0], |
249 Encode(_, | 243 frame_types.size())))) |
250 _, | 244 .Times(1) |
251 Pointee(ElementsAreArray(&frame_types[0], frame_types.size())))) | 245 .WillRepeatedly(Return(0)); |
252 .Times(1).WillRepeatedly(Return(0)); | |
253 } | 246 } |
254 | 247 |
255 static void ConfigureStream(int width, | 248 static void ConfigureStream(int width, |
256 int height, | 249 int height, |
257 int max_bitrate, | 250 int max_bitrate, |
258 SimulcastStream* stream) { | 251 SimulcastStream* stream) { |
259 assert(stream); | 252 assert(stream); |
260 stream->width = width; | 253 stream->width = width; |
261 stream->height = height; | 254 stream->height = height; |
262 stream->maxBitrate = max_bitrate; | 255 stream->maxBitrate = max_bitrate; |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 473 } |
481 { | 474 { |
482 // TODO(andresp): Find out why this fails with framerate = 7.5 | 475 // TODO(andresp): Find out why this fails with framerate = 7.5 |
483 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; | 476 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; |
484 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); | 477 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); |
485 } | 478 } |
486 } | 479 } |
487 } // namespace | 480 } // namespace |
488 } // namespace vcm | 481 } // namespace vcm |
489 } // namespace webrtc | 482 } // namespace webrtc |
OLD | NEW |