Per default endable reading incoming packet timestamp from socket

This cl per default enable the experiment WebRTC-SCM-Timestamp but
leaves the wiring in place for now to explictly allow disabling it.

Bug: webrtc:5773, webrtc:14066
Change-Id: I6118eef73384791ab4d1377e35d36435dc4fa0e8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/298442
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39624}
This commit is contained in:
Per K 2023-03-21 14:10:44 +01:00 committed by WebRTC LUCI CQ
parent 016bd7514d
commit 7efd372f02
3 changed files with 19 additions and 23 deletions

View File

@ -23,10 +23,10 @@
namespace rtc { namespace rtc {
// Returns true if the the client is in the experiment to get timestamps // Returns true if the experiement "WebRTC-SCM-Timestamp" is explicitly
// from the socket implementation. // disabled.
static bool IsScmTimeStampExperimentEnabled() { static bool IsScmTimeStampExperimentDisabled() {
return webrtc::field_trial::IsEnabled("WebRTC-SCM-Timestamp"); return webrtc::field_trial::IsDisabled("WebRTC-SCM-Timestamp");
} }
AsyncUDPSocket* AsyncUDPSocket::Create(Socket* socket, AsyncUDPSocket* AsyncUDPSocket::Create(Socket* socket,
@ -133,7 +133,7 @@ void AsyncUDPSocket::OnReadEvent(Socket* socket) {
} else { } else {
if (!socket_time_offset_) { if (!socket_time_offset_) {
socket_time_offset_ = socket_time_offset_ =
IsScmTimeStampExperimentEnabled() ? TimeMicros() - timestamp : 0; !IsScmTimeStampExperimentDisabled() ? TimeMicros() - timestamp : 0;
} }
timestamp += *socket_time_offset_; timestamp += *socket_time_offset_;
} }

View File

@ -122,10 +122,10 @@ class ScopedSetTrue {
bool* value_; bool* value_;
}; };
// Returns true if the the client is in the experiment to get timestamps // Returns true if the experiement "WebRTC-SCM-Timestamp" is explicitly
// from the socket implementation. // disabled.
bool IsScmTimeStampExperimentEnabled() { bool IsScmTimeStampExperimentDisabled() {
return webrtc::field_trial::IsEnabled("WebRTC-SCM-Timestamp"); return webrtc::field_trial::IsDisabled("WebRTC-SCM-Timestamp");
} }
} // namespace } // namespace
@ -137,7 +137,7 @@ PhysicalSocket::PhysicalSocket(PhysicalSocketServer* ss, SOCKET s)
error_(0), error_(0),
state_((s == INVALID_SOCKET) ? CS_CLOSED : CS_CONNECTED), state_((s == INVALID_SOCKET) ? CS_CLOSED : CS_CONNECTED),
resolver_(nullptr), resolver_(nullptr),
read_scm_timestamp_experiment_(IsScmTimeStampExperimentEnabled()) { read_scm_timestamp_experiment_(!IsScmTimeStampExperimentDisabled()) {
if (s_ != INVALID_SOCKET) { if (s_ != INVALID_SOCKET) {
SetEnabledEvents(DE_READ | DE_WRITE); SetEnabledEvents(DE_READ | DE_WRITE);
@ -720,7 +720,7 @@ bool SocketDispatcher::Initialize() {
ioctlsocket(s_, FIONBIO, &argp); ioctlsocket(s_, FIONBIO, &argp);
#elif defined(WEBRTC_POSIX) #elif defined(WEBRTC_POSIX)
fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK); fcntl(s_, F_SETFL, fcntl(s_, F_GETFL, 0) | O_NONBLOCK);
if (IsScmTimeStampExperimentEnabled()) { if (!IsScmTimeStampExperimentDisabled()) {
int value = 1; int value = 1;
// Attempt to get receive packet timestamp from the socket. // Attempt to get receive packet timestamp from the socket.
if (::setsockopt(s_, SOL_SOCKET, SO_TIMESTAMP, &value, sizeof(value)) != if (::setsockopt(s_, SOL_SOCKET, SO_TIMESTAMP, &value, sizeof(value)) !=

View File

@ -461,9 +461,6 @@ TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv6) {
#if defined(WEBRTC_POSIX) #if defined(WEBRTC_POSIX)
#if !defined(WEBRTC_MAC)
// We don't get recv timestamps on Mac without the experiment
// WebRTC-SCM-Timestamp
TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) { TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) {
MAYBE_SKIP_IPV4; MAYBE_SKIP_IPV4;
SocketTest::TestSocketRecvTimestampIPv4(); SocketTest::TestSocketRecvTimestampIPv4();
@ -472,18 +469,19 @@ TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) {
TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) { TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) {
SocketTest::TestSocketRecvTimestampIPv6(); SocketTest::TestSocketRecvTimestampIPv6();
} }
#endif
TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4ScmExperiment) { #if !defined(WEBRTC_MAC)
TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4ScmExperimentDisabled) {
MAYBE_SKIP_IPV4; MAYBE_SKIP_IPV4;
webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Enabled/"); webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Disabled/");
SocketTest::TestSocketRecvTimestampIPv4(); SocketTest::TestSocketRecvTimestampIPv4();
} }
TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6ScmExperiment) { TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6ScmExperimentDisabled) {
webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Enabled/"); webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Disabled/");
SocketTest::TestSocketRecvTimestampIPv6(); SocketTest::TestSocketRecvTimestampIPv6();
} }
#endif
// Verify that if the socket was unable to be bound to a real network interface // Verify that if the socket was unable to be bound to a real network interface
// (not loopback), Bind will return an error. // (not loopback), Bind will return an error.
@ -524,14 +522,12 @@ TEST_F(PhysicalSocketTest,
#endif #endif
TEST_F(PhysicalSocketTest, UdpSocketRecvTimestampUseRtcEpochIPv4ScmExperiment) { TEST_F(PhysicalSocketTest, UdpSocketRecvTimestampUseRtcEpochIPv4) {
MAYBE_SKIP_IPV4; MAYBE_SKIP_IPV4;
webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Enabled/");
SocketTest::TestUdpSocketRecvTimestampUseRtcEpochIPv4(); SocketTest::TestUdpSocketRecvTimestampUseRtcEpochIPv4();
} }
TEST_F(PhysicalSocketTest, UdpSocketRecvTimestampUseRtcEpochIPv6ScmExperiment) { TEST_F(PhysicalSocketTest, UdpSocketRecvTimestampUseRtcEpochIPv6) {
webrtc::test::ScopedFieldTrials trial("WebRTC-SCM-Timestamp/Enabled/");
SocketTest::TestUdpSocketRecvTimestampUseRtcEpochIPv6(); SocketTest::TestUdpSocketRecvTimestampUseRtcEpochIPv6();
} }