[Stats] Replace all uses of is_defined() with has_value().
Same method, different name. Unblocks replacing RTCStatsMember<T> with absl::optional<T>. Bug: webrtc:15164 Change-Id: I251dd44d3b0f9576b3b68915fe0406d1b3381e5c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334641 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41573}
This commit is contained in:
parent
d7478a8453
commit
ed1d084d0a
@ -56,7 +56,7 @@ class RTCStatsMemberInterface {
|
||||
virtual Type type() const = 0;
|
||||
virtual bool is_sequence() const = 0;
|
||||
virtual bool is_string() const = 0;
|
||||
virtual bool is_defined() const = 0;
|
||||
virtual bool has_value() const = 0;
|
||||
// Type and value comparator. The names are not compared. These operators are
|
||||
// exposed for testing.
|
||||
bool operator==(const RTCStatsMemberInterface& other) const {
|
||||
@ -97,7 +97,6 @@ class RTCStatsMember : public RTCStatsMemberInterface {
|
||||
Type type() const override { return StaticType(); }
|
||||
bool is_sequence() const override;
|
||||
bool is_string() const override;
|
||||
bool is_defined() const override { return value_.has_value(); }
|
||||
std::string ValueToString() const override;
|
||||
std::string ValueToJson() const override;
|
||||
|
||||
@ -124,7 +123,7 @@ class RTCStatsMember : public RTCStatsMemberInterface {
|
||||
// Getter methods that look the same as absl::optional<T>. Please prefer these
|
||||
// in order to unblock replacing RTCStatsMember<T> with absl::optional<T> in
|
||||
// the future (https://crbug.com/webrtc/15164).
|
||||
bool has_value() const { return value_.has_value(); }
|
||||
bool has_value() const override { return value_.has_value(); }
|
||||
const T& value() const { return value_.value(); }
|
||||
T& value() { return value_.value(); }
|
||||
T& operator*() {
|
||||
|
||||
@ -77,7 +77,7 @@ struct StringParamToString {
|
||||
std::string GetCurrentCodecMimeType(
|
||||
rtc::scoped_refptr<const RTCStatsReport> report,
|
||||
const RTCOutboundRtpStreamStats& outbound_rtp) {
|
||||
return outbound_rtp.codec_id.is_defined()
|
||||
return outbound_rtp.codec_id.has_value()
|
||||
? *report->GetAs<RTCCodecStats>(*outbound_rtp.codec_id)->mime_type
|
||||
: "";
|
||||
}
|
||||
@ -92,7 +92,7 @@ const RTCOutboundRtpStreamStats* FindOutboundRtpByRid(
|
||||
const std::vector<const RTCOutboundRtpStreamStats*>& outbound_rtps,
|
||||
const absl::string_view& rid) {
|
||||
for (const auto* outbound_rtp : outbound_rtps) {
|
||||
if (outbound_rtp->rid.is_defined() && *outbound_rtp->rid == rid) {
|
||||
if (outbound_rtp->rid.has_value() && *outbound_rtp->rid == rid) {
|
||||
return outbound_rtp;
|
||||
}
|
||||
}
|
||||
@ -261,7 +261,7 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
|
||||
}
|
||||
size_t num_sending_layers = 0;
|
||||
for (const auto* outbound_rtp : outbound_rtps) {
|
||||
if (outbound_rtp->bytes_sent.is_defined() &&
|
||||
if (outbound_rtp->bytes_sent.has_value() &&
|
||||
*outbound_rtp->bytes_sent > 0u) {
|
||||
++num_sending_layers;
|
||||
}
|
||||
@ -278,11 +278,11 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
|
||||
std::vector<const RTCOutboundRtpStreamStats*> outbound_rtps =
|
||||
report->GetStatsOfType<RTCOutboundRtpStreamStats>();
|
||||
auto* outbound_rtp = FindOutboundRtpByRid(outbound_rtps, rid);
|
||||
if (!outbound_rtp || !outbound_rtp->scalability_mode.is_defined() ||
|
||||
if (!outbound_rtp || !outbound_rtp->scalability_mode.has_value() ||
|
||||
*outbound_rtp->scalability_mode != expected_scalability_mode) {
|
||||
return false;
|
||||
}
|
||||
if (outbound_rtp->frame_height.is_defined()) {
|
||||
if (outbound_rtp->frame_height.has_value()) {
|
||||
RTC_LOG(LS_INFO) << "Waiting for target resolution (" << frame_height
|
||||
<< "p). Currently at " << *outbound_rtp->frame_height
|
||||
<< "p...";
|
||||
@ -290,7 +290,7 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
|
||||
RTC_LOG(LS_INFO)
|
||||
<< "Waiting for target resolution. No frames encoded yet...";
|
||||
}
|
||||
if (!outbound_rtp->frame_height.is_defined() ||
|
||||
if (!outbound_rtp->frame_height.has_value() ||
|
||||
*outbound_rtp->frame_height != frame_height) {
|
||||
// Sleep to avoid log spam when this is used in ASSERT_TRUE_WAIT().
|
||||
rtc::Thread::Current()->SleepMs(1000);
|
||||
@ -312,8 +312,8 @@ class PeerConnectionEncodingsIntegrationTest : public ::testing::Test {
|
||||
} else if (outbound_rtps.size() == 1u) {
|
||||
outbound_rtp = outbound_rtps[0];
|
||||
}
|
||||
if (!outbound_rtp || !outbound_rtp->frame_width.is_defined() ||
|
||||
!outbound_rtp->frame_height.is_defined()) {
|
||||
if (!outbound_rtp || !outbound_rtp->frame_width.has_value() ||
|
||||
!outbound_rtp->frame_height.has_value()) {
|
||||
// RTP not found by rid or has not encoded a frame yet.
|
||||
RTC_LOG(LS_ERROR) << "rid=" << resolution.rid << " does not have "
|
||||
<< "resolution metrics";
|
||||
|
||||
@ -264,7 +264,7 @@ TEST_F(PeerConnectionFieldTrialTest, ApplyFakeNetworkConfig) {
|
||||
std::vector<const RTCOutboundRtpStreamStats*> outbound_rtp_stats =
|
||||
caller->GetStats()->GetStatsOfType<RTCOutboundRtpStreamStats>();
|
||||
ASSERT_GE(outbound_rtp_stats.size(), 1u);
|
||||
ASSERT_TRUE(outbound_rtp_stats[0]->target_bitrate.is_defined());
|
||||
ASSERT_TRUE(outbound_rtp_stats[0]->target_bitrate.has_value());
|
||||
// Link capacity is limited to 500k, so BWE is expected to be close to 500k.
|
||||
ASSERT_LE(*outbound_rtp_stats[0]->target_bitrate, 500'000 * 1.1);
|
||||
}
|
||||
|
||||
@ -1356,15 +1356,15 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) {
|
||||
ASSERT_EQ(outbound_stream_stats.size(), 4u);
|
||||
std::vector<std::string> outbound_track_ids;
|
||||
for (const auto& stat : outbound_stream_stats) {
|
||||
ASSERT_TRUE(stat->bytes_sent.is_defined());
|
||||
ASSERT_TRUE(stat->bytes_sent.has_value());
|
||||
EXPECT_LT(0u, *stat->bytes_sent);
|
||||
if (*stat->kind == "video") {
|
||||
ASSERT_TRUE(stat->key_frames_encoded.is_defined());
|
||||
ASSERT_TRUE(stat->key_frames_encoded.has_value());
|
||||
EXPECT_GT(*stat->key_frames_encoded, 0u);
|
||||
ASSERT_TRUE(stat->frames_encoded.is_defined());
|
||||
ASSERT_TRUE(stat->frames_encoded.has_value());
|
||||
EXPECT_GE(*stat->frames_encoded, *stat->key_frames_encoded);
|
||||
}
|
||||
ASSERT_TRUE(stat->media_source_id.is_defined());
|
||||
ASSERT_TRUE(stat->media_source_id.has_value());
|
||||
const RTCMediaSourceStats* media_source =
|
||||
static_cast<const RTCMediaSourceStats*>(
|
||||
caller_report->Get(*stat->media_source_id));
|
||||
@ -1381,12 +1381,12 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) {
|
||||
ASSERT_EQ(4u, inbound_stream_stats.size());
|
||||
std::vector<std::string> inbound_track_ids;
|
||||
for (const auto& stat : inbound_stream_stats) {
|
||||
ASSERT_TRUE(stat->bytes_received.is_defined());
|
||||
ASSERT_TRUE(stat->bytes_received.has_value());
|
||||
EXPECT_LT(0u, *stat->bytes_received);
|
||||
if (*stat->kind == "video") {
|
||||
ASSERT_TRUE(stat->key_frames_decoded.is_defined());
|
||||
ASSERT_TRUE(stat->key_frames_decoded.has_value());
|
||||
EXPECT_GT(*stat->key_frames_decoded, 0u);
|
||||
ASSERT_TRUE(stat->frames_decoded.is_defined());
|
||||
ASSERT_TRUE(stat->frames_decoded.has_value());
|
||||
EXPECT_GE(*stat->frames_decoded, *stat->key_frames_decoded);
|
||||
}
|
||||
inbound_track_ids.push_back(*stat->track_identifier);
|
||||
@ -1417,7 +1417,7 @@ TEST_P(PeerConnectionIntegrationTest,
|
||||
auto inbound_stream_stats =
|
||||
report->GetStatsOfType<RTCInboundRtpStreamStats>();
|
||||
ASSERT_EQ(1U, inbound_stream_stats.size());
|
||||
ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.is_defined());
|
||||
ASSERT_TRUE(inbound_stream_stats[0]->bytes_received.has_value());
|
||||
ASSERT_GT(*inbound_stream_stats[0]->bytes_received, 0U);
|
||||
}
|
||||
|
||||
@ -1464,7 +1464,7 @@ TEST_P(PeerConnectionIntegrationTest,
|
||||
auto inbound_rtps = report->GetStatsOfType<RTCInboundRtpStreamStats>();
|
||||
auto index = FindFirstMediaStatsIndexByKind("audio", inbound_rtps);
|
||||
ASSERT_GE(index, 0);
|
||||
EXPECT_TRUE(inbound_rtps[index]->audio_level.is_defined());
|
||||
EXPECT_TRUE(inbound_rtps[index]->audio_level.has_value());
|
||||
}
|
||||
|
||||
// Test that DTLS 1.0 is used if both sides only support DTLS 1.0.
|
||||
@ -2952,7 +2952,7 @@ double GetAudioEnergyStat(PeerConnectionIntegrationWrapper* pc) {
|
||||
auto inbound_rtps = report->GetStatsOfType<RTCInboundRtpStreamStats>();
|
||||
RTC_CHECK(!inbound_rtps.empty());
|
||||
auto* inbound_rtp = inbound_rtps[0];
|
||||
if (!inbound_rtp->total_audio_energy.is_defined()) {
|
||||
if (!inbound_rtp->total_audio_energy.has_value()) {
|
||||
return 0.0;
|
||||
}
|
||||
return *inbound_rtp->total_audio_energy;
|
||||
@ -3776,7 +3776,7 @@ int NacksReceivedCount(PeerConnectionIntegrationWrapper& pc) {
|
||||
ADD_FAILURE();
|
||||
return 0;
|
||||
}
|
||||
if (!sender_stats[0]->nack_count.is_defined()) {
|
||||
if (!sender_stats[0]->nack_count.has_value()) {
|
||||
return 0;
|
||||
}
|
||||
return *sender_stats[0]->nack_count;
|
||||
@ -3789,7 +3789,7 @@ int NacksSentCount(PeerConnectionIntegrationWrapper& pc) {
|
||||
ADD_FAILURE();
|
||||
return 0;
|
||||
}
|
||||
if (!receiver_stats[0]->nack_count.is_defined()) {
|
||||
if (!receiver_stats[0]->nack_count.has_value()) {
|
||||
return 0;
|
||||
}
|
||||
return *receiver_stats[0]->nack_count;
|
||||
|
||||
@ -309,7 +309,7 @@ class PeerConnectionRampUpTest : public ::testing::Test {
|
||||
auto stats = caller_->GetStats();
|
||||
auto transport_stats = stats->GetStatsOfType<RTCTransportStats>();
|
||||
if (transport_stats.size() == 0u ||
|
||||
!transport_stats[0]->selected_candidate_pair_id.is_defined()) {
|
||||
!transport_stats[0]->selected_candidate_pair_id.has_value()) {
|
||||
return 0;
|
||||
}
|
||||
std::string selected_ice_id =
|
||||
@ -317,7 +317,7 @@ class PeerConnectionRampUpTest : public ::testing::Test {
|
||||
// Use the selected ICE candidate pair ID to get the appropriate ICE stats.
|
||||
const RTCIceCandidatePairStats ice_candidate_pair_stats =
|
||||
stats->Get(selected_ice_id)->cast_to<const RTCIceCandidatePairStats>();
|
||||
if (ice_candidate_pair_stats.available_outgoing_bitrate.is_defined()) {
|
||||
if (ice_candidate_pair_stats.available_outgoing_bitrate.has_value()) {
|
||||
return *ice_candidate_pair_stats.available_outgoing_bitrate;
|
||||
}
|
||||
// We couldn't get the `available_outgoing_bitrate` for the active candidate
|
||||
|
||||
@ -551,7 +551,7 @@ CreateRemoteOutboundAudioStreamStats(
|
||||
stats->ssrc = voice_receiver_info.ssrc();
|
||||
stats->kind = "audio";
|
||||
stats->transport_id = transport_id;
|
||||
if (inbound_audio_stats.codec_id.is_defined()) {
|
||||
if (inbound_audio_stats.codec_id.has_value()) {
|
||||
stats->codec_id = *inbound_audio_stats.codec_id;
|
||||
}
|
||||
// - RTCSentRtpStreamStats.
|
||||
@ -890,7 +890,7 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData(
|
||||
// transport paired with the RTP transport, otherwise the same
|
||||
// transport is used for RTCP and RTP.
|
||||
remote_inbound->transport_id =
|
||||
transport.rtcp_transport_stats_id.is_defined()
|
||||
transport.rtcp_transport_stats_id.has_value()
|
||||
? *transport.rtcp_transport_stats_id
|
||||
: *outbound_rtp.transport_id;
|
||||
}
|
||||
@ -898,13 +898,13 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData(
|
||||
// codec is switched out on the fly we may have received a Report Block
|
||||
// based on the previous codec and there is no way to tell which point in
|
||||
// time the codec changed for the remote end.
|
||||
const auto* codec_from_id = outbound_rtp.codec_id.is_defined()
|
||||
const auto* codec_from_id = outbound_rtp.codec_id.has_value()
|
||||
? report.Get(*outbound_rtp.codec_id)
|
||||
: nullptr;
|
||||
if (codec_from_id) {
|
||||
remote_inbound->codec_id = *outbound_rtp.codec_id;
|
||||
const auto& codec = codec_from_id->cast_to<RTCCodecStats>();
|
||||
if (codec.clock_rate.is_defined()) {
|
||||
if (codec.clock_rate.has_value()) {
|
||||
remote_inbound->jitter =
|
||||
report_block.jitter(*codec.clock_rate).seconds<double>();
|
||||
}
|
||||
@ -1051,7 +1051,7 @@ RTCStatsCollector::CreateReportFilteredBySelector(
|
||||
auto encodings = sender_selector->GetParametersInternal().encodings;
|
||||
for (const auto* outbound_rtp :
|
||||
report->GetStatsOfType<RTCOutboundRtpStreamStats>()) {
|
||||
RTC_DCHECK(outbound_rtp->ssrc.is_defined());
|
||||
RTC_DCHECK(outbound_rtp->ssrc.has_value());
|
||||
auto it = std::find_if(encodings.begin(), encodings.end(),
|
||||
[ssrc = *outbound_rtp->ssrc](
|
||||
const RtpEncodingParameters& encoding) {
|
||||
@ -1071,7 +1071,7 @@ RTCStatsCollector::CreateReportFilteredBySelector(
|
||||
if (ssrc.has_value()) {
|
||||
for (const auto* inbound_rtp :
|
||||
report->GetStatsOfType<RTCInboundRtpStreamStats>()) {
|
||||
RTC_DCHECK(inbound_rtp->ssrc.is_defined());
|
||||
RTC_DCHECK(inbound_rtp->ssrc.has_value());
|
||||
if (*inbound_rtp->ssrc == *ssrc) {
|
||||
rtpstream_ids.push_back(inbound_rtp->id());
|
||||
}
|
||||
|
||||
@ -2304,7 +2304,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio_PlayoutId) {
|
||||
ASSERT_TRUE(report->Get("ITTransportName1A1"));
|
||||
auto stats =
|
||||
report->Get("ITTransportName1A1")->cast_to<RTCInboundRtpStreamStats>();
|
||||
ASSERT_FALSE(stats.playout_id.is_defined());
|
||||
ASSERT_FALSE(stats.playout_id.has_value());
|
||||
}
|
||||
{
|
||||
// We do expect a playout id when receiving.
|
||||
@ -2315,7 +2315,7 @@ TEST_F(RTCStatsCollectorTest, CollectRTCInboundRtpStreamStats_Audio_PlayoutId) {
|
||||
ASSERT_TRUE(report->Get("ITTransportName1A1"));
|
||||
auto stats =
|
||||
report->Get("ITTransportName1A1")->cast_to<RTCInboundRtpStreamStats>();
|
||||
ASSERT_TRUE(stats.playout_id.is_defined());
|
||||
ASSERT_TRUE(stats.playout_id.has_value());
|
||||
EXPECT_EQ(*stats.playout_id, "AP");
|
||||
}
|
||||
}
|
||||
@ -2531,7 +2531,7 @@ TEST_F(RTCStatsCollectorTest, CollectGoogTimingFrameInfo) {
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
auto inbound_rtps = report->GetStatsOfType<RTCInboundRtpStreamStats>();
|
||||
ASSERT_EQ(inbound_rtps.size(), 1u);
|
||||
ASSERT_TRUE(inbound_rtps[0]->goog_timing_frame_info.is_defined());
|
||||
ASSERT_TRUE(inbound_rtps[0]->goog_timing_frame_info.has_value());
|
||||
EXPECT_EQ(*inbound_rtps[0]->goog_timing_frame_info,
|
||||
"1,2,3,4,5,6,7,8,9,10,11,12,13,1,0");
|
||||
}
|
||||
@ -3140,8 +3140,8 @@ TEST_F(RTCStatsCollectorTest,
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
ASSERT_TRUE(report->Get("SV42"));
|
||||
auto video_stats = report->Get("SV42")->cast_to<RTCVideoSourceStats>();
|
||||
EXPECT_FALSE(video_stats.frames_per_second.is_defined());
|
||||
EXPECT_FALSE(video_stats.frames.is_defined());
|
||||
EXPECT_FALSE(video_stats.frames_per_second.has_value());
|
||||
EXPECT_FALSE(video_stats.frames.has_value());
|
||||
}
|
||||
|
||||
// The track not having a source is not expected to be true in practise, but
|
||||
@ -3170,8 +3170,8 @@ TEST_F(RTCStatsCollectorTest,
|
||||
rtc::scoped_refptr<const RTCStatsReport> report = stats_->GetStatsReport();
|
||||
ASSERT_TRUE(report->Get("SV42"));
|
||||
auto video_stats = report->Get("SV42")->cast_to<RTCVideoSourceStats>();
|
||||
EXPECT_FALSE(video_stats.width.is_defined());
|
||||
EXPECT_FALSE(video_stats.height.is_defined());
|
||||
EXPECT_FALSE(video_stats.width.has_value());
|
||||
EXPECT_FALSE(video_stats.height.has_value());
|
||||
}
|
||||
|
||||
TEST_F(RTCStatsCollectorTest,
|
||||
@ -3372,9 +3372,9 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
|
||||
EXPECT_TRUE(remote_inbound_rtp.round_trip_time_measurements.is_defined());
|
||||
EXPECT_TRUE(remote_inbound_rtp.round_trip_time_measurements.has_value());
|
||||
EXPECT_EQ(0, *remote_inbound_rtp.round_trip_time_measurements);
|
||||
EXPECT_FALSE(remote_inbound_rtp.round_trip_time.is_defined());
|
||||
EXPECT_FALSE(remote_inbound_rtp.round_trip_time.has_value());
|
||||
}
|
||||
|
||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
@ -3436,10 +3436,10 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
|
||||
EXPECT_TRUE(remote_inbound_rtp.codec_id.is_defined());
|
||||
EXPECT_TRUE(remote_inbound_rtp.codec_id.has_value());
|
||||
EXPECT_TRUE(report->Get(*remote_inbound_rtp.codec_id));
|
||||
|
||||
EXPECT_TRUE(remote_inbound_rtp.jitter.is_defined());
|
||||
EXPECT_TRUE(remote_inbound_rtp.jitter.has_value());
|
||||
// The jitter (in seconds) is the report block's jitter divided by the codec's
|
||||
// clock rate.
|
||||
EXPECT_EQ(5.0, *remote_inbound_rtp.jitter);
|
||||
@ -3476,7 +3476,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||
auto& remote_inbound_rtp = report->Get(remote_inbound_rtp_id)
|
||||
->cast_to<RTCRemoteInboundRtpStreamStats>();
|
||||
|
||||
EXPECT_TRUE(remote_inbound_rtp.transport_id.is_defined());
|
||||
EXPECT_TRUE(remote_inbound_rtp.transport_id.has_value());
|
||||
EXPECT_EQ("TTransportName2", // 2 for RTCP
|
||||
*remote_inbound_rtp.transport_id);
|
||||
EXPECT_TRUE(report->Get(*remote_inbound_rtp.transport_id));
|
||||
|
||||
@ -44,7 +44,7 @@ void TraverseAndTakeVisitedStats(RTCStatsReport* report,
|
||||
|
||||
void AddIdIfDefined(const RTCStatsMember<std::string>& id,
|
||||
std::vector<const std::string*>* neighbor_ids) {
|
||||
if (id.is_defined())
|
||||
if (id.has_value())
|
||||
neighbor_ids->push_back(&(*id));
|
||||
}
|
||||
|
||||
|
||||
@ -649,8 +649,8 @@ class PeerConnectionIntegrationWrapper : public PeerConnectionObserver,
|
||||
auto received_stats = NewGetStats();
|
||||
auto rtp_stats =
|
||||
received_stats->GetStatsOfType<RTCInboundRtpStreamStats>()[0];
|
||||
ASSERT_TRUE(rtp_stats->relative_packet_arrival_delay.is_defined());
|
||||
ASSERT_TRUE(rtp_stats->packets_received.is_defined());
|
||||
ASSERT_TRUE(rtp_stats->relative_packet_arrival_delay.has_value());
|
||||
ASSERT_TRUE(rtp_stats->packets_received.has_value());
|
||||
rtp_stats_id_ = rtp_stats->id();
|
||||
audio_packets_stat_ = *rtp_stats->packets_received;
|
||||
audio_delay_stat_ = *rtp_stats->relative_packet_arrival_delay;
|
||||
|
||||
@ -210,7 +210,7 @@ class SvcVideoQualityAnalyzer : public DefaultVideoQualityAnalyzer {
|
||||
// Extract the scalability mode reported in the stats.
|
||||
auto outbound_stats = report->GetStatsOfType<RTCOutboundRtpStreamStats>();
|
||||
for (const auto& stat : outbound_stats) {
|
||||
if (stat->scalability_mode.is_defined()) {
|
||||
if (stat->scalability_mode.has_value()) {
|
||||
reported_scalability_mode_ = *stat->scalability_mode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ TEST(RTCStatsTest, RTCStatsAndAttributes) {
|
||||
stats.m_sequence_bool = sequence_bool;
|
||||
stats.m_sequence_int32 = sequence_int32;
|
||||
stats.m_sequence_uint32 = sequence_uint32;
|
||||
EXPECT_FALSE(stats.m_sequence_int64.is_defined());
|
||||
EXPECT_FALSE(stats.m_sequence_int64.has_value());
|
||||
stats.m_sequence_int64 = sequence_int64;
|
||||
stats.m_sequence_uint64 = sequence_uint64;
|
||||
stats.m_sequence_double = sequence_double;
|
||||
@ -382,8 +382,8 @@ TEST(RTCStatsTest, RTCStatsPrintsValidJson) {
|
||||
// "mUint32" should not be part of the generated JSON object.
|
||||
int m_uint32;
|
||||
int m_uint64;
|
||||
EXPECT_FALSE(stats.m_uint32.is_defined());
|
||||
EXPECT_FALSE(stats.m_uint64.is_defined());
|
||||
EXPECT_FALSE(stats.m_uint32.has_value());
|
||||
EXPECT_FALSE(stats.m_uint64.has_value());
|
||||
EXPECT_FALSE(rtc::GetIntFromJsonObject(json_output, "mUint32", &m_uint32));
|
||||
EXPECT_FALSE(rtc::GetIntFromJsonObject(json_output, "mUint64", &m_uint64));
|
||||
|
||||
@ -507,7 +507,7 @@ TEST(RTCStatsTest, ValueToString) {
|
||||
|
||||
TEST(RTCStatsDeathTest, ValueOfUndefinedMember) {
|
||||
RTCTestStats stats("testId", Timestamp::Micros(0));
|
||||
EXPECT_FALSE(stats.m_int32.is_defined());
|
||||
EXPECT_FALSE(stats.m_int32.has_value());
|
||||
EXPECT_DEATH(*stats.m_int32, "");
|
||||
}
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ void DefaultAudioQualityAnalyzer::OnStatsReports(
|
||||
auto stats = report->GetStatsOfType<RTCInboundRtpStreamStats>();
|
||||
|
||||
for (auto& stat : stats) {
|
||||
if (!stat->kind.is_defined() || !(*stat->kind == "audio")) {
|
||||
if (!stat->kind.has_value() || !(*stat->kind == "audio")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ void VideoQualityMetricsReporter::OnStatsReports(
|
||||
|
||||
auto transport_stats = report->GetStatsOfType<RTCTransportStats>();
|
||||
if (transport_stats.size() == 0u ||
|
||||
!transport_stats[0]->selected_candidate_pair_id.is_defined()) {
|
||||
!transport_stats[0]->selected_candidate_pair_id.has_value()) {
|
||||
return;
|
||||
}
|
||||
RTC_DCHECK_EQ(transport_stats.size(), 1);
|
||||
@ -71,7 +71,7 @@ void VideoQualityMetricsReporter::OnStatsReports(
|
||||
auto outbound_rtp_stats = report->GetStatsOfType<RTCOutboundRtpStreamStats>();
|
||||
StatsSample sample;
|
||||
for (auto& s : outbound_rtp_stats) {
|
||||
if (!s->kind.is_defined()) {
|
||||
if (!s->kind.has_value()) {
|
||||
continue;
|
||||
}
|
||||
if (!(*s->kind == "video")) {
|
||||
@ -89,7 +89,7 @@ void VideoQualityMetricsReporter::OnStatsReports(
|
||||
|
||||
MutexLock lock(&video_bwe_stats_lock_);
|
||||
VideoBweStats& video_bwe_stats = video_bwe_stats_[std::string(pc_label)];
|
||||
if (ice_candidate_pair_stats.available_outgoing_bitrate.is_defined()) {
|
||||
if (ice_candidate_pair_stats.available_outgoing_bitrate.has_value()) {
|
||||
video_bwe_stats.available_send_bandwidth.AddSample(
|
||||
DataRate::BitsPerSec(
|
||||
*ice_candidate_pair_stats.available_outgoing_bitrate)
|
||||
|
||||
@ -48,7 +48,7 @@ void CrossMediaMetricsReporter::OnStatsReports(
|
||||
sync_group_stats;
|
||||
for (const auto& stat : inbound_stats) {
|
||||
if (stat->estimated_playout_timestamp.value_or(0.) > 0 &&
|
||||
stat->track_identifier.is_defined()) {
|
||||
stat->track_identifier.has_value()) {
|
||||
sync_group_stats[reporter_helper_
|
||||
->GetStreamInfoFromTrackId(*stat->track_identifier)
|
||||
.sync_group]
|
||||
@ -66,8 +66,8 @@ void CrossMediaMetricsReporter::OnStatsReports(
|
||||
const RTCInboundRtpStreamStats* audio_stat = pair.second[0];
|
||||
const RTCInboundRtpStreamStats* video_stat = pair.second[1];
|
||||
|
||||
RTC_CHECK(pair.second.size() == 2 && audio_stat->kind.is_defined() &&
|
||||
video_stat->kind.is_defined() &&
|
||||
RTC_CHECK(pair.second.size() == 2 && audio_stat->kind.has_value() &&
|
||||
video_stat->kind.has_value() &&
|
||||
*audio_stat->kind != *video_stat->kind)
|
||||
<< "Sync group should consist of one audio and one video stream.";
|
||||
|
||||
@ -77,8 +77,8 @@ void CrossMediaMetricsReporter::OnStatsReports(
|
||||
// Stream labels of a sync group are same for all polls, so we need it add
|
||||
// it only once.
|
||||
if (stats_info_.find(sync_group) == stats_info_.end()) {
|
||||
RTC_CHECK(audio_stat->track_identifier.is_defined());
|
||||
RTC_CHECK(video_stat->track_identifier.is_defined());
|
||||
RTC_CHECK(audio_stat->track_identifier.has_value());
|
||||
RTC_CHECK(video_stat->track_identifier.has_value());
|
||||
stats_info_[sync_group].audio_stream_info =
|
||||
reporter_helper_->GetStreamInfoFromTrackId(
|
||||
*audio_stat->track_identifier);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user