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

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

Issue 2177523002: Fix issues with RestartingSendStreamPreservesRtpStatesWithRtx (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 4 years, 4 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/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | no next file » | 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> 10 #include <algorithm>
(...skipping 3044 matching lines...) Expand 10 before | Expand all | Expand 10 after
3055 } 3055 }
3056 3056
3057 void EndToEndTest::TestRtpStatePreservation(bool use_rtx, 3057 void EndToEndTest::TestRtpStatePreservation(bool use_rtx,
3058 bool provoke_rtcpsr_before_rtp) { 3058 bool provoke_rtcpsr_before_rtp) {
3059 class RtpSequenceObserver : public test::RtpRtcpObserver { 3059 class RtpSequenceObserver : public test::RtpRtcpObserver {
3060 public: 3060 public:
3061 explicit RtpSequenceObserver(bool use_rtx) 3061 explicit RtpSequenceObserver(bool use_rtx)
3062 : test::RtpRtcpObserver(kDefaultTimeoutMs), 3062 : test::RtpRtcpObserver(kDefaultTimeoutMs),
3063 ssrcs_to_observe_(kNumSsrcs) { 3063 ssrcs_to_observe_(kNumSsrcs) {
3064 for (size_t i = 0; i < kNumSsrcs; ++i) { 3064 for (size_t i = 0; i < kNumSsrcs; ++i) {
3065 configured_ssrcs_[kVideoSendSsrcs[i]] = true; 3065 ssrc_is_rtx_[kVideoSendSsrcs[i]] = false;
3066 if (use_rtx) 3066 if (use_rtx)
3067 configured_ssrcs_[kSendRtxSsrcs[i]] = true; 3067 ssrc_is_rtx_[kSendRtxSsrcs[i]] = true;
3068 } 3068 }
3069 } 3069 }
3070 3070
3071 void ResetExpectedSsrcs(size_t num_expected_ssrcs) { 3071 void ResetExpectedSsrcs(size_t num_expected_ssrcs) {
3072 rtc::CritScope lock(&crit_); 3072 rtc::CritScope lock(&crit_);
3073 ssrc_observed_.clear(); 3073 ssrc_observed_.clear();
3074 ssrcs_to_observe_ = num_expected_ssrcs; 3074 ssrcs_to_observe_ = num_expected_ssrcs;
3075 } 3075 }
3076 3076
3077 private: 3077 private:
(...skipping 22 matching lines...) Expand all
3100 Action OnSendRtp(const uint8_t* packet, size_t length) override { 3100 Action OnSendRtp(const uint8_t* packet, size_t length) override {
3101 RTPHeader header; 3101 RTPHeader header;
3102 EXPECT_TRUE(parser_->Parse(packet, length, &header)); 3102 EXPECT_TRUE(parser_->Parse(packet, length, &header));
3103 const uint32_t ssrc = header.ssrc; 3103 const uint32_t ssrc = header.ssrc;
3104 const int64_t sequence_number = 3104 const int64_t sequence_number =
3105 seq_numbers_unwrapper_.Unwrap(header.sequenceNumber); 3105 seq_numbers_unwrapper_.Unwrap(header.sequenceNumber);
3106 const uint32_t timestamp = header.timestamp; 3106 const uint32_t timestamp = header.timestamp;
3107 const bool only_padding = 3107 const bool only_padding =
3108 header.headerLength + header.paddingLength == length; 3108 header.headerLength + header.paddingLength == length;
3109 3109
3110 EXPECT_TRUE(configured_ssrcs_[ssrc]) 3110 EXPECT_TRUE(ssrc_is_rtx_.find(ssrc) != ssrc_is_rtx_.end())
3111 << "Received SSRC that wasn't configured: " << ssrc; 3111 << "Received SSRC that wasn't configured: " << ssrc;
3112 3112
3113 static const int64_t kMaxSequenceNumberGap = 100; 3113 static const int64_t kMaxSequenceNumberGap = 100;
3114 std::list<int64_t>* seq_numbers = &last_observed_seq_numbers_[ssrc]; 3114 std::list<int64_t>* seq_numbers = &last_observed_seq_numbers_[ssrc];
3115 if (seq_numbers->empty()) { 3115 if (seq_numbers->empty()) {
3116 seq_numbers->push_back(sequence_number); 3116 seq_numbers->push_back(sequence_number);
3117 } else { 3117 } else {
3118 // We shouldn't get replays of previous sequence numbers. 3118 // We shouldn't get replays of previous sequence numbers.
3119 for (int64_t observed : *seq_numbers) { 3119 for (int64_t observed : *seq_numbers) {
3120 EXPECT_NE(observed, sequence_number) 3120 EXPECT_NE(observed, sequence_number)
3121 << "Received sequence number " << sequence_number 3121 << "Received sequence number " << sequence_number
3122 << " for SSRC " << ssrc << " 2nd time."; 3122 << " for SSRC " << ssrc << " 2nd time.";
3123 } 3123 }
3124 // Verify sequence numbers are reasonably close. 3124 // Verify sequence numbers are reasonably close.
3125 int64_t latest_observed = seq_numbers->back(); 3125 int64_t latest_observed = seq_numbers->back();
3126 int64_t sequence_number_gap = sequence_number - latest_observed; 3126 int64_t sequence_number_gap = sequence_number - latest_observed;
3127 EXPECT_LE(std::abs(sequence_number_gap), kMaxSequenceNumberGap) 3127 EXPECT_LE(std::abs(sequence_number_gap), kMaxSequenceNumberGap)
3128 << "Gap in sequence numbers (" << latest_observed << " -> " 3128 << "Gap in sequence numbers (" << latest_observed << " -> "
3129 << sequence_number << ") too large for SSRC: " << ssrc << "."; 3129 << sequence_number << ") too large for SSRC: " << ssrc << ".";
3130 seq_numbers->push_back(sequence_number); 3130 seq_numbers->push_back(sequence_number);
3131 if (seq_numbers->size() >= kMaxSequenceNumberGap) { 3131 if (seq_numbers->size() >= kMaxSequenceNumberGap) {
3132 seq_numbers->pop_front(); 3132 seq_numbers->pop_front();
3133 } 3133 }
3134 } 3134 }
3135 3135
3136 rtc::CritScope lock(&crit_); 3136 if (!ssrc_is_rtx_[ssrc]) {
3137 ValidateTimestampGap(ssrc, timestamp, only_padding); 3137 rtc::CritScope lock(&crit_);
3138 ValidateTimestampGap(ssrc, timestamp, only_padding);
3138 3139
3139 // Wait for media packets on all ssrcs. 3140 // Wait for media packets on all ssrcs.
3140 if (!ssrc_observed_[ssrc] && !only_padding) { 3141 if (!ssrc_observed_[ssrc] && !only_padding) {
3141 ssrc_observed_[ssrc] = true; 3142 ssrc_observed_[ssrc] = true;
3142 if (--ssrcs_to_observe_ == 0) 3143 if (--ssrcs_to_observe_ == 0)
3143 observation_complete_.Set(); 3144 observation_complete_.Set();
3145 }
3144 } 3146 }
3145 3147
3146 return SEND_PACKET; 3148 return SEND_PACKET;
3147 } 3149 }
3148 3150
3149 Action OnSendRtcp(const uint8_t* packet, size_t length) override { 3151 Action OnSendRtcp(const uint8_t* packet, size_t length) override {
3150 test::RtcpPacketParser rtcp_parser; 3152 test::RtcpPacketParser rtcp_parser;
3151 rtcp_parser.Parse(packet, length); 3153 rtcp_parser.Parse(packet, length);
3152 if (rtcp_parser.sender_report()->num_packets() > 0) { 3154 if (rtcp_parser.sender_report()->num_packets() > 0) {
3153 uint32_t ssrc = rtcp_parser.sender_report()->Ssrc(); 3155 uint32_t ssrc = rtcp_parser.sender_report()->Ssrc();
3154 uint32_t rtcp_timestamp = rtcp_parser.sender_report()->RtpTimestamp(); 3156 uint32_t rtcp_timestamp = rtcp_parser.sender_report()->RtpTimestamp();
3155 3157
3156 rtc::CritScope lock(&crit_); 3158 rtc::CritScope lock(&crit_);
3157 ValidateTimestampGap(ssrc, rtcp_timestamp, false); 3159 ValidateTimestampGap(ssrc, rtcp_timestamp, false);
3158 } 3160 }
3159 return SEND_PACKET; 3161 return SEND_PACKET;
3160 } 3162 }
3161 3163
3162 SequenceNumberUnwrapper seq_numbers_unwrapper_; 3164 SequenceNumberUnwrapper seq_numbers_unwrapper_;
3163 std::map<uint32_t, std::list<int64_t>> last_observed_seq_numbers_; 3165 std::map<uint32_t, std::list<int64_t>> last_observed_seq_numbers_;
3164 std::map<uint32_t, uint32_t> last_observed_timestamp_; 3166 std::map<uint32_t, uint32_t> last_observed_timestamp_;
3165 std::map<uint32_t, bool> configured_ssrcs_; 3167 std::map<uint32_t, bool> ssrc_is_rtx_;
3166 3168
3167 rtc::CriticalSection crit_; 3169 rtc::CriticalSection crit_;
3168 size_t ssrcs_to_observe_ GUARDED_BY(crit_); 3170 size_t ssrcs_to_observe_ GUARDED_BY(crit_);
3169 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_); 3171 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_);
3170 } observer(use_rtx); 3172 } observer(use_rtx);
3171 3173
3172 CreateCalls(Call::Config(), Call::Config()); 3174 CreateCalls(Call::Config(), Call::Config());
3173 3175
3174 test::PacketTransport send_transport(sender_call_.get(), &observer, 3176 test::PacketTransport send_transport(sender_call_.get(), &observer,
3175 test::PacketTransport::kSender, 3177 test::PacketTransport::kSender,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3265 receive_transport.StopSending(); 3267 receive_transport.StopSending();
3266 3268
3267 Stop(); 3269 Stop();
3268 DestroyStreams(); 3270 DestroyStreams();
3269 } 3271 }
3270 3272
3271 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpState) { 3273 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpState) {
3272 TestRtpStatePreservation(false, false); 3274 TestRtpStatePreservation(false, false);
3273 } 3275 }
3274 3276
3275 // These tests are flaky. See: 3277 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpStatesWithRtx) {
3276 // https://bugs.chromium.org/p/webrtc/issues/detail?id=4332
3277 TEST_F(EndToEndTest, DISABLED_RestartingSendStreamPreservesRtpStatesWithRtx) {
3278 TestRtpStatePreservation(true, false); 3278 TestRtpStatePreservation(true, false);
3279 } 3279 }
3280 3280
3281 TEST_F(EndToEndTest, 3281 TEST_F(EndToEndTest, RestartingSendStreamKeepsRtpAndRtcpTimestampsSynced) {
3282 DISABLED_RestartingSendStreamKeepsRtpAndRtcpTimestampsSynced) {
3283 TestRtpStatePreservation(true, true); 3282 TestRtpStatePreservation(true, true);
3284 } 3283 }
3285 3284
3286 TEST_F(EndToEndTest, RespectsNetworkState) { 3285 TEST_F(EndToEndTest, RespectsNetworkState) {
3287 // TODO(pbos): Remove accepted downtime packets etc. when signaling network 3286 // TODO(pbos): Remove accepted downtime packets etc. when signaling network
3288 // down blocks until no more packets will be sent. 3287 // down blocks until no more packets will be sent.
3289 3288
3290 // Pacer will send from its packet list and then send required padding before 3289 // Pacer will send from its packet list and then send required padding before
3291 // checking paused_ again. This should be enough for one round of pacing, 3290 // checking paused_ again. This should be enough for one round of pacing,
3292 // otherwise increase. 3291 // otherwise increase.
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
3732 private: 3731 private:
3733 bool video_observed_; 3732 bool video_observed_;
3734 bool audio_observed_; 3733 bool audio_observed_;
3735 SequenceNumberUnwrapper unwrapper_; 3734 SequenceNumberUnwrapper unwrapper_;
3736 std::set<int64_t> received_packet_ids_; 3735 std::set<int64_t> received_packet_ids_;
3737 } test; 3736 } test;
3738 3737
3739 RunBaseTest(&test); 3738 RunBaseTest(&test);
3740 } 3739 }
3741 } // namespace webrtc 3740 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtp_sender_video.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698