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