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

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

Issue 1993113003: Refactor how padding is calculated. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed review comments. Created 4 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/video/video_send_stream.cc ('k') | webrtc/video/vie_encoder.h » ('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 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 int rtp_count_ GUARDED_BY(crit_); 948 int rtp_count_ GUARDED_BY(crit_);
949 int last_sequence_number_ GUARDED_BY(crit_); 949 int last_sequence_number_ GUARDED_BY(crit_);
950 int suspended_frame_count_ GUARDED_BY(crit_); 950 int suspended_frame_count_ GUARDED_BY(crit_);
951 int low_remb_bps_ GUARDED_BY(crit_); 951 int low_remb_bps_ GUARDED_BY(crit_);
952 int high_remb_bps_ GUARDED_BY(crit_); 952 int high_remb_bps_ GUARDED_BY(crit_);
953 } test; 953 } test;
954 954
955 RunBaseTest(&test); 955 RunBaseTest(&test);
956 } 956 }
957 957
958 // This test that padding stops being send after a while if the Camera stops
959 // producing video frames and that padding resumes if the camera restarts.
958 TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) { 960 TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) {
959 class NoPaddingWhenVideoIsMuted : public test::SendTest { 961 class NoPaddingWhenVideoIsMuted : public test::SendTest {
960 public: 962 public:
961 NoPaddingWhenVideoIsMuted() 963 NoPaddingWhenVideoIsMuted()
962 : SendTest(kDefaultTimeoutMs), 964 : SendTest(kDefaultTimeoutMs),
963 clock_(Clock::GetRealTimeClock()), 965 clock_(Clock::GetRealTimeClock()),
964 last_packet_time_ms_(-1), 966 last_packet_time_ms_(-1),
965 capturer_(nullptr) { 967 capturer_(nullptr) {
966 } 968 }
967 969
968 private: 970 private:
969 Action OnSendRtp(const uint8_t* packet, size_t length) override { 971 Action OnSendRtp(const uint8_t* packet, size_t length) override {
970 rtc::CritScope lock(&crit_); 972 rtc::CritScope lock(&crit_);
971 last_packet_time_ms_ = clock_->TimeInMilliseconds(); 973 last_packet_time_ms_ = clock_->TimeInMilliseconds();
972 capturer_->Stop(); 974
975 RTPHeader header;
976 parser_->Parse(packet, length, &header);
977 const bool only_padding =
978 header.headerLength + header.paddingLength == length;
979
980 if (test_state_ == kBeforeStopCapture) {
981 capturer_->Stop();
982 test_state_ = kWaitingForPadding;
983 } else if (test_state_ == kWaitingForPadding && only_padding) {
984 test_state_ = kWaitingForNoPackets;
985 } else if (test_state_ == kWaitingForPaddingAfterCameraRestart &&
986 only_padding) {
987 observation_complete_.Set();
988 }
973 return SEND_PACKET; 989 return SEND_PACKET;
974 } 990 }
975 991
976 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 992 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
977 rtc::CritScope lock(&crit_); 993 rtc::CritScope lock(&crit_);
978 const int kVideoMutedThresholdMs = 10000; 994 const int kNoPacketsThresholdMs = 2000;
979 if (last_packet_time_ms_ > 0 && 995 if (test_state_ == kWaitingForNoPackets &&
980 clock_->TimeInMilliseconds() - last_packet_time_ms_ > 996 (last_packet_time_ms_ > 0 &&
981 kVideoMutedThresholdMs) 997 clock_->TimeInMilliseconds() - last_packet_time_ms_ >
982 observation_complete_.Set(); 998 kNoPacketsThresholdMs)) {
983 // Receive statistics reporting having lost 50% of the packets. 999 capturer_->Start();
984 FakeReceiveStatistics receive_stats(kVideoSendSsrcs[0], 1, 1, 0); 1000 test_state_ = kWaitingForPaddingAfterCameraRestart;
985 RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), &receive_stats, 1001 }
986 nullptr, nullptr, transport_adapter_.get());
987
988 rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize);
989 rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]);
990
991 RTCPSender::FeedbackState feedback_state;
992
993 EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr));
994 return SEND_PACKET; 1002 return SEND_PACKET;
995 } 1003 }
996 1004
997 test::PacketTransport* CreateReceiveTransport() override {
998 test::PacketTransport* transport = new test::PacketTransport(
999 nullptr, this, test::PacketTransport::kReceiver,
1000 FakeNetworkPipe::Config());
1001 transport_adapter_.reset(new internal::TransportAdapter(transport));
1002 transport_adapter_->Enable();
1003 return transport;
1004 }
1005
1006 size_t GetNumVideoStreams() const override { return 3; } 1005 size_t GetNumVideoStreams() const override { return 3; }
1007 1006
1008 void OnFrameGeneratorCapturerCreated( 1007 void OnFrameGeneratorCapturerCreated(
1009 test::FrameGeneratorCapturer* frame_generator_capturer) override { 1008 test::FrameGeneratorCapturer* frame_generator_capturer) override {
1010 rtc::CritScope lock(&crit_); 1009 rtc::CritScope lock(&crit_);
1011 capturer_ = frame_generator_capturer; 1010 capturer_ = frame_generator_capturer;
1012 } 1011 }
1013 1012
1014 void PerformTest() override { 1013 void PerformTest() override {
1015 EXPECT_TRUE(Wait()) 1014 EXPECT_TRUE(Wait())
1016 << "Timed out while waiting for RTP packets to stop being sent."; 1015 << "Timed out while waiting for RTP packets to stop being sent.";
1017 } 1016 }
1018 1017
1018 enum TestState {
1019 kBeforeStopCapture,
1020 kWaitingForPadding,
1021 kWaitingForNoPackets,
1022 kWaitingForPaddingAfterCameraRestart
1023 };
1024
1025 TestState test_state_ = kBeforeStopCapture;
1019 Clock* const clock_; 1026 Clock* const clock_;
1020 std::unique_ptr<internal::TransportAdapter> transport_adapter_; 1027 std::unique_ptr<internal::TransportAdapter> transport_adapter_;
1021 rtc::CriticalSection crit_; 1028 rtc::CriticalSection crit_;
1022 int64_t last_packet_time_ms_ GUARDED_BY(crit_); 1029 int64_t last_packet_time_ms_ GUARDED_BY(crit_);
1023 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_); 1030 test::FrameGeneratorCapturer* capturer_ GUARDED_BY(crit_);
1024 } test; 1031 } test;
1025 1032
1026 RunBaseTest(&test); 1033 RunBaseTest(&test);
1027 } 1034 }
1028 1035
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2296 observation_complete_.Set(); 2303 observation_complete_.Set();
2297 } 2304 }
2298 } 2305 }
2299 } test; 2306 } test;
2300 2307
2301 RunBaseTest(&test); 2308 RunBaseTest(&test);
2302 } 2309 }
2303 #endif // !defined(RTC_DISABLE_VP9) 2310 #endif // !defined(RTC_DISABLE_VP9)
2304 2311
2305 } // namespace webrtc 2312 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream.cc ('k') | webrtc/video/vie_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698