| 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 804 // 2. As soon as the RTP stream has been detected, signal a low REMB value to | 804 // 2. As soon as the RTP stream has been detected, signal a low REMB value to |
| 805 // suspend the stream. | 805 // suspend the stream. |
| 806 // 3. Wait until |kSuspendTimeFrames| have been captured without seeing any RTP | 806 // 3. Wait until |kSuspendTimeFrames| have been captured without seeing any RTP |
| 807 // packets. | 807 // packets. |
| 808 // 4. Signal a high REMB and then wait for the RTP stream to start again. | 808 // 4. Signal a high REMB and then wait for the RTP stream to start again. |
| 809 // When the stream is detected again, and the stats show that the stream | 809 // When the stream is detected again, and the stats show that the stream |
| 810 // is no longer suspended, the test ends. | 810 // is no longer suspended, the test ends. |
| 811 TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { | 811 TEST_F(VideoSendStreamTest, SuspendBelowMinBitrate) { |
| 812 static const int kSuspendTimeFrames = 60; // Suspend for 2 seconds @ 30 fps. | 812 static const int kSuspendTimeFrames = 60; // Suspend for 2 seconds @ 30 fps. |
| 813 | 813 |
| 814 class RembObserver : public test::SendTest, public I420FrameCallback { | 814 class RembObserver : public test::SendTest, |
| 815 public rtc::VideoSinkInterface<VideoFrame> { |
| 815 public: | 816 public: |
| 816 RembObserver() | 817 RembObserver() |
| 817 : SendTest(kDefaultTimeoutMs), | 818 : SendTest(kDefaultTimeoutMs), |
| 818 clock_(Clock::GetRealTimeClock()), | 819 clock_(Clock::GetRealTimeClock()), |
| 819 test_state_(kBeforeSuspend), | 820 test_state_(kBeforeSuspend), |
| 820 rtp_count_(0), | 821 rtp_count_(0), |
| 821 last_sequence_number_(0), | 822 last_sequence_number_(0), |
| 822 suspended_frame_count_(0), | 823 suspended_frame_count_(0), |
| 823 low_remb_bps_(0), | 824 low_remb_bps_(0), |
| 824 high_remb_bps_(0) { | 825 high_remb_bps_(0) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 855 if (stats.suspended == false) { | 856 if (stats.suspended == false) { |
| 856 // Stats flipped to false. Test is complete. | 857 // Stats flipped to false. Test is complete. |
| 857 observation_complete_.Set(); | 858 observation_complete_.Set(); |
| 858 } | 859 } |
| 859 SendRtcpFeedback(0); // REMB is only sent if value is > 0. | 860 SendRtcpFeedback(0); // REMB is only sent if value is > 0. |
| 860 } | 861 } |
| 861 | 862 |
| 862 return SEND_PACKET; | 863 return SEND_PACKET; |
| 863 } | 864 } |
| 864 | 865 |
| 865 // This method implements the I420FrameCallback. | 866 // This method implements the rtc::VideoSinkInterface |
| 866 void FrameCallback(VideoFrame* video_frame) override { | 867 void OnFrame(const VideoFrame& video_frame) override { |
| 867 rtc::CritScope lock(&crit_); | 868 rtc::CritScope lock(&crit_); |
| 868 if (test_state_ == kDuringSuspend && | 869 if (test_state_ == kDuringSuspend && |
| 869 ++suspended_frame_count_ > kSuspendTimeFrames) { | 870 ++suspended_frame_count_ > kSuspendTimeFrames) { |
| 870 VideoSendStream::Stats stats = stream_->GetStats(); | 871 VideoSendStream::Stats stats = stream_->GetStats(); |
| 871 EXPECT_TRUE(stats.suspended); | 872 EXPECT_TRUE(stats.suspended); |
| 872 SendRtcpFeedback(high_remb_bps_); | 873 SendRtcpFeedback(high_remb_bps_); |
| 873 test_state_ = kWaitingForPacket; | 874 test_state_ = kWaitingForPacket; |
| 874 } | 875 } |
| 875 } | 876 } |
| 876 | 877 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 // New bitrate should be reconfigured above the previous max. As there's no | 1166 // New bitrate should be reconfigured above the previous max. As there's no |
| 1166 // network connection this shouldn't be flaky, as no bitrate should've been | 1167 // network connection this shouldn't be flaky, as no bitrate should've been |
| 1167 // reported in between. | 1168 // reported in between. |
| 1168 EXPECT_EQ(bitrate_config.start_bitrate_bps / 1000, | 1169 EXPECT_EQ(bitrate_config.start_bitrate_bps / 1000, |
| 1169 encoder.GetStartBitrateKbps()); | 1170 encoder.GetStartBitrateKbps()); |
| 1170 | 1171 |
| 1171 DestroyStreams(); | 1172 DestroyStreams(); |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1174 TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) { | 1175 TEST_F(VideoSendStreamTest, CapturesTextureAndVideoFrames) { |
| 1175 class FrameObserver : public I420FrameCallback { | 1176 class FrameObserver : public rtc::VideoSinkInterface<VideoFrame> { |
| 1176 public: | 1177 public: |
| 1177 FrameObserver() : output_frame_event_(false, false) {} | 1178 FrameObserver() : output_frame_event_(false, false) {} |
| 1178 | 1179 |
| 1179 void FrameCallback(VideoFrame* video_frame) override { | 1180 void OnFrame(const VideoFrame& video_frame) override { |
| 1180 output_frames_.push_back(*video_frame); | 1181 output_frames_.push_back(video_frame); |
| 1181 output_frame_event_.Set(); | 1182 output_frame_event_.Set(); |
| 1182 } | 1183 } |
| 1183 | 1184 |
| 1184 void WaitOutputFrame() { | 1185 void WaitOutputFrame() { |
| 1185 const int kWaitFrameTimeoutMs = 3000; | 1186 const int kWaitFrameTimeoutMs = 3000; |
| 1186 EXPECT_TRUE(output_frame_event_.Wait(kWaitFrameTimeoutMs)) | 1187 EXPECT_TRUE(output_frame_event_.Wait(kWaitFrameTimeoutMs)) |
| 1187 << "Timeout while waiting for output frames."; | 1188 << "Timeout while waiting for output frames."; |
| 1188 } | 1189 } |
| 1189 | 1190 |
| 1190 const std::vector<VideoFrame>& output_frames() const { | 1191 const std::vector<VideoFrame>& output_frames() const { |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 observation_complete_.Set(); | 2313 observation_complete_.Set(); |
| 2313 } | 2314 } |
| 2314 } | 2315 } |
| 2315 } test; | 2316 } test; |
| 2316 | 2317 |
| 2317 RunBaseTest(&test); | 2318 RunBaseTest(&test); |
| 2318 } | 2319 } |
| 2319 #endif | 2320 #endif |
| 2320 | 2321 |
| 2321 } // namespace webrtc | 2322 } // namespace webrtc |
| OLD | NEW |