Chromium Code Reviews| 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 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 924 ++current_size_frame_; | 924 ++current_size_frame_; |
| 925 } | 925 } |
| 926 } | 926 } |
| 927 } | 927 } |
| 928 | 928 |
| 929 return SEND_PACKET; | 929 return SEND_PACKET; |
| 930 } | 930 } |
| 931 | 931 |
| 932 void TriggerLossReport(const RTPHeader& header) { | 932 void TriggerLossReport(const RTPHeader& header) { |
| 933 // Send lossy receive reports to trigger FEC enabling. | 933 // Send lossy receive reports to trigger FEC enabling. |
| 934 if (packet_count_++ % 2 != 0) { | 934 const int kLossPercent = 5; |
| 935 // Receive statistics reporting having lost 50% of the packets. | 935 if (packet_count_++ % (100 / kLossPercent) != 0) { |
| 936 FakeReceiveStatistics lossy_receive_stats( | 936 FakeReceiveStatistics lossy_receive_stats( |
| 937 kVideoSendSsrcs[0], header.sequenceNumber, packet_count_ / 2, 127); | 937 kVideoSendSsrcs[0], header.sequenceNumber, |
| 938 (packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost. | |
| 939 static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent. | |
| 938 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), | 940 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), |
| 939 &lossy_receive_stats, nullptr, nullptr, | 941 &lossy_receive_stats, nullptr, nullptr, |
| 940 transport_adapter_.get()); | 942 transport_adapter_.get()); |
| 941 | 943 |
| 942 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); | 944 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); |
| 943 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); | 945 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); |
| 944 | 946 |
| 945 RTCPSender::FeedbackState feedback_state; | 947 RTCPSender::FeedbackState feedback_state; |
| 946 | 948 |
| 947 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); | 949 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 980 if (!test_generic_packetization_) | 982 if (!test_generic_packetization_) |
| 981 send_config->encoder_settings.payload_name = "VP8"; | 983 send_config->encoder_settings.payload_name = "VP8"; |
| 982 | 984 |
| 983 send_config->encoder_settings.encoder = &encoder_; | 985 send_config->encoder_settings.encoder = &encoder_; |
| 984 send_config->rtp.max_packet_size = kMaxPacketSize; | 986 send_config->rtp.max_packet_size = kMaxPacketSize; |
| 985 send_config->post_encode_callback = this; | 987 send_config->post_encode_callback = this; |
| 986 | 988 |
| 987 // Make sure there is at least one extension header, to make the RTP | 989 // Make sure there is at least one extension header, to make the RTP |
| 988 // header larger than the base length of 12 bytes. | 990 // header larger than the base length of 12 bytes. |
| 989 EXPECT_FALSE(send_config->rtp.extensions.empty()); | 991 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
| 992 | |
| 993 // Setup screen content disables frame dropping which makes this easier. | |
|
stefan-webrtc
2017/05/23 17:03:20
This seems a bit unfortunate. What if we want to r
sprang_webrtc
2017/05/24 09:07:07
Then we should probably expose some API surface to
| |
| 994 class VideoStreamFactory | |
| 995 : public VideoEncoderConfig::VideoStreamFactoryInterface { | |
| 996 public: | |
| 997 explicit VideoStreamFactory(size_t num_temporal_layers) | |
| 998 : num_temporal_layers_(num_temporal_layers) { | |
| 999 EXPECT_GT(num_temporal_layers, 0u); | |
| 1000 } | |
| 1001 | |
| 1002 private: | |
| 1003 std::vector<VideoStream> CreateEncoderStreams( | |
| 1004 int width, | |
| 1005 int height, | |
| 1006 const VideoEncoderConfig& encoder_config) override { | |
| 1007 std::vector<VideoStream> streams = | |
| 1008 test::CreateVideoStreams(width, height, encoder_config); | |
| 1009 for (VideoStream& stream : streams) { | |
| 1010 stream.temporal_layer_thresholds_bps.resize(num_temporal_layers_ - | |
| 1011 1); | |
| 1012 } | |
| 1013 return streams; | |
| 1014 } | |
| 1015 const size_t num_temporal_layers_; | |
| 1016 }; | |
| 1017 | |
| 1018 encoder_config->video_stream_factory = | |
| 1019 new rtc::RefCountedObject<VideoStreamFactory>(2); | |
| 1020 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen; | |
| 990 } | 1021 } |
| 991 | 1022 |
| 992 void PerformTest() override { | 1023 void PerformTest() override { |
| 993 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; | 1024 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; |
| 994 } | 1025 } |
| 995 | 1026 |
| 996 std::unique_ptr<internal::TransportAdapter> transport_adapter_; | 1027 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
| 997 test::ConfigurableFrameSizeEncoder encoder_; | 1028 test::ConfigurableFrameSizeEncoder encoder_; |
| 998 | 1029 |
| 999 const size_t max_packet_size_; | 1030 const size_t max_packet_size_; |
| (...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3331 rtc::CriticalSection crit_; | 3362 rtc::CriticalSection crit_; |
| 3332 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); | 3363 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); |
| 3333 bool first_packet_sent_ GUARDED_BY(&crit_); | 3364 bool first_packet_sent_ GUARDED_BY(&crit_); |
| 3334 rtc::Event bitrate_changed_event_; | 3365 rtc::Event bitrate_changed_event_; |
| 3335 } test; | 3366 } test; |
| 3336 | 3367 |
| 3337 RunBaseTest(&test); | 3368 RunBaseTest(&test); |
| 3338 } | 3369 } |
| 3339 | 3370 |
| 3340 } // namespace webrtc | 3371 } // namespace webrtc |
| OLD | NEW |