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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 ++current_size_frame_; | 930 ++current_size_frame_; |
931 } | 931 } |
932 } | 932 } |
933 } | 933 } |
934 | 934 |
935 return SEND_PACKET; | 935 return SEND_PACKET; |
936 } | 936 } |
937 | 937 |
938 void TriggerLossReport(const RTPHeader& header) { | 938 void TriggerLossReport(const RTPHeader& header) { |
939 // Send lossy receive reports to trigger FEC enabling. | 939 // Send lossy receive reports to trigger FEC enabling. |
940 const int kLossPercent = 5; | 940 if (packet_count_++ % 2 != 0) { |
941 if (packet_count_++ % (100 / kLossPercent) != 0) { | 941 // Receive statistics reporting having lost 50% of the packets. |
942 FakeReceiveStatistics lossy_receive_stats( | 942 FakeReceiveStatistics lossy_receive_stats( |
943 kVideoSendSsrcs[0], header.sequenceNumber, | 943 kVideoSendSsrcs[0], header.sequenceNumber, packet_count_ / 2, 127); |
944 (packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost. | |
945 static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent. | |
946 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), | 944 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), |
947 &lossy_receive_stats, nullptr, nullptr, | 945 &lossy_receive_stats, nullptr, nullptr, |
948 transport_adapter_.get()); | 946 transport_adapter_.get()); |
949 | 947 |
950 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); | 948 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); |
951 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); | 949 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); |
952 | 950 |
953 RTCPSender::FeedbackState feedback_state; | 951 RTCPSender::FeedbackState feedback_state; |
954 | 952 |
955 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); | 953 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 if (!test_generic_packetization_) | 986 if (!test_generic_packetization_) |
989 send_config->encoder_settings.payload_name = "VP8"; | 987 send_config->encoder_settings.payload_name = "VP8"; |
990 | 988 |
991 send_config->encoder_settings.encoder = &encoder_; | 989 send_config->encoder_settings.encoder = &encoder_; |
992 send_config->rtp.max_packet_size = kMaxPacketSize; | 990 send_config->rtp.max_packet_size = kMaxPacketSize; |
993 send_config->post_encode_callback = this; | 991 send_config->post_encode_callback = this; |
994 | 992 |
995 // Make sure there is at least one extension header, to make the RTP | 993 // Make sure there is at least one extension header, to make the RTP |
996 // header larger than the base length of 12 bytes. | 994 // header larger than the base length of 12 bytes. |
997 EXPECT_FALSE(send_config->rtp.extensions.empty()); | 995 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
998 | |
999 // Setup screen content disables frame dropping which makes this easier. | |
1000 class VideoStreamFactory | |
1001 : public VideoEncoderConfig::VideoStreamFactoryInterface { | |
1002 public: | |
1003 explicit VideoStreamFactory(size_t num_temporal_layers) | |
1004 : num_temporal_layers_(num_temporal_layers) { | |
1005 EXPECT_GT(num_temporal_layers, 0u); | |
1006 } | |
1007 | |
1008 private: | |
1009 std::vector<VideoStream> CreateEncoderStreams( | |
1010 int width, | |
1011 int height, | |
1012 const VideoEncoderConfig& encoder_config) override { | |
1013 std::vector<VideoStream> streams = | |
1014 test::CreateVideoStreams(width, height, encoder_config); | |
1015 for (VideoStream& stream : streams) { | |
1016 stream.temporal_layer_thresholds_bps.resize(num_temporal_layers_ - | |
1017 1); | |
1018 } | |
1019 return streams; | |
1020 } | |
1021 const size_t num_temporal_layers_; | |
1022 }; | |
1023 | |
1024 encoder_config->video_stream_factory = | |
1025 new rtc::RefCountedObject<VideoStreamFactory>(2); | |
1026 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; | |
1027 } | 996 } |
1028 | 997 |
1029 void PerformTest() override { | 998 void PerformTest() override { |
1030 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; | 999 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; |
1031 } | 1000 } |
1032 | 1001 |
1033 std::unique_ptr<internal::TransportAdapter> transport_adapter_; | 1002 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
1034 test::ConfigurableFrameSizeEncoder encoder_; | 1003 test::ConfigurableFrameSizeEncoder encoder_; |
1035 | 1004 |
1036 const size_t max_packet_size_; | 1005 const size_t max_packet_size_; |
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3368 rtc::CriticalSection crit_; | 3337 rtc::CriticalSection crit_; |
3369 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); | 3338 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); |
3370 bool first_packet_sent_ GUARDED_BY(&crit_); | 3339 bool first_packet_sent_ GUARDED_BY(&crit_); |
3371 rtc::Event bitrate_changed_event_; | 3340 rtc::Event bitrate_changed_event_; |
3372 } test; | 3341 } test; |
3373 | 3342 |
3374 RunBaseTest(&test); | 3343 RunBaseTest(&test); |
3375 } | 3344 } |
3376 | 3345 |
3377 } // namespace webrtc | 3346 } // namespace webrtc |
OLD | NEW |