mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
Use ArrayView versions of SendRtp and SendRtcp
This CL adds [[deprecated]] to the old signatures, and uses the new signatures throughout. Bug: webrtc:14870 Change-Id: Ic9a8198ac0a2f954e1b2e7d05a55dbe04342f958 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/314962 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#40517}
This commit is contained in:
parent
8dc55689d2
commit
34d82df2ba
11 changed files with 32 additions and 27 deletions
|
@ -48,6 +48,8 @@ class Transport {
|
|||
// New style functions. Default implementations are to accomodate
|
||||
// subclasses that haven't been converted to new style yet.
|
||||
// TODO(bugs.webrtc.org/14870): Deprecate and remove old functions.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
virtual bool SendRtp(rtc::ArrayView<const uint8_t> packet,
|
||||
const PacketOptions& options) {
|
||||
return SendRtp(packet.data(), packet.size(), options);
|
||||
|
@ -55,11 +57,17 @@ class Transport {
|
|||
virtual bool SendRtcp(rtc::ArrayView<const uint8_t> packet) {
|
||||
return SendRtcp(packet.data(), packet.size());
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
// Old style functions.
|
||||
virtual bool SendRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
const PacketOptions& options) = 0;
|
||||
virtual bool SendRtcp(const uint8_t* packet, size_t length) = 0;
|
||||
[[deprecated("Use ArrayView version")]] virtual bool
|
||||
SendRtp(const uint8_t* packet, size_t length, const PacketOptions& options) {
|
||||
return SendRtp(rtc::MakeArrayView(packet, length), options);
|
||||
}
|
||||
[[deprecated("Use ArrayView version")]] virtual bool SendRtcp(
|
||||
const uint8_t* packet,
|
||||
size_t length) {
|
||||
return SendRtcp(rtc::MakeArrayView(packet, length));
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~Transport() {}
|
||||
|
|
|
@ -356,10 +356,12 @@ void FakeNetworkPipe::DeliverNetworkPacket(NetworkPacket* packet) {
|
|||
return;
|
||||
}
|
||||
if (packet->is_rtcp()) {
|
||||
transport->SendRtcp(packet->data(), packet->data_length());
|
||||
transport->SendRtcp(
|
||||
rtc::MakeArrayView(packet->data(), packet->data_length()));
|
||||
} else {
|
||||
transport->SendRtp(packet->data(), packet->data_length(),
|
||||
packet->packet_options());
|
||||
transport->SendRtp(
|
||||
rtc::MakeArrayView(packet->data(), packet->data_length()),
|
||||
packet->packet_options());
|
||||
}
|
||||
} else if (receiver_) {
|
||||
int64_t packet_time_us = packet->packet_time_us().value_or(-1);
|
||||
|
|
|
@ -5589,8 +5589,7 @@ TEST_F(WebRtcVideoChannelTest, TestSetDscpOptions) {
|
|||
|
||||
// Packets should also self-identify their dscp in PacketOptions.
|
||||
const uint8_t kData[10] = {0};
|
||||
EXPECT_TRUE(ChannelImplAsTransport(send_channel.get())
|
||||
->SendRtcp(kData, sizeof(kData)));
|
||||
EXPECT_TRUE(ChannelImplAsTransport(send_channel.get())->SendRtcp(kData));
|
||||
EXPECT_EQ(rtc::DSCP_CS1, network_interface->options().dscp);
|
||||
send_channel->SetInterface(nullptr);
|
||||
|
||||
|
|
|
@ -3255,9 +3255,7 @@ TEST_P(WebRtcVoiceEngineTestFake, TestSetDscpOptions) {
|
|||
|
||||
// Packets should also self-identify their dscp in PacketOptions.
|
||||
const uint8_t kData[10] = {0};
|
||||
EXPECT_TRUE(SendImplFromPointer(channel.get())
|
||||
->transport()
|
||||
->SendRtcp(kData, sizeof(kData)));
|
||||
EXPECT_TRUE(SendImplFromPointer(channel.get())->transport()->SendRtcp(kData));
|
||||
EXPECT_EQ(rtc::DSCP_CS1, network_interface.options().dscp);
|
||||
channel->SetInterface(nullptr);
|
||||
|
||||
|
|
|
@ -416,7 +416,7 @@ bool DEPRECATED_RtpSenderEgress::SendPacketToNetwork(
|
|||
const PacedPacketInfo& pacing_info) {
|
||||
int bytes_sent = -1;
|
||||
if (transport_) {
|
||||
bytes_sent = transport_->SendRtp(packet.data(), packet.size(), options)
|
||||
bytes_sent = transport_->SendRtp(packet, options)
|
||||
? static_cast<int>(packet.size())
|
||||
: -1;
|
||||
if (event_log_ && bytes_sent > 0) {
|
||||
|
|
|
@ -242,7 +242,7 @@ int32_t RTCPSender::SendLossNotification(const FeedbackState& feedback_state,
|
|||
bool buffering_allowed) {
|
||||
int32_t error_code = -1;
|
||||
auto callback = [&](rtc::ArrayView<const uint8_t> packet) {
|
||||
transport_->SendRtcp(packet.data(), packet.size());
|
||||
transport_->SendRtcp(packet);
|
||||
error_code = 0;
|
||||
if (event_log_) {
|
||||
event_log_->Log(std::make_unique<RtcEventRtcpPacketOutgoing>(packet));
|
||||
|
@ -659,7 +659,7 @@ int32_t RTCPSender::SendRTCP(const FeedbackState& feedback_state,
|
|||
const uint16_t* nack_list) {
|
||||
int32_t error_code = -1;
|
||||
auto callback = [&](rtc::ArrayView<const uint8_t> packet) {
|
||||
if (transport_->SendRtcp(packet.data(), packet.size())) {
|
||||
if (transport_->SendRtcp(packet)) {
|
||||
error_code = 0;
|
||||
if (event_log_) {
|
||||
event_log_->Log(std::make_unique<RtcEventRtcpPacketOutgoing>(packet));
|
||||
|
@ -938,7 +938,7 @@ void RTCPSender::SendCombinedRtcpPacket(
|
|||
}
|
||||
RTC_DCHECK_LE(max_packet_size, IP_PACKET_SIZE);
|
||||
auto callback = [&](rtc::ArrayView<const uint8_t> packet) {
|
||||
if (transport_->SendRtcp(packet.data(), packet.size())) {
|
||||
if (transport_->SendRtcp(packet)) {
|
||||
if (event_log_)
|
||||
event_log_->Log(std::make_unique<RtcEventRtcpPacketOutgoing>(packet));
|
||||
}
|
||||
|
|
|
@ -522,7 +522,7 @@ bool RtpSenderEgress::SendPacketToNetwork(const RtpPacketToSend& packet,
|
|||
RTC_DCHECK_RUN_ON(worker_queue_);
|
||||
int bytes_sent = -1;
|
||||
if (transport_) {
|
||||
bytes_sent = transport_->SendRtp(packet.data(), packet.size(), options)
|
||||
bytes_sent = transport_->SendRtp(packet, options)
|
||||
? static_cast<int>(packet.size())
|
||||
: -1;
|
||||
if (event_log_ && bytes_sent > 0) {
|
||||
|
|
|
@ -166,7 +166,7 @@ TEST_F(RetransmissionEndToEndTest, ReceivesNackAndRetransmitsAudio) {
|
|||
nack.SetPacketIds(nack_list, 1);
|
||||
rtc::Buffer buffer = nack.Build();
|
||||
|
||||
EXPECT_TRUE(receive_transport_->SendRtcp(buffer.data(), buffer.size()));
|
||||
EXPECT_TRUE(receive_transport_->SendRtcp(buffer));
|
||||
}
|
||||
|
||||
return SEND_PACKET;
|
||||
|
|
|
@ -336,7 +336,7 @@ void RtpRtcpEndToEndTest::TestRtpStatePreservation(
|
|||
rtcp::RapidResyncRequest force_send_sr_back_request;
|
||||
rtc::Buffer packet = force_send_sr_back_request.Build();
|
||||
static_cast<webrtc::Transport*>(receive_transport_.get())
|
||||
->SendRtcp(packet.data(), packet.size());
|
||||
->SendRtcp(packet);
|
||||
}
|
||||
CreateFrameGeneratorCapturer(30, 1280, 720);
|
||||
StartVideoSources();
|
||||
|
|
|
@ -22,20 +22,19 @@ TransportAdapter::TransportAdapter(Transport* transport)
|
|||
|
||||
TransportAdapter::~TransportAdapter() = default;
|
||||
|
||||
bool TransportAdapter::SendRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
bool TransportAdapter::SendRtp(rtc::ArrayView<const uint8_t> packet,
|
||||
const PacketOptions& options) {
|
||||
if (!enabled_.load())
|
||||
return false;
|
||||
|
||||
return transport_->SendRtp(packet, length, options);
|
||||
return transport_->SendRtp(packet, options);
|
||||
}
|
||||
|
||||
bool TransportAdapter::SendRtcp(const uint8_t* packet, size_t length) {
|
||||
bool TransportAdapter::SendRtcp(rtc::ArrayView<const uint8_t> packet) {
|
||||
if (!enabled_.load())
|
||||
return false;
|
||||
|
||||
return transport_->SendRtcp(packet, length);
|
||||
return transport_->SendRtcp(packet);
|
||||
}
|
||||
|
||||
void TransportAdapter::Enable() {
|
||||
|
|
|
@ -25,10 +25,9 @@ class TransportAdapter : public Transport {
|
|||
explicit TransportAdapter(Transport* transport);
|
||||
~TransportAdapter() override;
|
||||
|
||||
bool SendRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
bool SendRtp(rtc::ArrayView<const uint8_t> packet,
|
||||
const PacketOptions& options) override;
|
||||
bool SendRtcp(const uint8_t* packet, size_t length) override;
|
||||
bool SendRtcp(rtc::ArrayView<const uint8_t> packet) override;
|
||||
|
||||
void Enable();
|
||||
void Disable();
|
||||
|
|
Loading…
Reference in a new issue