diff --git a/api/stats/rtc_stats_member.h b/api/stats/rtc_stats_member.h index 675a23cdbf..d2aa539cf5 100644 --- a/api/stats/rtc_stats_member.h +++ b/api/stats/rtc_stats_member.h @@ -102,9 +102,14 @@ class RTCStatsMember : public RTCStatsMemberInterface { std::string ValueToJson() const override; template - inline T ValueOrDefault(U default_value) const { + 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); + } // Assignment operators. T& operator=(const T& value) { diff --git a/pc/peer_connection_encodings_integrationtest.cc b/pc/peer_connection_encodings_integrationtest.cc index 5bf29e4b19..979032c1fa 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.ValueOrDefault(""), "L3T3"); + EXPECT_EQ(outbound_rtps[0]->scalability_mode.value_or(""), "L3T3"); } TEST_F(PeerConnectionEncodingsIntegrationTest, diff --git a/pc/rtc_stats_integrationtest.cc b/pc/rtc_stats_integrationtest.cc index d15b617f24..762dad6fcd 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.ValueOrDefault(0) > 0) { + if (inbound_stream.frames_received.value_or(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 bca52d9bfc..9797f4fcef 100644 --- a/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc +++ b/test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.cc @@ -47,24 +47,22 @@ void DefaultAudioQualityAnalyzer::OnStatsReports( } StatsSample sample; - sample.total_samples_received = - stat->total_samples_received.ValueOrDefault(0ul); - sample.concealed_samples = stat->concealed_samples.ValueOrDefault(0ul); + sample.total_samples_received = stat->total_samples_received.value_or(0ul); + sample.concealed_samples = stat->concealed_samples.value_or(0ul); sample.removed_samples_for_acceleration = - stat->removed_samples_for_acceleration.ValueOrDefault(0ul); + stat->removed_samples_for_acceleration.value_or(0ul); sample.inserted_samples_for_deceleration = - stat->inserted_samples_for_deceleration.ValueOrDefault(0ul); + stat->inserted_samples_for_deceleration.value_or(0ul); sample.silent_concealed_samples = - stat->silent_concealed_samples.ValueOrDefault(0ul); + stat->silent_concealed_samples.value_or(0ul); sample.jitter_buffer_delay = - TimeDelta::Seconds(stat->jitter_buffer_delay.ValueOrDefault(0.)); + TimeDelta::Seconds(stat->jitter_buffer_delay.value_or(0.)); sample.jitter_buffer_target_delay = - TimeDelta::Seconds(stat->jitter_buffer_target_delay.ValueOrDefault(0.)); + TimeDelta::Seconds(stat->jitter_buffer_target_delay.value_or(0.)); sample.jitter_buffer_emitted_count = - 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.); + 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.); 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 817b3caad0..3ae7fda04b 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.ValueOrDefault(0ul)); - sample.bytes_sent += DataSize::Bytes(s->bytes_sent.ValueOrDefault(0ul)); + DataSize::Bytes(s->retransmitted_bytes_sent.value_or(0ul)); + sample.bytes_sent += DataSize::Bytes(s->bytes_sent.value_or(0ul)); sample.header_bytes_sent += - DataSize::Bytes(s->header_bytes_sent.ValueOrDefault(0ul)); + DataSize::Bytes(s->header_bytes_sent.value_or(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 aad5946c9f..ed87f3c73e 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.ValueOrDefault(0.) > 0 && + if (stat->estimated_playout_timestamp.value_or(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 2d6aa597ce..257fecf309 100644 --- a/test/pc/e2e/network_quality_metrics_reporter.cc +++ b/test/pc/e2e/network_quality_metrics_reporter.cc @@ -79,15 +79,14 @@ void NetworkQualityMetricsReporter::OnStatsReports( auto inbound_stats = report->GetStatsOfType(); for (const auto& stat : inbound_stats) { payload_received += - DataSize::Bytes(stat->bytes_received.ValueOrDefault(0ul) + - stat->header_bytes_received.ValueOrDefault(0ul)); + DataSize::Bytes(stat->bytes_received.value_or(0ul) + + stat->header_bytes_received.value_or(0ul)); } auto outbound_stats = report->GetStatsOfType(); for (const auto& stat : outbound_stats) { - payload_sent += - DataSize::Bytes(stat->bytes_sent.ValueOrDefault(0ul) + - stat->header_bytes_sent.ValueOrDefault(0ul)); + payload_sent += DataSize::Bytes(stat->bytes_sent.value_or(0ul) + + stat->header_bytes_sent.value_or(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 eb5f29287e..b965a7acd8 100644 --- a/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc +++ b/test/pc/e2e/stats_based_network_quality_metrics_reporter.cc @@ -299,25 +299,23 @@ void StatsBasedNetworkQualityMetricsReporter::OnStatsReports( auto inbound_stats = report->GetStatsOfType(); for (const auto& stat : inbound_stats) { cur_stats.payload_received += - DataSize::Bytes(stat->bytes_received.ValueOrDefault(0ul) + - stat->header_bytes_received.ValueOrDefault(0ul)); + DataSize::Bytes(stat->bytes_received.value_or(0ul) + + stat->header_bytes_received.value_or(0ul)); } auto outbound_stats = report->GetStatsOfType(); for (const auto& stat : outbound_stats) { - cur_stats.payload_sent += - DataSize::Bytes(stat->bytes_sent.ValueOrDefault(0ul) + - stat->header_bytes_sent.ValueOrDefault(0ul)); + cur_stats.payload_sent += DataSize::Bytes( + stat->bytes_sent.value_or(0ul) + stat->header_bytes_sent.value_or(0ul)); } auto candidate_pairs_stats = report->GetStatsOfType(); for (const auto& stat : candidate_pairs_stats) { cur_stats.total_received += - 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); + 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); } MutexLock lock(&mutex_);