Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2903)

Unified Diff: webrtc/media/engine/webrtcvoiceengine.cc

Issue 1823503002: Reland Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/media/engine/webrtcvoiceengine.cc
diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc
index ae2518b73af9d74feed8a847d51c4f2f9b60ab9e..4f6ae434c70d067185dd46b702010a08cf8fb78d 100644
--- a/webrtc/media/engine/webrtcvoiceengine.cc
+++ b/webrtc/media/engine/webrtcvoiceengine.cc
@@ -2237,11 +2237,11 @@ bool WebRtcVoiceMediaChannel::InsertDtmf(uint32_t ssrc, int event,
}
void WebRtcVoiceMediaChannel::OnPacketReceived(
- rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
+ rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
uint32_t ssrc = 0;
- if (!GetRtpSsrc(packet->data(), packet->size(), &ssrc)) {
+ if (!GetRtpSsrc(packet->cdata(), packet->size(), &ssrc)) {
return;
}
@@ -2269,8 +2269,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
packet_time.not_before);
webrtc::PacketReceiver::DeliveryStatus delivery_result =
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
- reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
- webrtc_packet_time);
+ packet->cdata(), packet->size(), webrtc_packet_time);
if (webrtc::PacketReceiver::DELIVERY_OK != delivery_result) {
// If the SSRC is unknown here, route it to the default channel, if we have
// one. See: https://bugs.chromium.org/p/webrtc/issues/detail?id=5208
@@ -2288,26 +2287,25 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
// Pass it off to the decoder.
engine()->voe()->network()->ReceivedRTPPacket(
- channel, packet->data(), packet->size(), webrtc_packet_time);
+ channel, packet->cdata(), packet->size(), webrtc_packet_time);
}
void WebRtcVoiceMediaChannel::OnRtcpReceived(
- rtc::Buffer* packet, const rtc::PacketTime& packet_time) {
+ rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) {
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
// Forward packet to Call as well.
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
packet_time.not_before);
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
- reinterpret_cast<const uint8_t*>(packet->data()), packet->size(),
- webrtc_packet_time);
+ packet->cdata(), packet->size(), webrtc_packet_time);
// Sending channels need all RTCP packets with feedback information.
// Even sender reports can contain attached report blocks.
// Receiving channels need sender reports in order to create
// correct receiver reports.
int type = 0;
- if (!GetRtcpType(packet->data(), packet->size(), &type)) {
+ if (!GetRtcpType(packet->cdata(), packet->size(), &type)) {
LOG(LS_WARNING) << "Failed to parse type from received RTCP packet";
return;
}
@@ -2315,13 +2313,13 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
// If it is a sender report, find the receive channel that is listening.
if (type == kRtcpTypeSR) {
uint32_t ssrc = 0;
- if (!GetRtcpSsrc(packet->data(), packet->size(), &ssrc)) {
+ if (!GetRtcpSsrc(packet->cdata(), packet->size(), &ssrc)) {
return;
}
int recv_channel_id = GetReceiveChannelId(ssrc);
if (recv_channel_id != -1) {
engine()->voe()->network()->ReceivedRTCPPacket(
- recv_channel_id, packet->data(), packet->size());
+ recv_channel_id, packet->cdata(), packet->size());
}
}
@@ -2330,7 +2328,7 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
// will filter out RR internally.
for (const auto& ch : send_streams_) {
engine()->voe()->network()->ReceivedRTCPPacket(
- ch.second->channel(), packet->data(), packet->size());
+ ch.second->channel(), packet->cdata(), packet->size());
}
}

Powered by Google App Engine
This is Rietveld 408576698