Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2953053002: Reland of Periodically update codec bit/frame rate settings. (Closed)
Patch Set: Fix bug and add test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_encoder.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 ++current_size_frame_; 968 ++current_size_frame_;
969 } 969 }
970 } 970 }
971 } 971 }
972 972
973 return SEND_PACKET; 973 return SEND_PACKET;
974 } 974 }
975 975
976 void TriggerLossReport(const RTPHeader& header) { 976 void TriggerLossReport(const RTPHeader& header) {
977 // Send lossy receive reports to trigger FEC enabling. 977 // Send lossy receive reports to trigger FEC enabling.
978 if (packet_count_++ % 2 != 0) { 978 const int kLossPercent = 5;
979 // Receive statistics reporting having lost 50% of the packets. 979 if (packet_count_++ % (100 / kLossPercent) != 0) {
980 FakeReceiveStatistics lossy_receive_stats( 980 FakeReceiveStatistics lossy_receive_stats(
981 kVideoSendSsrcs[0], header.sequenceNumber, packet_count_ / 2, 127); 981 kVideoSendSsrcs[0], header.sequenceNumber,
982 (packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost.
983 static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent.
982 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), 984 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(),
983 &lossy_receive_stats, nullptr, nullptr, 985 &lossy_receive_stats, nullptr, nullptr,
984 transport_adapter_.get()); 986 transport_adapter_.get());
985 987
986 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); 988 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize);
987 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); 989 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]);
988 990
989 RTCPSender::FeedbackState feedback_state; 991 RTCPSender::FeedbackState feedback_state;
990 992
991 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); 993 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 if (!test_generic_packetization_) 1026 if (!test_generic_packetization_)
1025 send_config->encoder_settings.payload_name = "VP8"; 1027 send_config->encoder_settings.payload_name = "VP8";
1026 1028
1027 send_config->encoder_settings.encoder = &encoder_; 1029 send_config->encoder_settings.encoder = &encoder_;
1028 send_config->rtp.max_packet_size = kMaxPacketSize; 1030 send_config->rtp.max_packet_size = kMaxPacketSize;
1029 send_config->post_encode_callback = this; 1031 send_config->post_encode_callback = this;
1030 1032
1031 // Make sure there is at least one extension header, to make the RTP 1033 // Make sure there is at least one extension header, to make the RTP
1032 // header larger than the base length of 12 bytes. 1034 // header larger than the base length of 12 bytes.
1033 EXPECT_FALSE(send_config->rtp.extensions.empty()); 1035 EXPECT_FALSE(send_config->rtp.extensions.empty());
1036
1037 // Setup screen content disables frame dropping which makes this easier.
1038 class VideoStreamFactory
1039 : public VideoEncoderConfig::VideoStreamFactoryInterface {
1040 public:
1041 explicit VideoStreamFactory(size_t num_temporal_layers)
1042 : num_temporal_layers_(num_temporal_layers) {
1043 EXPECT_GT(num_temporal_layers, 0u);
1044 }
1045
1046 private:
1047 std::vector<VideoStream> CreateEncoderStreams(
1048 int width,
1049 int height,
1050 const VideoEncoderConfig& encoder_config) override {
1051 std::vector<VideoStream> streams =
1052 test::CreateVideoStreams(width, height, encoder_config);
1053 for (VideoStream& stream : streams) {
1054 stream.temporal_layer_thresholds_bps.resize(num_temporal_layers_ -
1055 1);
1056 }
1057 return streams;
1058 }
1059 const size_t num_temporal_layers_;
1060 };
1061
1062 encoder_config->video_stream_factory =
1063 new rtc::RefCountedObject<VideoStreamFactory>(2);
1064 encoder_config->content_type = VideoEncoderConfig::ContentType::kScreen;
1034 } 1065 }
1035 1066
1036 void PerformTest() override { 1067 void PerformTest() override {
1037 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; 1068 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets.";
1038 } 1069 }
1039 1070
1040 std::unique_ptr<internal::TransportAdapter> transport_adapter_; 1071 std::unique_ptr<internal::TransportAdapter> transport_adapter_;
1041 test::ConfigurableFrameSizeEncoder encoder_; 1072 test::ConfigurableFrameSizeEncoder encoder_;
1042 1073
1043 const size_t max_packet_size_; 1074 const size_t max_packet_size_;
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
3370 rtc::CriticalSection crit_; 3401 rtc::CriticalSection crit_;
3371 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); 3402 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_);
3372 bool first_packet_sent_ GUARDED_BY(&crit_); 3403 bool first_packet_sent_ GUARDED_BY(&crit_);
3373 rtc::Event bitrate_changed_event_; 3404 rtc::Event bitrate_changed_event_;
3374 } test; 3405 } test;
3375 3406
3376 RunBaseTest(&test); 3407 RunBaseTest(&test);
3377 } 3408 }
3378 3409
3379 } // namespace webrtc 3410 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_encoder.cc ('k') | webrtc/video/vie_encoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698