Replace ArrayView with std::span everywhere except api ArrayView is an alias to std::span. This change switch to use std::span directly instead of through the alias. Search&Replace MakeArrayView and ArrayView with std::span Search&Replace include "api/array_view.h" with include <span> Remove <span> include where std::span is not mentioned in the file Remove build dependencies on array_view target Bug: webrtc:439801349 Change-Id: I64bbdcf1300126286158ccbeda62c49e0c3ec83f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/460501 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47294}
diff --git a/audio/BUILD.gn b/audio/BUILD.gn index c39c42d..c710be0 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn
@@ -40,7 +40,6 @@ ] deps = [ - "../api:array_view", "../api:bitrate_allocation", "../api:call_api", "../api:field_trials_view", @@ -165,7 +164,6 @@ ":audio", ":audio_end_to_end_test", ":channel_receive_unittest", - "../api:array_view", "../api:bitrate_allocation", "../api:call_api", "../api:field_trials", @@ -252,7 +250,6 @@ sources = [ "channel_receive_unittest.cc" ] deps = [ ":audio", - "../api:array_view", "../api:make_ref_counted", "../api:mock_frame_transformer", "../api:scoped_refptr",
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index 4f31b48..4f052c6 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc
@@ -15,12 +15,12 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_format.h" @@ -446,7 +446,7 @@ return channel_receive_->SetMinimumPlayoutDelay(delay); } -void AudioReceiveStreamImpl::DeliverRtcp(ArrayView<const uint8_t> packet) { +void AudioReceiveStreamImpl::DeliverRtcp(std::span<const uint8_t> packet) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_receive_->ReceivedRTCPPacket(packet.data(), packet.size()); }
diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index 111cd89..41a470f 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h
@@ -16,11 +16,11 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_format.h" @@ -128,7 +128,7 @@ Timestamp time) override; bool SetMinimumPlayoutDelay(TimeDelta delay) override; - void DeliverRtcp(ArrayView<const uint8_t> packet); + void DeliverRtcp(std::span<const uint8_t> packet); void SetSyncGroup(absl::string_view sync_group);
diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 4c53757..25efcb8 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc
@@ -15,13 +15,13 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/strings/str_cat.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_processing.h" #include "api/audio_codecs/audio_encoder.h" @@ -495,7 +495,7 @@ return stats; } -void AudioSendStream::DeliverRtcp(ArrayView<const uint8_t> packet) { +void AudioSendStream::DeliverRtcp(std::span<const uint8_t> packet) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_send_->ReceivedRTCPPacket(packet.data(), packet.size()); // Poll if overhead has changed, which it can do if ack triggers us to stop
diff --git a/audio/audio_send_stream.h b/audio/audio_send_stream.h index 9bac560..7cc204c 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h
@@ -15,10 +15,10 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/environment/environment.h" #include "api/field_trials_view.h" @@ -103,7 +103,7 @@ webrtc::AudioSendStream::Stats GetStats( bool has_remote_tracks) const override; - void DeliverRtcp(ArrayView<const uint8_t> packet); + void DeliverRtcp(std::span<const uint8_t> packet); // Implements BitrateAllocatorObserver. uint32_t OnBitrateUpdated(BitrateAllocationUpdate update) override;
diff --git a/audio/audio_send_stream_tests.cc b/audio/audio_send_stream_tests.cc index 6c754a1..5379026 100644 --- a/audio/audio_send_stream_tests.cc +++ b/audio/audio_send_stream_tests.cc
@@ -10,10 +10,10 @@ #include <cstddef> #include <cstdint> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "api/rtp_headers.h" #include "api/rtp_parameters.h" #include "call/audio_receive_stream.h" @@ -56,7 +56,7 @@ CNameObserver() = default; private: - Action OnSendRtcp(ArrayView<const uint8_t> packet) override { + Action OnSendRtcp(std::span<const uint8_t> packet) override { RtcpPacketParser parser; EXPECT_TRUE(parser.Parse(packet)); if (parser.sdes()->num_packets() > 0) { @@ -89,7 +89,7 @@ NoExtensionsObserver() = default; private: - Action OnSendRtp(ArrayView<const uint8_t> packet) override { + Action OnSendRtp(std::span<const uint8_t> packet) override { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); // rtp packet is valid. EXPECT_EQ(packet[0] & 0b0001'0000, 0); // extension bit not set. @@ -119,7 +119,7 @@ extensions_.Register<AudioLevelExtension>(kAudioLevelExtensionId); } - Action OnSendRtp(ArrayView<const uint8_t> packet) override { + Action OnSendRtp(std::span<const uint8_t> packet) override { RtpPacket rtp_packet(&extensions_); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -164,7 +164,7 @@ } private: - Action OnSendRtp(ArrayView<const uint8_t> packet) override { + Action OnSendRtp(std::span<const uint8_t> packet) override { RtpPacket rtp_packet(&extensions_); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -210,7 +210,7 @@ DtmfObserver() = default; private: - Action OnSendRtp(ArrayView<const uint8_t> packet) override { + Action OnSendRtp(std::span<const uint8_t> packet) override { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet));
diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 2eb4a62..dfd4cd4 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc
@@ -17,11 +17,11 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -220,7 +220,7 @@ int GetRtpTimestampRateHz() const; - void OnReceivedPayloadData(ArrayView<const uint8_t> payload, + void OnReceivedPayloadData(std::span<const uint8_t> payload, const RTPHeader& header, Timestamp receive_time) RTC_RUN_ON(worker_thread_checker_); @@ -334,7 +334,7 @@ RTC_GUARDED_BY(worker_thread_checker_); }; -void ChannelReceive::OnReceivedPayloadData(ArrayView<const uint8_t> payload, +void ChannelReceive::OnReceivedPayloadData(std::span<const uint8_t> payload, const RTPHeader& header, Timestamp receive_time) { if (!playing_) { @@ -379,7 +379,7 @@ // Pass a callback to ChannelReceive::OnReceivedPayloadData, to be called by // the delegate to receive transformed audio. ChannelReceiveFrameTransformerDelegate::ReceiveFrameCallback - receive_audio_callback = [this](ArrayView<const uint8_t> packet, + receive_audio_callback = [this](std::span<const uint8_t> packet, const RTPHeader& header, Timestamp receive_time) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); @@ -737,7 +737,7 @@ frame_decryptor_->Decrypt( MediaType::AUDIO, csrcs, /*additional_data=*/{}, - ArrayView<const uint8_t>(payload, payload_data_length), + std::span<const uint8_t>(payload, payload_data_length), decrypted_audio_payload); if (decrypt_result.IsOk()) { @@ -755,7 +755,7 @@ payload_data_length = 0; } - ArrayView<const uint8_t> payload_data(payload, payload_data_length); + std::span<const uint8_t> payload_data(payload, payload_data_length); if (frame_transformer_delegate_) { // Asynchronously transform the received payload. After the payload is // transformed, the delegate will call OnReceivedPayloadData to handle it. @@ -778,7 +778,7 @@ UpdatePlayoutTimestamp(true, env_.clock().CurrentTime()); // Deliver RTCP packet to RTP/RTCP module for parsing - rtp_rtcp_->IncomingRtcpPacket(MakeArrayView(data, length)); + rtp_rtcp_->IncomingRtcpPacket(std::span(data, length)); std::optional<TimeDelta> rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) {
diff --git a/audio/channel_receive_frame_transformer_delegate.cc b/audio/channel_receive_frame_transformer_delegate.cc index 887edaa..b2422d0 100644 --- a/audio/channel_receive_frame_transformer_delegate.cc +++ b/audio/channel_receive_frame_transformer_delegate.cc
@@ -14,10 +14,10 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> -#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/rtp_headers.h" #include "api/scoped_refptr.h" @@ -34,7 +34,7 @@ class TransformableIncomingAudioFrame : public TransformableAudioFrameInterface { public: - TransformableIncomingAudioFrame(ArrayView<const uint8_t> payload, + TransformableIncomingAudioFrame(std::span<const uint8_t> payload, const RTPHeader& header, uint32_t ssrc, const std::string& codec_mime_type, @@ -46,9 +46,9 @@ codec_mime_type_(codec_mime_type), receive_time_(receive_time) {} ~TransformableIncomingAudioFrame() override = default; - ArrayView<const uint8_t> GetData() const override { return payload_; } + std::span<const uint8_t> GetData() const override { return payload_; } - void SetData(ArrayView<const uint8_t> data) override { + void SetData(std::span<const uint8_t> data) override { payload_.SetData(data.data(), data.size()); } @@ -59,8 +59,8 @@ uint8_t GetPayloadType() const override { return header_.payloadType; } uint32_t GetSsrc() const override { return ssrc_; } uint32_t GetTimestamp() const override { return header_.timestamp; } - ArrayView<const uint32_t> GetContributingSources() const override { - return ArrayView<const uint32_t>(header_.arrOfCSRCs, header_.numCSRCs); + std::span<const uint32_t> GetContributingSources() const override { + return std::span<const uint32_t>(header_.arrOfCSRCs, header_.numCSRCs); } Direction GetDirection() const override { return Direction::kReceiver; } @@ -159,7 +159,7 @@ } void ChannelReceiveFrameTransformerDelegate::Transform( - ArrayView<const uint8_t> packet, + std::span<const uint8_t> packet, const RTPHeader& header, uint32_t ssrc, const std::string& codec_mime_type,
diff --git a/audio/channel_receive_frame_transformer_delegate.h b/audio/channel_receive_frame_transformer_delegate.h index 1b5f04e..a0ba8fd 100644 --- a/audio/channel_receive_frame_transformer_delegate.h +++ b/audio/channel_receive_frame_transformer_delegate.h
@@ -14,9 +14,9 @@ #include <cstdint> #include <functional> #include <memory> +#include <span> #include <string> -#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/rtp_headers.h" #include "api/scoped_refptr.h" @@ -34,7 +34,7 @@ class ChannelReceiveFrameTransformerDelegate : public TransformedFrameCallback { public: using ReceiveFrameCallback = - std::function<void(webrtc::ArrayView<const uint8_t> packet, + std::function<void(std::span<const uint8_t> packet, const RTPHeader& header, Timestamp receive_time)>; ChannelReceiveFrameTransformerDelegate( @@ -54,7 +54,7 @@ // Delegates the call to FrameTransformerInterface::Transform, to transform // the frame asynchronously. - void Transform(ArrayView<const uint8_t> packet, + void Transform(std::span<const uint8_t> packet, const RTPHeader& header, uint32_t ssrc, const std::string& codec_mime_type,
diff --git a/audio/channel_receive_frame_transformer_delegate_unittest.cc b/audio/channel_receive_frame_transformer_delegate_unittest.cc index ae9a01c..01dbaee 100644 --- a/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/audio/channel_receive_frame_transformer_delegate_unittest.cc
@@ -12,9 +12,9 @@ #include <cstdint> #include <memory> +#include <span> #include <utility> -#include "api/array_view.h" #include "api/frame_transformer_factory.h" #include "api/frame_transformer_interface.h" #include "api/make_ref_counted.h" @@ -44,12 +44,12 @@ public: MOCK_METHOD(void, ReceiveFrame, - (ArrayView<const uint8_t> packet, + (std::span<const uint8_t> packet, const RTPHeader& header, Timestamp receive_time)); ChannelReceiveFrameTransformerDelegate::ReceiveFrameCallback callback() { - return [this](ArrayView<const uint8_t> packet, const RTPHeader& header, + return [this](std::span<const uint8_t> packet, const RTPHeader& header, Timestamp receive_time) { ReceiveFrame(packet, header, receive_time); }; @@ -101,7 +101,7 @@ ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); RTPHeader header; EXPECT_CALL(mock_channel, ReceiveFrame); ON_CALL(*mock_frame_transformer, Transform) @@ -132,7 +132,7 @@ ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); RTPHeader header; EXPECT_CALL(mock_channel, ReceiveFrame(ElementsAre(1, 2, 3, 4), _, kFakeReceiveTimestamp)); @@ -177,7 +177,7 @@ make_ref_counted<ChannelReceiveFrameTransformerDelegate>( mock_channel.callback(), mock_frame_transformer, Thread::Current()); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); RTPHeader header; delegate->StartShortCircuiting(); @@ -207,7 +207,7 @@ ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); RTPHeader header; std::unique_ptr<TransformableFrameInterface> frame; ON_CALL(*mock_frame_transformer, Transform) @@ -244,7 +244,7 @@ ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); RTPHeader header; uint8_t audio_level_dbov = 67; AudioLevel audio_level(/*voice_activity=*/true, audio_level_dbov); @@ -282,7 +282,7 @@ ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); Timestamp capture_time = Timestamp::Millis(1234); TimeDelta sender_capture_time_offsets[] = {TimeDelta::Millis(56), TimeDelta::Millis(-79)}; @@ -320,7 +320,7 @@ Thread::Current()); delegate->Init(); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView<const uint8_t> packet(data, sizeof(data)); + std::span<const uint8_t> packet(data, sizeof(data)); std::unique_ptr<TransformableFrameInterface> frame; ON_CALL(*mock_frame_transformer, Transform) .WillByDefault(
diff --git a/audio/channel_receive_unittest.cc b/audio/channel_receive_unittest.cc index 72e45c3..83cc6d5 100644 --- a/audio/channel_receive_unittest.cc +++ b/audio/channel_receive_unittest.cc
@@ -14,10 +14,10 @@ #include <cstdint> #include <cstring> #include <memory> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" @@ -142,7 +142,7 @@ } void HandleGeneratedRtcp(ChannelReceiveInterface& /* channel */, - ArrayView<const uint8_t> packet) { + std::span<const uint8_t> packet) { if (packet[1] == rtcp::ReceiverReport::kPacketType) { // Ignore RR, it requires no response } else { @@ -185,7 +185,7 @@ bool receiver_report_sent = false; EXPECT_CALL(transport_, SendRtcp) - .WillRepeatedly([&](ArrayView<const uint8_t> packet, + .WillRepeatedly([&](std::span<const uint8_t> packet, const PacketOptions& options) { if (packet.size() >= 2 && packet[1] == rtcp::ReceiverReport::kPacketType) { @@ -205,7 +205,7 @@ EXPECT_CALL(transport_, SendRtcp) .WillRepeatedly( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { HandleGeneratedRtcp(*channel, packet); return true; });
diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 68fd2f6..528bd26 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc
@@ -16,13 +16,13 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/functional/any_invocable.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" #include "api/call/bitrate_allocation.h" @@ -165,7 +165,7 @@ void SetInputMute(bool enable) override; // CSRCs. - void SetCsrcs(ArrayView<const uint32_t> csrcs) override; + void SetCsrcs(std::span<const uint32_t> csrcs) override; // Stats. ANAStats GetANAStatistics() const override; @@ -243,9 +243,9 @@ int32_t SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, - ArrayView<const uint8_t> payload, + std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov) RTC_RUN_ON(worker_thread_); @@ -418,9 +418,9 @@ int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, - ArrayView<const uint8_t> payload, + std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov) { // E2EE Custom Audio Frame Encryption (This is optional). // Keep this buffer around for the lifetime of the send call. @@ -695,7 +695,7 @@ RTC_DCHECK_RUN_ON(worker_thread_); // Deliver RTCP packet to RTP/RTCP module for parsing - rtp_rtcp_->IncomingRtcpPacket(MakeArrayView(data, length)); + rtp_rtcp_->IncomingRtcpPacket(std::span(data, length)); std::optional<TimeDelta> rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) { @@ -721,7 +721,7 @@ return input_mute_; } -void ChannelSend::SetCsrcs(ArrayView<const uint32_t> csrcs) { +void ChannelSend::SetCsrcs(std::span<const uint32_t> csrcs) { RTC_DCHECK_RUN_ON(worker_thread_); std::vector<uint32_t> csrcs_copy( csrcs.begin(), @@ -919,7 +919,7 @@ rms_level_.AnalyzeMuted(length); } else { rms_level_.Analyze( - ArrayView<const int16_t>(audio_frame->data(), length)); + std::span<const int16_t>(audio_frame->data(), length)); } } previous_frame_muted_ = is_muted; @@ -984,9 +984,9 @@ ChannelSendFrameTransformerDelegate::SendFrameCallback send_audio_callback = [this](AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_with_offset, - ArrayView<const uint8_t> payload, + std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov) { RTC_DCHECK_RUN_ON(worker_thread_); return SendRtpAudio(
diff --git a/audio/channel_send.h b/audio/channel_send.h index 185f3e9..ab97c3b 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h
@@ -15,10 +15,10 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -96,7 +96,7 @@ // Sets the list of CSRCs to be included in the RTP header. If more than // kRtpCsrcSize CSRCs are provided, only the first kRtpCsrcSize elements are // kept. - virtual void SetCsrcs(ArrayView<const uint32_t> csrcs) = 0; + virtual void SetCsrcs(std::span<const uint32_t> csrcs) = 0; virtual void ProcessAndEncodeAudio( std::unique_ptr<AudioFrame> audio_frame) = 0;
diff --git a/audio/channel_send_frame_transformer_delegate.cc b/audio/channel_send_frame_transformer_delegate.cc index 044f1c3..57079c3 100644 --- a/audio/channel_send_frame_transformer_delegate.cc +++ b/audio/channel_send_frame_transformer_delegate.cc
@@ -14,11 +14,11 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/scoped_refptr.h" #include "api/sequence_checker.h" @@ -91,8 +91,8 @@ sequence_number_(sequence_number), audio_level_dbov_(audio_level_dbov) {} ~TransformableOutgoingAudioFrame() override = default; - ArrayView<const uint8_t> GetData() const override { return payload_; } - void SetData(ArrayView<const uint8_t> data) override { + std::span<const uint8_t> GetData() const override { return payload_; } + void SetData(std::span<const uint8_t> data) override { payload_.SetData(data.data(), data.size()); } uint32_t GetTimestamp() const override { return rtp_timestamp_with_offset_; } @@ -110,7 +110,7 @@ Direction GetDirection() const override { return Direction::kSender; } std::string GetMimeType() const override { return codec_mime_type_; } - ArrayView<const uint32_t> GetContributingSources() const override { + std::span<const uint32_t> GetContributingSources() const override { return csrcs_; }
diff --git a/audio/channel_send_frame_transformer_delegate.h b/audio/channel_send_frame_transformer_delegate.h index c495af6..678f51f 100644 --- a/audio/channel_send_frame_transformer_delegate.h +++ b/audio/channel_send_frame_transformer_delegate.h
@@ -16,10 +16,10 @@ #include <functional> #include <memory> #include <optional> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/scoped_refptr.h" #include "api/task_queue/task_queue_base.h" @@ -40,9 +40,9 @@ std::function<int32_t(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_with_offset, - webrtc::ArrayView<const uint8_t> payload, + std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - webrtc::ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov)>; ChannelSendFrameTransformerDelegate( SendFrameCallback send_frame_callback,
diff --git a/audio/channel_send_frame_transformer_delegate_unittest.cc b/audio/channel_send_frame_transformer_delegate_unittest.cc index 20acb49..d5e19c1 100644 --- a/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/audio/channel_send_frame_transformer_delegate_unittest.cc
@@ -13,11 +13,11 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> #include "absl/memory/memory.h" -#include "api/array_view.h" #include "api/frame_transformer_interface.h" #include "api/make_ref_counted.h" #include "api/scoped_refptr.h" @@ -51,16 +51,16 @@ (AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp, - ArrayView<const uint8_t> payload, + std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov)); ChannelSendFrameTransformerDelegate::SendFrameCallback callback() { return [this](AudioFrameType frameType, uint8_t payloadType, - uint32_t rtp_timestamp, ArrayView<const uint8_t> payload, + uint32_t rtp_timestamp, std::span<const uint8_t> payload, int64_t absolute_capture_timestamp_ms, - ArrayView<const uint32_t> csrcs, + std::span<const uint32_t> csrcs, std::optional<uint8_t> audio_level_dbov) { return SendFrame(frameType, payloadType, rtp_timestamp, payload, absolute_capture_timestamp_ms, csrcs, audio_level_dbov); @@ -73,7 +73,7 @@ std::optional<uint8_t> audio_level_dbov) { std::unique_ptr<MockTransformableAudioFrame> mock_frame = std::make_unique<NiceMock<MockTransformableAudioFrame>>(); - ArrayView<const uint8_t> payload(mock_data); + std::span<const uint8_t> payload(mock_data); ON_CALL(*mock_frame, GetData).WillByDefault(Return(payload)); ON_CALL(*mock_frame, GetPayloadType).WillByDefault(Return(0)); ON_CALL(*mock_frame, GetDirection)
diff --git a/audio/channel_send_unittest.cc b/audio/channel_send_unittest.cc index 4835056..e777cf6 100644 --- a/audio/channel_send_unittest.cc +++ b/audio/channel_send_unittest.cc
@@ -14,10 +14,10 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_encoder_factory.h" @@ -155,7 +155,7 @@ channel_->StartSend(); uint32_t timestamp; int sent_packets = 0; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { ++sent_packets; RtpPacketReceived packet; @@ -190,7 +190,7 @@ EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::optional<uint32_t> sent_timestamp; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { RtpPacketReceived packet; packet.Parse(data); @@ -239,7 +239,7 @@ EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::vector<uint8_t> sent_audio_levels; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { RtpPacketReceived packet(&extension_manager); packet.Parse(data); @@ -303,7 +303,7 @@ EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::optional<uint8_t> sent_audio_level; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { RtpPacketReceived packet(&extension_manager); packet.Parse(data); @@ -323,7 +323,7 @@ ON_CALL(*mock_frame, AudioLevel()).WillByDefault(Return(audio_level)); uint8_t payload[10]; ON_CALL(*mock_frame, GetData()) - .WillByDefault(Return(ArrayView<uint8_t>(&payload[0], 10))); + .WillByDefault(Return(std::span<uint8_t>(&payload[0], 10))); EXPECT_THAT(WaitUntil([&] { return callback; }, IsTrue()), IsRtcOk()); callback->OnTransformedFrame(std::move(mock_frame)); @@ -415,7 +415,7 @@ channel_->SetCsrcs(expected_csrcs); std::vector<uint32_t> csrcs; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { RtpPacketReceived packet; packet.Parse(data); @@ -500,7 +500,7 @@ channel_->StartSend(); std::vector<uint32_t> sent_csrcs; - auto send_rtp = [&](ArrayView<const uint8_t> data, + auto send_rtp = [&](std::span<const uint8_t> data, const PacketOptions& /* options */) { RtpPacketReceived packet; packet.Parse(data);
diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index db4d73a..c460bb1 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h
@@ -16,11 +16,11 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_encoder.h" @@ -208,7 +208,7 @@ RegisterPacketOverhead, (int packet_byte_overhead), (override)); - MOCK_METHOD(void, SetCsrcs, (ArrayView<const uint32_t> csrcs), (override)); + MOCK_METHOD(void, SetCsrcs, (std::span<const uint32_t> csrcs), (override)); }; } // namespace test } // namespace webrtc
diff --git a/audio/voip/BUILD.gn b/audio/voip/BUILD.gn index 5780fd2..dd5e127 100644 --- a/audio/voip/BUILD.gn +++ b/audio/voip/BUILD.gn
@@ -16,7 +16,6 @@ deps = [ ":audio_channel", "..:audio", - "../../api:array_view", "../../api:make_ref_counted", "../../api:scoped_refptr", "../../api:transport_api", @@ -43,7 +42,6 @@ deps = [ ":audio_egress", ":audio_ingress", - "../../api:array_view", "../../api:ref_count", "../../api:rtp_headers", "../../api:scoped_refptr", @@ -67,7 +65,6 @@ ] deps = [ "..:audio", - "../../api:array_view", "../../api:scoped_refptr", "../../api/audio:audio_mixer_api", "../../api/audio_codecs:audio_codecs_api", @@ -97,7 +94,6 @@ ] deps = [ "..:audio", - "../../api:array_view", "../../api:sequence_checker", "../../api/audio:audio_frame_api", "../../api/audio_codecs:audio_codecs_api",
diff --git a/audio/voip/audio_channel.h b/audio/voip/audio_channel.h index b670b31..268e15e 100644 --- a/audio/voip/audio_channel.h +++ b/audio/voip/audio_channel.h
@@ -15,9 +15,9 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <utility> -#include "api/array_view.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_encoder.h" @@ -83,10 +83,10 @@ // APIs relayed to AudioIngress. bool IsPlaying() const { return ingress_->IsPlaying(); } - void ReceivedRTPPacket(ArrayView<const uint8_t> rtp_packet) { + void ReceivedRTPPacket(std::span<const uint8_t> rtp_packet) { ingress_->ReceivedRTPPacket(rtp_packet); } - void ReceivedRTCPPacket(ArrayView<const uint8_t> rtcp_packet) { + void ReceivedRTCPPacket(std::span<const uint8_t> rtcp_packet) { ingress_->ReceivedRTCPPacket(rtcp_packet); } void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs) {
diff --git a/audio/voip/audio_egress.cc b/audio/voip/audio_egress.cc index fc69d2b..36ffe21 100644 --- a/audio/voip/audio_egress.cc +++ b/audio/voip/audio_egress.cc
@@ -13,9 +13,9 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> #include <utility> -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_encoder.h" #include "api/audio_codecs/audio_format.h" @@ -132,7 +132,7 @@ size_t payload_size) { RTC_DCHECK_RUN_ON(&encoder_queue_checker_); - ArrayView<const uint8_t> payload(payload_data, payload_size); + std::span<const uint8_t> payload(payload_data, payload_size); // Currently we don't get a capture time from downstream modules (ADM, // AudioTransportImpl).
diff --git a/audio/voip/audio_ingress.cc b/audio/voip/audio_ingress.cc index b4525a1..1e2fa34 100644 --- a/audio/voip/audio_ingress.cc +++ b/audio/voip/audio_ingress.cc
@@ -14,10 +14,10 @@ #include <ctime> #include <map> #include <optional> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_format.h" @@ -160,7 +160,7 @@ neteq_->SetCodecs(codecs); } -void AudioIngress::ReceivedRTPPacket(ArrayView<const uint8_t> rtp_packet) { +void AudioIngress::ReceivedRTPPacket(std::span<const uint8_t> rtp_packet) { RtpPacketReceived rtp_packet_received; rtp_packet_received.Parse(rtp_packet.data(), rtp_packet.size()); @@ -204,7 +204,7 @@ const uint8_t* payload = rtp_packet_received.data() + header.headerLength; size_t payload_length = packet_length - header.headerLength; size_t payload_data_length = payload_length - header.paddingLength; - auto data_view = ArrayView<const uint8_t>(payload, payload_data_length); + auto data_view = std::span<const uint8_t>(payload, payload_data_length); // Push the incoming payload (parsed and ready for decoding) into NetEq. if (!data_view.empty()) { @@ -217,7 +217,7 @@ } } -void AudioIngress::ReceivedRTCPPacket(ArrayView<const uint8_t> rtcp_packet) { +void AudioIngress::ReceivedRTCPPacket(std::span<const uint8_t> rtcp_packet) { rtcp::CommonHeader rtcp_header; if (rtcp_header.Parse(rtcp_packet.data(), rtcp_packet.size()) && (rtcp_header.type() == rtcp::SenderReport::kPacketType ||
diff --git a/audio/voip/audio_ingress.h b/audio/voip/audio_ingress.h index e6d9836..a8ec34f 100644 --- a/audio/voip/audio_ingress.h +++ b/audio/voip/audio_ingress.h
@@ -17,8 +17,8 @@ #include <map> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" #include "api/audio_codecs/audio_format.h" @@ -72,8 +72,8 @@ void SetReceiveCodecs(const std::map<int, SdpAudioFormat>& codecs); // APIs to handle received RTP/RTCP packets from caller. - void ReceivedRTPPacket(ArrayView<const uint8_t> rtp_packet); - void ReceivedRTCPPacket(ArrayView<const uint8_t> rtcp_packet); + void ReceivedRTPPacket(std::span<const uint8_t> rtp_packet); + void ReceivedRTCPPacket(std::span<const uint8_t> rtcp_packet); // See comments on LevelFullRange, TotalEnergy, TotalDuration from // audio/audio_level.h.
diff --git a/audio/voip/test/BUILD.gn b/audio/voip/test/BUILD.gn index c0efeb6..0c1acf0 100644 --- a/audio/voip/test/BUILD.gn +++ b/audio/voip/test/BUILD.gn
@@ -49,7 +49,6 @@ deps = [ ":mock_task_queue", "..:audio_channel", - "../../../api:array_view", "../../../api:make_ref_counted", "../../../api:scoped_refptr", "../../../api/audio:audio_frame_api", @@ -76,7 +75,6 @@ deps = [ "..:audio_egress", "..:audio_ingress", - "../../../api:array_view", "../../../api:rtp_headers", "../../../api:scoped_refptr", "../../../api/audio:audio_frame_api", @@ -102,7 +100,6 @@ sources = [ "audio_egress_unittest.cc" ] deps = [ "..:audio_egress", - "../../../api:array_view", "../../../api:rtp_headers", "../../../api:scoped_refptr", "../../../api:transport_api",
diff --git a/audio/voip/test/audio_channel_unittest.cc b/audio/voip/test/audio_channel_unittest.cc index 8b4c32f..a707e2d 100644 --- a/audio/voip/test/audio_channel_unittest.cc +++ b/audio/voip/test/audio_channel_unittest.cc
@@ -14,10 +14,10 @@ #include <cstring> #include <memory> #include <optional> +#include <span> #include <utility> #include "absl/functional/any_invocable.h" -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -120,7 +120,7 @@ // Resulted RTP packet is looped back into AudioChannel and gets decoded into // audio frame to see if it has some signal to indicate its validity. TEST_F(AudioChannelTest, PlayRtpByLocalLoop) { - auto loop_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto loop_rtp = [&](std::span<const uint8_t> packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; @@ -145,7 +145,7 @@ // Validate assigned local SSRC is resulted in RTP packet. TEST_F(AudioChannelTest, VerifyLocalSsrcAsAssigned) { RtpPacketReceived rtp; - auto loop_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto loop_rtp = [&](std::span<const uint8_t> packet, Unused) { rtp.Parse(packet); return true; }; @@ -160,7 +160,7 @@ // Check metrics after processing an RTP packet. TEST_F(AudioChannelTest, TestIngressStatistics) { - auto loop_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto loop_rtp = [&](std::span<const uint8_t> packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; @@ -237,11 +237,11 @@ // Check ChannelStatistics metric after processing RTP and RTCP packets. TEST_F(AudioChannelTest, TestChannelStatistics) { - auto loop_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto loop_rtp = [&](std::span<const uint8_t> packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; - auto loop_rtcp = [&](ArrayView<const uint8_t> packet, Unused) { + auto loop_rtcp = [&](std::span<const uint8_t> packet, Unused) { audio_channel_->ReceivedRTCPPacket(packet); return true; }; @@ -306,7 +306,7 @@ auto send_recv_rtp = [&](scoped_refptr<AudioChannel> rtp_sender, scoped_refptr<AudioChannel> rtp_receiver) { // Setup routing logic via transport_. - auto route_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto route_rtp = [&](std::span<const uint8_t> packet, Unused) { rtp_receiver->ReceivedRTPPacket(packet); return true; }; @@ -328,7 +328,7 @@ auto send_recv_rtcp = [&](scoped_refptr<AudioChannel> rtcp_sender, scoped_refptr<AudioChannel> rtcp_receiver) { // Setup routing logic via transport_. - auto route_rtcp = [&](ArrayView<const uint8_t> packet, Unused) { + auto route_rtcp = [&](std::span<const uint8_t> packet, Unused) { rtcp_receiver->ReceivedRTCPPacket(packet); return true; };
diff --git a/audio/voip/test/audio_egress_unittest.cc b/audio/voip/test/audio_egress_unittest.cc index a086ab9..5cf9a2a 100644 --- a/audio/voip/test/audio_egress_unittest.cc +++ b/audio/voip/test/audio_egress_unittest.cc
@@ -14,8 +14,8 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio_codecs/audio_encoder_factory.h" #include "api/audio_codecs/audio_format.h" @@ -131,7 +131,7 @@ Event event; int rtp_count = 0; RtpPacketReceived rtp; - auto rtp_sent = [&](ArrayView<const uint8_t> packet, Unused) { + auto rtp_sent = [&](std::span<const uint8_t> packet, Unused) { rtp.Parse(packet); if (++rtp_count == kExpected) { event.Set(); @@ -169,7 +169,7 @@ Event event; int rtp_count = 0; RtpPacketReceived rtp; - auto rtp_sent = [&](ArrayView<const uint8_t> packet, Unused) { + auto rtp_sent = [&](std::span<const uint8_t> packet, Unused) { rtp.Parse(packet); if (++rtp_count == kExpected) { event.Set(); @@ -204,7 +204,7 @@ constexpr int kExpected = 10; Event event; int rtp_count = 0; - auto rtp_sent = [&](ArrayView<const uint8_t> /* packet */, Unused) { + auto rtp_sent = [&](std::span<const uint8_t> /* packet */, Unused) { if (++rtp_count == kExpected) { event.Set(); } @@ -278,7 +278,7 @@ // It's possible that we may have actual audio RTP packets along with // DTMF packtets. We are only interested in the exact number of DTMF // packets rtp stack is emitting. - auto rtp_sent = [&](ArrayView<const uint8_t> packet, Unused) { + auto rtp_sent = [&](std::span<const uint8_t> packet, Unused) { RtpPacketReceived rtp; rtp.Parse(packet); if (is_dtmf(rtp) && ++dtmf_count == kExpected) { @@ -305,7 +305,7 @@ constexpr int kExpected = 6; Event event; int rtp_count = 0; - auto rtp_sent = [&](ArrayView<const uint8_t> /* packet */, Unused) { + auto rtp_sent = [&](std::span<const uint8_t> /* packet */, Unused) { if (++rtp_count == kExpected) { event.Set(); }
diff --git a/audio/voip/test/audio_ingress_unittest.cc b/audio/voip/test/audio_ingress_unittest.cc index 477e653..23e39aef 100644 --- a/audio/voip/test/audio_ingress_unittest.cc +++ b/audio/voip/test/audio_ingress_unittest.cc
@@ -13,8 +13,8 @@ #include <cstddef> #include <cstdint> #include <memory> +#include <span> -#include "api/array_view.h" #include "api/audio/audio_frame.h" #include "api/audio/audio_mixer.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -125,7 +125,7 @@ TEST_F(AudioIngressTest, GetAudioFrameAfterRtpReceived) { Event event; - auto handle_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto handle_rtp = [&](std::span<const uint8_t> packet, Unused) { ingress_->ReceivedRTPPacket(packet); event.Set(); return true; @@ -155,7 +155,7 @@ constexpr int kNumRtp = 6; int rtp_count = 0; Event event; - auto handle_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto handle_rtp = [&](std::span<const uint8_t> packet, Unused) { ingress_->ReceivedRTPPacket(packet); if (++rtp_count == kNumRtp) { event.Set(); @@ -186,7 +186,7 @@ TEST_F(AudioIngressTest, PreferredSampleRate) { Event event; - auto handle_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto handle_rtp = [&](std::span<const uint8_t> packet, Unused) { ingress_->ReceivedRTPPacket(packet); event.Set(); return true; @@ -215,7 +215,7 @@ constexpr int kNumRtp = 6; int rtp_count = 0; Event event; - auto handle_rtp = [&](ArrayView<const uint8_t> packet, Unused) { + auto handle_rtp = [&](std::span<const uint8_t> packet, Unused) { ingress_->ReceivedRTPPacket(packet); if (++rtp_count == kNumRtp) { event.Set();
diff --git a/audio/voip/voip_core.cc b/audio/voip/voip_core.cc index d3ce340..a5d5fc3 100644 --- a/audio/voip/voip_core.cc +++ b/audio/voip/voip_core.cc
@@ -16,10 +16,10 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_device.h" #include "api/audio/audio_processing.h" #include "api/audio_codecs/audio_decoder_factory.h" @@ -367,7 +367,7 @@ } VoipResult VoipCore::ReceivedRTPPacket(ChannelId channel_id, - ArrayView<const uint8_t> rtp_packet) { + std::span<const uint8_t> rtp_packet) { scoped_refptr<AudioChannel> channel = GetChannel(channel_id); if (!channel) { @@ -380,7 +380,7 @@ } VoipResult VoipCore::ReceivedRTCPPacket(ChannelId channel_id, - ArrayView<const uint8_t> rtcp_packet) { + std::span<const uint8_t> rtcp_packet) { scoped_refptr<AudioChannel> channel = GetChannel(channel_id); if (!channel) {
diff --git a/audio/voip/voip_core.h b/audio/voip/voip_core.h index dbd9150..45eca08 100644 --- a/audio/voip/voip_core.h +++ b/audio/voip/voip_core.h
@@ -15,9 +15,9 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <unordered_map> -#include "api/array_view.h" #include "api/audio/audio_device.h" #include "api/audio/audio_mixer.h" #include "api/audio/audio_processing.h" @@ -81,9 +81,9 @@ // Implements VoipNetwork interfaces. VoipResult ReceivedRTPPacket(ChannelId channel_id, - ArrayView<const uint8_t> rtp_packet) override; + std::span<const uint8_t> rtp_packet) override; VoipResult ReceivedRTCPPacket(ChannelId channel_id, - ArrayView<const uint8_t> rtcp_packet) override; + std::span<const uint8_t> rtcp_packet) override; // Implements VoipCodec interfaces. VoipResult SetSendCodec(ChannelId channel_id,
diff --git a/call/BUILD.gn b/call/BUILD.gn index b116163..a8ad708 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn
@@ -109,7 +109,6 @@ "rtp_transport_controller_send_interface.h", ] deps = [ - "../api:array_view", "../api:fec_controller_api", "../api:frame_transformer_interface", "../api:network_state_predictor_api", @@ -148,7 +147,6 @@ ] deps = [ ":rtp_interfaces", - "../api:array_view", "../api:sequence_checker", "../api/environment", "../logging:rtc_event_rtp_rtcp", @@ -178,7 +176,6 @@ deps = [ ":bitrate_configurator", ":rtp_interfaces", - "../api:array_view", "../api:bitrate_allocation", "../api:fec_controller_api", "../api:field_trials_view", @@ -306,7 +303,6 @@ ":version", ":video_receive_stream_api", ":video_send_stream_api", - "../api:array_view", "../api:fec_controller_api", "../api:field_trials_view", "../api:rtp_headers", @@ -407,7 +403,6 @@ ] deps = [ ":rtp_interfaces", - "../api:array_view", "../api:frame_transformer_interface", "../api:rtp_parameters", "../api:rtp_sender_interface", @@ -474,7 +469,6 @@ ] deps = [ ":simulated_packet_receiver", - "../api:array_view", "../api:rtp_parameters", "../api:simulated_network_api", "../api:transport_api", @@ -521,7 +515,6 @@ ":rtp_sender", ":video_receive_stream_api", ":video_send_stream_api", - "../api:array_view", "../api:bitrate_allocation", "../api:create_frame_generator", "../api:field_trials", @@ -625,7 +618,6 @@ ":fake_network", ":video_receive_stream_api", ":video_send_stream_api", - "../api:array_view", "../api:field_trials_view", "../api:make_ref_counted", "../api:rtc_event_log_output_file",
diff --git a/call/call.cc b/call/call.cc index a7fd3e3..df8786c8 100644 --- a/call/call.cc +++ b/call/call.cc
@@ -18,6 +18,7 @@ #include <memory> #include <optional> #include <set> +#include <span> #include <string> #include <utility> #include <vector> @@ -25,7 +26,6 @@ #include "absl/functional/bind_front.h" #include "absl/strings/string_view.h" #include "api/adaptation/resource.h" -#include "api/array_view.h" #include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/media_types.h" @@ -1343,7 +1343,7 @@ receive_stats_.AddReceivedRtcpBytes(static_cast<int>(packet.size())); bool rtcp_delivered = false; - ArrayView<const uint8_t> packet_view(packet.cdata(), packet.size()); + std::span<const uint8_t> packet_view(packet.cdata(), packet.size()); for (VideoReceiveStream2* stream : video_receive_streams_) { if (stream->DeliverRtcp(packet_view)) rtcp_delivered = true;
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 9cd29d8..2eae4f4 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc
@@ -16,13 +16,13 @@ #include <limits> #include <map> #include <memory> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/flags/flag.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/audio/audio_device.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h" @@ -566,7 +566,7 @@ private: // TODO(holmer): Run this with a timer instead of once per packet. - Action OnSendRtp(ArrayView<const uint8_t> /* packet */) override { + Action OnSendRtp(std::span<const uint8_t> /* packet */) override { task_queue_->PostTask(SafeTask(task_safety_flag_, [this]() { VideoSendStream::Stats stats = send_stream_->GetStats(); @@ -1021,7 +1021,7 @@ } } - Action OnSendRtp(ArrayView<const uint8_t> /* packet */) override { + Action OnSendRtp(std::span<const uint8_t> /* packet */) override { const Timestamp now = clock_->CurrentTime(); if (now - last_getstats_time_ > kMinGetStatsInterval) { last_getstats_time_ = now;
diff --git a/call/fake_network_pipe.cc b/call/fake_network_pipe.cc index 4504b6c..a816593 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc
@@ -16,10 +16,10 @@ #include <memory> #include <optional> #include <queue> +#include <span> #include <utility> #include <vector> -#include "api/array_view.h" #include "api/call/transport.h" #include "api/media_types.h" #include "api/test/simulated_network.h" @@ -142,7 +142,7 @@ } } -bool FakeNetworkPipe::SendRtp(ArrayView<const uint8_t> packet, +bool FakeNetworkPipe::SendRtp(std::span<const uint8_t> packet, const PacketOptions& options, Transport* transport) { RTC_DCHECK(transport); @@ -150,7 +150,7 @@ return true; } -bool FakeNetworkPipe::SendRtcp(ArrayView<const uint8_t> packet, +bool FakeNetworkPipe::SendRtcp(std::span<const uint8_t> packet, Transport* transport) { RTC_DCHECK(transport); EnqueuePacket(CopyOnWriteBuffer(packet), std::nullopt, true, transport); @@ -322,10 +322,10 @@ return; } if (packet->is_rtcp()) { - transport->SendRtcp(MakeArrayView(packet->data(), packet->data_length()), + transport->SendRtcp(std::span(packet->data(), packet->data_length()), packet->packet_options()); } else { - transport->SendRtp(MakeArrayView(packet->data(), packet->data_length()), + transport->SendRtp(std::span(packet->data(), packet->data_length()), packet->packet_options()); } } else if (receiver_) {
diff --git a/call/fake_network_pipe.h b/call/fake_network_pipe.h index a30c50e..168f8af 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h
@@ -17,8 +17,8 @@ #include <map> #include <memory> #include <optional> +#include <span> -#include "api/array_view.h" #include "api/call/transport.h" #include "api/test/simulated_network.h" #include "call/simulated_packet_receiver.h" @@ -133,10 +133,10 @@ // Methods for use with Transport interface. When/if packets are delivered, // they will be passed to the instance specified by the `transport` parameter. // Note that that instance must be in the map of active transports. - bool SendRtp(ArrayView<const uint8_t> packet, + bool SendRtp(std::span<const uint8_t> packet, const PacketOptions& options, Transport* transport); - bool SendRtcp(ArrayView<const uint8_t> packet, Transport* transport); + bool SendRtcp(std::span<const uint8_t> packet, Transport* transport); // Implements the PacketReceiver interface. When/if packets are delivered, // they will be passed directly to the receiver instance given in
diff --git a/call/flexfec_receive_stream_impl.cc b/call/flexfec_receive_stream_impl.cc index 8b16d4c..d694d06 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc
@@ -14,7 +14,6 @@ #include <memory> #include <string> -#include "api/array_view.h" #include "api/environment/environment.h" #include "api/sequence_checker.h" #include "call/flexfec_receive_stream.h"
diff --git a/call/flexfec_receive_stream_unittest.cc b/call/flexfec_receive_stream_unittest.cc index be769db..27c8d2c 100644 --- a/call/flexfec_receive_stream_unittest.cc +++ b/call/flexfec_receive_stream_unittest.cc
@@ -12,9 +12,9 @@ #include <cstdint> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/call/transport.h" #include "api/environment/environment_factory.h" #include "api/rtp_headers.h" @@ -52,7 +52,7 @@ return config; } -RtpPacketReceived ParsePacket(ArrayView<const uint8_t> packet) { +RtpPacketReceived ParsePacket(std::span<const uint8_t> packet) { RtpPacketReceived parsed_packet(nullptr); EXPECT_TRUE(parsed_packet.Parse(packet)); return parsed_packet;
diff --git a/call/rtp_config.cc b/call/rtp_config.cc index 115912c..f48ae30 100644 --- a/call/rtp_config.cc +++ b/call/rtp_config.cc
@@ -19,7 +19,6 @@ #include <vector> #include "absl/algorithm/container.h" -#include "api/array_view.h" #include "api/rtp_headers.h" #include "rtc_base/checks.h" #include "rtc_base/strings/string_builder.h"
diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index cd5fe0e..edc9190 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc
@@ -14,12 +14,12 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/call/transport.h" #include "api/fec_controller.h" #include "api/frame_transformer_interface.h" @@ -898,7 +898,7 @@ void RtpTransportControllerSend::OnReport( Timestamp receive_time, - ArrayView<const ReportBlockData> report_blocks) { + std::span<const ReportBlockData> report_blocks) { RTC_DCHECK_RUN_ON(&sequence_checker_); if (report_blocks.empty()) return;
diff --git a/call/rtp_transport_controller_send.h b/call/rtp_transport_controller_send.h index 26becb0..f5d0cde 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h
@@ -16,11 +16,11 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/environment/environment.h" #include "api/fec_controller.h" #include "api/frame_transformer_interface.h" @@ -129,7 +129,7 @@ void OnReceiverEstimatedMaxBitrate(Timestamp receive_time, DataRate bitrate) override; void OnReport(Timestamp receive_time, - ArrayView<const ReportBlockData> report_blocks) override; + std::span<const ReportBlockData> report_blocks) override; void OnRttUpdate(Timestamp receive_time, TimeDelta rtt) override; void OnTransportFeedback(Timestamp receive_time, const rtcp::TransportFeedback& feedback) override;
diff --git a/call/rtp_video_sender.cc b/call/rtp_video_sender.cc index c25fe19..73e8898 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc
@@ -17,6 +17,7 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> @@ -24,7 +25,6 @@ #include "absl/algorithm/container.h" #include "absl/base/nullability.h" #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/crypto/crypto_options.h" #include "api/environment/environment.h" @@ -719,7 +719,7 @@ return post_encode_overhead; } -void RtpVideoSender::DeliverRtcp(ArrayView<const uint8_t> packet) { +void RtpVideoSender::DeliverRtcp(std::span<const uint8_t> packet) { // Runs on a network thread. for (const RtpStreamSender& stream : rtp_streams_) stream.rtp_rtcp->IncomingRtcpPacket(packet); @@ -920,7 +920,7 @@ std::vector<RtpSequenceNumberMap::Info> RtpVideoSender::GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView<const uint16_t> sequence_numbers) const { + std::span<const uint16_t> sequence_numbers) const { for (const auto& rtp_stream : rtp_streams_) { if (ssrc == rtp_stream.rtp_rtcp->SSRC()) { return rtp_stream.rtp_rtcp->GetSentRtpPacketInfos(sequence_numbers); @@ -1015,7 +1015,7 @@ // clean up anyway. continue; } - ArrayView<const uint16_t> rtp_sequence_numbers(kv.second); + std::span<const uint16_t> rtp_sequence_numbers(kv.second); it->second->OnPacketsAcknowledged(rtp_sequence_numbers); } } @@ -1027,7 +1027,7 @@ rtp_config_.max_packet_size); } -void RtpVideoSender::SetCsrcs(ArrayView<const uint32_t> csrcs) { +void RtpVideoSender::SetCsrcs(std::span<const uint32_t> csrcs) { MutexLock lock(&mutex_); csrcs_.assign(csrcs.begin(), csrcs.begin() + std::min<size_t>(csrcs.size(), kRtpCsrcSize));
diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index ca7d098..5d35e5d 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h
@@ -15,10 +15,10 @@ #include <cstdint> #include <map> #include <memory> +#include <span> #include <vector> #include "absl/base/nullability.h" -#include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" @@ -113,7 +113,7 @@ std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const RTC_LOCKS_EXCLUDED(mutex_) override; - void DeliverRtcp(ArrayView<const uint8_t> packet) + void DeliverRtcp(std::span<const uint8_t> packet) RTC_LOCKS_EXCLUDED(mutex_) override; // Implements webrtc::VCMProtectionCallback. int ProtectionRequest(const FecProtectionParams* delta_params, @@ -158,12 +158,12 @@ // Sets the list of CSRCs to be included in every packet. If more than // kRtpCsrcSize CSRCs are provided, only the first kRtpCsrcSize elements are // kept. - void SetCsrcs(ArrayView<const uint32_t> csrcs) + void SetCsrcs(std::span<const uint32_t> csrcs) RTC_LOCKS_EXCLUDED(mutex_) override; std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView<const uint16_t> sequence_numbers) const + std::span<const uint16_t> sequence_numbers) const RTC_LOCKS_EXCLUDED(mutex_) override; // From StreamFeedbackObserver.
diff --git a/call/rtp_video_sender_interface.h b/call/rtp_video_sender_interface.h index 754fe03..035044c 100644 --- a/call/rtp_video_sender_interface.h +++ b/call/rtp_video_sender_interface.h
@@ -14,9 +14,9 @@ #include <cstddef> #include <cstdint> #include <map> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/fec_controller_override.h" #include "api/video/video_layers_allocation.h" @@ -40,7 +40,7 @@ virtual std::map<uint32_t, RtpState> GetRtpStates() const = 0; virtual std::map<uint32_t, RtpPayloadState> GetRtpPayloadStates() const = 0; - virtual void DeliverRtcp(ArrayView<const uint8_t> packet) = 0; + virtual void DeliverRtcp(std::span<const uint8_t> packet) = 0; virtual void OnBitrateAllocationUpdated( const VideoBitrateAllocation& bitrate) = 0; @@ -55,10 +55,10 @@ virtual void SetEncodingData(size_t width, size_t height, size_t num_temporal_layers) = 0; - virtual void SetCsrcs(ArrayView<const uint32_t> csrcs) = 0; + virtual void SetCsrcs(std::span<const uint32_t> csrcs) = 0; virtual std::vector<RtpSequenceNumberMap::Info> GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView<const uint16_t> sequence_numbers) const = 0; + std::span<const uint16_t> sequence_numbers) const = 0; // Implements FecControllerOverride. void SetFecAllowed(bool fec_allowed) override = 0;
diff --git a/call/rtp_video_sender_unittest.cc b/call/rtp_video_sender_unittest.cc index 5014cf5..a979e05 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc
@@ -15,10 +15,10 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <vector> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "api/call/bitrate_allocation.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" @@ -137,7 +137,7 @@ const std::vector<uint32_t>& ssrcs, const std::vector<uint32_t>& rtx_ssrcs, int payload_type, - ArrayView<const int> payload_types) { + std::span<const int> payload_types) { VideoSendStream::Config config(transport); config.rtp.ssrcs = ssrcs; config.rtp.rtx.ssrcs = rtx_ssrcs; @@ -511,7 +511,7 @@ .Times(2) .WillRepeatedly( [&rtp_sequence_numbers, &transport_sequence_numbers]( - ArrayView<const uint8_t> packet, const PacketOptions& options) { + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); rtp_sequence_numbers.push_back(rtp_packet.SequenceNumber()); @@ -537,13 +537,13 @@ EXPECT_CALL(test.transport(), SendRtp) .Times(2) .WillRepeatedly([&retransmitted_rtp_sequence_numbers]( - ArrayView<const uint8_t> packet, + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); EXPECT_EQ(rtp_packet.Ssrc(), kRtxSsrc1); // Capture the retransmitted sequence number from the RTX header. - ArrayView<const uint8_t> payload = rtp_packet.payload(); + std::span<const uint8_t> payload = rtp_packet.payload(); retransmitted_rtp_sequence_numbers.push_back( ByteReader<uint16_t>::ReadBigEndian(payload.data())); return true; @@ -578,13 +578,13 @@ // still be retransmitted. test.AdvanceTime(TimeDelta::Millis(33)); EXPECT_CALL(test.transport(), SendRtp) - .WillOnce([&lost_packet_feedback](ArrayView<const uint8_t> packet, + .WillOnce([&lost_packet_feedback](std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); EXPECT_EQ(rtp_packet.Ssrc(), kRtxSsrc1); // Capture the retransmitted sequence number from the RTX header. - ArrayView<const uint8_t> payload = rtp_packet.payload(); + std::span<const uint8_t> payload = rtp_packet.payload(); EXPECT_EQ(lost_packet_feedback.rtp_sequence_number, ByteReader<uint16_t>::ReadBigEndian(payload.data())); return true; @@ -681,7 +681,7 @@ EXPECT_CALL(test.transport(), SendRtp) .WillOnce( [&frame1_rtp_sequence_number, &frame1_transport_sequence_number]( - ArrayView<const uint8_t> packet, const PacketOptions& options) { + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); frame1_rtp_sequence_number = rtp_packet.SequenceNumber(); @@ -700,7 +700,7 @@ EXPECT_CALL(test.transport(), SendRtp) .WillOnce( [&frame2_rtp_sequence_number, &frame2_transport_sequence_number]( - ArrayView<const uint8_t> packet, const PacketOptions& options) { + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); frame2_rtp_sequence_number = rtp_packet.SequenceNumber(); @@ -717,7 +717,7 @@ // Inject a transport feedback where the packet for the first frame is lost, // expect a retransmission for it. EXPECT_CALL(test.transport(), SendRtp) - .WillOnce([&frame1_rtp_sequence_number](ArrayView<const uint8_t> packet, + .WillOnce([&frame1_rtp_sequence_number](std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -725,7 +725,7 @@ // Retransmitted sequence number from the RTX header should match // the lost packet. - ArrayView<const uint8_t> payload = rtp_packet.payload(); + std::span<const uint8_t> payload = rtp_packet.payload(); EXPECT_EQ(ByteReader<uint16_t>::ReadBigEndian(payload.data()), frame1_rtp_sequence_number); return true; @@ -760,7 +760,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -824,7 +824,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -883,7 +883,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -938,7 +938,7 @@ std::vector<RtpPacket> sent_packets; EXPECT_CALL(test.transport(), SendRtp) .Times(3) - .WillRepeatedly([&](ArrayView<const uint8_t> packet, + .WillRepeatedly([&](std::span<const uint8_t> packet, const PacketOptions& options) -> bool { RtpPacket& rtp_packet = sent_packets.emplace_back(); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -983,7 +983,7 @@ EXPECT_CALL(test.transport(), SendRtp) .Times(3) .WillRepeatedly( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket& rtp_packet = sent_rtx_packets.emplace_back(); EXPECT_TRUE(rtp_packet.Parse(packet)); return true; @@ -1009,7 +1009,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions&) { + [&](std::span<const uint8_t> packet, const PacketOptions&) { EXPECT_TRUE(sent_packets.emplace_back(&extensions).Parse(packet)); return true; }); @@ -1055,7 +1055,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1111,7 +1111,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1165,7 +1165,7 @@ std::vector<RtpPacket> sent_packets; EXPECT_CALL(test.transport(), SendRtp(_, _)) .Times(2) - .WillRepeatedly([&](ArrayView<const uint8_t> packet, + .WillRepeatedly([&](std::span<const uint8_t> packet, const PacketOptions& options) -> bool { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); @@ -1223,7 +1223,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1269,7 +1269,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1381,7 +1381,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1459,7 +1459,7 @@ std::vector<RtpPacket> sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView<const uint8_t> packet, const PacketOptions& options) { + [&](std::span<const uint8_t> packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1552,7 +1552,7 @@ .Times(2) .WillRepeatedly( [&rtp_sequence_numbers, &transport_sequence_numbers]( - ArrayView<const uint8_t> packet, const PacketOptions& options) { + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); rtp_sequence_numbers.push_back(rtp_packet.SequenceNumber()); @@ -1587,13 +1587,13 @@ EXPECT_CALL(test.transport(), SendRtp) .Times(1) .WillRepeatedly([&retransmitted_rtp_sequence_numbers]( - ArrayView<const uint8_t> packet, + std::span<const uint8_t> packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); EXPECT_EQ(rtp_packet.Ssrc(), kRtxSsrc1); // Capture the retransmitted sequence number from the RTX header. - ArrayView<const uint8_t> payload = rtp_packet.payload(); + std::span<const uint8_t> payload = rtp_packet.payload(); retransmitted_rtp_sequence_numbers.push_back( ByteReader<uint16_t>::ReadBigEndian(payload.data())); return true;
diff --git a/call/rtx_receive_stream.cc b/call/rtx_receive_stream.cc index d725d28..2f77380 100644 --- a/call/rtx_receive_stream.cc +++ b/call/rtx_receive_stream.cc
@@ -14,9 +14,9 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <utility> -#include "api/array_view.h" #include "api/environment/environment.h" #include "api/sequence_checker.h" #include "call/rtp_packet_sink_interface.h" @@ -78,7 +78,7 @@ if (rtp_receive_statistics_) { rtp_receive_statistics_->OnRtpPacket(rtx_packet); } - ArrayView<const uint8_t> payload = rtx_packet.payload(); + std::span<const uint8_t> payload = rtx_packet.payload(); if (payload.size() < kRtxHeaderSize) { LogRtpPacketToEventLog(rtx_packet, /*osn=*/std::nullopt);
diff --git a/call/rtx_receive_stream_unittest.cc b/call/rtx_receive_stream_unittest.cc index 80fd8c9..9a30cc4 100644 --- a/call/rtx_receive_stream_unittest.cc +++ b/call/rtx_receive_stream_unittest.cc
@@ -14,8 +14,8 @@ #include <cstdint> #include <cstring> #include <map> +#include <span> -#include "api/array_view.h" #include "api/environment/environment.h" #include "api/rtc_event_log/rtc_event.h" #include "api/units/timestamp.h" @@ -123,7 +123,7 @@ } template <typename T> -ArrayView<T> Truncate(ArrayView<T> a, size_t drop) { +std::span<T> Truncate(std::span<T> a, size_t drop) { return a.subspan(0, a.size() - drop); } @@ -134,7 +134,7 @@ Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacket))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([](const RtpPacketReceived& packet) { @@ -152,7 +152,7 @@ Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacket))); EXPECT_FALSE(rtx_packet.recovered()); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([](const RtpPacketReceived& packet) { @@ -171,7 +171,7 @@ Environment env = CreateTestEnvironment({.event_log = &log}); RtxReceiveStream rtx_sink(env, &media_sink, payload_type_mapping, kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacket))); EXPECT_CALL(log, LogProxy(_)); rtx_sink.OnRtpPacket(rtx_packet); } @@ -183,7 +183,7 @@ RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; EXPECT_TRUE( - rtx_packet.Parse(Truncate(ArrayView<const uint8_t>(kRtxPacket), 2))); + rtx_packet.Parse(Truncate(std::span<const uint8_t>(kRtxPacket), 2))); EXPECT_CALL(log, LogProxy(_)); rtx_sink.OnRtpPacket(rtx_packet); } @@ -195,7 +195,7 @@ RtpHeaderExtensionMap extension_map; extension_map.RegisterByType(3, kRtpExtensionVideoRotation); RtpPacketReceived rtx_packet(&extension_map); - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacketWithCVO))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacketWithCVO))); VideoRotation rotation = kVideoRotation_0; EXPECT_TRUE(rtx_packet.GetExtension<VideoOrientation>(&rotation)); @@ -220,7 +220,7 @@ Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet(nullptr); - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacket))); rtx_packet.set_arrival_time(Timestamp::Millis(123)); EXPECT_CALL(media_sink, OnRtpPacket(Property(&RtpPacketReceived::arrival_time, Timestamp::Millis(123)))); @@ -236,14 +236,14 @@ constexpr int kRtxPayloadOffset = 14; uint8_t large_rtx_packet[kRtxPacketSize]; memcpy(large_rtx_packet, kRtxPacket, sizeof(kRtxPacket)); - ArrayView<uint8_t> payload(large_rtx_packet + kRtxPayloadOffset, + std::span<uint8_t> payload(large_rtx_packet + kRtxPayloadOffset, kRtxPacketSize - kRtxPayloadOffset); // Fill payload. for (size_t i = 0; i < payload.size(); i++) { payload[i] = i; } - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(large_rtx_packet))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(large_rtx_packet))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([&](const RtpPacketReceived& packet) { @@ -267,10 +267,10 @@ uint8_t large_rtx_packet[kRtxPacketSize]; memcpy(large_rtx_packet, kRtxPacketWithPadding, sizeof(kRtxPacketWithPadding)); - ArrayView<uint8_t> payload( + std::span<uint8_t> payload( large_rtx_packet + kRtxPayloadOffset, kRtxPacketSize - kRtxPayloadOffset - kRtxPaddingSize); - ArrayView<uint8_t> padding( + std::span<uint8_t> padding( large_rtx_packet + kRtxPacketSize - kRtxPaddingSize, kRtxPaddingSize); // Fill payload. @@ -282,7 +282,7 @@ padding[i] = kRtxPaddingSize; } - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(large_rtx_packet))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(large_rtx_packet))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([&](const RtpPacketReceived& packet) { @@ -314,7 +314,7 @@ Environment env = CreateTestEnvironment({.event_log = &log}); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView<const uint8_t>(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span<const uint8_t>(kRtxPacket))); EXPECT_CALL(log, LogProxy(IsRtcEventRtpPacketIncomingPtrWithSsrcAndOsn( kRtxSSRC, kMediaSeqno)));
diff --git a/call/video_send_stream.h b/call/video_send_stream.h index c5a24d2..683be5f 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h
@@ -15,11 +15,11 @@ #include <map> #include <optional> +#include <span> #include <string> #include <vector> #include "api/adaptation/resource.h" -#include "api/array_view.h" #include "api/call/transport.h" #include "api/crypto/crypto_options.h" #include "api/frame_transformer_interface.h" @@ -264,7 +264,7 @@ virtual void SetStats(const Stats& stats) { RTC_CHECK_NOTREACHED(); } // Sets the list of CSRCs to be included in every packet. - virtual void SetCsrcs(ArrayView<const uint32_t> csrcs) = 0; + virtual void SetCsrcs(std::span<const uint32_t> csrcs) = 0; virtual void GenerateKeyFrame(const std::vector<std::string>& rids) = 0;
diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn index 83e9ef9..c54c797 100644 --- a/common_audio/BUILD.gn +++ b/common_audio/BUILD.gn
@@ -45,7 +45,6 @@ deps = [ ":common_audio_c", ":sinc_resampler", - "../api:array_view", "../api/audio:audio_frame_api", "../api/units:timestamp", "../rtc_base:checks",
diff --git a/common_audio/channel_buffer.h b/common_audio/channel_buffer.h index 7d040e5..5a79f00 100644 --- a/common_audio/channel_buffer.h +++ b/common_audio/channel_buffer.h
@@ -14,9 +14,9 @@ #include <cstdint> #include <cstring> #include <memory> +#include <span> #include <vector> -#include "api/array_view.h" #include "api/audio/audio_view.h" #include "rtc_base/checks.h" @@ -89,19 +89,19 @@ num_channels_(num_channels), num_bands_(num_bands), bands_view_(num_allocated_channels_, - std::vector<ArrayView<T>>(num_bands_)), + std::vector<std::span<T>>(num_bands_)), channels_view_(num_bands_, - std::vector<ArrayView<T>>(num_allocated_channels_)) { + std::vector<std::span<T>>(num_allocated_channels_)) { // Temporarily cast away const_ness to allow populating the array views. auto* bands_view = - const_cast<std::vector<std::vector<ArrayView<T>>>*>(&bands_view_); + const_cast<std::vector<std::vector<std::span<T>>>*>(&bands_view_); auto* channels_view = - const_cast<std::vector<std::vector<ArrayView<T>>>*>(&channels_view_); + const_cast<std::vector<std::vector<std::span<T>>>*>(&channels_view_); for (size_t ch = 0; ch < num_allocated_channels_; ++ch) { for (size_t band = 0; band < num_bands_; ++band) { (*channels_view)[band][ch] = - ArrayView<T>(&data_[ch * num_frames_ + band * num_frames_per_band_], + std::span<T>(&data_[ch * num_frames_ + band * num_frames_per_band_], num_frames_per_band_); (*bands_view)[ch][band] = channels_view_[band][ch]; channels_[band * num_allocated_channels_ + ch] = @@ -133,10 +133,10 @@ const ChannelBuffer<T>* t = this; return const_cast<T* const*>(t->channels(band)); } - ArrayView<const ArrayView<T>> channels_view(size_t band = 0) { + std::span<const std::span<T>> channels_view(size_t band = 0) { return channels_view_[band]; } - ArrayView<const ArrayView<T>> channels_view(size_t band = 0) const { + std::span<const std::span<T>> channels_view(size_t band = 0) const { return channels_view_[band]; } @@ -157,10 +157,10 @@ return const_cast<T* const*>(t->bands(channel)); } - ArrayView<const ArrayView<T>> bands_view(size_t channel) { + std::span<const std::span<T>> bands_view(size_t channel) { return bands_view_[channel]; } - ArrayView<const ArrayView<T>> bands_view(size_t channel) const { + std::span<const std::span<T>> bands_view(size_t channel) const { return bands_view_[channel]; } @@ -204,8 +204,8 @@ // Number of channels the user sees. size_t num_channels_; const size_t num_bands_; - const std::vector<std::vector<ArrayView<T>>> bands_view_; - const std::vector<std::vector<ArrayView<T>>> channels_view_; + const std::vector<std::vector<std::span<T>>> bands_view_; + const std::vector<std::vector<std::span<T>>> channels_view_; }; // One int16_t and one float ChannelBuffer that are kept in sync. The sync is
diff --git a/common_audio/include/audio_util.h b/common_audio/include/audio_util.h index 672ebd1..0b04f81 100644 --- a/common_audio/include/audio_util.h +++ b/common_audio/include/audio_util.h
@@ -106,7 +106,7 @@ // Copy audio from `src` channels to `dest` channels unless `src` and `dest` // point to the same address. `src` and `dest` must have the same number of // channels, and there must be sufficient space allocated in `dest`. -// TODO: b/335805780 - Accept ArrayView. +// TODO: b/335805780 - Accept std::span. template <typename T> void CopyAudioIfNeeded(const T* const* src, int num_frames,
diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 4dd7670..dae37ec 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn
@@ -65,7 +65,6 @@ "turnserver/read_auth_file.h", ] deps = [ - "../api:array_view", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -677,7 +676,6 @@ ] deps = [ - "../api:array_view", "../api:async_dns_resolver", "../api:audio_options_api", "../api:create_frame_generator",
diff --git a/examples/androidvoip/BUILD.gn b/examples/androidvoip/BUILD.gn index 1954875..c26d2b2 100644 --- a/examples/androidvoip/BUILD.gn +++ b/examples/androidvoip/BUILD.gn
@@ -55,7 +55,6 @@ deps = [ ":generated_jni", - "../../api:array_view", "../../api:sequence_checker", "../../api/audio:builtin_audio_processing_builder", "../../api/environment",
diff --git a/examples/androidvoip/jni/android_voip_client.cc b/examples/androidvoip/jni/android_voip_client.cc index 2c1fd43..53489da 100644 --- a/examples/androidvoip/jni/android_voip_client.cc +++ b/examples/androidvoip/jni/android_voip_client.cc
@@ -20,12 +20,12 @@ #include <map> #include <memory> #include <optional> +#include <span> #include <string> #include <utility> #include <vector> #include "absl/memory/memory.h" -#include "api/array_view.h" #include "api/audio/builtin_audio_processing_builder.h" #include "api/audio_codecs/audio_format.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" @@ -481,7 +481,7 @@ } } -bool AndroidVoipClient::SendRtp(webrtc::ArrayView<const uint8_t> packet, +bool AndroidVoipClient::SendRtp(std::span<const uint8_t> packet, const webrtc::PacketOptions& options) { std::vector<uint8_t> packet_copy(packet.begin(), packet.end()); voip_thread_->PostTask([this, packet_copy = std::move(packet_copy)] { @@ -501,7 +501,7 @@ } } -bool AndroidVoipClient::SendRtcp(webrtc::ArrayView<const uint8_t> packet, +bool AndroidVoipClient::SendRtcp(std::span<const uint8_t> packet, const webrtc::PacketOptions& options) { std::vector<uint8_t> packet_copy(packet.begin(), packet.end()); voip_thread_->PostTask([this, packet_copy = std::move(packet_copy)] { @@ -519,7 +519,7 @@ } webrtc::VoipResult result = voip_engine_->Network().ReceivedRTPPacket( *channel_, - webrtc::ArrayView<const uint8_t>(packet_copy.data(), packet_copy.size())); + std::span<const uint8_t>(packet_copy.data(), packet_copy.size())); RTC_CHECK(result == webrtc::VoipResult::kOk); } @@ -543,7 +543,7 @@ } webrtc::VoipResult result = voip_engine_->Network().ReceivedRTCPPacket( *channel_, - webrtc::ArrayView<const uint8_t>(packet_copy.data(), packet_copy.size())); + std::span<const uint8_t>(packet_copy.data(), packet_copy.size())); RTC_CHECK(result == webrtc::VoipResult::kOk); }
diff --git a/examples/androidvoip/jni/android_voip_client.h b/examples/androidvoip/jni/android_voip_client.h index 7d9e499..885921f 100644 --- a/examples/androidvoip/jni/android_voip_client.h +++ b/examples/androidvoip/jni/android_voip_client.h
@@ -16,10 +16,10 @@ #include <cstdint> #include <memory> #include <optional> +#include <span> #include <string> #include <vector> -#include "api/array_view.h" #include "api/audio_codecs/audio_format.h" #include "api/call/transport.h" #include "api/environment/environment.h" @@ -121,9 +121,9 @@ void Delete(JNIEnv* env); // Implementation for Transport. - bool SendRtp(webrtc::ArrayView<const uint8_t> packet, + bool SendRtp(std::span<const uint8_t> packet, const webrtc::PacketOptions& options) override; - bool SendRtcp(webrtc::ArrayView<const uint8_t> packet, + bool SendRtcp(std::span<const uint8_t> packet, const webrtc::PacketOptions& options) override; void OnSignalReadRTPPacket(webrtc::AsyncPacketSocket* socket,
diff --git a/examples/peerconnection/client/linux/main_wnd.h b/examples/peerconnection/client/linux/main_wnd.h index cee1d3a..db730e6 100644 --- a/examples/peerconnection/client/linux/main_wnd.h +++ b/examples/peerconnection/client/linux/main_wnd.h
@@ -14,9 +14,9 @@ #include <stdint.h> #include <memory> +#include <span> #include <string> -#include "api/array_view.h" #include "api/media_stream_interface.h" #include "api/scoped_refptr.h" #include "api/video/video_frame.h" @@ -94,7 +94,7 @@ // VideoSinkInterface implementation void OnFrame(const webrtc::VideoFrame& frame) override; - webrtc::ArrayView<const uint8_t> image() const { return image_; } + std::span<const uint8_t> image() const { return image_; } int width() const { return width_; }
diff --git a/examples/turnserver/read_auth_file.cc b/examples/turnserver/read_auth_file.cc index c1b6eff..65d1e41 100644 --- a/examples/turnserver/read_auth_file.cc +++ b/examples/turnserver/read_auth_file.cc
@@ -13,10 +13,10 @@ #include <cstddef> #include <istream> #include <map> +#include <span> #include <string> #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "rtc_base/string_encode.h" namespace webrtc_examples { @@ -28,7 +28,7 @@ if (sep == std::string::npos) continue; char buf[32]; - size_t len = webrtc::hex_decode(webrtc::ArrayView<char>(buf), + size_t len = webrtc::hex_decode(std::span<char>(buf), absl::string_view(line).substr(sep + 1)); if (len > 0) { name_to_key.emplace(line.substr(0, sep), std::string(buf, len));
diff --git a/system_wrappers/BUILD.gn b/system_wrappers/BUILD.gn index 12a5a82..a3e9a49 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn
@@ -23,7 +23,6 @@ defines = [] libs = [] deps = [ - "../api:array_view", "../api/units:time_delta", "../api/units:timestamp", "../rtc_base:checks",