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 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" | 25 #include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h" |
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" | 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" |
27 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" | 27 #include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h" |
28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
29 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" | 29 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" |
30 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 30 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
31 #include "webrtc/system_wrappers/include/sleep.h" | 31 #include "webrtc/system_wrappers/include/sleep.h" |
32 #include "webrtc/test/call_test.h" | 32 #include "webrtc/test/call_test.h" |
33 #include "webrtc/test/configurable_frame_size_encoder.h" | 33 #include "webrtc/test/configurable_frame_size_encoder.h" |
34 #include "webrtc/test/fake_texture_frame.h" | 34 #include "webrtc/test/fake_texture_frame.h" |
| 35 #include "webrtc/test/frame_utils.h" |
35 #include "webrtc/test/null_transport.h" | 36 #include "webrtc/test/null_transport.h" |
36 #include "webrtc/test/testsupport/perf_test.h" | 37 #include "webrtc/test/testsupport/perf_test.h" |
37 #include "webrtc/video/send_statistics_proxy.h" | 38 #include "webrtc/video/send_statistics_proxy.h" |
38 #include "webrtc/video_frame.h" | 39 #include "webrtc/video_frame.h" |
39 #include "webrtc/video_send_stream.h" | 40 #include "webrtc/video_send_stream.h" |
40 | 41 |
41 namespace webrtc { | 42 namespace webrtc { |
42 | 43 |
43 enum VideoFormat { kGeneric, kVP8, }; | 44 enum VideoFormat { kGeneric, kVP8, }; |
44 | 45 |
45 void ExpectEqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); | |
46 void ExpectEqualTextureFrames(const VideoFrame& frame1, | |
47 const VideoFrame& frame2); | |
48 void ExpectEqualBufferFrames(const VideoFrame& frame1, | |
49 const VideoFrame& frame2); | |
50 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 46 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, |
51 const std::vector<VideoFrame>& frames2); | 47 const std::vector<VideoFrame>& frames2); |
52 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); | 48 VideoFrame CreateVideoFrame(int width, int height, uint8_t data); |
53 | 49 |
54 class VideoSendStreamTest : public test::CallTest { | 50 class VideoSendStreamTest : public test::CallTest { |
55 protected: | 51 protected: |
56 void TestNackRetransmission(uint32_t retransmit_ssrc, | 52 void TestNackRetransmission(uint32_t retransmit_ssrc, |
57 uint8_t retransmit_payload_type); | 53 uint8_t retransmit_payload_type); |
58 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 54 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); |
59 | 55 |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 } | 1233 } |
1238 video_send_stream_->Stop(); | 1234 video_send_stream_->Stop(); |
1239 | 1235 |
1240 // Test if the input and output frames are the same. render_time_ms and | 1236 // Test if the input and output frames are the same. render_time_ms and |
1241 // timestamp are not compared because capturer sets those values. | 1237 // timestamp are not compared because capturer sets those values. |
1242 ExpectEqualFramesVector(input_frames, observer.output_frames()); | 1238 ExpectEqualFramesVector(input_frames, observer.output_frames()); |
1243 | 1239 |
1244 DestroyStreams(); | 1240 DestroyStreams(); |
1245 } | 1241 } |
1246 | 1242 |
1247 void ExpectEqualFrames(const VideoFrame& frame1, const VideoFrame& frame2) { | |
1248 if (frame1.native_handle() || frame2.native_handle()) | |
1249 ExpectEqualTextureFrames(frame1, frame2); | |
1250 else | |
1251 ExpectEqualBufferFrames(frame1, frame2); | |
1252 } | |
1253 | |
1254 void ExpectEqualTextureFrames(const VideoFrame& frame1, | |
1255 const VideoFrame& frame2) { | |
1256 EXPECT_EQ(frame1.native_handle(), frame2.native_handle()); | |
1257 EXPECT_EQ(frame1.width(), frame2.width()); | |
1258 EXPECT_EQ(frame1.height(), frame2.height()); | |
1259 } | |
1260 | |
1261 void ExpectEqualBufferFrames(const VideoFrame& frame1, | |
1262 const VideoFrame& frame2) { | |
1263 EXPECT_EQ(frame1.width(), frame2.width()); | |
1264 EXPECT_EQ(frame1.height(), frame2.height()); | |
1265 EXPECT_EQ(frame1.stride(kYPlane), frame2.stride(kYPlane)); | |
1266 EXPECT_EQ(frame1.stride(kUPlane), frame2.stride(kUPlane)); | |
1267 EXPECT_EQ(frame1.stride(kVPlane), frame2.stride(kVPlane)); | |
1268 ASSERT_EQ(frame1.allocated_size(kYPlane), frame2.allocated_size(kYPlane)); | |
1269 EXPECT_EQ(0, | |
1270 memcmp(frame1.buffer(kYPlane), | |
1271 frame2.buffer(kYPlane), | |
1272 frame1.allocated_size(kYPlane))); | |
1273 ASSERT_EQ(frame1.allocated_size(kUPlane), frame2.allocated_size(kUPlane)); | |
1274 EXPECT_EQ(0, | |
1275 memcmp(frame1.buffer(kUPlane), | |
1276 frame2.buffer(kUPlane), | |
1277 frame1.allocated_size(kUPlane))); | |
1278 ASSERT_EQ(frame1.allocated_size(kVPlane), frame2.allocated_size(kVPlane)); | |
1279 EXPECT_EQ(0, | |
1280 memcmp(frame1.buffer(kVPlane), | |
1281 frame2.buffer(kVPlane), | |
1282 frame1.allocated_size(kVPlane))); | |
1283 } | |
1284 | |
1285 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 1243 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, |
1286 const std::vector<VideoFrame>& frames2) { | 1244 const std::vector<VideoFrame>& frames2) { |
1287 EXPECT_EQ(frames1.size(), frames2.size()); | 1245 EXPECT_EQ(frames1.size(), frames2.size()); |
1288 for (size_t i = 0; i < std::min(frames1.size(), frames2.size()); ++i) | 1246 for (size_t i = 0; i < std::min(frames1.size(), frames2.size()); ++i) |
1289 ExpectEqualFrames(frames1[i], frames2[i]); | 1247 // Compare frame buffers, since we don't care about differing timestamps. |
| 1248 EXPECT_TRUE(test::FrameBufsEqual(frames1[i].video_frame_buffer(), |
| 1249 frames2[i].video_frame_buffer())); |
1290 } | 1250 } |
1291 | 1251 |
1292 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) { | 1252 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) { |
1293 const int kSizeY = width * height * 2; | 1253 const int kSizeY = width * height * 2; |
1294 std::unique_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]); | 1254 std::unique_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]); |
1295 memset(buffer.get(), data, kSizeY); | 1255 memset(buffer.get(), data, kSizeY); |
1296 VideoFrame frame; | 1256 VideoFrame frame; |
1297 frame.CreateFrame(buffer.get(), buffer.get(), buffer.get(), width, height, | 1257 frame.CreateFrame(buffer.get(), buffer.get(), buffer.get(), width, height, |
1298 width, width / 2, width / 2, kVideoRotation_0); | 1258 width, width / 2, width / 2, kVideoRotation_0); |
1299 frame.set_timestamp(data); | 1259 frame.set_timestamp(data); |
(...skipping 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2312 observation_complete_.Set(); | 2272 observation_complete_.Set(); |
2313 } | 2273 } |
2314 } | 2274 } |
2315 } test; | 2275 } test; |
2316 | 2276 |
2317 RunBaseTest(&test); | 2277 RunBaseTest(&test); |
2318 } | 2278 } |
2319 #endif | 2279 #endif |
2320 | 2280 |
2321 } // namespace webrtc | 2281 } // namespace webrtc |
OLD | NEW |