OLD | NEW |
1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
2 * | 2 * |
3 * Use of this source code is governed by a BSD-style license | 3 * Use of this source code is governed by a BSD-style license |
4 * that can be found in the LICENSE file in the root of the source | 4 * that can be found in the LICENSE file in the root of the source |
5 * tree. An additional intellectual property rights grant can be found | 5 * tree. An additional intellectual property rights grant can be found |
6 * in the file PATENTS. All contributing project authors may | 6 * in the file PATENTS. All contributing project authors may |
7 * be found in the AUTHORS file in the root of the source tree. | 7 * be found in the AUTHORS file in the root of the source tree. |
8 */ | 8 */ |
9 | 9 |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "webrtc/modules/video_coding/test/stream_generator.h" | 22 #include "webrtc/modules/video_coding/test/stream_generator.h" |
23 #include "webrtc/modules/video_coding/timing.h" | 23 #include "webrtc/modules/video_coding/timing.h" |
24 #include "webrtc/modules/video_coding/test/test_util.h" | 24 #include "webrtc/modules/video_coding/test/test_util.h" |
25 #include "webrtc/system_wrappers/include/clock.h" | 25 #include "webrtc/system_wrappers/include/clock.h" |
26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 | 29 |
30 class TestVCMReceiver : public ::testing::Test { | 30 class TestVCMReceiver : public ::testing::Test { |
31 protected: | 31 protected: |
32 enum { kWidth = 640 }; | |
33 enum { kHeight = 480 }; | |
34 | |
35 TestVCMReceiver() | 32 TestVCMReceiver() |
36 : clock_(new SimulatedClock(0)), | 33 : clock_(new SimulatedClock(0)), |
37 timing_(clock_.get()), | 34 timing_(clock_.get()), |
38 receiver_(&timing_, clock_.get(), &event_factory_) { | 35 receiver_(&timing_, clock_.get(), &event_factory_) { |
39 stream_generator_.reset( | 36 stream_generator_.reset( |
40 new StreamGenerator(0, clock_->TimeInMilliseconds())); | 37 new StreamGenerator(0, clock_->TimeInMilliseconds())); |
41 } | 38 } |
42 | 39 |
43 virtual void SetUp() { receiver_.Reset(); } | 40 virtual void SetUp() { receiver_.Reset(); } |
44 | 41 |
45 int32_t InsertPacket(int index) { | 42 int32_t InsertPacket(int index) { |
46 VCMPacket packet; | 43 VCMPacket packet; |
47 bool packet_available = stream_generator_->GetPacket(&packet, index); | 44 bool packet_available = stream_generator_->GetPacket(&packet, index); |
48 EXPECT_TRUE(packet_available); | 45 EXPECT_TRUE(packet_available); |
49 if (!packet_available) | 46 if (!packet_available) |
50 return kGeneralError; // Return here to avoid crashes below. | 47 return kGeneralError; // Return here to avoid crashes below. |
51 return receiver_.InsertPacket(packet, kWidth, kHeight); | 48 return receiver_.InsertPacket(packet); |
52 } | 49 } |
53 | 50 |
54 int32_t InsertPacketAndPop(int index) { | 51 int32_t InsertPacketAndPop(int index) { |
55 VCMPacket packet; | 52 VCMPacket packet; |
56 bool packet_available = stream_generator_->PopPacket(&packet, index); | 53 bool packet_available = stream_generator_->PopPacket(&packet, index); |
57 EXPECT_TRUE(packet_available); | 54 EXPECT_TRUE(packet_available); |
58 if (!packet_available) | 55 if (!packet_available) |
59 return kGeneralError; // Return here to avoid crashes below. | 56 return kGeneralError; // Return here to avoid crashes below. |
60 return receiver_.InsertPacket(packet, kWidth, kHeight); | 57 return receiver_.InsertPacket(packet); |
61 } | 58 } |
62 | 59 |
63 int32_t InsertFrame(FrameType frame_type, bool complete) { | 60 int32_t InsertFrame(FrameType frame_type, bool complete) { |
64 int num_of_packets = complete ? 1 : 2; | 61 int num_of_packets = complete ? 1 : 2; |
65 stream_generator_->GenerateFrame( | 62 stream_generator_->GenerateFrame( |
66 frame_type, (frame_type != kEmptyFrame) ? num_of_packets : 0, | 63 frame_type, (frame_type != kEmptyFrame) ? num_of_packets : 0, |
67 (frame_type == kEmptyFrame) ? 1 : 0, clock_->TimeInMilliseconds()); | 64 (frame_type == kEmptyFrame) ? 1 : 0, clock_->TimeInMilliseconds()); |
68 int32_t ret = InsertPacketAndPop(0); | 65 int32_t ret = InsertPacketAndPop(0); |
69 if (!complete) { | 66 if (!complete) { |
70 // Drop the second packet. | 67 // Drop the second packet. |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 VCMPacket packet; | 328 VCMPacket packet; |
332 stream_generator_->GenerateFrame(FrameType::kVideoFrameKey, | 329 stream_generator_->GenerateFrame(FrameType::kVideoFrameKey, |
333 1, // media packets | 330 1, // media packets |
334 0, // empty packets | 331 0, // empty packets |
335 render_timestamp_ms); | 332 render_timestamp_ms); |
336 | 333 |
337 bool packet_available = stream_generator_->PopPacket(&packet, 0); | 334 bool packet_available = stream_generator_->PopPacket(&packet, 0); |
338 EXPECT_TRUE(packet_available); | 335 EXPECT_TRUE(packet_available); |
339 if (!packet_available) | 336 if (!packet_available) |
340 return; // Return here to avoid crashes below. | 337 return; // Return here to avoid crashes below. |
341 receiver_->InsertPacket(packet, 640, 480); | 338 receiver_->InsertPacket(packet); |
342 } | 339 } |
343 | 340 |
344 std::queue<TimestampPair> timestamps_; | 341 std::queue<TimestampPair> timestamps_; |
345 StreamGenerator* stream_generator_; | 342 StreamGenerator* stream_generator_; |
346 VCMReceiver* receiver_; | 343 VCMReceiver* receiver_; |
347 }; | 344 }; |
348 | 345 |
349 // Use a SimulatedClockWithFrames | 346 // Use a SimulatedClockWithFrames |
350 // Wait call will do either of these: | 347 // Wait call will do either of these: |
351 // 1. If |stop_on_frame| is true, the clock will be turned to the exact instant | 348 // 1. If |stop_on_frame| is true, the clock will be turned to the exact instant |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 end_time); | 504 end_time); |
508 receiver_.ReleaseFrame(frame); | 505 receiver_.ReleaseFrame(frame); |
509 ++num_frames_return; | 506 ++num_frames_return; |
510 } else { | 507 } else { |
511 EXPECT_EQ(kMaxWaitTime, end_time - start_time); | 508 EXPECT_EQ(kMaxWaitTime, end_time - start_time); |
512 } | 509 } |
513 } | 510 } |
514 } | 511 } |
515 | 512 |
516 } // namespace webrtc | 513 } // namespace webrtc |
OLD | NEW |