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

Unified Diff: webrtc/modules/audio_coding/neteq/neteq_impl.cc

Issue 1429943004: AcmReceiver::InsertPacket and NetEq::InsertPacket: Take ArrayView arguments (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix log message Created 5 years, 1 month 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/modules/audio_coding/neteq/neteq_impl.cc
diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
index d9ae15e7faa3481b2dff43b5a71c5f57f2cbff3f..bbd3220c00b20f33523b68d31508bcdfc03f6d51 100644
--- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc
+++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc
@@ -121,17 +121,16 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
NetEqImpl::~NetEqImpl() = default;
int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
- const uint8_t* payload,
- size_t length_bytes,
+ rtc::ArrayView<const uint8_t> payload,
uint32_t receive_timestamp) {
CriticalSectionScoped lock(crit_sect_.get());
- LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp <<
- ", sn=" << rtp_header.header.sequenceNumber <<
- ", pt=" << static_cast<int>(rtp_header.header.payloadType) <<
- ", ssrc=" << rtp_header.header.ssrc <<
- ", len=" << length_bytes;
- int error = InsertPacketInternal(rtp_header, payload, length_bytes,
- receive_timestamp, false);
+ LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp
+ << ", sn=" << rtp_header.header.sequenceNumber
+ << ", pt=" << static_cast<int>(rtp_header.header.payloadType)
+ << ", ssrc=" << rtp_header.header.ssrc
+ << ", len=" << payload.size();
+ int error =
+ InsertPacketInternal(rtp_header, payload, receive_timestamp, false);
if (error != 0) {
error_code_ = error;
return kFail;
@@ -149,8 +148,8 @@ int NetEqImpl::InsertSyncPacket(const WebRtcRTPHeader& rtp_header,
", ssrc=" << rtp_header.header.ssrc;
const uint8_t kSyncPayload[] = { 's', 'y', 'n', 'c' };
- int error = InsertPacketInternal(
- rtp_header, kSyncPayload, sizeof(kSyncPayload), receive_timestamp, true);
+ int error =
+ InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true);
if (error != 0) {
error_code_ = error;
@@ -445,12 +444,11 @@ const SyncBuffer* NetEqImpl::sync_buffer_for_test() const {
// Methods below this line are private.
int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
- const uint8_t* payload,
- size_t length_bytes,
+ rtc::ArrayView<const uint8_t> payload,
uint32_t receive_timestamp,
bool is_sync_packet) {
- if (!payload) {
- LOG_F(LS_ERROR) << "payload == NULL";
+ if (payload.empty()) {
+ LOG_F(LS_ERROR) << "payload is empty";
return kInvalidPointer;
}
// Sanity checks for sync-packets.
@@ -486,7 +484,7 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
packet->header.timestamp = rtp_header.header.timestamp;
packet->header.ssrc = rtp_header.header.ssrc;
packet->header.numCSRCs = 0;
- packet->payload_length = length_bytes;
+ packet->payload_length = payload.size();
packet->primary = true;
packet->waiting_time = 0;
packet->payload = new uint8_t[packet->payload_length];
@@ -494,8 +492,8 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
if (!packet->payload) {
LOG_F(LS_ERROR) << "Payload pointer is NULL.";
}
- assert(payload); // Already checked above.
- memcpy(packet->payload, payload, packet->payload_length);
+ assert(!payload.empty()); // Already checked above.
+ memcpy(packet->payload, payload.data(), packet->payload_length);
// Insert packet in a packet list.
packet_list.push_back(packet);
// Save main payloads header for later.
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl.h ('k') | webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698