Add sanity checks to UpdateDelayStatistics and patch unit tests.
RtpPacket::UpdateDelayStatistics was previously optimized with several sanity checks added. These sanity checks caused many of the unit tests in peerconnection_integration_unittests to fail and the CL was therefore reverted. This CL contains the sanity checks along with patches so that the unit tests pass. Bug: webrtc:9439 Change-Id: Ia5f5e8b125e5f3f4b79d433e2282901143530a25 Reviewed-on: https://webrtc-review.googlesource.com/99802 Reviewed-by: Björn Terelius <terelius@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Commit-Queue: Johannes Kron <kron@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24813}
This commit is contained in:

committed by
Commit Bot

parent
bdbbc51b93
commit
965e7942a3
@ -15,13 +15,26 @@
|
||||
|
||||
namespace cricket {
|
||||
|
||||
FakeFrameSource::FakeFrameSource(int width, int height, int interval_us)
|
||||
: width_(width), height_(height), interval_us_(interval_us) {
|
||||
FakeFrameSource::FakeFrameSource(int width,
|
||||
int height,
|
||||
int interval_us,
|
||||
int64_t timestamp_offset_us)
|
||||
: width_(width),
|
||||
height_(height),
|
||||
interval_us_(interval_us),
|
||||
next_timestamp_us_(timestamp_offset_us) {
|
||||
RTC_CHECK_GT(width_, 0);
|
||||
RTC_CHECK_GT(height_, 0);
|
||||
RTC_CHECK_GT(interval_us_, 0);
|
||||
RTC_CHECK_GE(next_timestamp_us_, 0);
|
||||
}
|
||||
|
||||
FakeFrameSource::FakeFrameSource(int width, int height, int interval_us)
|
||||
: FakeFrameSource(width,
|
||||
height,
|
||||
interval_us,
|
||||
rtc::kNumMicrosecsPerMillisec) {}
|
||||
|
||||
webrtc::VideoRotation FakeFrameSource::GetRotation() const {
|
||||
return rotation_;
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ namespace cricket {
|
||||
|
||||
class FakeFrameSource {
|
||||
public:
|
||||
FakeFrameSource(int width,
|
||||
int height,
|
||||
int interval_us,
|
||||
int64_t timestamp_offset_us);
|
||||
FakeFrameSource(int width, int height, int interval_us);
|
||||
|
||||
webrtc::VideoRotation GetRotation() const;
|
||||
@ -39,7 +43,7 @@ class FakeFrameSource {
|
||||
const int interval_us_;
|
||||
|
||||
webrtc::VideoRotation rotation_ = webrtc::kVideoRotation_0;
|
||||
int64_t next_timestamp_us_ = rtc::kNumMicrosecsPerMillisec;
|
||||
int64_t next_timestamp_us_;
|
||||
};
|
||||
|
||||
} // namespace cricket
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "modules/rtp_rtcp/source/rtp_sender.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@ -1011,7 +1012,15 @@ void RTPSender::UpdateDelayStatistics(int64_t capture_time_ms, int64_t now_ms) {
|
||||
{
|
||||
rtc::CritScope cs(&statistics_crit_);
|
||||
// TODO(holmer): Compute this iteratively instead.
|
||||
send_delays_[now_ms] = now_ms - capture_time_ms;
|
||||
RTC_DCHECK_GE(now_ms, static_cast<int64_t>(0));
|
||||
RTC_DCHECK_LE(now_ms, std::numeric_limits<int64_t>::max() / 2);
|
||||
RTC_DCHECK_GE(capture_time_ms, static_cast<int64_t>(0));
|
||||
RTC_DCHECK_LE(capture_time_ms, std::numeric_limits<int64_t>::max() / 2);
|
||||
int64_t diff_ms = now_ms - capture_time_ms;
|
||||
RTC_DCHECK_GE(diff_ms, static_cast<int64_t>(0));
|
||||
RTC_DCHECK_LE(diff_ms,
|
||||
static_cast<int64_t>(std::numeric_limits<int>::max()));
|
||||
send_delays_[now_ms] = diff_ms;
|
||||
send_delays_.erase(
|
||||
send_delays_.begin(),
|
||||
send_delays_.lower_bound(now_ms - kSendSideDelayWindowMs));
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "rtc_base/fakenetwork.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "rtc_base/system/arch.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "rtc_base/virtualsocketserver.h"
|
||||
|
||||
namespace {
|
||||
@ -224,9 +225,11 @@ class OrtcFactoryIntegrationTest : public testing::Test {
|
||||
rtc::scoped_refptr<webrtc::VideoTrackInterface>
|
||||
CreateLocalVideoTrackAndFakeSource(const std::string& id,
|
||||
OrtcFactoryInterface* ortc_factory) {
|
||||
FakePeriodicVideoSource::Config config;
|
||||
config.timestamp_offset_ms = rtc::TimeMillis();
|
||||
fake_video_track_sources_.emplace_back(
|
||||
new rtc::RefCountedObject<FakePeriodicVideoTrackSource>(
|
||||
false /* remote */));
|
||||
config, false /* remote */));
|
||||
return rtc::scoped_refptr<VideoTrackInterface>(
|
||||
ortc_factory->CreateVideoTrack(id, fake_video_track_sources_.back()));
|
||||
}
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "rtc_base/numerics/safe_conversions.h"
|
||||
#include "rtc_base/testcertificateverifier.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
#include "rtc_base/virtualsocketserver.h"
|
||||
#include "system_wrappers/include/metrics_default.h"
|
||||
#include "test/gmock.h"
|
||||
@ -348,8 +349,9 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::VideoTrackInterface> CreateLocalVideoTrack() {
|
||||
return CreateLocalVideoTrackInternal(
|
||||
webrtc::FakePeriodicVideoSource::Config());
|
||||
webrtc::FakePeriodicVideoSource::Config config;
|
||||
config.timestamp_offset_ms = rtc::TimeMillis();
|
||||
return CreateLocalVideoTrackInternal(config);
|
||||
}
|
||||
|
||||
rtc::scoped_refptr<webrtc::VideoTrackInterface>
|
||||
@ -362,6 +364,7 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
|
||||
CreateLocalVideoTrackWithRotation(webrtc::VideoRotation rotation) {
|
||||
webrtc::FakePeriodicVideoSource::Config config;
|
||||
config.rotation = rotation;
|
||||
config.timestamp_offset_ms = rtc::TimeMillis();
|
||||
return CreateLocalVideoTrackInternal(config);
|
||||
}
|
||||
|
||||
@ -1836,6 +1839,7 @@ TEST_P(PeerConnectionIntegrationTest,
|
||||
webrtc::FakePeriodicVideoSource::Config config;
|
||||
config.width = 1280;
|
||||
config.height = 720;
|
||||
config.timestamp_offset_ms = rtc::TimeMillis();
|
||||
caller()->AddTrack(caller()->CreateLocalVideoTrackWithConfig(config));
|
||||
callee()->AddTrack(callee()->CreateLocalVideoTrackWithConfig(config));
|
||||
|
||||
|
@ -33,6 +33,7 @@ class FakePeriodicVideoSource final
|
||||
int height = kDefaultHeight;
|
||||
int frame_interval_ms = kDefaultFrameIntervalMs;
|
||||
VideoRotation rotation = kVideoRotation_0;
|
||||
int64_t timestamp_offset_ms = 0;
|
||||
};
|
||||
|
||||
FakePeriodicVideoSource() : FakePeriodicVideoSource(Config()) {}
|
||||
@ -67,7 +68,8 @@ class FakePeriodicVideoSource final
|
||||
frame_source_(
|
||||
config.width,
|
||||
config.height,
|
||||
config.frame_interval_ms * rtc::kNumMicrosecsPerMillisec),
|
||||
config.frame_interval_ms * rtc::kNumMicrosecsPerMillisec,
|
||||
config.timestamp_offset_ms * rtc::kNumMicrosecsPerMillisec),
|
||||
broadcaster_(broadcaster) {
|
||||
frame_source_.SetRotation(config.rotation);
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "pc/test/mockpeerconnectionobservers.h"
|
||||
#include "pc/test/peerconnectiontestwrapper.h"
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "rtc_base/timeutils.h"
|
||||
|
||||
using webrtc::FakeConstraints;
|
||||
using webrtc::FakeVideoTrackRenderer;
|
||||
@ -287,6 +288,7 @@ PeerConnectionTestWrapper::GetUserMedia(
|
||||
// Set max frame rate to 10fps to reduce the risk of the tests to be flaky.
|
||||
webrtc::FakePeriodicVideoSource::Config config;
|
||||
config.frame_interval_ms = 100;
|
||||
config.timestamp_offset_ms = rtc::TimeMillis();
|
||||
|
||||
rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> source =
|
||||
new rtc::RefCountedObject<webrtc::FakePeriodicVideoTrackSource>(
|
||||
|
Reference in New Issue
Block a user