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

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: allowed timestamp gap to be negative too 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"
21 #include "webrtc/base/timeutils.h"
20 #include "webrtc/call.h" 22 #include "webrtc/call.h"
21 #include "webrtc/call/transport_adapter.h" 23 #include "webrtc/call/transport_adapter.h"
22 #include "webrtc/frame_callback.h" 24 #include "webrtc/frame_callback.h"
25 #include "webrtc/modules/include/module_common_types.h"
23 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
24 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 27 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
25 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" 28 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
26 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 29 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
27 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h" 30 #include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
28 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" 31 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
29 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 32 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
30 #include "webrtc/system_wrappers/include/metrics.h" 33 #include "webrtc/system_wrappers/include/metrics.h"
31 #include "webrtc/system_wrappers/include/sleep.h" 34 #include "webrtc/system_wrappers/include/sleep.h"
32 #include "webrtc/test/call_test.h" 35 #include "webrtc/test/call_test.h"
(...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after
2928 private: 2931 private:
2929 size_t ssrcs_to_observe_; 2932 size_t ssrcs_to_observe_;
2930 std::map<uint32_t, bool> observed_redundant_retransmission_; 2933 std::map<uint32_t, bool> observed_redundant_retransmission_;
2931 std::map<uint32_t, bool> registered_rtx_ssrc_; 2934 std::map<uint32_t, bool> registered_rtx_ssrc_;
2932 } test; 2935 } test;
2933 2936
2934 RunBaseTest(&test); 2937 RunBaseTest(&test);
2935 } 2938 }
2936 2939
2937 void EndToEndTest::TestRtpStatePreservation(bool use_rtx) { 2940 void EndToEndTest::TestRtpStatePreservation(bool use_rtx) {
2938 static const uint32_t kMaxSequenceNumberGap = 100;
2939 static const uint64_t kMaxTimestampGap = kDefaultTimeoutMs * 90;
2940 class RtpSequenceObserver : public test::RtpRtcpObserver { 2941 class RtpSequenceObserver : public test::RtpRtcpObserver {
2941 public: 2942 public:
2942 explicit RtpSequenceObserver(bool use_rtx) 2943 explicit RtpSequenceObserver(bool use_rtx)
2943 : test::RtpRtcpObserver(kDefaultTimeoutMs), 2944 : test::RtpRtcpObserver(kDefaultTimeoutMs),
2944 ssrcs_to_observe_(kNumSsrcs) { 2945 ssrcs_to_observe_(kNumSsrcs) {
2945 for (size_t i = 0; i < kNumSsrcs; ++i) { 2946 for (size_t i = 0; i < kNumSsrcs; ++i) {
2946 configured_ssrcs_[kVideoSendSsrcs[i]] = true; 2947 configured_ssrcs_[kVideoSendSsrcs[i]] = true;
2947 if (use_rtx) 2948 if (use_rtx)
2948 configured_ssrcs_[kSendRtxSsrcs[i]] = true; 2949 configured_ssrcs_[kSendRtxSsrcs[i]] = true;
2949 } 2950 }
2950 } 2951 }
2951 2952
2952 void ResetExpectedSsrcs(size_t num_expected_ssrcs) { 2953 void ResetExpectedSsrcs(size_t num_expected_ssrcs) {
2953 rtc::CritScope lock(&crit_); 2954 rtc::CritScope lock(&crit_);
2954 ssrc_observed_.clear(); 2955 ssrc_observed_.clear();
2955 ssrcs_to_observe_ = num_expected_ssrcs; 2956 ssrcs_to_observe_ = num_expected_ssrcs;
2956 } 2957 }
2957 2958
2958 private: 2959 private:
2959 Action OnSendRtp(const uint8_t* packet, size_t length) override { 2960 Action OnSendRtp(const uint8_t* packet, size_t length) override {
2960 RTPHeader header; 2961 RTPHeader header;
2961 EXPECT_TRUE(parser_->Parse(packet, length, &header)); 2962 EXPECT_TRUE(parser_->Parse(packet, length, &header));
2962 const uint32_t ssrc = header.ssrc; 2963 const uint32_t ssrc = header.ssrc;
2963 const uint16_t sequence_number = header.sequenceNumber; 2964 const int64_t sequence_number =
2965 seq_numbers_unwrapper_.Unwrap(header.sequenceNumber);
2964 const uint32_t timestamp = header.timestamp; 2966 const uint32_t timestamp = header.timestamp;
2965 const bool only_padding = 2967 const bool only_padding =
2966 header.headerLength + header.paddingLength == length; 2968 header.headerLength + header.paddingLength == length;
2967 2969
2968 EXPECT_TRUE(configured_ssrcs_[ssrc]) 2970 EXPECT_TRUE(configured_ssrcs_[ssrc])
2969 << "Received SSRC that wasn't configured: " << ssrc; 2971 << "Received SSRC that wasn't configured: " << ssrc;
2970 2972
2971 std::map<uint32_t, uint16_t>::iterator it = 2973 static const int64_t kMaxSequenceNumberGap = 100;
2972 last_observed_sequence_number_.find(header.ssrc); 2974 std::list<int64_t>* seq_numbers = &last_observed_seq_numbers_[ssrc];
2973 if (it == last_observed_sequence_number_.end()) { 2975 if (seq_numbers->empty()) {
2974 last_observed_sequence_number_[ssrc] = sequence_number; 2976 seq_numbers->push_back(sequence_number);
2977 } else {
2978 // We shouldn't get replays of previous sequence numbers.
2979 for (int64_t observed : *seq_numbers) {
2980 EXPECT_NE(observed, sequence_number)
2981 << "Received sequence number " << sequence_number
2982 << " for SSRC " << ssrc << " 2nd time.";
2983 }
2984 // Verify sequence numbers are reasonably close.
2985 int64_t latest_observed = seq_numbers->back();
2986 int64_t sequence_number_gap = sequence_number - latest_observed;
2987 EXPECT_LE(std::abs(sequence_number_gap), kMaxSequenceNumberGap)
2988 << "Gap in sequence numbers (" << latest_observed << " -> "
2989 << sequence_number << ") too large for SSRC: " << ssrc << ".";
2990 seq_numbers->push_back(sequence_number);
2991 if (seq_numbers->size() >= kMaxSequenceNumberGap) {
2992 seq_numbers->pop_front();
2993 }
2994 }
2995
2996 static const int32_t kMaxTimestampGap = kDefaultTimeoutMs * 90;
2997 auto timestamp_it = last_observed_timestamp_.find(ssrc);
2998 if (timestamp_it == last_observed_timestamp_.end()) {
2975 last_observed_timestamp_[ssrc] = timestamp; 2999 last_observed_timestamp_[ssrc] = timestamp;
2976 } else { 3000 } else {
2977 // Verify sequence numbers are reasonably close. 3001 // Verify timestamps are reasonably close.
2978 uint32_t extended_sequence_number = sequence_number; 3002 uint32_t latest_observed = timestamp_it->second;
2979 // Check for roll-over. 3003 int32_t timestamp_gap = rtc::TimeDiff(timestamp, latest_observed);
2980 if (sequence_number < last_observed_sequence_number_[ssrc]) 3004 EXPECT_LE(std::abs(timestamp_gap), kMaxTimestampGap)
2981 extended_sequence_number += 0xFFFFu + 1; 3005 << "Gap in timestamps (" << latest_observed << " -> "
2982 EXPECT_LE( 3006 << timestamp << ") too large for SSRC: " << ssrc << ".";
2983 extended_sequence_number - last_observed_sequence_number_[ssrc], 3007 timestamp_it->second = timestamp;
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
2991 // increasing timestamps. Right now padding packets add a delta which
2992 // can cause reordering between padding packets and regular packets,
2993 // hence we drop padding-only packets to not flake.
2994 if (only_padding) {
2995 // Verify that timestamps are reasonably close.
2996 uint64_t extended_timestamp = timestamp;
2997 // Check for roll-over.
2998 if (timestamp < last_observed_timestamp_[ssrc])
2999 extended_timestamp += static_cast<uint64_t>(0xFFFFFFFFu) + 1;
3000 EXPECT_LE(extended_timestamp - last_observed_timestamp_[ssrc],
3001 kMaxTimestampGap)
3002 << "Gap in timestamps (" << last_observed_timestamp_[ssrc]
3003 << " -> " << timestamp << ") too large for SSRC: " << ssrc << ".";
3004 }
3005 last_observed_timestamp_[ssrc] = timestamp;
3006 } 3008 }
3007 3009
3008 rtc::CritScope lock(&crit_); 3010 rtc::CritScope lock(&crit_);
3009 // Wait for media packets on all ssrcs. 3011 // Wait for media packets on all ssrcs.
3010 if (!ssrc_observed_[ssrc] && !only_padding) { 3012 if (!ssrc_observed_[ssrc] && !only_padding) {
3011 ssrc_observed_[ssrc] = true; 3013 ssrc_observed_[ssrc] = true;
3012 if (--ssrcs_to_observe_ == 0) 3014 if (--ssrcs_to_observe_ == 0)
3013 observation_complete_.Set(); 3015 observation_complete_.Set();
3014 } 3016 }
3015 3017
3016 return SEND_PACKET; 3018 return SEND_PACKET;
3017 } 3019 }
3018 3020
3019 std::map<uint32_t, uint16_t> last_observed_sequence_number_; 3021 SequenceNumberUnwrapper seq_numbers_unwrapper_;
3022 std::map<uint32_t, std::list<int64_t>> last_observed_seq_numbers_;
3020 std::map<uint32_t, uint32_t> last_observed_timestamp_; 3023 std::map<uint32_t, uint32_t> last_observed_timestamp_;
3021 std::map<uint32_t, bool> configured_ssrcs_; 3024 std::map<uint32_t, bool> configured_ssrcs_;
3022 3025
3023 rtc::CriticalSection crit_; 3026 rtc::CriticalSection crit_;
3024 size_t ssrcs_to_observe_ GUARDED_BY(crit_); 3027 size_t ssrcs_to_observe_ GUARDED_BY(crit_);
3025 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_); 3028 std::map<uint32_t, bool> ssrc_observed_ GUARDED_BY(crit_);
3026 } observer(use_rtx); 3029 } observer(use_rtx);
3027 3030
3028 CreateCalls(Call::Config(), Call::Config()); 3031 CreateCalls(Call::Config(), Call::Config());
3029 3032
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
3108 << "Timed out waiting for all SSRCs to send packets."; 3111 << "Timed out waiting for all SSRCs to send packets.";
3109 } 3112 }
3110 3113
3111 send_transport.StopSending(); 3114 send_transport.StopSending();
3112 receive_transport.StopSending(); 3115 receive_transport.StopSending();
3113 3116
3114 Stop(); 3117 Stop();
3115 DestroyStreams(); 3118 DestroyStreams();
3116 } 3119 }
3117 3120
3118 TEST_F(EndToEndTest, DISABLED_RestartingSendStreamPreservesRtpState) { 3121 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpState) {
3119 TestRtpStatePreservation(false); 3122 TestRtpStatePreservation(false);
3120 } 3123 }
3121 3124
3122 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpStatesWithRtx) { 3125 TEST_F(EndToEndTest, RestartingSendStreamPreservesRtpStatesWithRtx) {
3123 TestRtpStatePreservation(true); 3126 TestRtpStatePreservation(true);
3124 } 3127 }
3125 3128
3126 TEST_F(EndToEndTest, RespectsNetworkState) { 3129 TEST_F(EndToEndTest, RespectsNetworkState) {
3127 // TODO(pbos): Remove accepted downtime packets etc. when signaling network 3130 // TODO(pbos): Remove accepted downtime packets etc. when signaling network
3128 // down blocks until no more packets will be sent. 3131 // down blocks until no more packets will be sent.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3499 private: 3502 private:
3500 bool video_observed_; 3503 bool video_observed_;
3501 bool audio_observed_; 3504 bool audio_observed_;
3502 SequenceNumberUnwrapper unwrapper_; 3505 SequenceNumberUnwrapper unwrapper_;
3503 std::set<int64_t> received_packet_ids_; 3506 std::set<int64_t> received_packet_ids_;
3504 } test; 3507 } test;
3505 3508
3506 RunBaseTest(&test); 3509 RunBaseTest(&test);
3507 } 3510 }
3508 } // namespace webrtc 3511 } // 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