diff options
author | Danil Chapovalov <danilchap@webrtc.org> | 2018-06-15 12:28:07 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2018-06-15 12:09:49 +0000 |
commit | b9b146c9feaf6fd610c3d96b6ed532c447f4bb89 (patch) | |
tree | 27ba8995c071edf50c8b8cbc1e2d61c12b31a096 /audio | |
parent | e61d72b37c64d970851976a490dc9d65061e1568 (diff) | |
download | webrtc-b9b146c9feaf6fd610c3d96b6ed532c447f4bb89.tar.gz |
Replace rtc::Optional with absl::optional in audio, call and video
This is a no-op change because rtc::Optional is an alias to absl::optional
This CL generated by running script with parameters 'audio call video':
#!/bin/bash
find $@ -type f \( -name \*.h -o -name \*.cc \) \
-exec sed -i 's|rtc::Optional|absl::optional|g' {} \+ \
-exec sed -i 's|rtc::nullopt|absl::nullopt|g' {} \+ \
-exec sed -i 's|#include "api/optional.h"|#include "absl/types/optional.h"|' {} \+
find $@ -type f -name BUILD.gn \
-exec sed -r -i 's|"(../)*api:optional"|"//third_party/abseil-cpp/absl/types:optional"|' {} \+;
git cl format
Bug: webrtc:9078
Change-Id: I02c5db956846a88a268a300ba086703a02d62e36
Reviewed-on: https://webrtc-review.googlesource.com/83722
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23628}
Diffstat (limited to 'audio')
-rw-r--r-- | audio/BUILD.gn | 2 | ||||
-rw-r--r-- | audio/audio_receive_stream.cc | 6 | ||||
-rw-r--r-- | audio/audio_receive_stream.h | 2 | ||||
-rw-r--r-- | audio/audio_send_stream.cc | 10 | ||||
-rw-r--r-- | audio/audio_send_stream.h | 6 | ||||
-rw-r--r-- | audio/audio_send_stream_unittest.cc | 10 | ||||
-rw-r--r-- | audio/channel.cc | 4 | ||||
-rw-r--r-- | audio/channel.h | 6 | ||||
-rw-r--r-- | audio/time_interval.h | 4 | ||||
-rw-r--r-- | audio/transport_feedback_packet_loss_tracker.cc | 18 | ||||
-rw-r--r-- | audio/transport_feedback_packet_loss_tracker.h | 10 | ||||
-rw-r--r-- | audio/transport_feedback_packet_loss_tracker_unittest.cc | 28 |
12 files changed, 53 insertions, 53 deletions
diff --git a/audio/BUILD.gn b/audio/BUILD.gn index 75a62c2f75..709fd7fade 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -49,7 +49,6 @@ rtc_static_library("audio") { "../api:array_view", "../api:call_api", "../api:libjingle_peerconnection_api", - "../api:optional", "../api:transport_api", "../api/audio:aec3_factory", "../api/audio:audio_frame_api", @@ -87,6 +86,7 @@ rtc_static_library("audio") { "../system_wrappers:field_trial_api", "../system_wrappers:metrics_api", "utility:audio_frame_operations", + "//third_party/abseil-cpp/absl/types:optional", ] } if (rtc_include_tests) { diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 941439fae1..b52563bed1 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -257,7 +257,7 @@ int AudioReceiveStream::id() const { return config_.rtp.remote_ssrc; } -rtc::Optional<Syncable::Info> AudioReceiveStream::GetInfo() const { +absl::optional<Syncable::Info> AudioReceiveStream::GetInfo() const { RTC_DCHECK_RUN_ON(&module_process_thread_checker_); Syncable::Info info; @@ -270,14 +270,14 @@ rtc::Optional<Syncable::Info> AudioReceiveStream::GetInfo() const { if (!rtp_receiver->GetLatestTimestamps( &info.latest_received_capture_timestamp, &info.latest_receive_time_ms)) { - return rtc::nullopt; + return absl::nullopt; } if (rtp_rtcp->RemoteNTP(&info.capture_time_ntp_secs, &info.capture_time_ntp_frac, nullptr, nullptr, &info.capture_time_source_clock) != 0) { - return rtc::nullopt; + return absl::nullopt; } info.current_delay_ms = channel_proxy_->GetDelayEstimate(); diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index 09007f0497..64552e35c0 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -80,7 +80,7 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, // Syncable int id() const override; - rtc::Optional<Syncable::Info> GetInfo() const override; + absl::optional<Syncable::Info> GetInfo() const override; uint32_t GetPlayoutTimestamp() const override; void SetMinimumPlayoutDelay(int delay_ms) override; diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index fe955594ef..8ed78eb461 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -91,7 +91,7 @@ AudioSendStream::AudioSendStream( BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional<RtpState>& suspended_rtp_state, + const absl::optional<RtpState>& suspended_rtp_state, TimeInterval* overall_call_lifetime) : AudioSendStream(config, audio_state, @@ -115,7 +115,7 @@ AudioSendStream::AudioSendStream( BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional<RtpState>& suspended_rtp_state, + const absl::optional<RtpState>& suspended_rtp_state, TimeInterval* overall_call_lifetime, std::unique_ptr<voe::ChannelProxy> channel_proxy) : worker_queue_(worker_queue), @@ -445,8 +445,8 @@ void AudioSendStream::OnPacketAdded(uint32_t ssrc, uint16_t seq_num) { void AudioSendStream::OnPacketFeedbackVector( const std::vector<PacketFeedback>& packet_feedback_vector) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - rtc::Optional<float> plr; - rtc::Optional<float> rplr; + absl::optional<float> plr; + absl::optional<float> rplr; { rtc::CritScope lock(&packet_loss_tracker_cs_); packet_loss_tracker_.OnPacketFeedbackVector(packet_feedback_vector); @@ -584,7 +584,7 @@ bool AudioSendStream::ReconfigureSendCodec(AudioSendStream* stream, return SetupSendCodec(stream, new_config); } - const rtc::Optional<int>& new_target_bitrate_bps = + const absl::optional<int>& new_target_bitrate_bps = new_config.send_codec_spec->target_bitrate_bps; // If a bitrate has been specified for the codec, use it over the // codec's default. diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index c51c7a3b2f..efc9c0e8fe 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -49,7 +49,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional<RtpState>& suspended_rtp_state, + const absl::optional<RtpState>& suspended_rtp_state, TimeInterval* overall_call_lifetime); // For unit tests, which need to supply a mock channel proxy. AudioSendStream(const webrtc::AudioSendStream::Config& config, @@ -59,7 +59,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, BitrateAllocator* bitrate_allocator, RtcEventLog* event_log, RtcpRttStats* rtcp_rtt_stats, - const rtc::Optional<RtpState>& suspended_rtp_state, + const absl::optional<RtpState>& suspended_rtp_state, TimeInterval* overall_call_lifetime, std::unique_ptr<voe::ChannelProxy> channel_proxy); ~AudioSendStream() override; @@ -146,7 +146,7 @@ class AudioSendStream final : public webrtc::AudioSendStream, RTC_GUARDED_BY(&packet_loss_tracker_cs_); RtpRtcp* rtp_rtcp_module_; - rtc::Optional<RtpState> const suspended_rtp_state_; + absl::optional<RtpState> const suspended_rtp_state_; std::unique_ptr<TimedTransport> timed_send_transport_adapter_; TimeInterval active_lifetime_; diff --git a/audio/audio_send_stream_unittest.cc b/audio/audio_send_stream_unittest.cc index d39912000c..d0bc45f4f7 100644 --- a/audio/audio_send_stream_unittest.cc +++ b/audio/audio_send_stream_unittest.cc @@ -109,17 +109,17 @@ rtc::scoped_refptr<MockAudioEncoderFactory> SetupEncoderFactoryMock() { std::begin(kCodecSpecs), std::end(kCodecSpecs)))); ON_CALL(*factory.get(), QueryAudioEncoder(_)) .WillByDefault(Invoke( - [](const SdpAudioFormat& format) -> rtc::Optional<AudioCodecInfo> { + [](const SdpAudioFormat& format) -> absl::optional<AudioCodecInfo> { for (const auto& spec : kCodecSpecs) { if (format == spec.format) { return spec.info; } } - return rtc::nullopt; + return absl::nullopt; })); ON_CALL(*factory.get(), MakeAudioEncoderMock(_, _, _, _)) .WillByDefault(Invoke([](int payload_type, const SdpAudioFormat& format, - rtc::Optional<AudioCodecPairId> codec_pair_id, + absl::optional<AudioCodecPairId> codec_pair_id, std::unique_ptr<AudioEncoder>* return_value) { *return_value = SetupAudioEncoderMock(payload_type, format); })); @@ -166,7 +166,7 @@ struct ConfigHelper { return std::unique_ptr<internal::AudioSendStream>( new internal::AudioSendStream( stream_config_, audio_state_, &worker_queue_, &rtp_transport_, - &bitrate_allocator_, &event_log_, &rtcp_rtt_stats_, rtc::nullopt, + &bitrate_allocator_, &event_log_, &rtcp_rtt_stats_, absl::nullopt, &active_lifetime_, std::unique_ptr<voe::ChannelProxy>(channel_proxy_))); } @@ -424,7 +424,7 @@ TEST(AudioSendStreamTest, SendCodecAppliesAudioNetworkAdaptor) { EXPECT_CALL(helper.mock_encoder_factory(), MakeAudioEncoderMock(_, _, _, _)) .WillOnce(Invoke([&kAnaConfigString, &kAnaReconfigString]( int payload_type, const SdpAudioFormat& format, - rtc::Optional<AudioCodecPairId> codec_pair_id, + absl::optional<AudioCodecPairId> codec_pair_id, std::unique_ptr<AudioEncoder>* return_value) { auto mock_encoder = SetupAudioEncoderMock(payload_type, format); EXPECT_CALL(*mock_encoder, diff --git a/audio/channel.cc b/audio/channel.cc index e5dc5c2814..ecde1725bd 100644 --- a/audio/channel.cc +++ b/audio/channel.cc @@ -509,7 +509,7 @@ Channel::Channel(rtc::TaskQueue* encoder_queue, 0, false, rtc::scoped_refptr<AudioDecoderFactory>(), - rtc::nullopt) { + absl::nullopt) { RTC_DCHECK(encoder_queue); encoder_queue_ = encoder_queue; } @@ -520,7 +520,7 @@ Channel::Channel(ProcessThread* module_process_thread, size_t jitter_buffer_max_packets, bool jitter_buffer_fast_playout, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, - rtc::Optional<AudioCodecPairId> codec_pair_id) + absl::optional<AudioCodecPairId> codec_pair_id) : event_log_proxy_(new RtcEventLogProxy()), rtp_payload_registry_(new RTPPayloadRegistry()), rtp_receive_statistics_( diff --git a/audio/channel.h b/audio/channel.h index 6f79868391..9830a2507d 100644 --- a/audio/channel.h +++ b/audio/channel.h @@ -16,11 +16,11 @@ #include <string> #include <vector> +#include "absl/types/optional.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_encoder.h" #include "api/call/audio_sink.h" #include "api/call/transport.h" -#include "api/optional.h" #include "audio/audio_level.h" #include "common_types.h" // NOLINT(build/include) #include "modules/audio_coding/include/audio_coding_module.h" @@ -158,7 +158,7 @@ class Channel size_t jitter_buffer_max_packets, bool jitter_buffer_fast_playout, rtc::scoped_refptr<AudioDecoderFactory> decoder_factory, - rtc::Optional<AudioCodecPairId> codec_pair_id); + absl::optional<AudioCodecPairId> codec_pair_id); virtual ~Channel(); void SetSink(AudioSinkInterface* sink); @@ -353,7 +353,7 @@ class Channel RemoteNtpTimeEstimator ntp_estimator_ RTC_GUARDED_BY(ts_stats_lock_); // Timestamp of the audio pulled from NetEq. - rtc::Optional<uint32_t> jitter_buffer_playout_timestamp_; + absl::optional<uint32_t> jitter_buffer_playout_timestamp_; rtc::CriticalSection video_sync_lock_; uint32_t playout_timestamp_rtp_ RTC_GUARDED_BY(video_sync_lock_); diff --git a/audio/time_interval.h b/audio/time_interval.h index 88b2f7dd4f..79fe29d9d5 100644 --- a/audio/time_interval.h +++ b/audio/time_interval.h @@ -13,7 +13,7 @@ #include <stdint.h> -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -57,7 +57,7 @@ class TimeInterval { int64_t first, last; }; - rtc::Optional<Interval> interval_; + absl::optional<Interval> interval_; }; } // namespace webrtc diff --git a/audio/transport_feedback_packet_loss_tracker.cc b/audio/transport_feedback_packet_loss_tracker.cc index 101b6b4881..7e0c5c542f 100644 --- a/audio/transport_feedback_packet_loss_tracker.cc +++ b/audio/transport_feedback_packet_loss_tracker.cc @@ -116,12 +116,12 @@ void TransportFeedbackPacketLossTracker::OnPacketFeedbackVector( } } -rtc::Optional<float> -TransportFeedbackPacketLossTracker::GetPacketLossRate() const { +absl::optional<float> TransportFeedbackPacketLossTracker::GetPacketLossRate() + const { return plr_state_.GetMetric(); } -rtc::Optional<float> +absl::optional<float> TransportFeedbackPacketLossTracker::GetRecoverablePacketLossRate() const { return rplr_state_.GetMetric(); } @@ -344,20 +344,20 @@ void TransportFeedbackPacketLossTracker::Validate() const { // Testing only! RTC_CHECK_EQ(rplr_state_.num_recoverable_losses_, recoverable_losses); } -rtc::Optional<float> -TransportFeedbackPacketLossTracker::PlrState::GetMetric() const { +absl::optional<float> TransportFeedbackPacketLossTracker::PlrState::GetMetric() + const { const size_t total = num_lost_packets_ + num_received_packets_; if (total < min_num_acked_packets_) { - return rtc::nullopt; + return absl::nullopt; } else { return static_cast<float>(num_lost_packets_) / total; } } -rtc::Optional<float> -TransportFeedbackPacketLossTracker::RplrState::GetMetric() const { +absl::optional<float> TransportFeedbackPacketLossTracker::RplrState::GetMetric() + const { if (num_acked_pairs_ < min_num_acked_pairs_) { - return rtc::nullopt; + return absl::nullopt; } else { return static_cast<float>(num_recoverable_losses_) / num_acked_pairs_; } diff --git a/audio/transport_feedback_packet_loss_tracker.h b/audio/transport_feedback_packet_loss_tracker.h index 4ad49024a8..7d58d6c4bd 100644 --- a/audio/transport_feedback_packet_loss_tracker.h +++ b/audio/transport_feedback_packet_loss_tracker.h @@ -14,7 +14,7 @@ #include <map> #include <vector> -#include "api/optional.h" +#include "absl/types/optional.h" namespace webrtc { @@ -43,11 +43,11 @@ class TransportFeedbackPacketLossTracker final { // Returns the packet loss rate, if the window has enough packet statuses to // reliably compute it. Otherwise, returns empty. - rtc::Optional<float> GetPacketLossRate() const; + absl::optional<float> GetPacketLossRate() const; // Returns the first-order-FEC recoverable packet loss rate, if the window has // enough status pairs to reliably compute it. Otherwise, returns empty. - rtc::Optional<float> GetRecoverablePacketLossRate() const; + absl::optional<float> GetRecoverablePacketLossRate() const; // Verifies that the internal states are correct. Only used for tests. void Validate() const; @@ -108,7 +108,7 @@ class TransportFeedbackPacketLossTracker final { num_received_packets_ = 0; num_lost_packets_ = 0; } - rtc::Optional<float> GetMetric() const; + absl::optional<float> GetMetric() const; const size_t min_num_acked_packets_; size_t num_received_packets_; size_t num_lost_packets_; @@ -124,7 +124,7 @@ class TransportFeedbackPacketLossTracker final { num_acked_pairs_ = 0; num_recoverable_losses_ = 0; } - rtc::Optional<float> GetMetric() const; + absl::optional<float> GetMetric() const; // Recoverable packets are those which were lost, but immediately followed // by a properly received packet. If that second packet carried FEC, // the data from the former (lost) packet could be recovered. diff --git a/audio/transport_feedback_packet_loss_tracker_unittest.cc b/audio/transport_feedback_packet_loss_tracker_unittest.cc index 8f8fe05d7a..b190c62c05 100644 --- a/audio/transport_feedback_packet_loss_tracker_unittest.cc +++ b/audio/transport_feedback_packet_loss_tracker_unittest.cc @@ -94,18 +94,18 @@ class TransportFeedbackPacketLossTrackerTest // value is as expected. void ValidatePacketLossStatistics( const TransportFeedbackPacketLossTracker& tracker, - rtc::Optional<float> expected_plr, - rtc::Optional<float> expected_rplr) { - // TODO(eladalon): Comparing the rtc::Optional<float> directly would have + absl::optional<float> expected_plr, + absl::optional<float> expected_rplr) { + // TODO(eladalon): Comparing the absl::optional<float> directly would have // given concise code, but less readable error messages. If we modify - // the way rtc::Optional is printed, we can get rid of this. - rtc::Optional<float> plr = tracker.GetPacketLossRate(); + // the way absl::optional is printed, we can get rid of this. + absl::optional<float> plr = tracker.GetPacketLossRate(); EXPECT_EQ(static_cast<bool>(expected_plr), static_cast<bool>(plr)); if (expected_plr && plr) { EXPECT_EQ(*expected_plr, *plr); } - rtc::Optional<float> rplr = tracker.GetRecoverablePacketLossRate(); + absl::optional<float> rplr = tracker.GetRecoverablePacketLossRate(); EXPECT_EQ(static_cast<bool>(expected_rplr), static_cast<bool>(rplr)); if (expected_rplr && rplr) { EXPECT_EQ(*expected_rplr, *rplr); @@ -127,7 +127,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, EmptyWindow) { TransportFeedbackPacketLossTracker tracker(kDefaultMaxWindowSizeMs, 5, 5); // PLR and RPLR reported as unknown before reception of first feedback. - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // A feedback received for an empty window has no effect. @@ -136,7 +136,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, EmptyWindowFeedback) { // Feedback doesn't correspond to any packets - ignored. AddTransportFeedbackAndValidate(&tracker, base_, {true, false, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); // After the packets are transmitted, acking them would have an effect. SendPackets(&tracker, base_, 3, kDefaultSendIntervalMs); @@ -153,7 +153,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, PartiallyFilledWindow) { // Expected window contents: [] -> [1001]. SendPackets(&tracker, base_, 3, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // Sanity check on minimum filled window - PLR known, RPLR unknown. @@ -166,7 +166,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, PlrMinimumFilledWindow) { SendPackets(&tracker, base_, 5, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, rtc::nullopt); + ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, absl::nullopt); } // Sanity check on minimum filled window - PLR unknown, RPLR known. @@ -179,7 +179,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, RplrMinimumFilledWindow) { SendPackets(&tracker, base_, 5, kDefaultSendIntervalMs); AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, rtc::nullopt, 1.0f / 4.0f); + ValidatePacketLossStatistics(tracker, absl::nullopt, 1.0f / 4.0f); } // If packets are sent close enough together that the clock reading for both @@ -203,7 +203,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, ExtendWindow) { // Expected window contents: [] -> [10011]. AddTransportFeedbackAndValidate(&tracker, base_, {true, false, false, true, true}); - ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, rtc::nullopt); + ValidatePacketLossStatistics(tracker, 2.0f / 5.0f, absl::nullopt); // Expected window contents: [10011] -> [1001110101]. AddTransportFeedbackAndValidate(&tracker, base_ + 5, @@ -520,7 +520,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, RepeatedSeqNumResetsWindow) { // A reset occurs. SendPackets(&tracker, {static_cast<uint16_t>(base_ + 2)}, kDefaultSendIntervalMs); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } // The window is reset by the sending of a packet which is 0x8000 or more @@ -539,7 +539,7 @@ TEST_P(TransportFeedbackPacketLossTrackerTest, // A reset occurs. SendPackets(&tracker, {static_cast<uint16_t>(base_ + 5 + 0x8000)}, kDefaultSendIntervalMs); - ValidatePacketLossStatistics(tracker, rtc::nullopt, rtc::nullopt); + ValidatePacketLossStatistics(tracker, absl::nullopt, absl::nullopt); } #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |