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

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

Issue 2883963002: Periodically update codec bit/frame rate settings. (Closed)
Patch Set: Dumb typo 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 919 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (packet_count_++ % 2 != 0) { 940 const int kLossPercent = 5;
941 // Receive statistics reporting having lost 50% of the packets. 941 if (packet_count_++ % (100 / kLossPercent) != 0) {
942 FakeReceiveStatistics lossy_receive_stats( 942 FakeReceiveStatistics lossy_receive_stats(
943 kVideoSendSsrcs[0], header.sequenceNumber, packet_count_ / 2, 127); 943 kVideoSendSsrcs[0], header.sequenceNumber,
944 (packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost.
945 static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent.
944 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), 946 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(),
945 &lossy_receive_stats, nullptr, nullptr, 947 &lossy_receive_stats, nullptr, nullptr,
946 transport_adapter_.get()); 948 transport_adapter_.get());
947 949
948 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize); 950 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize);
949 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]); 951 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]);
950 952
951 RTCPSender::FeedbackState feedback_state; 953 RTCPSender::FeedbackState feedback_state;
952 954
953 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr)); 955 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 if (!test_generic_packetization_) 988 if (!test_generic_packetization_)
987 send_config->encoder_settings.payload_name = "VP8"; 989 send_config->encoder_settings.payload_name = "VP8";
988 990
989 send_config->encoder_settings.encoder = &encoder_; 991 send_config->encoder_settings.encoder = &encoder_;
990 send_config->rtp.max_packet_size = kMaxPacketSize; 992 send_config->rtp.max_packet_size = kMaxPacketSize;
991 send_config->post_encode_callback = this; 993 send_config->post_encode_callback = this;
992 994
993 // Make sure there is at least one extension header, to make the RTP 995 // Make sure there is at least one extension header, to make the RTP
994 // header larger than the base length of 12 bytes. 996 // header larger than the base length of 12 bytes.
995 EXPECT_FALSE(send_config->rtp.extensions.empty()); 997 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;
996 } 1027 }
997 1028
998 void PerformTest() override { 1029 void PerformTest() override {
999 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; 1030 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets.";
1000 } 1031 }
1001 1032
1002 std::unique_ptr<internal::TransportAdapter> transport_adapter_; 1033 std::unique_ptr<internal::TransportAdapter> transport_adapter_;
1003 test::ConfigurableFrameSizeEncoder encoder_; 1034 test::ConfigurableFrameSizeEncoder encoder_;
1004 1035
1005 const size_t max_packet_size_; 1036 const size_t max_packet_size_;
(...skipping 2331 matching lines...) Expand 10 before | Expand all | Expand 10 after
3337 rtc::CriticalSection crit_; 3368 rtc::CriticalSection crit_;
3338 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); 3369 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_);
3339 bool first_packet_sent_ GUARDED_BY(&crit_); 3370 bool first_packet_sent_ GUARDED_BY(&crit_);
3340 rtc::Event bitrate_changed_event_; 3371 rtc::Event bitrate_changed_event_;
3341 } test; 3372 } test;
3342 3373
3343 RunBaseTest(&test); 3374 RunBaseTest(&test);
3344 } 3375 }
3345 3376
3346 } // namespace webrtc 3377 } // 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