Using absl::optional for round trip time return type handling.
No-Try: True Bug: webrtc:11989 Change-Id: If2ed9b83468c03b82b372e64d8012e5786295476 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197060 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32827}
This commit is contained in:
@ -78,6 +78,7 @@ rtc_library("audio_ingress") {
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../utility:audio_frame_operations",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
||||
rtc_library("audio_egress") {
|
||||
|
@ -184,8 +184,8 @@ void AudioIngress::ReceivedRTCPPacket(
|
||||
// Deliver RTCP packet to RTP/RTCP module for parsing.
|
||||
rtp_rtcp_->IncomingRtcpPacket(rtcp_packet.data(), rtcp_packet.size());
|
||||
|
||||
int64_t rtt = GetRoundTripTime();
|
||||
if (rtt == -1) {
|
||||
absl::optional<int64_t> rtt = GetRoundTripTime();
|
||||
if (!rtt.has_value()) {
|
||||
// Waiting for valid RTT.
|
||||
return;
|
||||
}
|
||||
@ -199,18 +199,18 @@ void AudioIngress::ReceivedRTCPPacket(
|
||||
|
||||
{
|
||||
MutexLock lock(&lock_);
|
||||
ntp_estimator_.UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp);
|
||||
ntp_estimator_.UpdateRtcpTimestamp(*rtt, ntp_secs, ntp_frac, rtp_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
int64_t AudioIngress::GetRoundTripTime() {
|
||||
absl::optional<int64_t> AudioIngress::GetRoundTripTime() {
|
||||
const std::vector<ReportBlockData>& report_data =
|
||||
rtp_rtcp_->GetLatestReportBlockData();
|
||||
|
||||
// If we do not have report block which means remote RTCP hasn't be received
|
||||
// yet, return -1 as to indicate uninitialized value.
|
||||
if (report_data.empty()) {
|
||||
return -1;
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
// We don't know in advance the remote SSRC used by the other end's receiver
|
||||
@ -226,7 +226,11 @@ int64_t AudioIngress::GetRoundTripTime() {
|
||||
rtp_rtcp_->SetRemoteSSRC(sender_ssrc);
|
||||
}
|
||||
|
||||
return (block_data.has_rtt() ? block_data.last_rtt_ms() : -1);
|
||||
if (!block_data.has_rtt()) {
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
return block_data.last_rtt_ms();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/array_view.h"
|
||||
#include "api/audio/audio_mixer.h"
|
||||
#include "api/rtp_headers.h"
|
||||
@ -78,10 +79,6 @@ class AudioIngress : public AudioMixer::Source {
|
||||
return output_audio_level_.TotalDuration();
|
||||
}
|
||||
|
||||
// Returns network round trip time (RTT) measued by RTCP exchange with
|
||||
// remote media endpoint. RTT value -1 indicates that it's not initialized.
|
||||
int64_t GetRoundTripTime();
|
||||
|
||||
NetworkStatistics GetNetworkStatistics() const {
|
||||
NetworkStatistics stats;
|
||||
acm_receiver_.GetNetworkStatistics(&stats,
|
||||
@ -105,6 +102,10 @@ class AudioIngress : public AudioMixer::Source {
|
||||
}
|
||||
|
||||
private:
|
||||
// Returns network round trip time (RTT) measued by RTCP exchange with
|
||||
// remote media endpoint. Returns absl::nullopt when it's not initialized.
|
||||
absl::optional<int64_t> GetRoundTripTime();
|
||||
|
||||
// Indicates AudioIngress status as caller invokes Start/StopPlaying.
|
||||
// If not playing, incoming RTP data processing is skipped, thus
|
||||
// producing no data to output device.
|
||||
|
Reference in New Issue
Block a user