diff --git a/audio/BUILD.gn b/audio/BUILD.gn index c39c42dd70..c710be09b9 100644 --- a/audio/BUILD.gn +++ b/audio/BUILD.gn @@ -40,7 +40,6 @@ rtc_library("audio") { ] deps = [ - "../api:array_view", "../api:bitrate_allocation", "../api:call_api", "../api:field_trials_view", @@ -165,7 +164,6 @@ if (rtc_include_tests) { ":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 @@ if (rtc_include_tests) { 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 4f31b489ea..4f052c6a21 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -15,12 +15,12 @@ #include #include #include +#include #include #include #include #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 @@ bool AudioReceiveStreamImpl::SetMinimumPlayoutDelay(TimeDelta delay) { return channel_receive_->SetMinimumPlayoutDelay(delay); } -void AudioReceiveStreamImpl::DeliverRtcp(ArrayView packet) { +void AudioReceiveStreamImpl::DeliverRtcp(std::span 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 111cd898dc..41a470f8b8 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #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 @@ class AudioReceiveStreamImpl final : public webrtc::AudioReceiveStreamInterface, Timestamp time) override; bool SetMinimumPlayoutDelay(TimeDelta delay) override; - void DeliverRtcp(ArrayView packet); + void DeliverRtcp(std::span packet); void SetSyncGroup(absl::string_view sync_group); diff --git a/audio/audio_send_stream.cc b/audio/audio_send_stream.cc index 4c53757e74..25efcb8f92 100644 --- a/audio/audio_send_stream.cc +++ b/audio/audio_send_stream.cc @@ -15,13 +15,13 @@ #include #include #include +#include #include #include #include #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 @@ webrtc::AudioSendStream::Stats AudioSendStream::GetStats( return stats; } -void AudioSendStream::DeliverRtcp(ArrayView packet) { +void AudioSendStream::DeliverRtcp(std::span 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 9bac56005a..7cc204c7bd 100644 --- a/audio/audio_send_stream.h +++ b/audio/audio_send_stream.h @@ -15,10 +15,10 @@ #include #include #include +#include #include #include -#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 @@ class AudioSendStream final : public webrtc::AudioSendStream, webrtc::AudioSendStream::Stats GetStats( bool has_remote_tracks) const override; - void DeliverRtcp(ArrayView packet); + void DeliverRtcp(std::span 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 6c754a1878..5379026c1d 100644 --- a/audio/audio_send_stream_tests.cc +++ b/audio/audio_send_stream_tests.cc @@ -10,10 +10,10 @@ #include #include +#include #include #include -#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 @@ TEST_F(AudioSendStreamCallTest, SupportsCName) { CNameObserver() = default; private: - Action OnSendRtcp(ArrayView packet) override { + Action OnSendRtcp(std::span packet) override { RtcpPacketParser parser; EXPECT_TRUE(parser.Parse(packet)); if (parser.sdes()->num_packets() > 0) { @@ -89,7 +89,7 @@ TEST_F(AudioSendStreamCallTest, NoExtensionsByDefault) { NoExtensionsObserver() = default; private: - Action OnSendRtp(ArrayView packet) override { + Action OnSendRtp(std::span 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 @@ TEST_F(AudioSendStreamCallTest, SupportsAudioLevel) { extensions_.Register(kAudioLevelExtensionId); } - Action OnSendRtp(ArrayView packet) override { + Action OnSendRtp(std::span packet) override { RtpPacket rtp_packet(&extensions_); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -164,7 +164,7 @@ class TransportWideSequenceNumberObserver : public AudioSendTest { } private: - Action OnSendRtp(ArrayView packet) override { + Action OnSendRtp(std::span packet) override { RtpPacket rtp_packet(&extensions_); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -210,7 +210,7 @@ TEST_F(AudioSendStreamCallTest, SendDtmf) { DtmfObserver() = default; private: - Action OnSendRtp(ArrayView packet) override { + Action OnSendRtp(std::span packet) override { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); diff --git a/audio/channel_receive.cc b/audio/channel_receive.cc index 2eb4a6202a..dfd4cd4091 100644 --- a/audio/channel_receive.cc +++ b/audio/channel_receive.cc @@ -17,11 +17,11 @@ #include #include #include +#include #include #include #include -#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 @@ class ChannelReceive : public ChannelReceiveInterface, int GetRtpTimestampRateHz() const; - void OnReceivedPayloadData(ArrayView payload, + void OnReceivedPayloadData(std::span payload, const RTPHeader& header, Timestamp receive_time) RTC_RUN_ON(worker_thread_checker_); @@ -334,7 +334,7 @@ class ChannelReceive : public ChannelReceiveInterface, RTC_GUARDED_BY(worker_thread_checker_); }; -void ChannelReceive::OnReceivedPayloadData(ArrayView payload, +void ChannelReceive::OnReceivedPayloadData(std::span payload, const RTPHeader& header, Timestamp receive_time) { if (!playing_) { @@ -379,7 +379,7 @@ void ChannelReceive::InitFrameTransformerDelegate( // Pass a callback to ChannelReceive::OnReceivedPayloadData, to be called by // the delegate to receive transformed audio. ChannelReceiveFrameTransformerDelegate::ReceiveFrameCallback - receive_audio_callback = [this](ArrayView packet, + receive_audio_callback = [this](std::span packet, const RTPHeader& header, Timestamp receive_time) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); @@ -737,7 +737,7 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, frame_decryptor_->Decrypt( MediaType::AUDIO, csrcs, /*additional_data=*/{}, - ArrayView(payload, payload_data_length), + std::span(payload, payload_data_length), decrypted_audio_payload); if (decrypt_result.IsOk()) { @@ -755,7 +755,7 @@ void ChannelReceive::ReceivePacket(const uint8_t* packet, payload_data_length = 0; } - ArrayView payload_data(payload, payload_data_length); + std::span 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 @@ void ChannelReceive::ReceivedRTCPPacket(const uint8_t* data, size_t length) { 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 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 887edaa2ee..b2422d0aab 100644 --- a/audio/channel_receive_frame_transformer_delegate.cc +++ b/audio/channel_receive_frame_transformer_delegate.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#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 @@ namespace webrtc { class TransformableIncomingAudioFrame : public TransformableAudioFrameInterface { public: - TransformableIncomingAudioFrame(ArrayView payload, + TransformableIncomingAudioFrame(std::span payload, const RTPHeader& header, uint32_t ssrc, const std::string& codec_mime_type, @@ -46,9 +46,9 @@ class TransformableIncomingAudioFrame codec_mime_type_(codec_mime_type), receive_time_(receive_time) {} ~TransformableIncomingAudioFrame() override = default; - ArrayView GetData() const override { return payload_; } + std::span GetData() const override { return payload_; } - void SetData(ArrayView data) override { + void SetData(std::span data) override { payload_.SetData(data.data(), data.size()); } @@ -59,8 +59,8 @@ class TransformableIncomingAudioFrame uint8_t GetPayloadType() const override { return header_.payloadType; } uint32_t GetSsrc() const override { return ssrc_; } uint32_t GetTimestamp() const override { return header_.timestamp; } - ArrayView GetContributingSources() const override { - return ArrayView(header_.arrOfCSRCs, header_.numCSRCs); + std::span GetContributingSources() const override { + return std::span(header_.arrOfCSRCs, header_.numCSRCs); } Direction GetDirection() const override { return Direction::kReceiver; } @@ -159,7 +159,7 @@ void ChannelReceiveFrameTransformerDelegate::Reset() { } void ChannelReceiveFrameTransformerDelegate::Transform( - ArrayView packet, + std::span 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 1b5f04eeee..a0ba8fd0f2 100644 --- a/audio/channel_receive_frame_transformer_delegate.h +++ b/audio/channel_receive_frame_transformer_delegate.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#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 @@ namespace webrtc { class ChannelReceiveFrameTransformerDelegate : public TransformedFrameCallback { public: using ReceiveFrameCallback = - std::function packet, + std::function packet, const RTPHeader& header, Timestamp receive_time)>; ChannelReceiveFrameTransformerDelegate( @@ -54,7 +54,7 @@ class ChannelReceiveFrameTransformerDelegate : public TransformedFrameCallback { // Delegates the call to FrameTransformerInterface::Transform, to transform // the frame asynchronously. - void Transform(ArrayView packet, + void Transform(std::span 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 ae9a01cd69..01dbaee486 100644 --- a/audio/channel_receive_frame_transformer_delegate_unittest.cc +++ b/audio/channel_receive_frame_transformer_delegate_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#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 @@ class MockChannelReceive { public: MOCK_METHOD(void, ReceiveFrame, - (ArrayView packet, + (std::span packet, const RTPHeader& header, Timestamp receive_time)); ChannelReceiveFrameTransformerDelegate::ReceiveFrameCallback callback() { - return [this](ArrayView packet, const RTPHeader& header, + return [this](std::span packet, const RTPHeader& header, Timestamp receive_time) { ReceiveFrame(packet, header, receive_time); }; @@ -101,7 +101,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span packet(data, sizeof(data)); RTPHeader header; EXPECT_CALL(mock_channel, ReceiveFrame); ON_CALL(*mock_frame_transformer, Transform) @@ -132,7 +132,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span packet(data, sizeof(data)); RTPHeader header; EXPECT_CALL(mock_channel, ReceiveFrame(ElementsAre(1, 2, 3, 4), _, kFakeReceiveTimestamp)); @@ -177,7 +177,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, make_ref_counted( mock_channel.callback(), mock_frame_transformer, Thread::Current()); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span packet(data, sizeof(data)); RTPHeader header; delegate->StartShortCircuiting(); @@ -207,7 +207,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span packet(data, sizeof(data)); RTPHeader header; std::unique_ptr frame; ON_CALL(*mock_frame_transformer, Transform) @@ -244,7 +244,7 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span 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 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, ASSERT_TRUE(callback); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span 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 @@ TEST(ChannelReceiveFrameTransformerDelegateTest, SetAudioLevel) { Thread::Current()); delegate->Init(); const uint8_t data[] = {1, 2, 3, 4}; - ArrayView packet(data, sizeof(data)); + std::span packet(data, sizeof(data)); std::unique_ptr frame; ON_CALL(*mock_frame_transformer, Transform) .WillByDefault( diff --git a/audio/channel_receive_unittest.cc b/audio/channel_receive_unittest.cc index 72e45c3958..83cc6d56e0 100644 --- a/audio/channel_receive_unittest.cc +++ b/audio/channel_receive_unittest.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #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 @@ class ChannelReceiveTest : public Test { } void HandleGeneratedRtcp(ChannelReceiveInterface& /* channel */, - ArrayView packet) { + std::span packet) { if (packet[1] == rtcp::ReceiverReport::kPacketType) { // Ignore RR, it requires no response } else { @@ -185,7 +185,7 @@ TEST_F(ChannelReceiveTest, ReceiveReportGeneratedOnTime) { bool receiver_report_sent = false; EXPECT_CALL(transport_, SendRtcp) - .WillRepeatedly([&](ArrayView packet, + .WillRepeatedly([&](std::span packet, const PacketOptions& options) { if (packet.size() >= 2 && packet[1] == rtcp::ReceiverReport::kPacketType) { @@ -205,7 +205,7 @@ TEST_F(ChannelReceiveTest, CaptureStartTimeBecomesValid) { EXPECT_CALL(transport_, SendRtcp) .WillRepeatedly( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { HandleGeneratedRtcp(*channel, packet); return true; }); diff --git a/audio/channel_send.cc b/audio/channel_send.cc index 68fd2f62d9..528bd26851 100644 --- a/audio/channel_send.cc +++ b/audio/channel_send.cc @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #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 @@ class ChannelSend : public ChannelSendInterface, void SetInputMute(bool enable) override; // CSRCs. - void SetCsrcs(ArrayView csrcs) override; + void SetCsrcs(std::span csrcs) override; // Stats. ANAStats GetANAStatistics() const override; @@ -243,9 +243,9 @@ class ChannelSend : public ChannelSendInterface, int32_t SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, - ArrayView payload, + std::span payload, int64_t absolute_capture_timestamp_ms, - ArrayView csrcs, + std::span csrcs, std::optional audio_level_dbov) RTC_RUN_ON(worker_thread_); @@ -418,9 +418,9 @@ int32_t ChannelSend::SendData(AudioFrameType frameType, int32_t ChannelSend::SendRtpAudio(AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_without_offset, - ArrayView payload, + std::span payload, int64_t absolute_capture_timestamp_ms, - ArrayView csrcs, + std::span csrcs, std::optional 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 @@ void ChannelSend::ReceivedRTCPPacket(const uint8_t* data, size_t length) { 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 rtt = rtp_rtcp_->LastRtt(); if (!rtt.has_value()) { @@ -721,7 +721,7 @@ bool ChannelSend::InputMute() const { return input_mute_; } -void ChannelSend::SetCsrcs(ArrayView csrcs) { +void ChannelSend::SetCsrcs(std::span csrcs) { RTC_DCHECK_RUN_ON(worker_thread_); std::vector csrcs_copy( csrcs.begin(), @@ -919,7 +919,7 @@ void ChannelSend::ProcessAndEncodeAudio( rms_level_.AnalyzeMuted(length); } else { rms_level_.Analyze( - ArrayView(audio_frame->data(), length)); + std::span(audio_frame->data(), length)); } } previous_frame_muted_ = is_muted; @@ -984,9 +984,9 @@ void ChannelSend::InitFrameTransformerDelegate( ChannelSendFrameTransformerDelegate::SendFrameCallback send_audio_callback = [this](AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp_with_offset, - ArrayView payload, + std::span payload, int64_t absolute_capture_timestamp_ms, - ArrayView csrcs, + std::span csrcs, std::optional audio_level_dbov) { RTC_DCHECK_RUN_ON(worker_thread_); return SendRtpAudio( diff --git a/audio/channel_send.h b/audio/channel_send.h index 185f3e9975..ab97c3b64e 100644 --- a/audio/channel_send.h +++ b/audio/channel_send.h @@ -15,10 +15,10 @@ #include #include #include +#include #include #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 @@ class ChannelSendInterface { // 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 csrcs) = 0; + virtual void SetCsrcs(std::span csrcs) = 0; virtual void ProcessAndEncodeAudio( std::unique_ptr audio_frame) = 0; diff --git a/audio/channel_send_frame_transformer_delegate.cc b/audio/channel_send_frame_transformer_delegate.cc index 044f1c3d31..57079c3605 100644 --- a/audio/channel_send_frame_transformer_delegate.cc +++ b/audio/channel_send_frame_transformer_delegate.cc @@ -14,11 +14,11 @@ #include #include #include +#include #include #include #include -#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 @@ class TransformableOutgoingAudioFrame sequence_number_(sequence_number), audio_level_dbov_(audio_level_dbov) {} ~TransformableOutgoingAudioFrame() override = default; - ArrayView GetData() const override { return payload_; } - void SetData(ArrayView data) override { + std::span GetData() const override { return payload_; } + void SetData(std::span data) override { payload_.SetData(data.data(), data.size()); } uint32_t GetTimestamp() const override { return rtp_timestamp_with_offset_; } @@ -110,7 +110,7 @@ class TransformableOutgoingAudioFrame Direction GetDirection() const override { return Direction::kSender; } std::string GetMimeType() const override { return codec_mime_type_; } - ArrayView GetContributingSources() const override { + std::span GetContributingSources() const override { return csrcs_; } diff --git a/audio/channel_send_frame_transformer_delegate.h b/audio/channel_send_frame_transformer_delegate.h index c495af6a69..678f51fcb3 100644 --- a/audio/channel_send_frame_transformer_delegate.h +++ b/audio/channel_send_frame_transformer_delegate.h @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#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 @@ class ChannelSendFrameTransformerDelegate : public TransformedFrameCallback { std::function payload, + std::span payload, int64_t absolute_capture_timestamp_ms, - webrtc::ArrayView csrcs, + std::span csrcs, std::optional 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 20acb49c6d..d5e19c1827 100644 --- a/audio/channel_send_frame_transformer_delegate_unittest.cc +++ b/audio/channel_send_frame_transformer_delegate_unittest.cc @@ -13,11 +13,11 @@ #include #include #include +#include #include #include #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 @@ class MockChannelSend { (AudioFrameType frameType, uint8_t payloadType, uint32_t rtp_timestamp, - ArrayView payload, + std::span payload, int64_t absolute_capture_timestamp_ms, - ArrayView csrcs, + std::span csrcs, std::optional audio_level_dbov)); ChannelSendFrameTransformerDelegate::SendFrameCallback callback() { return [this](AudioFrameType frameType, uint8_t payloadType, - uint32_t rtp_timestamp, ArrayView payload, + uint32_t rtp_timestamp, std::span payload, int64_t absolute_capture_timestamp_ms, - ArrayView csrcs, + std::span csrcs, std::optional audio_level_dbov) { return SendFrame(frameType, payloadType, rtp_timestamp, payload, absolute_capture_timestamp_ms, csrcs, audio_level_dbov); @@ -73,7 +73,7 @@ std::unique_ptr CreateMockReceiverFrame( std::optional audio_level_dbov) { std::unique_ptr mock_frame = std::make_unique>(); - ArrayView payload(mock_data); + std::span 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 4835056070..e777cf6bef 100644 --- a/audio/channel_send_unittest.cc +++ b/audio/channel_send_unittest.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#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 @@ TEST_F(ChannelSendTest, IncreaseRtpTimestampByPauseDuration) { channel_->StartSend(); uint32_t timestamp; int sent_packets = 0; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span data, const PacketOptions& /* options */) { ++sent_packets; RtpPacketReceived packet; @@ -190,7 +190,7 @@ TEST_F(ChannelSendTest, FrameTransformerGetsCorrectTimestamp) { EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::optional sent_timestamp; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span data, const PacketOptions& /* options */) { RtpPacketReceived packet; packet.Parse(data); @@ -239,7 +239,7 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToCorrectTransformedFrame) { EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::vector sent_audio_levels; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span data, const PacketOptions& /* options */) { RtpPacketReceived packet(&extension_manager); packet.Parse(data); @@ -303,7 +303,7 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToInsertedTransformedFrame) { EXPECT_CALL(*mock_frame_transformer, UnregisterTransformedFrameCallback); std::optional sent_audio_level; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span data, const PacketOptions& /* options */) { RtpPacketReceived packet(&extension_manager); packet.Parse(data); @@ -323,7 +323,7 @@ TEST_F(ChannelSendTest, AudioLevelsAttachedToInsertedTransformedFrame) { ON_CALL(*mock_frame, AudioLevel()).WillByDefault(Return(audio_level)); uint8_t payload[10]; ON_CALL(*mock_frame, GetData()) - .WillByDefault(Return(ArrayView(&payload[0], 10))); + .WillByDefault(Return(std::span(&payload[0], 10))); EXPECT_THAT(WaitUntil([&] { return callback; }, IsTrue()), IsRtcOk()); callback->OnTransformedFrame(std::move(mock_frame)); @@ -415,7 +415,7 @@ TEST_F(ChannelSendTest, ConfiguredCsrcsAreIncludedInRtpPackets) { channel_->SetCsrcs(expected_csrcs); std::vector csrcs; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span data, const PacketOptions& /* options */) { RtpPacketReceived packet; packet.Parse(data); @@ -500,7 +500,7 @@ TEST_F(ChannelSendTest, FrameTransformerTakesPrecedenceOverSetCsrcs) { channel_->StartSend(); std::vector sent_csrcs; - auto send_rtp = [&](ArrayView data, + auto send_rtp = [&](std::span 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 db4d73adaf..c460bb119b 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #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 @@ class MockChannelSend : public voe::ChannelSendInterface { RegisterPacketOverhead, (int packet_byte_overhead), (override)); - MOCK_METHOD(void, SetCsrcs, (ArrayView csrcs), (override)); + MOCK_METHOD(void, SetCsrcs, (std::span csrcs), (override)); }; } // namespace test } // namespace webrtc diff --git a/audio/voip/BUILD.gn b/audio/voip/BUILD.gn index 5780fd2c92..dd5e127e13 100644 --- a/audio/voip/BUILD.gn +++ b/audio/voip/BUILD.gn @@ -16,7 +16,6 @@ rtc_library("voip_core") { deps = [ ":audio_channel", "..:audio", - "../../api:array_view", "../../api:make_ref_counted", "../../api:scoped_refptr", "../../api:transport_api", @@ -43,7 +42,6 @@ rtc_library("audio_channel") { deps = [ ":audio_egress", ":audio_ingress", - "../../api:array_view", "../../api:ref_count", "../../api:rtp_headers", "../../api:scoped_refptr", @@ -67,7 +65,6 @@ rtc_library("audio_ingress") { ] deps = [ "..:audio", - "../../api:array_view", "../../api:scoped_refptr", "../../api/audio:audio_mixer_api", "../../api/audio_codecs:audio_codecs_api", @@ -97,7 +94,6 @@ rtc_library("audio_egress") { ] 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 b670b310f3..268e15eb76 100644 --- a/audio/voip/audio_channel.h +++ b/audio/voip/audio_channel.h @@ -15,9 +15,9 @@ #include #include #include +#include #include -#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 @@ class AudioChannel : public RefCountInterface { // APIs relayed to AudioIngress. bool IsPlaying() const { return ingress_->IsPlaying(); } - void ReceivedRTPPacket(ArrayView rtp_packet) { + void ReceivedRTPPacket(std::span rtp_packet) { ingress_->ReceivedRTPPacket(rtp_packet); } - void ReceivedRTCPPacket(ArrayView rtcp_packet) { + void ReceivedRTCPPacket(std::span rtcp_packet) { ingress_->ReceivedRTCPPacket(rtcp_packet); } void SetReceiveCodecs(const std::map& codecs) { diff --git a/audio/voip/audio_egress.cc b/audio/voip/audio_egress.cc index fc69d2b6d7..36ffe21d44 100644 --- a/audio/voip/audio_egress.cc +++ b/audio/voip/audio_egress.cc @@ -13,9 +13,9 @@ #include #include #include +#include #include -#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 @@ int32_t AudioEgress::SendData(AudioFrameType frame_type, size_t payload_size) { RTC_DCHECK_RUN_ON(&encoder_queue_checker_); - ArrayView payload(payload_data, payload_size); + std::span 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 b4525a18cd..1e2fa34838 100644 --- a/audio/voip/audio_ingress.cc +++ b/audio/voip/audio_ingress.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #include -#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 @@ void AudioIngress::SetReceiveCodecs( neteq_->SetCodecs(codecs); } -void AudioIngress::ReceivedRTPPacket(ArrayView rtp_packet) { +void AudioIngress::ReceivedRTPPacket(std::span rtp_packet) { RtpPacketReceived rtp_packet_received; rtp_packet_received.Parse(rtp_packet.data(), rtp_packet.size()); @@ -204,7 +204,7 @@ void AudioIngress::ReceivedRTPPacket(ArrayView rtp_packet) { 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(payload, payload_data_length); + auto data_view = std::span(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::ReceivedRTPPacket(ArrayView rtp_packet) { } } -void AudioIngress::ReceivedRTCPPacket(ArrayView rtcp_packet) { +void AudioIngress::ReceivedRTCPPacket(std::span 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 e6d9836fd4..a8ec34f02d 100644 --- a/audio/voip/audio_ingress.h +++ b/audio/voip/audio_ingress.h @@ -17,8 +17,8 @@ #include #include #include +#include -#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 @@ class AudioIngress : public AudioMixer::Source { void SetReceiveCodecs(const std::map& codecs); // APIs to handle received RTP/RTCP packets from caller. - void ReceivedRTPPacket(ArrayView rtp_packet); - void ReceivedRTCPPacket(ArrayView rtcp_packet); + void ReceivedRTPPacket(std::span rtp_packet); + void ReceivedRTCPPacket(std::span 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 c0efeb6c8a..0c1acf0d68 100644 --- a/audio/voip/test/BUILD.gn +++ b/audio/voip/test/BUILD.gn @@ -49,7 +49,6 @@ if (rtc_include_tests) { 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 @@ if (rtc_include_tests) { deps = [ "..:audio_egress", "..:audio_ingress", - "../../../api:array_view", "../../../api:rtp_headers", "../../../api:scoped_refptr", "../../../api/audio:audio_frame_api", @@ -102,7 +100,6 @@ if (rtc_include_tests) { 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 8b4c32f273..a707e2d5ad 100644 --- a/audio/voip/test/audio_channel_unittest.cc +++ b/audio/voip/test/audio_channel_unittest.cc @@ -14,10 +14,10 @@ #include #include #include +#include #include #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 @@ class AudioChannelTest : public ::testing::Test { // 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 packet, Unused) { + auto loop_rtp = [&](std::span packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; @@ -145,7 +145,7 @@ TEST_F(AudioChannelTest, PlayRtpByLocalLoop) { // Validate assigned local SSRC is resulted in RTP packet. TEST_F(AudioChannelTest, VerifyLocalSsrcAsAssigned) { RtpPacketReceived rtp; - auto loop_rtp = [&](ArrayView packet, Unused) { + auto loop_rtp = [&](std::span packet, Unused) { rtp.Parse(packet); return true; }; @@ -160,7 +160,7 @@ TEST_F(AudioChannelTest, VerifyLocalSsrcAsAssigned) { // Check metrics after processing an RTP packet. TEST_F(AudioChannelTest, TestIngressStatistics) { - auto loop_rtp = [&](ArrayView packet, Unused) { + auto loop_rtp = [&](std::span packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; @@ -237,11 +237,11 @@ TEST_F(AudioChannelTest, TestIngressStatistics) { // Check ChannelStatistics metric after processing RTP and RTCP packets. TEST_F(AudioChannelTest, TestChannelStatistics) { - auto loop_rtp = [&](ArrayView packet, Unused) { + auto loop_rtp = [&](std::span packet, Unused) { audio_channel_->ReceivedRTPPacket(packet); return true; }; - auto loop_rtcp = [&](ArrayView packet, Unused) { + auto loop_rtcp = [&](std::span packet, Unused) { audio_channel_->ReceivedRTCPPacket(packet); return true; }; @@ -306,7 +306,7 @@ TEST_F(AudioChannelTest, RttIsAvailableAfterChangeOfRemoteSsrc) { auto send_recv_rtp = [&](scoped_refptr rtp_sender, scoped_refptr rtp_receiver) { // Setup routing logic via transport_. - auto route_rtp = [&](ArrayView packet, Unused) { + auto route_rtp = [&](std::span packet, Unused) { rtp_receiver->ReceivedRTPPacket(packet); return true; }; @@ -328,7 +328,7 @@ TEST_F(AudioChannelTest, RttIsAvailableAfterChangeOfRemoteSsrc) { auto send_recv_rtcp = [&](scoped_refptr rtcp_sender, scoped_refptr rtcp_receiver) { // Setup routing logic via transport_. - auto route_rtcp = [&](ArrayView packet, Unused) { + auto route_rtcp = [&](std::span 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 a086ab9e04..5cf9a2aa43 100644 --- a/audio/voip/test/audio_egress_unittest.cc +++ b/audio/voip/test/audio_egress_unittest.cc @@ -14,8 +14,8 @@ #include #include #include +#include -#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 @@ TEST_F(AudioEgressTest, ProcessAudioWithMute) { Event event; int rtp_count = 0; RtpPacketReceived rtp; - auto rtp_sent = [&](ArrayView packet, Unused) { + auto rtp_sent = [&](std::span packet, Unused) { rtp.Parse(packet); if (++rtp_count == kExpected) { event.Set(); @@ -169,7 +169,7 @@ TEST_F(AudioEgressTest, ProcessAudioWithSineWave) { Event event; int rtp_count = 0; RtpPacketReceived rtp; - auto rtp_sent = [&](ArrayView packet, Unused) { + auto rtp_sent = [&](std::span packet, Unused) { rtp.Parse(packet); if (++rtp_count == kExpected) { event.Set(); @@ -204,7 +204,7 @@ TEST_F(AudioEgressTest, SkipAudioEncodingAfterStopSend) { constexpr int kExpected = 10; Event event; int rtp_count = 0; - auto rtp_sent = [&](ArrayView /* packet */, Unused) { + auto rtp_sent = [&](std::span /* packet */, Unused) { if (++rtp_count == kExpected) { event.Set(); } @@ -278,7 +278,7 @@ TEST_F(AudioEgressTest, SendDTMF) { // 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 packet, Unused) { + auto rtp_sent = [&](std::span packet, Unused) { RtpPacketReceived rtp; rtp.Parse(packet); if (is_dtmf(rtp) && ++dtmf_count == kExpected) { @@ -305,7 +305,7 @@ TEST_F(AudioEgressTest, TestAudioInputLevelAndEnergyDuration) { constexpr int kExpected = 6; Event event; int rtp_count = 0; - auto rtp_sent = [&](ArrayView /* packet */, Unused) { + auto rtp_sent = [&](std::span /* 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 477e653e59..23e39aefe5 100644 --- a/audio/voip/test/audio_ingress_unittest.cc +++ b/audio/voip/test/audio_ingress_unittest.cc @@ -13,8 +13,8 @@ #include #include #include +#include -#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, PlayingAfterStartAndStop) { TEST_F(AudioIngressTest, GetAudioFrameAfterRtpReceived) { Event event; - auto handle_rtp = [&](ArrayView packet, Unused) { + auto handle_rtp = [&](std::span packet, Unused) { ingress_->ReceivedRTPPacket(packet); event.Set(); return true; @@ -155,7 +155,7 @@ TEST_F(AudioIngressTest, TestSpeechOutputLevelAndEnergyDuration) { constexpr int kNumRtp = 6; int rtp_count = 0; Event event; - auto handle_rtp = [&](ArrayView packet, Unused) { + auto handle_rtp = [&](std::span packet, Unused) { ingress_->ReceivedRTPPacket(packet); if (++rtp_count == kNumRtp) { event.Set(); @@ -186,7 +186,7 @@ TEST_F(AudioIngressTest, TestSpeechOutputLevelAndEnergyDuration) { TEST_F(AudioIngressTest, PreferredSampleRate) { Event event; - auto handle_rtp = [&](ArrayView packet, Unused) { + auto handle_rtp = [&](std::span packet, Unused) { ingress_->ReceivedRTPPacket(packet); event.Set(); return true; @@ -215,7 +215,7 @@ TEST_F(AudioIngressTest, GetMutedAudioFrameAfterRtpReceivedAndStopPlay) { constexpr int kNumRtp = 6; int rtp_count = 0; Event event; - auto handle_rtp = [&](ArrayView packet, Unused) { + auto handle_rtp = [&](std::span 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 d3ce340ac9..a5d5fc3d9f 100644 --- a/audio/voip/voip_core.cc +++ b/audio/voip/voip_core.cc @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#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::StopPlayout(ChannelId channel_id) { } VoipResult VoipCore::ReceivedRTPPacket(ChannelId channel_id, - ArrayView rtp_packet) { + std::span rtp_packet) { scoped_refptr channel = GetChannel(channel_id); if (!channel) { @@ -380,7 +380,7 @@ VoipResult VoipCore::ReceivedRTPPacket(ChannelId channel_id, } VoipResult VoipCore::ReceivedRTCPPacket(ChannelId channel_id, - ArrayView rtcp_packet) { + std::span rtcp_packet) { scoped_refptr channel = GetChannel(channel_id); if (!channel) { diff --git a/audio/voip/voip_core.h b/audio/voip/voip_core.h index dbd9150be9..45eca080c8 100644 --- a/audio/voip/voip_core.h +++ b/audio/voip/voip_core.h @@ -15,9 +15,9 @@ #include #include #include +#include #include -#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 @@ class VoipCore : public VoipEngine, // Implements VoipNetwork interfaces. VoipResult ReceivedRTPPacket(ChannelId channel_id, - ArrayView rtp_packet) override; + std::span rtp_packet) override; VoipResult ReceivedRTCPPacket(ChannelId channel_id, - ArrayView rtcp_packet) override; + std::span rtcp_packet) override; // Implements VoipCodec interfaces. VoipResult SetSendCodec(ChannelId channel_id, diff --git a/call/BUILD.gn b/call/BUILD.gn index b11616353c..a8ad708290 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -109,7 +109,6 @@ rtc_library("rtp_interfaces") { "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 @@ rtc_library("rtp_receiver") { ] deps = [ ":rtp_interfaces", - "../api:array_view", "../api:sequence_checker", "../api/environment", "../logging:rtc_event_rtp_rtcp", @@ -178,7 +176,6 @@ rtc_library("rtp_sender") { deps = [ ":bitrate_configurator", ":rtp_interfaces", - "../api:array_view", "../api:bitrate_allocation", "../api:fec_controller_api", "../api:field_trials_view", @@ -306,7 +303,6 @@ rtc_library("call") { ":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 @@ rtc_library("video_send_stream_api") { ] deps = [ ":rtp_interfaces", - "../api:array_view", "../api:frame_transformer_interface", "../api:rtp_parameters", "../api:rtp_sender_interface", @@ -474,7 +469,6 @@ rtc_library("fake_network") { ] deps = [ ":simulated_packet_receiver", - "../api:array_view", "../api:rtp_parameters", "../api:simulated_network_api", "../api:transport_api", @@ -521,7 +515,6 @@ if (rtc_include_tests) { ":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 @@ if (rtc_include_tests) { ":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 a7fd3e3142..df8786c886 100644 --- a/call/call.cc +++ b/call/call.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -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 @@ void Call::DeliverRtcpPacket(CopyOnWriteBuffer packet) { receive_stats_.AddReceivedRtcpBytes(static_cast(packet.size())); bool rtcp_delivered = false; - ArrayView packet_view(packet.cdata(), packet.size()); + std::span 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 9cd29d8d1c..2eae4f4290 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -16,13 +16,13 @@ #include #include #include +#include #include #include #include #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 @@ void CallPerfTest::TestMinTransmitBitrate(bool pad_to_min_bitrate) { private: // TODO(holmer): Run this with a timer instead of once per packet. - Action OnSendRtp(ArrayView /* packet */) override { + Action OnSendRtp(std::span /* packet */) override { task_queue_->PostTask(SafeTask(task_safety_flag_, [this]() { VideoSendStream::Stats stats = send_stream_->GetStats(); @@ -1021,7 +1021,7 @@ void CallPerfTest::TestEncodeFramerate(VideoEncoderFactory* encoder_factory, } } - Action OnSendRtp(ArrayView /* packet */) override { + Action OnSendRtp(std::span /* 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 4504b6c704..a816593728 100644 --- a/call/fake_network_pipe.cc +++ b/call/fake_network_pipe.cc @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#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 @@ void FakeNetworkPipe::RemoveActiveTransport(Transport* transport) { } } -bool FakeNetworkPipe::SendRtp(ArrayView packet, +bool FakeNetworkPipe::SendRtp(std::span packet, const PacketOptions& options, Transport* transport) { RTC_DCHECK(transport); @@ -150,7 +150,7 @@ bool FakeNetworkPipe::SendRtp(ArrayView packet, return true; } -bool FakeNetworkPipe::SendRtcp(ArrayView packet, +bool FakeNetworkPipe::SendRtcp(std::span packet, Transport* transport) { RTC_DCHECK(transport); EnqueuePacket(CopyOnWriteBuffer(packet), std::nullopt, true, transport); @@ -322,10 +322,10 @@ void FakeNetworkPipe::DeliverNetworkPacket(NetworkPacket* packet) { 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 a30c50eecb..168f8afffa 100644 --- a/call/fake_network_pipe.h +++ b/call/fake_network_pipe.h @@ -17,8 +17,8 @@ #include #include #include +#include -#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 @@ class FakeNetworkPipe : public SimulatedPacketReceiverInterface { // 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 packet, + bool SendRtp(std::span packet, const PacketOptions& options, Transport* transport); - bool SendRtcp(ArrayView packet, Transport* transport); + bool SendRtcp(std::span 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 8b16d4cbc8..d694d06f14 100644 --- a/call/flexfec_receive_stream_impl.cc +++ b/call/flexfec_receive_stream_impl.cc @@ -14,7 +14,6 @@ #include #include -#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 be769db5d1..27c8d2c285 100644 --- a/call/flexfec_receive_stream_unittest.cc +++ b/call/flexfec_receive_stream_unittest.cc @@ -12,9 +12,9 @@ #include #include +#include #include -#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 @@ FlexfecReceiveStream::Config CreateDefaultConfig( return config; } -RtpPacketReceived ParsePacket(ArrayView packet) { +RtpPacketReceived ParsePacket(std::span 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 115912cd46..f48ae30462 100644 --- a/call/rtp_config.cc +++ b/call/rtp_config.cc @@ -19,7 +19,6 @@ #include #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 cd5fe0e9fc..edc91904d8 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -14,12 +14,12 @@ #include #include #include +#include #include #include #include #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::PostUpdates(NetworkControlUpdate update) { void RtpTransportControllerSend::OnReport( Timestamp receive_time, - ArrayView report_blocks) { + std::span 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 26becb0f91..f5d0cdef5f 100644 --- a/call/rtp_transport_controller_send.h +++ b/call/rtp_transport_controller_send.h @@ -16,11 +16,11 @@ #include #include #include +#include #include #include #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 @@ class RtpTransportControllerSend final void OnReceiverEstimatedMaxBitrate(Timestamp receive_time, DataRate bitrate) override; void OnReport(Timestamp receive_time, - ArrayView report_blocks) override; + std::span 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 c25fe194bf..73e8898784 100644 --- a/call/rtp_video_sender.cc +++ b/call/rtp_video_sender.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -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 @@ DataRate RtpVideoSender::GetPostEncodeOverhead() const { return post_encode_overhead; } -void RtpVideoSender::DeliverRtcp(ArrayView packet) { +void RtpVideoSender::DeliverRtcp(std::span packet) { // Runs on a network thread. for (const RtpStreamSender& stream : rtp_streams_) stream.rtp_rtcp->IncomingRtcpPacket(packet); @@ -920,7 +920,7 @@ uint32_t RtpVideoSender::GetProtectionBitrateBps() const { std::vector RtpVideoSender::GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView sequence_numbers) const { + std::span 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 @@ void RtpVideoSender::OnPacketFeedbackVector( // clean up anyway. continue; } - ArrayView rtp_sequence_numbers(kv.second); + std::span rtp_sequence_numbers(kv.second); it->second->OnPacketsAcknowledged(rtp_sequence_numbers); } } @@ -1027,7 +1027,7 @@ void RtpVideoSender::SetEncodingData(size_t width, rtp_config_.max_packet_size); } -void RtpVideoSender::SetCsrcs(ArrayView csrcs) { +void RtpVideoSender::SetCsrcs(std::span csrcs) { MutexLock lock(&mutex_); csrcs_.assign(csrcs.begin(), csrcs.begin() + std::min(csrcs.size(), kRtpCsrcSize)); diff --git a/call/rtp_video_sender.h b/call/rtp_video_sender.h index ca7d0989d1..5d35e5d492 100644 --- a/call/rtp_video_sender.h +++ b/call/rtp_video_sender.h @@ -15,10 +15,10 @@ #include #include #include +#include #include #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 @@ class RtpVideoSender : public RtpVideoSenderInterface, std::map GetRtpPayloadStates() const RTC_LOCKS_EXCLUDED(mutex_) override; - void DeliverRtcp(ArrayView packet) + void DeliverRtcp(std::span packet) RTC_LOCKS_EXCLUDED(mutex_) override; // Implements webrtc::VCMProtectionCallback. int ProtectionRequest(const FecProtectionParams* delta_params, @@ -158,12 +158,12 @@ class RtpVideoSender : public RtpVideoSenderInterface, // 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 csrcs) + void SetCsrcs(std::span csrcs) RTC_LOCKS_EXCLUDED(mutex_) override; std::vector GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView sequence_numbers) const + std::span 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 754fe03cd4..035044cd82 100644 --- a/call/rtp_video_sender_interface.h +++ b/call/rtp_video_sender_interface.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#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 @@ class RtpVideoSenderInterface : public EncodedImageCallback, virtual std::map GetRtpStates() const = 0; virtual std::map GetRtpPayloadStates() const = 0; - virtual void DeliverRtcp(ArrayView packet) = 0; + virtual void DeliverRtcp(std::span packet) = 0; virtual void OnBitrateAllocationUpdated( const VideoBitrateAllocation& bitrate) = 0; @@ -55,10 +55,10 @@ class RtpVideoSenderInterface : public EncodedImageCallback, virtual void SetEncodingData(size_t width, size_t height, size_t num_temporal_layers) = 0; - virtual void SetCsrcs(ArrayView csrcs) = 0; + virtual void SetCsrcs(std::span csrcs) = 0; virtual std::vector GetSentRtpPacketInfos( uint32_t ssrc, - ArrayView sequence_numbers) const = 0; + std::span 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 5014cf5dad..a979e05db7 100644 --- a/call/rtp_video_sender_unittest.cc +++ b/call/rtp_video_sender_unittest.cc @@ -15,10 +15,10 @@ #include #include #include +#include #include #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 @@ VideoSendStream::Config CreateVideoSendStreamConfig( const std::vector& ssrcs, const std::vector& rtx_ssrcs, int payload_type, - ArrayView payload_types) { + std::span payload_types) { VideoSendStream::Config config(transport); config.rtp.ssrcs = ssrcs; config.rtp.rtx.ssrcs = rtx_ssrcs; @@ -511,7 +511,7 @@ TEST(RtpVideoSenderTest, DoesNotRetrasmitAckedPackets) { .Times(2) .WillRepeatedly( [&rtp_sequence_numbers, &transport_sequence_numbers]( - ArrayView packet, const PacketOptions& options) { + std::span 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 @@ TEST(RtpVideoSenderTest, DoesNotRetrasmitAckedPackets) { EXPECT_CALL(test.transport(), SendRtp) .Times(2) .WillRepeatedly([&retransmitted_rtp_sequence_numbers]( - ArrayView packet, + std::span 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 payload = rtp_packet.payload(); + std::span payload = rtp_packet.payload(); retransmitted_rtp_sequence_numbers.push_back( ByteReader::ReadBigEndian(payload.data())); return true; @@ -578,13 +578,13 @@ TEST(RtpVideoSenderTest, DoesNotRetrasmitAckedPackets) { // still be retransmitted. test.AdvanceTime(TimeDelta::Millis(33)); EXPECT_CALL(test.transport(), SendRtp) - .WillOnce([&lost_packet_feedback](ArrayView packet, + .WillOnce([&lost_packet_feedback](std::span 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 payload = rtp_packet.payload(); + std::span payload = rtp_packet.payload(); EXPECT_EQ(lost_packet_feedback.rtp_sequence_number, ByteReader::ReadBigEndian(payload.data())); return true; @@ -681,7 +681,7 @@ TEST(RtpVideoSenderTest, EarlyRetransmits) { EXPECT_CALL(test.transport(), SendRtp) .WillOnce( [&frame1_rtp_sequence_number, &frame1_transport_sequence_number]( - ArrayView packet, const PacketOptions& options) { + std::span packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); frame1_rtp_sequence_number = rtp_packet.SequenceNumber(); @@ -700,7 +700,7 @@ TEST(RtpVideoSenderTest, EarlyRetransmits) { EXPECT_CALL(test.transport(), SendRtp) .WillOnce( [&frame2_rtp_sequence_number, &frame2_transport_sequence_number]( - ArrayView packet, const PacketOptions& options) { + std::span packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); frame2_rtp_sequence_number = rtp_packet.SequenceNumber(); @@ -717,7 +717,7 @@ TEST(RtpVideoSenderTest, EarlyRetransmits) { // 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 packet, + .WillOnce([&frame1_rtp_sequence_number](std::span packet, const PacketOptions& options) { RtpPacket rtp_packet; EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -725,7 +725,7 @@ TEST(RtpVideoSenderTest, EarlyRetransmits) { // Retransmitted sequence number from the RTX header should match // the lost packet. - ArrayView payload = rtp_packet.payload(); + std::span payload = rtp_packet.payload(); EXPECT_EQ(ByteReader::ReadBigEndian(payload.data()), frame1_rtp_sequence_number); return true; @@ -760,7 +760,7 @@ TEST(RtpVideoSenderTest, SupportsDependencyDescriptor) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -824,7 +824,7 @@ TEST(RtpVideoSenderTest, SimulcastIndependentFrameIds) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -883,7 +883,7 @@ TEST(RtpVideoSenderTest, std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -938,7 +938,7 @@ TEST(RtpVideoSenderTest, MixedCodecSimulcastPayloadType) { std::vector sent_packets; EXPECT_CALL(test.transport(), SendRtp) .Times(3) - .WillRepeatedly([&](ArrayView packet, + .WillRepeatedly([&](std::span packet, const PacketOptions& options) -> bool { RtpPacket& rtp_packet = sent_packets.emplace_back(); EXPECT_TRUE(rtp_packet.Parse(packet)); @@ -983,7 +983,7 @@ TEST(RtpVideoSenderTest, MixedCodecSimulcastPayloadType) { EXPECT_CALL(test.transport(), SendRtp) .Times(3) .WillRepeatedly( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { RtpPacket& rtp_packet = sent_rtx_packets.emplace_back(); EXPECT_TRUE(rtp_packet.Parse(packet)); return true; @@ -1009,7 +1009,7 @@ TEST(RtpVideoSenderTest, std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions&) { + [&](std::span packet, const PacketOptions&) { EXPECT_TRUE(sent_packets.emplace_back(&extensions).Parse(packet)); return true; }); @@ -1055,7 +1055,7 @@ TEST(RtpVideoSenderTest, SupportsDependencyDescriptorForVp9) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1111,7 +1111,7 @@ TEST(RtpVideoSenderTest, std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1165,7 +1165,7 @@ TEST(RtpVideoSenderTest, std::vector sent_packets; EXPECT_CALL(test.transport(), SendRtp(_, _)) .Times(2) - .WillRepeatedly([&](ArrayView packet, + .WillRepeatedly([&](std::span packet, const PacketOptions& options) -> bool { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); @@ -1223,7 +1223,7 @@ TEST(RtpVideoSenderTest, GenerateDependecyDescriptorForGenericCodecs) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1269,7 +1269,7 @@ TEST(RtpVideoSenderTest, SupportsStoppingUsingDependencyDescriptor) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1381,7 +1381,7 @@ TEST(RtpVideoSenderTest, ClearsPendingPacketsOnInactivation) { std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1459,7 +1459,7 @@ TEST(RtpVideoSenderTest, std::vector sent_packets; ON_CALL(test.transport(), SendRtp) .WillByDefault( - [&](ArrayView packet, const PacketOptions& options) { + [&](std::span packet, const PacketOptions& options) { sent_packets.emplace_back(&extensions); EXPECT_TRUE(sent_packets.back().Parse(packet)); return true; @@ -1552,7 +1552,7 @@ TEST(RtpVideoSenderTest, RetransmitsBaseLayerOnly) { .Times(2) .WillRepeatedly( [&rtp_sequence_numbers, &transport_sequence_numbers]( - ArrayView packet, const PacketOptions& options) { + std::span 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 @@ TEST(RtpVideoSenderTest, RetransmitsBaseLayerOnly) { EXPECT_CALL(test.transport(), SendRtp) .Times(1) .WillRepeatedly([&retransmitted_rtp_sequence_numbers]( - ArrayView packet, + std::span 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 payload = rtp_packet.payload(); + std::span payload = rtp_packet.payload(); retransmitted_rtp_sequence_numbers.push_back( ByteReader::ReadBigEndian(payload.data())); return true; diff --git a/call/rtx_receive_stream.cc b/call/rtx_receive_stream.cc index d725d285da..2f773802de 100644 --- a/call/rtx_receive_stream.cc +++ b/call/rtx_receive_stream.cc @@ -14,9 +14,9 @@ #include #include #include +#include #include -#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 @@ void RtxReceiveStream::OnRtpPacket(const RtpPacketReceived& rtx_packet) { if (rtp_receive_statistics_) { rtp_receive_statistics_->OnRtpPacket(rtx_packet); } - ArrayView payload = rtx_packet.payload(); + std::span 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 80fd8c96ca..9a30cc437e 100644 --- a/call/rtx_receive_stream_unittest.cc +++ b/call/rtx_receive_stream_unittest.cc @@ -14,8 +14,8 @@ #include #include #include +#include -#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 @@ std::map PayloadTypeMapping() { } template -ArrayView Truncate(ArrayView a, size_t drop) { +std::span Truncate(std::span a, size_t drop) { return a.subspan(0, a.size() - drop); } @@ -134,7 +134,7 @@ TEST(RtxReceiveStreamTest, RestoresPacketPayload) { Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span(kRtxPacket))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([](const RtpPacketReceived& packet) { @@ -152,7 +152,7 @@ TEST(RtxReceiveStreamTest, SetsRecoveredFlag) { Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span(kRtxPacket))); EXPECT_FALSE(rtx_packet.recovered()); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([](const RtpPacketReceived& packet) { @@ -171,7 +171,7 @@ TEST(RtxReceiveStreamTest, IgnoresUnknownPayloadType) { 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(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span(kRtxPacket))); EXPECT_CALL(log, LogProxy(_)); rtx_sink.OnRtpPacket(rtx_packet); } @@ -183,7 +183,7 @@ TEST(RtxReceiveStreamTest, IgnoresTruncatedPacket) { RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; EXPECT_TRUE( - rtx_packet.Parse(Truncate(ArrayView(kRtxPacket), 2))); + rtx_packet.Parse(Truncate(std::span(kRtxPacket), 2))); EXPECT_CALL(log, LogProxy(_)); rtx_sink.OnRtpPacket(rtx_packet); } @@ -195,7 +195,7 @@ TEST(RtxReceiveStreamTest, CopiesRtpHeaderExtensions) { RtpHeaderExtensionMap extension_map; extension_map.RegisterByType(3, kRtpExtensionVideoRotation); RtpPacketReceived rtx_packet(&extension_map); - EXPECT_TRUE(rtx_packet.Parse(ArrayView(kRtxPacketWithCVO))); + EXPECT_TRUE(rtx_packet.Parse(std::span(kRtxPacketWithCVO))); VideoRotation rotation = kVideoRotation_0; EXPECT_TRUE(rtx_packet.GetExtension(&rotation)); @@ -220,7 +220,7 @@ TEST(RtxReceiveStreamTest, PropagatesArrivalTime) { Environment env = CreateTestEnvironment(); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet(nullptr); - EXPECT_TRUE(rtx_packet.Parse(ArrayView(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span(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 @@ TEST(RtxReceiveStreamTest, SupportsLargePacket) { constexpr int kRtxPayloadOffset = 14; uint8_t large_rtx_packet[kRtxPacketSize]; memcpy(large_rtx_packet, kRtxPacket, sizeof(kRtxPacket)); - ArrayView payload(large_rtx_packet + kRtxPayloadOffset, + std::span 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(large_rtx_packet))); + EXPECT_TRUE(rtx_packet.Parse(std::span(large_rtx_packet))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([&](const RtpPacketReceived& packet) { @@ -267,10 +267,10 @@ TEST(RtxReceiveStreamTest, SupportsLargePacketWithPadding) { uint8_t large_rtx_packet[kRtxPacketSize]; memcpy(large_rtx_packet, kRtxPacketWithPadding, sizeof(kRtxPacketWithPadding)); - ArrayView payload( + std::span payload( large_rtx_packet + kRtxPayloadOffset, kRtxPacketSize - kRtxPayloadOffset - kRtxPaddingSize); - ArrayView padding( + std::span padding( large_rtx_packet + kRtxPacketSize - kRtxPaddingSize, kRtxPaddingSize); // Fill payload. @@ -282,7 +282,7 @@ TEST(RtxReceiveStreamTest, SupportsLargePacketWithPadding) { padding[i] = kRtxPaddingSize; } - EXPECT_TRUE(rtx_packet.Parse(ArrayView(large_rtx_packet))); + EXPECT_TRUE(rtx_packet.Parse(std::span(large_rtx_packet))); EXPECT_CALL(media_sink, OnRtpPacket) .WillOnce([&](const RtpPacketReceived& packet) { @@ -314,7 +314,7 @@ TEST(RtxReceiveStreamTest, LogsRtpPacketIncoming) { Environment env = CreateTestEnvironment({.event_log = &log}); RtxReceiveStream rtx_sink(env, &media_sink, PayloadTypeMapping(), kMediaSSRC); RtpPacketReceived rtx_packet; - EXPECT_TRUE(rtx_packet.Parse(ArrayView(kRtxPacket))); + EXPECT_TRUE(rtx_packet.Parse(std::span(kRtxPacket))); EXPECT_CALL(log, LogProxy(IsRtcEventRtpPacketIncomingPtrWithSsrcAndOsn( kRtxSSRC, kMediaSeqno))); diff --git a/call/video_send_stream.h b/call/video_send_stream.h index c5a24d2c48..683be5f469 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h @@ -15,11 +15,11 @@ #include #include +#include #include #include #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 @@ class VideoSendStream { virtual void SetStats(const Stats& stats) { RTC_CHECK_NOTREACHED(); } // Sets the list of CSRCs to be included in every packet. - virtual void SetCsrcs(ArrayView csrcs) = 0; + virtual void SetCsrcs(std::span csrcs) = 0; virtual void GenerateKeyFrame(const std::vector& rids) = 0; diff --git a/common_audio/BUILD.gn b/common_audio/BUILD.gn index 83e9ef98a0..c54c797a84 100644 --- a/common_audio/BUILD.gn +++ b/common_audio/BUILD.gn @@ -45,7 +45,6 @@ rtc_library("common_audio") { 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 7d040e5d5f..5a79f00450 100644 --- a/common_audio/channel_buffer.h +++ b/common_audio/channel_buffer.h @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include "api/array_view.h" #include "api/audio/audio_view.h" #include "rtc_base/checks.h" @@ -89,19 +89,19 @@ class ChannelBuffer { num_channels_(num_channels), num_bands_(num_bands), bands_view_(num_allocated_channels_, - std::vector>(num_bands_)), + std::vector>(num_bands_)), channels_view_(num_bands_, - std::vector>(num_allocated_channels_)) { + std::vector>(num_allocated_channels_)) { // Temporarily cast away const_ness to allow populating the array views. auto* bands_view = - const_cast>>*>(&bands_view_); + const_cast>>*>(&bands_view_); auto* channels_view = - const_cast>>*>(&channels_view_); + const_cast>>*>(&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(&data_[ch * num_frames_ + band * num_frames_per_band_], + std::span(&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 @@ class ChannelBuffer { const ChannelBuffer* t = this; return const_cast(t->channels(band)); } - ArrayView> channels_view(size_t band = 0) { + std::span> channels_view(size_t band = 0) { return channels_view_[band]; } - ArrayView> channels_view(size_t band = 0) const { + std::span> channels_view(size_t band = 0) const { return channels_view_[band]; } @@ -157,10 +157,10 @@ class ChannelBuffer { return const_cast(t->bands(channel)); } - ArrayView> bands_view(size_t channel) { + std::span> bands_view(size_t channel) { return bands_view_[channel]; } - ArrayView> bands_view(size_t channel) const { + std::span> bands_view(size_t channel) const { return bands_view_[channel]; } @@ -204,8 +204,8 @@ class ChannelBuffer { // Number of channels the user sees. size_t num_channels_; const size_t num_bands_; - const std::vector>> bands_view_; - const std::vector>> channels_view_; + const std::vector>> bands_view_; + const std::vector>> 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 672ebd1aa0..0b04f812bb 100644 --- a/common_audio/include/audio_util.h +++ b/common_audio/include/audio_util.h @@ -106,7 +106,7 @@ inline float FloatS16ToDbfs(float v) { // 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 void CopyAudioIfNeeded(const T* const* src, int num_frames, diff --git a/examples/BUILD.gn b/examples/BUILD.gn index 4dd7670cd3..dae37ec578 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -65,7 +65,6 @@ rtc_library("read_auth_file") { "turnserver/read_auth_file.h", ] deps = [ - "../api:array_view", "../rtc_base:stringutils", "//third_party/abseil-cpp/absl/strings:string_view", ] @@ -677,7 +676,6 @@ if (is_linux || is_chromeos || is_win) { ] 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 1954875050..c26d2b2b50 100644 --- a/examples/androidvoip/BUILD.gn +++ b/examples/androidvoip/BUILD.gn @@ -55,7 +55,6 @@ if (is_android) { 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 2c1fd43d02..53489da5e2 100644 --- a/examples/androidvoip/jni/android_voip_client.cc +++ b/examples/androidvoip/jni/android_voip_client.cc @@ -20,12 +20,12 @@ #include #include #include +#include #include #include #include #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 @@ void AndroidVoipClient::SendRtpPacket(const std::vector& packet_copy) { } } -bool AndroidVoipClient::SendRtp(webrtc::ArrayView packet, +bool AndroidVoipClient::SendRtp(std::span packet, const webrtc::PacketOptions& options) { std::vector packet_copy(packet.begin(), packet.end()); voip_thread_->PostTask([this, packet_copy = std::move(packet_copy)] { @@ -501,7 +501,7 @@ void AndroidVoipClient::SendRtcpPacket( } } -bool AndroidVoipClient::SendRtcp(webrtc::ArrayView packet, +bool AndroidVoipClient::SendRtcp(std::span packet, const webrtc::PacketOptions& options) { std::vector packet_copy(packet.begin(), packet.end()); voip_thread_->PostTask([this, packet_copy = std::move(packet_copy)] { @@ -519,7 +519,7 @@ void AndroidVoipClient::ReadRTPPacket(const std::vector& packet_copy) { } webrtc::VoipResult result = voip_engine_->Network().ReceivedRTPPacket( *channel_, - webrtc::ArrayView(packet_copy.data(), packet_copy.size())); + std::span(packet_copy.data(), packet_copy.size())); RTC_CHECK(result == webrtc::VoipResult::kOk); } @@ -543,7 +543,7 @@ void AndroidVoipClient::ReadRTCPPacket( } webrtc::VoipResult result = voip_engine_->Network().ReceivedRTCPPacket( *channel_, - webrtc::ArrayView(packet_copy.data(), packet_copy.size())); + std::span(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 7d9e499ae3..885921fd50 100644 --- a/examples/androidvoip/jni/android_voip_client.h +++ b/examples/androidvoip/jni/android_voip_client.h @@ -16,10 +16,10 @@ #include #include #include +#include #include #include -#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 @@ class AndroidVoipClient : public webrtc::Transport { void Delete(JNIEnv* env); // Implementation for Transport. - bool SendRtp(webrtc::ArrayView packet, + bool SendRtp(std::span packet, const webrtc::PacketOptions& options) override; - bool SendRtcp(webrtc::ArrayView packet, + bool SendRtcp(std::span 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 cee1d3ab64..db730e662e 100644 --- a/examples/peerconnection/client/linux/main_wnd.h +++ b/examples/peerconnection/client/linux/main_wnd.h @@ -14,9 +14,9 @@ #include #include +#include #include -#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 @@ class GtkMainWnd : public MainWindow { // VideoSinkInterface implementation void OnFrame(const webrtc::VideoFrame& frame) override; - webrtc::ArrayView image() const { return image_; } + std::span 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 c1b6eff2d6..65d1e41971 100644 --- a/examples/turnserver/read_auth_file.cc +++ b/examples/turnserver/read_auth_file.cc @@ -13,10 +13,10 @@ #include #include #include +#include #include #include "absl/strings/string_view.h" -#include "api/array_view.h" #include "rtc_base/string_encode.h" namespace webrtc_examples { @@ -28,7 +28,7 @@ std::map ReadAuthFile(std::istream* s) { if (sep == std::string::npos) continue; char buf[32]; - size_t len = webrtc::hex_decode(webrtc::ArrayView(buf), + size_t len = webrtc::hex_decode(std::span(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 12a5a828f8..a3e9a49204 100644 --- a/system_wrappers/BUILD.gn +++ b/system_wrappers/BUILD.gn @@ -23,7 +23,6 @@ rtc_library("system_wrappers") { defines = [] libs = [] deps = [ - "../api:array_view", "../api/units:time_delta", "../api/units:timestamp", "../rtc_base:checks",