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

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

Issue 1661923002: Re-enable RestartingSendStreamPreservesRtpState. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 | « tools/valgrind-webrtc/gtest_exclude/video_engine_tests.gtest-memcheck.txt ('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>
11 #include <list>
11 #include <map> 12 #include <map>
12 #include <sstream> 13 #include <sstream>
13 #include <string> 14 #include <string>
14 15
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
18 #include "webrtc/base/event.h" 19 #include "webrtc/base/event.h"
19 #include "webrtc/base/scoped_ptr.h" 20 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/call.h" 21 #include "webrtc/call.h"
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 private: 2929 private:
2929 size_t ssrcs_to_observe_; 2930 size_t ssrcs_to_observe_;
2930 std::map<uint32_t, bool> observed_redundant_retransmission_; 2931 std::map<uint32_t, bool> observed_redundant_retransmission_;
2931 std::map<uint32_t, bool> registered_rtx_ssrc_; 2932 std::map<uint32_t, bool> registered_rtx_ssrc_;
2932 } test; 2933 } test;
2933 2934
2934 RunBaseTest(&test); 2935 RunBaseTest(&test);
2935 } 2936 }
2936 2937
2937 void EndToEndTest::TestRtpStatePreservation(bool use_rtx) { 2938 void EndToEndTest::TestRtpStatePreservation(bool use_rtx) {
2938 static const uint32_t kMaxSequenceNumberGap = 100;
2939 static const uint64_t kMaxTimestampGap = kDefaultTimeoutMs * 90; 2939 static const uint64_t kMaxTimestampGap = kDefaultTimeoutMs * 90;
2940 class RtpSequenceObserver : public test::RtpRtcpObserver { 2940 class RtpSequenceObserver : public test::RtpRtcpObserver {
2941 public: 2941 public:
2942 explicit RtpSequenceObserver(bool use_rtx) 2942 explicit RtpSequenceObserver(bool use_rtx)
2943 : test::RtpRtcpObserver(kDefaultTimeoutMs), 2943 : test::RtpRtcpObserver(kDefaultTimeoutMs),
2944 ssrcs_to_observe_(kNumSsrcs) { 2944 ssrcs_to_observe_(kNumSsrcs) {
2945 for (size_t i = 0; i < kNumSsrcs; ++i) { 2945 for (size_t i = 0; i < kNumSsrcs; ++i) {
2946 configured_ssrcs_[kVideoSendSsrcs[i]] = true; 2946 configured_ssrcs_[kVideoSendSsrcs[i]] = true;
2947 if (use_rtx) 2947 if (use_rtx)
2948 configured_ssrcs_[kSendRtxSsrcs[i]] = true; 2948 configured_ssrcs_[kSendRtxSsrcs[i]] = true;
(...skipping 12 matching lines...) Expand all
2961 EXPECT_TRUE(parser_->Parse(packet, length, &header)); 2961 EXPECT_TRUE(parser_->Parse(packet, length, &header));
2962 const uint32_t ssrc = header.ssrc; 2962 const uint32_t ssrc = header.ssrc;
2963 const uint16_t sequence_number = header.sequenceNumber; 2963 const uint16_t sequence_number = header.sequenceNumber;
2964 const uint32_t timestamp = header.timestamp; 2964 const uint32_t timestamp = header.timestamp;
2965 const bool only_padding = 2965 const bool only_padding =
2966 header.headerLength + header.paddingLength == length; 2966 header.headerLength + header.paddingLength == length;
2967 2967
2968 EXPECT_TRUE(configured_ssrcs_[ssrc]) 2968 EXPECT_TRUE(configured_ssrcs_[ssrc])
2969 << "Received SSRC that wasn't configured: " << ssrc; 2969 << "Received SSRC that wasn't configured: " << ssrc;
2970 2970
2971 std::map<uint32_t, uint16_t>::iterator it = 2971 static const uint16_t kMaxSequenceNumberGap = 100;
2972 last_observed_sequence_number_.find(header.ssrc); 2972 std::list<uint16_t>& seq_numbers = last_observed_seq_numbers_[ssrc];
pbos-webrtc 2016/02/03 13:03:27 pointer instead of reference here please.
danilchap 2016/02/03 14:04:48 Done.
2973 if (it == last_observed_sequence_number_.end()) { 2973 if (seq_numbers.empty()) {
2974 last_observed_sequence_number_[ssrc] = sequence_number; 2974 seq_numbers.push_back(sequence_number);
2975 } else {
2976 // We shouldn't get replays of previous sequence numbers.
2977 for (uint16_t observed : seq_numbers) {
2978 EXPECT_NE(observed, sequence_number)
2979 << "Received sequence number " << sequence_number
2980 << " for SSRC " << ssrc << " 2nd time.";
2981 }
2982 // Verify sequence numbers are reasonably close.
pbos-webrtc 2016/02/03 13:03:27 There should be some timediff function that does t
danilchap 2016/02/03 14:04:48 Failed to find it. Thank you for pointing where it
2983 uint16_t latest_observed = seq_numbers.back();
2984 uint16_t diff = sequence_number - latest_observed;
2985 uint16_t abs_diff;
2986 if (diff < 0x8000) { // Positive difference.
2987 abs_diff = diff;
2988 } else { // Negative difference.
2989 abs_diff = (0xffff - diff) + 1;
2990 }
2991 EXPECT_LE(abs_diff, kMaxSequenceNumberGap)
2992 << "Gap in sequence numbers ("
2993 << latest_observed << " -> " << sequence_number
2994 << ") too large for SSRC: " << ssrc << ".";
2995 seq_numbers.push_back(sequence_number);
2996 if (seq_numbers.size() >= kMaxSequenceNumberGap) {
2997 seq_numbers.pop_front();
2998 }
2999 }
3000
3001 std::map<uint32_t, uint32_t>::iterator it =
3002 last_observed_timestamp_.find(ssrc);
3003 if (it == last_observed_timestamp_.end()) {
2975 last_observed_timestamp_[ssrc] = timestamp; 3004 last_observed_timestamp_[ssrc] = timestamp;
2976 } else { 3005 } else {
2977 // Verify sequence numbers are reasonably close.
2978 uint32_t extended_sequence_number = sequence_number;
2979 // Check for roll-over.
2980 if (sequence_number < last_observed_sequence_number_[ssrc])
2981 extended_sequence_number += 0xFFFFu + 1;
2982 EXPECT_LE(
2983 extended_sequence_number - last_observed_sequence_number_[ssrc],
2984 kMaxSequenceNumberGap)
2985 << "Gap in sequence numbers ("
2986 << last_observed_sequence_number_[ssrc] << " -> " << sequence_number
2987 << ") too large for SSRC: " << ssrc << ".";
2988 last_observed_sequence_number_[ssrc] = sequence_number;
2989
2990 // TODO(pbos): Remove this check if we ever have monotonically 3006 // TODO(pbos): Remove this check if we ever have monotonically
2991 // increasing timestamps. Right now padding packets add a delta which 3007 // increasing timestamps. Right now padding packets add a delta which
2992 // can cause reordering between padding packets and regular packets, 3008 // can cause reordering between padding packets and regular packets,
2993 // hence we drop padding-only packets to not flake. 3009 // hence we drop padding-only packets to not flake.
2994 if (only_padding) { 3010 if (only_padding) {
2995 // Verify that timestamps are reasonably close. 3011 // Verify that timestamps are reasonably close.
2996 uint64_t extended_timestamp = timestamp; 3012 uint64_t extended_timestamp = timestamp;
2997 // Check for roll-over. 3013 // Check for roll-over.
2998 if (timestamp < last_observed_timestamp_[ssrc]) 3014 if (timestamp < last_observed_timestamp_[ssrc])
2999 extended_timestamp += static_cast<uint64_t>(0xFFFFFFFFu) + 1; 3015 extended_timestamp += static_cast<uint64_t>(0xFFFFFFFFu) + 1;
3000 EXPECT_LE(extended_timestamp - last_observed_timestamp_[ssrc], 3016 EXPECT_LE(extended_timestamp - last_observed_timestamp_[ssrc],
3001 kMaxTimestampGap) 3017 kMaxTimestampGap)
3002 << "Gap in timestamps (" << last_observed_timestamp_[ssrc] 3018 << "Gap in timestamps (" << last_observed_timestamp_[ssrc]
3003 << " -> " << timestamp << ") too large for SSRC: " << ssrc << "."; 3019 << " -> " << timestamp << ") too large for SSRC: " << ssrc << ".";
3004 } 3020 }
3005 last_observed_timestamp_[ssrc] = timestamp; 3021 last_observed_timestamp_[ssrc] = timestamp;
3006 } 3022 }
3007 3023
3008 rtc::CritScope lock(&crit_); 3024 rtc::CritScope lock(&crit_);
3009 // Wait for media packets on all ssrcs. 3025 // Wait for media packets on all ssrcs.
3010 if (!ssrc_observed_[ssrc] && !only_padding) { 3026 if (!ssrc_observed_[ssrc] && !only_padding) {
3011 ssrc_observed_[ssrc] = true; 3027 ssrc_observed_[ssrc] = true;
3012 if (--ssrcs_to_observe_ == 0) 3028 if (--ssrcs_to_observe_ == 0)
3013 observation_complete_.Set(); 3029 observation_complete_.Set();
3014 } 3030 }
3015 3031
3016 return SEND_PACKET; 3032 return SEND_PACKET;
3017 } 3033 }
3018 3034
3019 std::map<uint32_t, uint16_t> last_observed_sequence_number_; 3035 std::map<uint32_t, std::list<uint16_t>> last_observed_seq_numbers_;
3020 std::map<uint32_t, uint32_t> last_observed_timestamp_; 3036 std::map<uint32_t, uint32_t> last_observed_timestamp_;
3021 std::map<uint32_t, bool> configured_ssrcs_; 3037 std::map<uint32_t, bool> configured_ssrcs_;
3022 3038
3023 rtc::CriticalSection crit_; 3039 rtc::CriticalSection crit_;
3024 size_t ssrcs_to_observe_ GUARDED_BY(crit_); 3040 size_t ssrcs_to_observe_ GUARDED_BY(crit_);
3025 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_); 3041 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_);
3026 } observer(use_rtx); 3042 } observer(use_rtx);
3027 3043
3028 CreateCalls(Call::Config(), Call::Config()); 3044 CreateCalls(Call::Config(), Call::Config());
3029 3045
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 << "Timed out waiting for all SSRCs to send packets."; 3124 << "Timed out waiting for all SSRCs to send packets.";
3109 } 3125 }
3110 3126
3111 send_transport.StopSending(); 3127 send_transport.StopSending();
3112 receive_transport.StopSending(); 3128 receive_transport.StopSending();
3113 3129
3114 Stop(); 3130 Stop();
3115 DestroyStreams(); 3131 DestroyStreams();
3116 } 3132 }
3117 3133
3118 TEST_F(EndToEndTest, DISABLED_RestartingSendStreamPreservesRtpState) { 3134 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpState) {
3119 TestRtpStatePreservation(false); 3135 TestRtpStatePreservation(false);
3120 } 3136 }
3121 3137
3122 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpStatesWithRtx) { 3138 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpStatesWithRtx) {
3123 TestRtpStatePreservation(true); 3139 TestRtpStatePreservation(true);
3124 } 3140 }
3125 3141
3126 TEST_F(EndToEndTest, RespectsNetworkState) { 3142 TEST_F(EndToEndTest, RespectsNetworkState) {
3127 // TODO(pbos): Remove accepted downtime packets etc. when signaling network 3143 // TODO(pbos): Remove accepted downtime packets etc. when signaling network
3128 // down blocks until no more packets will be sent. 3144 // down blocks until no more packets will be sent.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 private: 3515 private:
3500 bool video_observed_; 3516 bool video_observed_;
3501 bool audio_observed_; 3517 bool audio_observed_;
3502 SequenceNumberUnwrapper unwrapper_; 3518 SequenceNumberUnwrapper unwrapper_;
3503 std::set<int64_t> received_packet_ids_; 3519 std::set<int64_t> received_packet_ids_;
3504 } test; 3520 } test;
3505 3521
3506 RunBaseTest(&test); 3522 RunBaseTest(&test);
3507 } 3523 }
3508 } // namespace webrtc 3524 } // namespace webrtc
OLDNEW
« no previous file with comments | « tools/valgrind-webrtc/gtest_exclude/video_engine_tests.gtest-memcheck.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698