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 |
| 11 #include <memory> |
11 #include <vector> | 12 #include <vector> |
12 | 13 |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 #include "webrtc/base/bind.h" | 16 #include "webrtc/base/bind.h" |
16 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/criticalsection.h" | 18 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/base/event.h" | 19 #include "webrtc/base/event.h" |
19 #include "webrtc/base/logging.h" | 20 #include "webrtc/base/logging.h" |
20 #include "webrtc/base/platform_thread.h" | 21 #include "webrtc/base/platform_thread.h" |
21 #include "webrtc/base/scoped_ptr.h" | |
22 #include "webrtc/call.h" | 22 #include "webrtc/call.h" |
23 #include "webrtc/call/transport_adapter.h" | 23 #include "webrtc/call/transport_adapter.h" |
24 #include "webrtc/frame_callback.h" | 24 #include "webrtc/frame_callback.h" |
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/ref_count.h" | 31 #include "webrtc/system_wrappers/include/ref_count.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 return false; | 297 return false; |
298 } | 298 } |
299 | 299 |
300 bool IsPacketInOrder(uint16_t sequence_number) const override { | 300 bool IsPacketInOrder(uint16_t sequence_number) const override { |
301 return true; | 301 return true; |
302 } | 302 } |
303 | 303 |
304 RtcpStatistics stats_; | 304 RtcpStatistics stats_; |
305 }; | 305 }; |
306 | 306 |
307 rtc::scoped_ptr<LossyStatistician> lossy_stats_; | 307 std::unique_ptr<LossyStatistician> lossy_stats_; |
308 StatisticianMap stats_map_; | 308 StatisticianMap stats_map_; |
309 }; | 309 }; |
310 | 310 |
311 class FecObserver : public test::EndToEndTest { | 311 class FecObserver : public test::EndToEndTest { |
312 public: | 312 public: |
313 FecObserver(bool header_extensions_enabled, | 313 FecObserver(bool header_extensions_enabled, |
314 bool use_nack, | 314 bool use_nack, |
315 bool expect_red, | 315 bool expect_red, |
316 const std::string& codec) | 316 const std::string& codec) |
317 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), | 317 : EndToEndTest(VideoSendStreamTest::kDefaultTimeoutMs), |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 (*receive_configs)[0].rtp.fec.red_payload_type = | 435 (*receive_configs)[0].rtp.fec.red_payload_type = |
436 send_config->rtp.fec.red_payload_type; | 436 send_config->rtp.fec.red_payload_type; |
437 (*receive_configs)[0].rtp.fec.ulpfec_payload_type = | 437 (*receive_configs)[0].rtp.fec.ulpfec_payload_type = |
438 send_config->rtp.fec.ulpfec_payload_type; | 438 send_config->rtp.fec.ulpfec_payload_type; |
439 } | 439 } |
440 | 440 |
441 void PerformTest() override { | 441 void PerformTest() override { |
442 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; | 442 EXPECT_TRUE(Wait()) << "Timed out waiting for FEC and media packets."; |
443 } | 443 } |
444 | 444 |
445 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 445 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
446 rtc::scoped_ptr<VideoEncoder> encoder_; | 446 std::unique_ptr<VideoEncoder> encoder_; |
447 const std::string payload_name_; | 447 const std::string payload_name_; |
448 const bool use_nack_; | 448 const bool use_nack_; |
449 const bool expect_red_; | 449 const bool expect_red_; |
450 int send_count_; | 450 int send_count_; |
451 bool received_media_; | 451 bool received_media_; |
452 bool received_fec_; | 452 bool received_fec_; |
453 bool header_extensions_enabled_; | 453 bool header_extensions_enabled_; |
454 RTPHeader prev_header_; | 454 RTPHeader prev_header_; |
455 }; | 455 }; |
456 | 456 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; | 555 send_config->rtp.nack.rtp_history_ms = kNackRtpHistoryMs; |
556 send_config->rtp.rtx.payload_type = retransmit_payload_type_; | 556 send_config->rtp.rtx.payload_type = retransmit_payload_type_; |
557 if (retransmit_ssrc_ != kVideoSendSsrcs[0]) | 557 if (retransmit_ssrc_ != kVideoSendSsrcs[0]) |
558 send_config->rtp.rtx.ssrcs.push_back(retransmit_ssrc_); | 558 send_config->rtp.rtx.ssrcs.push_back(retransmit_ssrc_); |
559 } | 559 } |
560 | 560 |
561 void PerformTest() override { | 561 void PerformTest() override { |
562 EXPECT_TRUE(Wait()) << "Timed out while waiting for NACK retransmission."; | 562 EXPECT_TRUE(Wait()) << "Timed out while waiting for NACK retransmission."; |
563 } | 563 } |
564 | 564 |
565 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 565 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
566 int send_count_; | 566 int send_count_; |
567 uint32_t retransmit_ssrc_; | 567 uint32_t retransmit_ssrc_; |
568 uint8_t retransmit_payload_type_; | 568 uint8_t retransmit_payload_type_; |
569 int nacked_sequence_number_; | 569 int nacked_sequence_number_; |
570 } test(retransmit_ssrc, retransmit_payload_type); | 570 } test(retransmit_ssrc, retransmit_payload_type); |
571 | 571 |
572 RunBaseTest(&test); | 572 RunBaseTest(&test); |
573 } | 573 } |
574 | 574 |
575 TEST_F(VideoSendStreamTest, RetransmitsNack) { | 575 TEST_F(VideoSendStreamTest, RetransmitsNack) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 | 751 |
752 // Make sure there is at least one extension header, to make the RTP | 752 // Make sure there is at least one extension header, to make the RTP |
753 // header larger than the base length of 12 bytes. | 753 // header larger than the base length of 12 bytes. |
754 EXPECT_FALSE(send_config->rtp.extensions.empty()); | 754 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
755 } | 755 } |
756 | 756 |
757 void PerformTest() override { | 757 void PerformTest() override { |
758 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; | 758 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; |
759 } | 759 } |
760 | 760 |
761 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 761 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
762 test::ConfigurableFrameSizeEncoder encoder_; | 762 test::ConfigurableFrameSizeEncoder encoder_; |
763 | 763 |
764 const size_t max_packet_size_; | 764 const size_t max_packet_size_; |
765 const size_t stop_size_; | 765 const size_t stop_size_; |
766 const bool test_generic_packetization_; | 766 const bool test_generic_packetization_; |
767 const bool use_fec_; | 767 const bool use_fec_; |
768 | 768 |
769 uint32_t packet_count_; | 769 uint32_t packet_count_; |
770 size_t accumulated_size_; | 770 size_t accumulated_size_; |
771 size_t accumulated_payload_; | 771 size_t accumulated_payload_; |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); | 930 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); |
931 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); | 931 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); |
932 if (remb_value > 0) { | 932 if (remb_value > 0) { |
933 rtcp_sender.SetREMBStatus(true); | 933 rtcp_sender.SetREMBStatus(true); |
934 rtcp_sender.SetREMBData(remb_value, std::vector<uint32_t>()); | 934 rtcp_sender.SetREMBData(remb_value, std::vector<uint32_t>()); |
935 } | 935 } |
936 RTCPSender::FeedbackState feedback_state; | 936 RTCPSender::FeedbackState feedback_state; |
937 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); | 937 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); |
938 } | 938 } |
939 | 939 |
940 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 940 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
941 Clock* const clock_; | 941 Clock* const clock_; |
942 VideoSendStream* stream_; | 942 VideoSendStream* stream_; |
943 | 943 |
944 rtc::CriticalSection crit_; | 944 rtc::CriticalSection crit_; |
945 TestState test_state_ GUARDED_BY(crit_); | 945 TestState test_state_ GUARDED_BY(crit_); |
946 int rtp_count_ GUARDED_BY(crit_); | 946 int rtp_count_ GUARDED_BY(crit_); |
947 int last_sequence_number_ GUARDED_BY(crit_); | 947 int last_sequence_number_ GUARDED_BY(crit_); |
948 int suspended_frame_count_ GUARDED_BY(crit_); | 948 int suspended_frame_count_ GUARDED_BY(crit_); |
949 int low_remb_bps_ GUARDED_BY(crit_); | 949 int low_remb_bps_ GUARDED_BY(crit_); |
950 int high_remb_bps_ GUARDED_BY(crit_); | 950 int high_remb_bps_ GUARDED_BY(crit_); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 rtc::CritScope lock(&crit_); | 1008 rtc::CritScope lock(&crit_); |
1009 capturer_ = frame_generator_capturer; | 1009 capturer_ = frame_generator_capturer; |
1010 } | 1010 } |
1011 | 1011 |
1012 void PerformTest() override { | 1012 void PerformTest() override { |
1013 EXPECT_TRUE(Wait()) | 1013 EXPECT_TRUE(Wait()) |
1014 << "Timed out while waiting for RTP packets to stop being sent."; | 1014 << "Timed out while waiting for RTP packets to stop being sent."; |
1015 } | 1015 } |
1016 | 1016 |
1017 Clock* const clock_; | 1017 Clock* const clock_; |
1018 rtc::scoped_ptr<internal::TransportAdapter> transport_adapter_; | 1018 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
1019 rtc::CriticalSection crit_; | 1019 rtc::CriticalSection crit_; |
1020 int64_t last_packet_time_ms_ GUARDED_BY(crit_); | 1020 int64_t last_packet_time_ms_ GUARDED_BY(crit_); |
1021 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); | 1021 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); |
1022 } test; | 1022 } test; |
1023 | 1023 |
1024 RunBaseTest(&test); | 1024 RunBaseTest(&test); |
1025 } | 1025 } |
1026 | 1026 |
1027 // This test first observes "high" bitrate use at which point it sends a REMB to | 1027 // This test first observes "high" bitrate use at which point it sends a REMB to |
1028 // indicate that it should be lowered significantly. The test then observes that | 1028 // indicate that it should be lowered significantly. The test then observes that |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 new internal::TransportAdapter(send_config->send_transport)); | 1096 new internal::TransportAdapter(send_config->send_transport)); |
1097 feedback_transport_->Enable(); | 1097 feedback_transport_->Enable(); |
1098 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; | 1098 encoder_config->min_transmit_bitrate_bps = kMinTransmitBitrateBps; |
1099 } | 1099 } |
1100 | 1100 |
1101 void PerformTest() override { | 1101 void PerformTest() override { |
1102 EXPECT_TRUE(Wait()) | 1102 EXPECT_TRUE(Wait()) |
1103 << "Timeout while waiting for low bitrate stats after REMB."; | 1103 << "Timeout while waiting for low bitrate stats after REMB."; |
1104 } | 1104 } |
1105 | 1105 |
1106 rtc::scoped_ptr<RtpRtcp> rtp_rtcp_; | 1106 std::unique_ptr<RtpRtcp> rtp_rtcp_; |
1107 rtc::scoped_ptr<internal::TransportAdapter> feedback_transport_; | 1107 std::unique_ptr<internal::TransportAdapter> feedback_transport_; |
1108 VideoSendStream* stream_; | 1108 VideoSendStream* stream_; |
1109 bool bitrate_capped_; | 1109 bool bitrate_capped_; |
1110 } test; | 1110 } test; |
1111 | 1111 |
1112 RunBaseTest(&test); | 1112 RunBaseTest(&test); |
1113 } | 1113 } |
1114 | 1114 |
1115 TEST_F(VideoSendStreamTest, CanReconfigureToUseStartBitrateAbovePreviousMax) { | 1115 TEST_F(VideoSendStreamTest, CanReconfigureToUseStartBitrateAbovePreviousMax) { |
1116 class StartBitrateObserver : public test::FakeEncoder { | 1116 class StartBitrateObserver : public test::FakeEncoder { |
1117 public: | 1117 public: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 | 1285 |
1286 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, | 1286 void ExpectEqualFramesVector(const std::vector<VideoFrame>& frames1, |
1287 const std::vector<VideoFrame>& frames2) { | 1287 const std::vector<VideoFrame>& frames2) { |
1288 EXPECT_EQ(frames1.size(), frames2.size()); | 1288 EXPECT_EQ(frames1.size(), frames2.size()); |
1289 for (size_t i = 0; i < std::min(frames1.size(), frames2.size()); ++i) | 1289 for (size_t i = 0; i < std::min(frames1.size(), frames2.size()); ++i) |
1290 ExpectEqualFrames(frames1[i], frames2[i]); | 1290 ExpectEqualFrames(frames1[i], frames2[i]); |
1291 } | 1291 } |
1292 | 1292 |
1293 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) { | 1293 VideoFrame CreateVideoFrame(int width, int height, uint8_t data) { |
1294 const int kSizeY = width * height * 2; | 1294 const int kSizeY = width * height * 2; |
1295 rtc::scoped_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]); | 1295 std::unique_ptr<uint8_t[]> buffer(new uint8_t[kSizeY]); |
1296 memset(buffer.get(), data, kSizeY); | 1296 memset(buffer.get(), data, kSizeY); |
1297 VideoFrame frame; | 1297 VideoFrame frame; |
1298 frame.CreateFrame(buffer.get(), buffer.get(), buffer.get(), width, height, | 1298 frame.CreateFrame(buffer.get(), buffer.get(), buffer.get(), width, height, |
1299 width, width / 2, width / 2, kVideoRotation_0); | 1299 width, width / 2, width / 2, kVideoRotation_0); |
1300 frame.set_timestamp(data); | 1300 frame.set_timestamp(data); |
1301 frame.set_render_time_ms(data); | 1301 frame.set_render_time_ms(data); |
1302 return frame; | 1302 return frame; |
1303 } | 1303 } |
1304 | 1304 |
1305 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { | 1305 TEST_F(VideoSendStreamTest, EncoderIsProperlyInitializedAndDestroyed) { |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2161 | 2161 |
2162 // Compare with last packet in previous frame. | 2162 // Compare with last packet in previous frame. |
2163 if (frames_sent_ == 0) | 2163 if (frames_sent_ == 0) |
2164 return; | 2164 return; |
2165 EXPECT_TRUE(last_vp9_.end_of_frame); | 2165 EXPECT_TRUE(last_vp9_.end_of_frame); |
2166 EXPECT_TRUE(last_header_.markerBit); | 2166 EXPECT_TRUE(last_header_.markerBit); |
2167 EXPECT_TRUE(ContinuousPictureId(vp9)); | 2167 EXPECT_TRUE(ContinuousPictureId(vp9)); |
2168 VerifyTl0Idx(vp9); | 2168 VerifyTl0Idx(vp9); |
2169 } | 2169 } |
2170 | 2170 |
2171 rtc::scoped_ptr<VP9Encoder> vp9_encoder_; | 2171 std::unique_ptr<VP9Encoder> vp9_encoder_; |
2172 VideoCodecVP9 vp9_settings_; | 2172 VideoCodecVP9 vp9_settings_; |
2173 webrtc::VideoEncoderConfig encoder_config_; | 2173 webrtc::VideoEncoderConfig encoder_config_; |
2174 RTPHeader last_header_; | 2174 RTPHeader last_header_; |
2175 RTPVideoHeaderVP9 last_vp9_; | 2175 RTPVideoHeaderVP9 last_vp9_; |
2176 size_t packets_sent_; | 2176 size_t packets_sent_; |
2177 size_t frames_sent_; | 2177 size_t frames_sent_; |
2178 }; | 2178 }; |
2179 | 2179 |
2180 TEST_F(VideoSendStreamTest, Vp9NonFlexMode_1Tl1SLayers) { | 2180 TEST_F(VideoSendStreamTest, Vp9NonFlexMode_1Tl1SLayers) { |
2181 const uint8_t kNumTemporalLayers = 1; | 2181 const uint8_t kNumTemporalLayers = 1; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 observation_complete_.Set(); | 2313 observation_complete_.Set(); |
2314 } | 2314 } |
2315 } | 2315 } |
2316 } test; | 2316 } test; |
2317 | 2317 |
2318 RunBaseTest(&test); | 2318 RunBaseTest(&test); |
2319 } | 2319 } |
2320 #endif | 2320 #endif |
2321 | 2321 |
2322 } // namespace webrtc | 2322 } // namespace webrtc |
OLD | NEW |