From 111e3818222876a0684c0643b29a1feda2d93f8e Mon Sep 17 00:00:00 2001 From: Mirko Bonadei Date: Wed, 17 Jan 2024 14:37:31 +0000 Subject: [PATCH] Revert "[Stats] Add value_or() and migrate from ValueOrDefault()." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9e4a97bb02663604b02e219b9d501a8dd91b5614. Reason for revert: Breaks downstream project Original change's description: > [Stats] Add value_or() and migrate from ValueOrDefault(). > > Yet another prerequisite for replacing RTCStatsMember with > absl::optional, but this looks like the last one. > > Bug: webrtc:15164 > Change-Id: I2cde51e8c8c951f71b48ccd45e07146091a99616 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334647 > Commit-Queue: Henrik Boström > Reviewed-by: Harald Alvestrand > Cr-Commit-Position: refs/heads/main@{#41541} Bug: webrtc:15164 Change-Id: I89af6470c82d07981d8d064aa6ff8b50fae42b12 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334801 Bot-Commit: rubber-stamper@appspot.gserviceaccount.com Owners-Override: Mirko Bonadei Commit-Queue: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#41548} --- api/stats/rtc_stats_member.h | 7 +----- ...er_connection_encodings_integrationtest.cc | 2 +- pc/rtc_stats_integrationtest.cc | 2 +- .../audio/default_audio_quality_analyzer.cc | 22 ++++++++++--------- .../video/video_quality_metrics_reporter.cc | 6 ++--- test/pc/e2e/cross_media_metrics_reporter.cc | 2 +- .../e2e/network_quality_metrics_reporter.cc | 9 ++++---- ..._based_network_quality_metrics_reporter.cc | 18 ++++++++------- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/api/stats/rtc_stats_member.h b/api/stats/rtc_stats_member.h index d2aa539cf5..675a23cdbf 100644 --- a/api/stats/rtc_stats_member.h +++ b/api/stats/rtc_stats_member.h @@ -101,14 +101,9 @@ class RTCStatsMember : public RTCStatsMemberInterface { std::string ValueToString() const override; std::string ValueToJson() const override; - template - inline T value_or(U default_value) const { - return value_.value_or(default_value); - } - // TODO(https://crbug.com/webrtc/15164): Migrate to value_or() and delete. template inline T ValueOrDefault(U default_value) const { - return value_or(default_value); + return value_.value_or(default_value); } // Assignment operators. diff --git a/pc/peer_connection_encodings_integrationtest.cc b/pc/peer_connection_encodings_integrationtest.cc index 979032c1fa..5bf29e4b19 100644 --- a/pc/peer_connection_encodings_integrationtest.cc +++ b/pc/peer_connection_encodings_integrationtest.cc @@ -1191,7 +1191,7 @@ TEST_F(PeerConnectionEncodingsIntegrationTest, ASSERT_EQ(outbound_rtps.size(), 1u); std::string codec_name = GetCurrentCodecMimeType(report, *outbound_rtps[0]); EXPECT_STRCASEEQ(("video/" + vp9->name).c_str(), codec_name.c_str()); - EXPECT_EQ(outbound_rtps[0]->scalability_mode.value_or(""), "L3T3"); + EXPECT_EQ(outbound_rtps[0]->scalability_mode.ValueOrDefault(""), "L3T3"); } TEST_F(PeerConnectionEncodingsIntegrationTest, diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index 762dad6fcd..d15b617f24 100644 --- a/pc/rtc_stats_integrationtest.cc +++ b/pc/rtc_stats_integrationtest.cc @@ -638,7 +638,7 @@ class RTCStatsReportVerifier { inbound_stream.header_bytes_received); verifier.TestAttributeIsDefined( inbound_stream.last_packet_received_timestamp); - if (inbound_stream.frames_received.value_or(0) > 0) { + if (inbound_stream.frames_received.ValueOrDefault(0) > 0) { verifier.TestAttributeIsNonNegative(inbound_stream.frame_width); verifier.TestAttributeIsNonNegative( inbound_stream.frame_height); diff --git a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc index 9797f4fcef..bca52d9bfc 100644 --- a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc @@ -47,22 +47,24 @@ void DefaultAudioQualityAnalyzer::OnStatsReports( } StatsSample sample; - sample.total_samples_received = stat->total_samples_received.value_or(0ul); - sample.concealed_samples = stat->concealed_samples.value_or(0ul); + sample.total_samples_received = + stat->total_samples_received.ValueOrDefault(0ul); + sample.concealed_samples = stat->concealed_samples.ValueOrDefault(0ul); sample.removed_samples_for_acceleration = - stat->removed_samples_for_acceleration.value_or(0ul); + stat->removed_samples_for_acceleration.ValueOrDefault(0ul); sample.inserted_samples_for_deceleration = - stat->inserted_samples_for_deceleration.value_or(0ul); + stat->inserted_samples_for_deceleration.ValueOrDefault(0ul); sample.silent_concealed_samples = - stat->silent_concealed_samples.value_or(0ul); + stat->silent_concealed_samples.ValueOrDefault(0ul); sample.jitter_buffer_delay = - TimeDelta::Seconds(stat->jitter_buffer_delay.value_or(0.)); + TimeDelta::Seconds(stat->jitter_buffer_delay.ValueOrDefault(0.)); sample.jitter_buffer_target_delay = - TimeDelta::Seconds(stat->jitter_buffer_target_delay.value_or(0.)); + TimeDelta::Seconds(stat->jitter_buffer_target_delay.ValueOrDefault(0.)); sample.jitter_buffer_emitted_count = - stat->jitter_buffer_emitted_count.value_or(0ul); - sample.total_samples_duration = stat->total_samples_duration.value_or(0.); - sample.total_audio_energy = stat->total_audio_energy.value_or(0.); + stat->jitter_buffer_emitted_count.ValueOrDefault(0ul); + sample.total_samples_duration = + stat->total_samples_duration.ValueOrDefault(0.); + sample.total_audio_energy = stat->total_audio_energy.ValueOrDefault(0.); TrackIdStreamInfoMap::StreamInfo stream_info = analyzer_helper_->GetStreamInfoFromTrackId(*stat->track_identifier); diff --git a/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc b/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc index 3ae7fda04b..817b3caad0 100644 --- a/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc +++ b/test/pc/e2e/analyzer/video/video_quality_metrics_reporter.cc @@ -81,10 +81,10 @@ void VideoQualityMetricsReporter::OnStatsReports( sample.sample_time = s->timestamp(); } sample.retransmitted_bytes_sent += - DataSize::Bytes(s->retransmitted_bytes_sent.value_or(0ul)); - sample.bytes_sent += DataSize::Bytes(s->bytes_sent.value_or(0ul)); + DataSize::Bytes(s->retransmitted_bytes_sent.ValueOrDefault(0ul)); + sample.bytes_sent += DataSize::Bytes(s->bytes_sent.ValueOrDefault(0ul)); sample.header_bytes_sent += - DataSize::Bytes(s->header_bytes_sent.value_or(0ul)); + DataSize::Bytes(s->header_bytes_sent.ValueOrDefault(0ul)); } MutexLock lock(&video_bwe_stats_lock_); diff --git a/test/pc/e2e/cross_media_metrics_reporter.cc b/test/pc/e2e/cross_media_metrics_reporter.cc index ed87f3c73e..aad5946c9f 100644 --- a/test/pc/e2e/cross_media_metrics_reporter.cc +++ b/test/pc/e2e/cross_media_metrics_reporter.cc @@ -47,7 +47,7 @@ void CrossMediaMetricsReporter::OnStatsReports( std::map> sync_group_stats; for (const auto& stat : inbound_stats) { - if (stat->estimated_playout_timestamp.value_or(0.) > 0 && + if (stat->estimated_playout_timestamp.ValueOrDefault(0.) > 0 && stat->track_identifier.is_defined()) { sync_group_stats[reporter_helper_ ->GetStreamInfoFromTrackId(*stat->track_identifier) diff --git a/test/pc/e2e/network_quality_metrics_reporter.cc b/test/pc/e2e/network_quality_metrics_reporter.cc index 257fecf309..2d6aa597ce 100644 --- a/test/pc/e2e/network_quality_metrics_reporter.cc +++ b/test/pc/e2e/network_quality_metrics_reporter.cc @@ -79,14 +79,15 @@ void NetworkQualityMetricsReporter::OnStatsReports( auto inbound_stats = report->GetStatsOfType(); for (const auto& stat : inbound_stats) { payload_received += - DataSize::Bytes(stat->bytes_received.value_or(0ul) + - stat->header_bytes_received.value_or(0ul)); + DataSize::Bytes(stat->bytes_received.ValueOrDefault(0ul) + + stat->header_bytes_received.ValueOrDefault(0ul)); } auto outbound_stats = report->GetStatsOfType(); for (const auto& stat : outbound_stats) { - payload_sent += DataSize::Bytes(stat->bytes_sent.value_or(0ul) + - stat->header_bytes_sent.value_or(0ul)); + payload_sent += + DataSize::Bytes(stat->bytes_sent.ValueOrDefault(0ul) + + stat->header_bytes_sent.ValueOrDefault(0ul)); } MutexLock lock(&lock_); diff --git a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc index b965a7acd8..eb5f29287e 100644 --- a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc +++ b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc @@ -299,23 +299,25 @@ void StatsBasedNetworkQualityMetricsReporter::OnStatsReports( auto inbound_stats = report->GetStatsOfType(); for (const auto& stat : inbound_stats) { cur_stats.payload_received += - DataSize::Bytes(stat->bytes_received.value_or(0ul) + - stat->header_bytes_received.value_or(0ul)); + DataSize::Bytes(stat->bytes_received.ValueOrDefault(0ul) + + stat->header_bytes_received.ValueOrDefault(0ul)); } auto outbound_stats = report->GetStatsOfType(); for (const auto& stat : outbound_stats) { - cur_stats.payload_sent += DataSize::Bytes( - stat->bytes_sent.value_or(0ul) + stat->header_bytes_sent.value_or(0ul)); + cur_stats.payload_sent += + DataSize::Bytes(stat->bytes_sent.ValueOrDefault(0ul) + + stat->header_bytes_sent.ValueOrDefault(0ul)); } auto candidate_pairs_stats = report->GetStatsOfType(); for (const auto& stat : candidate_pairs_stats) { cur_stats.total_received += - DataSize::Bytes(stat->bytes_received.value_or(0ul)); - cur_stats.total_sent += DataSize::Bytes(stat->bytes_sent.value_or(0ul)); - cur_stats.packets_received += stat->packets_received.value_or(0ul); - cur_stats.packets_sent += stat->packets_sent.value_or(0ul); + DataSize::Bytes(stat->bytes_received.ValueOrDefault(0ul)); + cur_stats.total_sent += + DataSize::Bytes(stat->bytes_sent.ValueOrDefault(0ul)); + cur_stats.packets_received += stat->packets_received.ValueOrDefault(0ul); + cur_stats.packets_sent += stat->packets_sent.ValueOrDefault(0ul); } MutexLock lock(&mutex_);