stats: more consistent use of has_value() for optionals
replacing
if (optional) { ...}
with the more explicit
if (optional.has_value()) { ... }
No functional changes.
BUG=None
Change-Id: I005fd3df307880b07cfda0cbe435efb0e0717a88
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/281362
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#38544}
This commit is contained in:
parent
3e7e15d240
commit
42e5ed38a7
@ -380,7 +380,7 @@ std::string GetCodecIdAndMaybeCreateCodecStats(
|
|||||||
std::make_unique<RTCCodecStats>(codec_id, timestamp_us));
|
std::make_unique<RTCCodecStats>(codec_id, timestamp_us));
|
||||||
codec_stats->payload_type = payload_type;
|
codec_stats->payload_type = payload_type;
|
||||||
codec_stats->mime_type = codec_params.mime_type();
|
codec_stats->mime_type = codec_params.mime_type();
|
||||||
if (codec_params.clock_rate) {
|
if (codec_params.clock_rate.has_value()) {
|
||||||
codec_stats->clock_rate = static_cast<uint32_t>(*codec_params.clock_rate);
|
codec_stats->clock_rate = static_cast<uint32_t>(*codec_params.clock_rate);
|
||||||
}
|
}
|
||||||
if (codec_params.num_channels) {
|
if (codec_params.num_channels) {
|
||||||
@ -419,17 +419,17 @@ void SetInboundRTPStreamStatsFromMediaReceiverInfo(
|
|||||||
static_cast<int32_t>(media_receiver_info.packets_lost);
|
static_cast<int32_t>(media_receiver_info.packets_lost);
|
||||||
inbound_stats->jitter_buffer_delay =
|
inbound_stats->jitter_buffer_delay =
|
||||||
media_receiver_info.jitter_buffer_delay_seconds;
|
media_receiver_info.jitter_buffer_delay_seconds;
|
||||||
if (media_receiver_info.jitter_buffer_target_delay_seconds) {
|
if (media_receiver_info.jitter_buffer_target_delay_seconds.has_value()) {
|
||||||
inbound_stats->jitter_buffer_target_delay =
|
inbound_stats->jitter_buffer_target_delay =
|
||||||
*media_receiver_info.jitter_buffer_target_delay_seconds;
|
*media_receiver_info.jitter_buffer_target_delay_seconds;
|
||||||
}
|
}
|
||||||
if (media_receiver_info.jitter_buffer_minimum_delay_seconds) {
|
if (media_receiver_info.jitter_buffer_minimum_delay_seconds.has_value()) {
|
||||||
inbound_stats->jitter_buffer_minimum_delay =
|
inbound_stats->jitter_buffer_minimum_delay =
|
||||||
*media_receiver_info.jitter_buffer_minimum_delay_seconds;
|
*media_receiver_info.jitter_buffer_minimum_delay_seconds;
|
||||||
}
|
}
|
||||||
inbound_stats->jitter_buffer_emitted_count =
|
inbound_stats->jitter_buffer_emitted_count =
|
||||||
media_receiver_info.jitter_buffer_emitted_count;
|
media_receiver_info.jitter_buffer_emitted_count;
|
||||||
if (media_receiver_info.nacks_sent) {
|
if (media_receiver_info.nacks_sent.has_value()) {
|
||||||
inbound_stats->nack_count = *media_receiver_info.nacks_sent;
|
inbound_stats->nack_count = *media_receiver_info.nacks_sent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,11 +482,11 @@ std::unique_ptr<RTCInboundRTPStreamStats> CreateInboundAudioStreamStats(
|
|||||||
voice_receiver_info.total_output_duration;
|
voice_receiver_info.total_output_duration;
|
||||||
// `fir_count`, `pli_count` and `sli_count` are only valid for video and are
|
// `fir_count`, `pli_count` and `sli_count` are only valid for video and are
|
||||||
// purposefully left undefined for audio.
|
// purposefully left undefined for audio.
|
||||||
if (voice_receiver_info.last_packet_received_timestamp_ms) {
|
if (voice_receiver_info.last_packet_received_timestamp_ms.has_value()) {
|
||||||
inbound_audio->last_packet_received_timestamp = static_cast<double>(
|
inbound_audio->last_packet_received_timestamp = static_cast<double>(
|
||||||
*voice_receiver_info.last_packet_received_timestamp_ms);
|
*voice_receiver_info.last_packet_received_timestamp_ms);
|
||||||
}
|
}
|
||||||
if (voice_receiver_info.estimated_playout_ntp_timestamp_ms) {
|
if (voice_receiver_info.estimated_playout_ntp_timestamp_ms.has_value()) {
|
||||||
// TODO(bugs.webrtc.org/10529): Fix time origin.
|
// TODO(bugs.webrtc.org/10529): Fix time origin.
|
||||||
inbound_audio->estimated_playout_timestamp = static_cast<double>(
|
inbound_audio->estimated_playout_timestamp = static_cast<double>(
|
||||||
*voice_receiver_info.estimated_playout_ntp_timestamp_ms);
|
*voice_receiver_info.estimated_playout_ntp_timestamp_ms);
|
||||||
@ -551,7 +551,7 @@ CreateRemoteOutboundAudioStreamStats(
|
|||||||
stats->remote_timestamp = static_cast<double>(
|
stats->remote_timestamp = static_cast<double>(
|
||||||
voice_receiver_info.last_sender_report_remote_timestamp_ms.value());
|
voice_receiver_info.last_sender_report_remote_timestamp_ms.value());
|
||||||
stats->reports_sent = voice_receiver_info.sender_reports_reports_count;
|
stats->reports_sent = voice_receiver_info.sender_reports_reports_count;
|
||||||
if (voice_receiver_info.round_trip_time) {
|
if (voice_receiver_info.round_trip_time.has_value()) {
|
||||||
stats->round_trip_time =
|
stats->round_trip_time =
|
||||||
voice_receiver_info.round_trip_time->seconds<double>();
|
voice_receiver_info.round_trip_time->seconds<double>();
|
||||||
}
|
}
|
||||||
@ -607,7 +607,7 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo(
|
|||||||
if (video_receiver_info.framerate_decoded > 0) {
|
if (video_receiver_info.framerate_decoded > 0) {
|
||||||
inbound_video->frames_per_second = video_receiver_info.framerate_decoded;
|
inbound_video->frames_per_second = video_receiver_info.framerate_decoded;
|
||||||
}
|
}
|
||||||
if (video_receiver_info.qp_sum) {
|
if (video_receiver_info.qp_sum.has_value()) {
|
||||||
inbound_video->qp_sum = *video_receiver_info.qp_sum;
|
inbound_video->qp_sum = *video_receiver_info.qp_sum;
|
||||||
}
|
}
|
||||||
if (video_receiver_info.timing_frame_info.has_value()) {
|
if (video_receiver_info.timing_frame_info.has_value()) {
|
||||||
@ -637,11 +637,11 @@ void SetInboundRTPStreamStatsFromVideoReceiverInfo(
|
|||||||
inbound_video->min_playout_delay =
|
inbound_video->min_playout_delay =
|
||||||
static_cast<double>(video_receiver_info.min_playout_delay_ms) /
|
static_cast<double>(video_receiver_info.min_playout_delay_ms) /
|
||||||
rtc::kNumMillisecsPerSec;
|
rtc::kNumMillisecsPerSec;
|
||||||
if (video_receiver_info.last_packet_received_timestamp_ms) {
|
if (video_receiver_info.last_packet_received_timestamp_ms.has_value()) {
|
||||||
inbound_video->last_packet_received_timestamp = static_cast<double>(
|
inbound_video->last_packet_received_timestamp = static_cast<double>(
|
||||||
*video_receiver_info.last_packet_received_timestamp_ms);
|
*video_receiver_info.last_packet_received_timestamp_ms);
|
||||||
}
|
}
|
||||||
if (video_receiver_info.estimated_playout_ntp_timestamp_ms) {
|
if (video_receiver_info.estimated_playout_ntp_timestamp_ms.has_value()) {
|
||||||
// TODO(bugs.webrtc.org/10529): Fix time origin if needed.
|
// TODO(bugs.webrtc.org/10529): Fix time origin if needed.
|
||||||
inbound_video->estimated_playout_timestamp = static_cast<double>(
|
inbound_video->estimated_playout_timestamp = static_cast<double>(
|
||||||
*video_receiver_info.estimated_playout_ntp_timestamp_ms);
|
*video_receiver_info.estimated_playout_ntp_timestamp_ms);
|
||||||
@ -694,7 +694,7 @@ void SetOutboundRTPStreamStatsFromVoiceSenderInfo(
|
|||||||
outbound_audio->mid = mid;
|
outbound_audio->mid = mid;
|
||||||
outbound_audio->media_type = "audio";
|
outbound_audio->media_type = "audio";
|
||||||
outbound_audio->kind = "audio";
|
outbound_audio->kind = "audio";
|
||||||
if (voice_sender_info.target_bitrate &&
|
if (voice_sender_info.target_bitrate.has_value() &&
|
||||||
*voice_sender_info.target_bitrate > 0) {
|
*voice_sender_info.target_bitrate > 0) {
|
||||||
outbound_audio->target_bitrate = *voice_sender_info.target_bitrate;
|
outbound_audio->target_bitrate = *voice_sender_info.target_bitrate;
|
||||||
}
|
}
|
||||||
@ -739,10 +739,10 @@ void SetOutboundRTPStreamStatsFromVideoSenderInfo(
|
|||||||
static_cast<uint32_t>(video_sender_info.firs_rcvd);
|
static_cast<uint32_t>(video_sender_info.firs_rcvd);
|
||||||
outbound_video->pli_count =
|
outbound_video->pli_count =
|
||||||
static_cast<uint32_t>(video_sender_info.plis_rcvd);
|
static_cast<uint32_t>(video_sender_info.plis_rcvd);
|
||||||
if (video_sender_info.qp_sum)
|
if (video_sender_info.qp_sum.has_value())
|
||||||
outbound_video->qp_sum = *video_sender_info.qp_sum;
|
outbound_video->qp_sum = *video_sender_info.qp_sum;
|
||||||
if (video_sender_info.target_bitrate &&
|
if (video_sender_info.target_bitrate.has_value() &&
|
||||||
video_sender_info.target_bitrate > 0) {
|
*video_sender_info.target_bitrate > 0) {
|
||||||
outbound_video->target_bitrate = *video_sender_info.target_bitrate;
|
outbound_video->target_bitrate = *video_sender_info.target_bitrate;
|
||||||
}
|
}
|
||||||
outbound_video->frames_encoded = video_sender_info.frames_encoded;
|
outbound_video->frames_encoded = video_sender_info.frames_encoded;
|
||||||
@ -781,7 +781,7 @@ void SetOutboundRTPStreamStatsFromVideoSenderInfo(
|
|||||||
outbound_video->encoder_implementation =
|
outbound_video->encoder_implementation =
|
||||||
video_sender_info.encoder_implementation_name;
|
video_sender_info.encoder_implementation_name;
|
||||||
}
|
}
|
||||||
if (video_sender_info.rid) {
|
if (video_sender_info.rid.has_value()) {
|
||||||
outbound_video->rid = *video_sender_info.rid;
|
outbound_video->rid = *video_sender_info.rid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -971,10 +971,10 @@ const std::string& ProduceIceCandidateStats(int64_t timestamp_us,
|
|||||||
template <typename StatsType>
|
template <typename StatsType>
|
||||||
void SetAudioProcessingStats(StatsType* stats,
|
void SetAudioProcessingStats(StatsType* stats,
|
||||||
const AudioProcessingStats& apm_stats) {
|
const AudioProcessingStats& apm_stats) {
|
||||||
if (apm_stats.echo_return_loss) {
|
if (apm_stats.echo_return_loss.has_value()) {
|
||||||
stats->echo_return_loss = *apm_stats.echo_return_loss;
|
stats->echo_return_loss = *apm_stats.echo_return_loss;
|
||||||
}
|
}
|
||||||
if (apm_stats.echo_return_loss_enhancement) {
|
if (apm_stats.echo_return_loss_enhancement.has_value()) {
|
||||||
stats->echo_return_loss_enhancement =
|
stats->echo_return_loss_enhancement =
|
||||||
*apm_stats.echo_return_loss_enhancement;
|
*apm_stats.echo_return_loss_enhancement;
|
||||||
}
|
}
|
||||||
@ -1694,7 +1694,7 @@ void RTCStatsCollector::ProduceIceCandidateAndPairStats_n(
|
|||||||
candidate_pair_stats->total_round_trip_time =
|
candidate_pair_stats->total_round_trip_time =
|
||||||
static_cast<double>(info.total_round_trip_time_ms) /
|
static_cast<double>(info.total_round_trip_time_ms) /
|
||||||
rtc::kNumMillisecsPerSec;
|
rtc::kNumMillisecsPerSec;
|
||||||
if (info.current_round_trip_time_ms) {
|
if (info.current_round_trip_time_ms.has_value()) {
|
||||||
candidate_pair_stats->current_round_trip_time =
|
candidate_pair_stats->current_round_trip_time =
|
||||||
static_cast<double>(*info.current_round_trip_time_ms) /
|
static_cast<double>(*info.current_round_trip_time_ms) /
|
||||||
rtc::kNumMillisecsPerSec;
|
rtc::kNumMillisecsPerSec;
|
||||||
@ -1727,7 +1727,7 @@ void RTCStatsCollector::ProduceIceCandidateAndPairStats_n(
|
|||||||
info.sent_ping_requests_total -
|
info.sent_ping_requests_total -
|
||||||
info.sent_ping_requests_before_first_response);
|
info.sent_ping_requests_before_first_response);
|
||||||
|
|
||||||
if (info.last_data_received) {
|
if (info.last_data_received.has_value()) {
|
||||||
candidate_pair_stats->last_packet_received_timestamp =
|
candidate_pair_stats->last_packet_received_timestamp =
|
||||||
static_cast<double>(info.last_data_received->ms());
|
static_cast<double>(info.last_data_received->ms());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user