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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/video/video_send_stream_tests.cc
diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc
index 265d7495b177ce2f4f174225d6febe22eb8d5a37..39f0038996ba44c75826a692bd0fecf05252f41a 100644
--- a/webrtc/video/video_send_stream_tests.cc
+++ b/webrtc/video/video_send_stream_tests.cc
@@ -955,6 +955,8 @@ TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) {
RunBaseTest(&test);
}
+// This test that padding stops being send after a while if the Camera stops
+// producing video frames and that padding resumes if the camera restarts.
TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) {
class NoPaddingWhenVideoIsMuted : public test::SendTest {
public:
@@ -969,40 +971,37 @@ TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) {
Action OnSendRtp(const uint8_t* packet, size_t length) override {
rtc::CritScope lock(&crit_);
last_packet_time_ms_ = clock_->TimeInMilliseconds();
- capturer_->Stop();
+
+ RTPHeader header;
+ parser_->Parse(packet, length, &header);
+ const bool only_padding =
+ header.headerLength + header.paddingLength == length;
+
+ if (test_state_ == kBeforeStopCapture) {
+ capturer_->Stop();
+ test_state_ = kWaitingForPadding;
+ } else if (test_state_ == kWaitingForPadding && only_padding) {
+ test_state_ = kWaitingForNoPackets;
+ } else if (test_state_ == kWaitingForPaddingAfterCameraRestart &&
+ only_padding) {
+ observation_complete_.Set();
+ }
return SEND_PACKET;
}
Action OnSendRtcp(const uint8_t* packet, size_t length) override {
rtc::CritScope lock(&crit_);
- const int kVideoMutedThresholdMs = 10000;
- if (last_packet_time_ms_ > 0 &&
- clock_->TimeInMilliseconds() - last_packet_time_ms_ >
- kVideoMutedThresholdMs)
- observation_complete_.Set();
- // Receive statistics reporting having lost 50% of the packets.
- FakeReceiveStatistics receive_stats(kVideoSendSsrcs[0], 1, 1, 0);
- RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), &receive_stats,
- nullptr, nullptr, transport_adapter_.get());
-
- rtcp_sender.SetRTCPStatus(RtcpMode::kReducedSize);
- rtcp_sender.SetRemoteSSRC(kVideoSendSsrcs[0]);
-
- RTCPSender::FeedbackState feedback_state;
-
- EXPECT_EQ(0, rtcp_sender.SendRTCP(feedback_state, kRtcpRr));
+ const int kNoPacketsThresholdMs = 2000;
+ if (test_state_ == kWaitingForNoPackets &&
+ (last_packet_time_ms_ > 0 &&
+ clock_->TimeInMilliseconds() - last_packet_time_ms_ >
+ kNoPacketsThresholdMs)) {
+ capturer_->Start();
+ test_state_ = kWaitingForPaddingAfterCameraRestart;
+ }
return SEND_PACKET;
}
- test::PacketTransport* CreateReceiveTransport() override {
- test::PacketTransport* transport = new test::PacketTransport(
- nullptr, this, test::PacketTransport::kReceiver,
- FakeNetworkPipe::Config());
- transport_adapter_.reset(new internal::TransportAdapter(transport));
- transport_adapter_->Enable();
- return transport;
- }
-
size_t GetNumVideoStreams() const override { return 3; }
void OnFrameGeneratorCapturerCreated(
@@ -1016,6 +1015,14 @@ TEST_F(VideoSendStreamTest, NoPaddingWhenVideoIsMuted) {
<< "Timed out while waiting for RTP packets to stop being sent.";
}
+ enum TestState {
+ kBeforeStopCapture,
+ kWaitingForPadding,
+ kWaitingForNoPackets,
+ kWaitingForPaddingAfterCameraRestart
+ };
+
+ TestState test_state_ = kBeforeStopCapture;
Clock* const clock_;
std::unique_ptr<internal::TransportAdapter> transport_adapter_;
rtc::CriticalSection crit_;
« 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