AcmReceiver::InsertPacket and NetEq::InsertPacket: Take ArrayView arguments
Instead of separate pointer and size arguments. Review URL: https://codereview.webrtc.org/1429943004 Cr-Commit-Position: refs/heads/master@{#10606}
This commit is contained in:
@ -163,15 +163,14 @@ int AcmReceiver::current_sample_rate_hz() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* incoming_payload,
|
rtc::ArrayView<const uint8_t> incoming_payload) {
|
||||||
size_t length_payload) {
|
|
||||||
uint32_t receive_timestamp = 0;
|
uint32_t receive_timestamp = 0;
|
||||||
const RTPHeader* header = &rtp_header.header; // Just a shorthand.
|
const RTPHeader* header = &rtp_header.header; // Just a shorthand.
|
||||||
|
|
||||||
{
|
{
|
||||||
CriticalSectionScoped lock(crit_sect_.get());
|
CriticalSectionScoped lock(crit_sect_.get());
|
||||||
|
|
||||||
const Decoder* decoder = RtpHeaderToDecoder(*header, incoming_payload);
|
const Decoder* decoder = RtpHeaderToDecoder(*header, incoming_payload[0]);
|
||||||
if (!decoder) {
|
if (!decoder) {
|
||||||
LOG_F(LS_ERROR) << "Payload-type "
|
LOG_F(LS_ERROR) << "Payload-type "
|
||||||
<< static_cast<int>(header->payloadType)
|
<< static_cast<int>(header->payloadType)
|
||||||
@ -197,8 +196,8 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
|||||||
|
|
||||||
} // |crit_sect_| is released.
|
} // |crit_sect_| is released.
|
||||||
|
|
||||||
if (neteq_->InsertPacket(rtp_header, incoming_payload, length_payload,
|
if (neteq_->InsertPacket(rtp_header, incoming_payload, receive_timestamp) <
|
||||||
receive_timestamp) < 0) {
|
0) {
|
||||||
LOG(LERROR) << "AcmReceiver::InsertPacket "
|
LOG(LERROR) << "AcmReceiver::InsertPacket "
|
||||||
<< static_cast<int>(header->payloadType)
|
<< static_cast<int>(header->payloadType)
|
||||||
<< " Failed to insert packet";
|
<< " Failed to insert packet";
|
||||||
@ -512,14 +511,14 @@ void AcmReceiver::ResetInitialDelay() {
|
|||||||
|
|
||||||
const AcmReceiver::Decoder* AcmReceiver::RtpHeaderToDecoder(
|
const AcmReceiver::Decoder* AcmReceiver::RtpHeaderToDecoder(
|
||||||
const RTPHeader& rtp_header,
|
const RTPHeader& rtp_header,
|
||||||
const uint8_t* payload) const {
|
uint8_t payload_type) const {
|
||||||
auto it = decoders_.find(rtp_header.payloadType);
|
auto it = decoders_.find(rtp_header.payloadType);
|
||||||
const auto red_index =
|
const auto red_index =
|
||||||
RentACodec::CodecIndexFromId(RentACodec::CodecId::kRED);
|
RentACodec::CodecIndexFromId(RentACodec::CodecId::kRED);
|
||||||
if (red_index && // This ensures that RED is defined in WebRTC.
|
if (red_index && // This ensures that RED is defined in WebRTC.
|
||||||
it != decoders_.end() && it->second.acm_codec_id == *red_index) {
|
it != decoders_.end() && it->second.acm_codec_id == *red_index) {
|
||||||
// This is a RED packet, get the payload of the audio codec.
|
// This is a RED packet, get the payload of the audio codec.
|
||||||
it = decoders_.find(payload[0] & 0x7F);
|
it = decoders_.find(payload_type & 0x7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the payload is registered.
|
// Check if the payload is registered.
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "webrtc/base/array_view.h"
|
||||||
#include "webrtc/base/scoped_ptr.h"
|
#include "webrtc/base/scoped_ptr.h"
|
||||||
#include "webrtc/base/thread_annotations.h"
|
#include "webrtc/base/thread_annotations.h"
|
||||||
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
||||||
@ -65,8 +66,7 @@ class AcmReceiver {
|
|||||||
// <0 if NetEq returned an error.
|
// <0 if NetEq returned an error.
|
||||||
//
|
//
|
||||||
int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* incoming_payload,
|
rtc::ArrayView<const uint8_t> incoming_payload);
|
||||||
size_t length_payload);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Asks NetEq for 10 milliseconds of decoded audio.
|
// Asks NetEq for 10 milliseconds of decoded audio.
|
||||||
@ -278,7 +278,7 @@ class AcmReceiver {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header,
|
const Decoder* RtpHeaderToDecoder(const RTPHeader& rtp_header,
|
||||||
const uint8_t* payload) const
|
uint8_t payload_type) const
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||||
|
|
||||||
uint32_t NowInTimestamp(int decoder_sampling_rate) const;
|
uint32_t NowInTimestamp(int decoder_sampling_rate) const;
|
||||||
|
|||||||
@ -141,8 +141,9 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
|
|||||||
rtp_header_.type.Audio.isCNG = true;
|
rtp_header_.type.Audio.isCNG = true;
|
||||||
rtp_header_.header.timestamp = timestamp;
|
rtp_header_.header.timestamp = timestamp;
|
||||||
|
|
||||||
int ret_val = receiver_->InsertPacket(rtp_header_, payload_data,
|
int ret_val = receiver_->InsertPacket(
|
||||||
payload_len_bytes);
|
rtp_header_,
|
||||||
|
rtc::ArrayView<const uint8_t>(payload_data, payload_len_bytes));
|
||||||
if (ret_val < 0) {
|
if (ret_val < 0) {
|
||||||
assert(false);
|
assert(false);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@ -611,7 +611,9 @@ int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
|
|||||||
int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
|
int AudioCodingModuleImpl::IncomingPacket(const uint8_t* incoming_payload,
|
||||||
const size_t payload_length,
|
const size_t payload_length,
|
||||||
const WebRtcRTPHeader& rtp_header) {
|
const WebRtcRTPHeader& rtp_header) {
|
||||||
return receiver_.InsertPacket(rtp_header, incoming_payload, payload_length);
|
return receiver_.InsertPacket(
|
||||||
|
rtp_header,
|
||||||
|
rtc::ArrayView<const uint8_t>(incoming_payload, payload_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minimum playout delay (Used for lip-sync).
|
// Minimum playout delay (Used for lip-sync).
|
||||||
|
|||||||
@ -147,8 +147,7 @@ class NetEq {
|
|||||||
// the same tick rate as the RTP timestamp of the current payload.
|
// the same tick rate as the RTP timestamp of the current payload.
|
||||||
// Returns 0 on success, -1 on failure.
|
// Returns 0 on success, -1 on failure.
|
||||||
virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
virtual int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* payload,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
size_t length_bytes,
|
|
||||||
uint32_t receive_timestamp) = 0;
|
uint32_t receive_timestamp) = 0;
|
||||||
|
|
||||||
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
||||||
|
|||||||
@ -105,7 +105,8 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest {
|
|||||||
uint32_t time_now = 0;
|
uint32_t time_now = 0;
|
||||||
for (int k = 0; k < num_loops; ++k) {
|
for (int k = 0; k < num_loops; ++k) {
|
||||||
while (time_now >= next_arrival_time) {
|
while (time_now >= next_arrival_time) {
|
||||||
InsertPacket(rtp_header_, encoded_, payload_size_bytes_,
|
InsertPacket(rtp_header_, rtc::ArrayView<const uint8_t>(
|
||||||
|
encoded_, payload_size_bytes_),
|
||||||
next_arrival_time);
|
next_arrival_time);
|
||||||
// Get next input packet.
|
// Get next input packet.
|
||||||
do {
|
do {
|
||||||
@ -124,17 +125,14 @@ class NetEqExternalDecoderUnitTest : public test::NetEqExternalDecoderTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertPacket(WebRtcRTPHeader rtp_header, const uint8_t* payload,
|
void InsertPacket(WebRtcRTPHeader rtp_header,
|
||||||
size_t payload_size_bytes,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
uint32_t receive_timestamp) override {
|
uint32_t receive_timestamp) override {
|
||||||
EXPECT_CALL(*external_decoder_,
|
EXPECT_CALL(
|
||||||
IncomingPacket(_,
|
*external_decoder_,
|
||||||
payload_size_bytes,
|
IncomingPacket(_, payload.size(), rtp_header.header.sequenceNumber,
|
||||||
rtp_header.header.sequenceNumber,
|
rtp_header.header.timestamp, receive_timestamp));
|
||||||
rtp_header.header.timestamp,
|
|
||||||
receive_timestamp));
|
|
||||||
NetEqExternalDecoderTest::InsertPacket(rtp_header, payload,
|
NetEqExternalDecoderTest::InsertPacket(rtp_header, payload,
|
||||||
payload_size_bytes,
|
|
||||||
receive_timestamp);
|
receive_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,18 +208,15 @@ class NetEqExternalVsInternalDecoderTest : public NetEqExternalDecoderUnitTest,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InsertPacket(WebRtcRTPHeader rtp_header, const uint8_t* payload,
|
void InsertPacket(WebRtcRTPHeader rtp_header,
|
||||||
size_t payload_size_bytes,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
uint32_t receive_timestamp) override {
|
uint32_t receive_timestamp) override {
|
||||||
// Insert packet in internal decoder.
|
// Insert packet in internal decoder.
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(NetEq::kOK, neteq_internal_->InsertPacket(rtp_header, payload,
|
||||||
NetEq::kOK,
|
receive_timestamp));
|
||||||
neteq_internal_->InsertPacket(
|
|
||||||
rtp_header, payload, payload_size_bytes, receive_timestamp));
|
|
||||||
|
|
||||||
// Insert packet in external decoder instance.
|
// Insert packet in external decoder instance.
|
||||||
NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload,
|
NetEqExternalDecoderUnitTest::InsertPacket(rtp_header, payload,
|
||||||
payload_size_bytes,
|
|
||||||
receive_timestamp);
|
receive_timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -121,17 +121,16 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
|
|||||||
NetEqImpl::~NetEqImpl() = default;
|
NetEqImpl::~NetEqImpl() = default;
|
||||||
|
|
||||||
int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* payload,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
size_t length_bytes,
|
|
||||||
uint32_t receive_timestamp) {
|
uint32_t receive_timestamp) {
|
||||||
CriticalSectionScoped lock(crit_sect_.get());
|
CriticalSectionScoped lock(crit_sect_.get());
|
||||||
LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp <<
|
LOG(LS_VERBOSE) << "InsertPacket: ts=" << rtp_header.header.timestamp
|
||||||
", sn=" << rtp_header.header.sequenceNumber <<
|
<< ", sn=" << rtp_header.header.sequenceNumber
|
||||||
", pt=" << static_cast<int>(rtp_header.header.payloadType) <<
|
<< ", pt=" << static_cast<int>(rtp_header.header.payloadType)
|
||||||
", ssrc=" << rtp_header.header.ssrc <<
|
<< ", ssrc=" << rtp_header.header.ssrc
|
||||||
", len=" << length_bytes;
|
<< ", len=" << payload.size();
|
||||||
int error = InsertPacketInternal(rtp_header, payload, length_bytes,
|
int error =
|
||||||
receive_timestamp, false);
|
InsertPacketInternal(rtp_header, payload, receive_timestamp, false);
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
error_code_ = error;
|
error_code_ = error;
|
||||||
return kFail;
|
return kFail;
|
||||||
@ -149,8 +148,8 @@ int NetEqImpl::InsertSyncPacket(const WebRtcRTPHeader& rtp_header,
|
|||||||
", ssrc=" << rtp_header.header.ssrc;
|
", ssrc=" << rtp_header.header.ssrc;
|
||||||
|
|
||||||
const uint8_t kSyncPayload[] = { 's', 'y', 'n', 'c' };
|
const uint8_t kSyncPayload[] = { 's', 'y', 'n', 'c' };
|
||||||
int error = InsertPacketInternal(
|
int error =
|
||||||
rtp_header, kSyncPayload, sizeof(kSyncPayload), receive_timestamp, true);
|
InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true);
|
||||||
|
|
||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
error_code_ = error;
|
error_code_ = error;
|
||||||
@ -445,12 +444,11 @@ const SyncBuffer* NetEqImpl::sync_buffer_for_test() const {
|
|||||||
// Methods below this line are private.
|
// Methods below this line are private.
|
||||||
|
|
||||||
int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* payload,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
size_t length_bytes,
|
|
||||||
uint32_t receive_timestamp,
|
uint32_t receive_timestamp,
|
||||||
bool is_sync_packet) {
|
bool is_sync_packet) {
|
||||||
if (!payload) {
|
if (payload.empty()) {
|
||||||
LOG_F(LS_ERROR) << "payload == NULL";
|
LOG_F(LS_ERROR) << "payload is empty";
|
||||||
return kInvalidPointer;
|
return kInvalidPointer;
|
||||||
}
|
}
|
||||||
// Sanity checks for sync-packets.
|
// 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.timestamp = rtp_header.header.timestamp;
|
||||||
packet->header.ssrc = rtp_header.header.ssrc;
|
packet->header.ssrc = rtp_header.header.ssrc;
|
||||||
packet->header.numCSRCs = 0;
|
packet->header.numCSRCs = 0;
|
||||||
packet->payload_length = length_bytes;
|
packet->payload_length = payload.size();
|
||||||
packet->primary = true;
|
packet->primary = true;
|
||||||
packet->waiting_time = 0;
|
packet->waiting_time = 0;
|
||||||
packet->payload = new uint8_t[packet->payload_length];
|
packet->payload = new uint8_t[packet->payload_length];
|
||||||
@ -494,8 +492,8 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
|||||||
if (!packet->payload) {
|
if (!packet->payload) {
|
||||||
LOG_F(LS_ERROR) << "Payload pointer is NULL.";
|
LOG_F(LS_ERROR) << "Payload pointer is NULL.";
|
||||||
}
|
}
|
||||||
assert(payload); // Already checked above.
|
assert(!payload.empty()); // Already checked above.
|
||||||
memcpy(packet->payload, payload, packet->payload_length);
|
memcpy(packet->payload, payload.data(), packet->payload_length);
|
||||||
// Insert packet in a packet list.
|
// Insert packet in a packet list.
|
||||||
packet_list.push_back(packet);
|
packet_list.push_back(packet);
|
||||||
// Save main payloads header for later.
|
// Save main payloads header for later.
|
||||||
|
|||||||
@ -79,8 +79,7 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
// the same tick rate as the RTP timestamp of the current payload.
|
// the same tick rate as the RTP timestamp of the current payload.
|
||||||
// Returns 0 on success, -1 on failure.
|
// Returns 0 on success, -1 on failure.
|
||||||
int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
int InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* payload,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
size_t length_bytes,
|
|
||||||
uint32_t receive_timestamp) override;
|
uint32_t receive_timestamp) override;
|
||||||
|
|
||||||
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
// Inserts a sync-packet into packet queue. Sync-packets are decoded to
|
||||||
@ -207,8 +206,7 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
// above. Returns 0 on success, otherwise an error code.
|
// above. Returns 0 on success, otherwise an error code.
|
||||||
// TODO(hlundin): Merge this with InsertPacket above?
|
// TODO(hlundin): Merge this with InsertPacket above?
|
||||||
int InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
int InsertPacketInternal(const WebRtcRTPHeader& rtp_header,
|
||||||
const uint8_t* payload,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
size_t length_bytes,
|
|
||||||
uint32_t receive_timestamp,
|
uint32_t receive_timestamp,
|
||||||
bool is_sync_packet)
|
bool is_sync_packet)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||||
|
|||||||
@ -359,13 +359,12 @@ TEST_F(NetEqImplTest, InsertPacket) {
|
|||||||
.WillRepeatedly(Return(PayloadSplitter::kOK));
|
.WillRepeatedly(Return(PayloadSplitter::kOK));
|
||||||
|
|
||||||
// Insert first packet.
|
// Insert first packet.
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLength, kFirstReceiveTime);
|
neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime);
|
||||||
|
|
||||||
// Insert second packet.
|
// Insert second packet.
|
||||||
rtp_header.header.timestamp += 160;
|
rtp_header.header.timestamp += 160;
|
||||||
rtp_header.header.sequenceNumber += 1;
|
rtp_header.header.sequenceNumber += 1;
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLength,
|
neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155);
|
||||||
kFirstReceiveTime + 155);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
||||||
@ -389,8 +388,7 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
|||||||
// Insert packets. The buffer should not flush.
|
// Insert packets. The buffer should not flush.
|
||||||
for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) {
|
for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) {
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
rtp_header.header.timestamp += kPayloadLengthSamples;
|
rtp_header.header.timestamp += kPayloadLengthSamples;
|
||||||
rtp_header.header.sequenceNumber += 1;
|
rtp_header.header.sequenceNumber += 1;
|
||||||
EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer());
|
EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer());
|
||||||
@ -399,8 +397,7 @@ TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) {
|
|||||||
// Insert one more packet and make sure the buffer got flushed. That is, it
|
// Insert one more packet and make sure the buffer got flushed. That is, it
|
||||||
// should only hold one single packet.
|
// should only hold one single packet.
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer());
|
EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer());
|
||||||
const RTPHeader* test_header = packet_buffer_->NextRtpHeader();
|
const RTPHeader* test_header = packet_buffer_->NextRtpHeader();
|
||||||
EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp);
|
EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp);
|
||||||
@ -463,8 +460,7 @@ TEST_F(NetEqImplTest, VerifyTimestampPropagation) {
|
|||||||
|
|
||||||
// Insert one packet.
|
// Insert one packet.
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
// Pull audio once.
|
// Pull audio once.
|
||||||
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
|
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
|
||||||
@ -543,8 +539,7 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
|
|||||||
|
|
||||||
// Insert one packet.
|
// Insert one packet.
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
// Pull audio once.
|
// Pull audio once.
|
||||||
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
|
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000);
|
||||||
@ -566,14 +561,12 @@ TEST_F(NetEqImplTest, ReorderedPacket) {
|
|||||||
rtp_header.header.timestamp -= kPayloadLengthSamples;
|
rtp_header.header.timestamp -= kPayloadLengthSamples;
|
||||||
payload[0] = 1;
|
payload[0] = 1;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
rtp_header.header.sequenceNumber += 2;
|
rtp_header.header.sequenceNumber += 2;
|
||||||
rtp_header.header.timestamp += 2 * kPayloadLengthSamples;
|
rtp_header.header.timestamp += 2 * kPayloadLengthSamples;
|
||||||
payload[0] = 2;
|
payload[0] = 2;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
// Expect only the second packet to be decoded (the one with "2" as the first
|
// Expect only the second packet to be decoded (the one with "2" as the first
|
||||||
// payload byte).
|
// payload byte).
|
||||||
@ -622,8 +615,7 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) {
|
|||||||
// Insert one packet. Note that we have not registered any payload type, so
|
// Insert one packet. Note that we have not registered any payload type, so
|
||||||
// this packet will be rejected.
|
// this packet will be rejected.
|
||||||
EXPECT_EQ(NetEq::kFail,
|
EXPECT_EQ(NetEq::kFail,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
|
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
|
||||||
|
|
||||||
// Pull audio once.
|
// Pull audio once.
|
||||||
@ -649,8 +641,7 @@ TEST_F(NetEqImplTest, FirstPacketUnknown) {
|
|||||||
rtp_header.header.sequenceNumber++;
|
rtp_header.header.sequenceNumber++;
|
||||||
rtp_header.header.timestamp += kPayloadLengthSamples;
|
rtp_header.header.timestamp += kPayloadLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer());
|
EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,16 +721,14 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
|
|||||||
|
|
||||||
// Insert one packet (decoder will return speech).
|
// Insert one packet (decoder will return speech).
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
// Insert second packet (decoder will return CNG).
|
// Insert second packet (decoder will return CNG).
|
||||||
payload[0] = 1;
|
payload[0] = 1;
|
||||||
rtp_header.header.sequenceNumber++;
|
rtp_header.header.sequenceNumber++;
|
||||||
rtp_header.header.timestamp += kPayloadLengthSamples;
|
rtp_header.header.timestamp += kPayloadLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
|
const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
|
||||||
int16_t output[kMaxOutputSize];
|
int16_t output[kMaxOutputSize];
|
||||||
@ -785,8 +774,7 @@ TEST_F(NetEqImplTest, CodecInternalCng) {
|
|||||||
rtp_header.header.sequenceNumber += 2;
|
rtp_header.header.sequenceNumber += 2;
|
||||||
rtp_header.header.timestamp += 2 * kPayloadLengthSamples;
|
rtp_header.header.timestamp += 2 * kPayloadLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
for (size_t i = 6; i < 8; ++i) {
|
for (size_t i = 6; i < 8; ++i) {
|
||||||
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
|
ASSERT_EQ(kMaxOutputSize, samples_per_channel);
|
||||||
@ -871,8 +859,7 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) {
|
|||||||
// Insert one packet.
|
// Insert one packet.
|
||||||
payload[0] = kFirstPayloadValue; // This will make Decode() fail.
|
payload[0] = kFirstPayloadValue; // This will make Decode() fail.
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
// Insert another packet.
|
// Insert another packet.
|
||||||
payload[0] = kSecondPayloadValue; // This will make Decode() successful.
|
payload[0] = kSecondPayloadValue; // This will make Decode() successful.
|
||||||
@ -881,8 +868,7 @@ TEST_F(NetEqImplTest, UnsupportedDecoder) {
|
|||||||
// the second packet get decoded.
|
// the second packet get decoded.
|
||||||
rtp_header.header.timestamp += 3 * kPayloadLengthSamples;
|
rtp_header.header.timestamp += 3 * kPayloadLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
rtp_header, payload, kPayloadLengthBytes, kReceiveTime));
|
|
||||||
|
|
||||||
const size_t kMaxOutputSize =
|
const size_t kMaxOutputSize =
|
||||||
static_cast<size_t>(10 * kSampleRateHz / 1000 * kChannels);
|
static_cast<size_t>(10 * kSampleRateHz / 1000 * kChannels);
|
||||||
@ -932,8 +918,7 @@ TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) {
|
|||||||
for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) {
|
for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) {
|
||||||
EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer());
|
EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer());
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
rtp_header.header.timestamp +=
|
rtp_header.header.timestamp +=
|
||||||
rtc::checked_cast<uint32_t>(kPayloadLengthSamples);
|
rtc::checked_cast<uint32_t>(kPayloadLengthSamples);
|
||||||
++rtp_header.header.sequenceNumber;
|
++rtp_header.header.sequenceNumber;
|
||||||
@ -987,8 +972,7 @@ TEST_F(NetEqImplTest, DecodedPayloadTooShort) {
|
|||||||
|
|
||||||
// Insert one packet.
|
// Insert one packet.
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
|
|
||||||
EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength());
|
EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength());
|
||||||
|
|
||||||
@ -1086,8 +1070,7 @@ TEST_F(NetEqImplTest, DecodingError) {
|
|||||||
rtp_header.header.sequenceNumber += 1;
|
rtp_header.header.sequenceNumber += 1;
|
||||||
rtp_header.header.timestamp += kFrameLengthSamples;
|
rtp_header.header.timestamp += kFrameLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull audio.
|
// Pull audio.
|
||||||
@ -1208,8 +1191,7 @@ TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) {
|
|||||||
rtp_header.header.sequenceNumber += 1;
|
rtp_header.header.sequenceNumber += 1;
|
||||||
rtp_header.header.timestamp += kFrameLengthSamples;
|
rtp_header.header.timestamp += kFrameLengthSamples;
|
||||||
EXPECT_EQ(NetEq::kOK,
|
EXPECT_EQ(NetEq::kOK,
|
||||||
neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes,
|
neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
|
||||||
kReceiveTime));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pull audio.
|
// Pull audio.
|
||||||
|
|||||||
@ -191,8 +191,7 @@ struct NetEqNetworkStatsCheck {
|
|||||||
frame_size_samples_,
|
frame_size_samples_,
|
||||||
&rtp_header_);
|
&rtp_header_);
|
||||||
if (!Lost(next_send_time)) {
|
if (!Lost(next_send_time)) {
|
||||||
InsertPacket(rtp_header_, payload_, kPayloadSizeByte,
|
InsertPacket(rtp_header_, payload_, next_send_time);
|
||||||
next_send_time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GetOutputAudio(kMaxOutputSize, output_, &output_type);
|
GetOutputAudio(kMaxOutputSize, output_, &output_type);
|
||||||
|
|||||||
@ -196,14 +196,16 @@ class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> {
|
|||||||
while (time_now >= next_arrival_time) {
|
while (time_now >= next_arrival_time) {
|
||||||
// Insert packet in mono instance.
|
// Insert packet in mono instance.
|
||||||
ASSERT_EQ(NetEq::kOK,
|
ASSERT_EQ(NetEq::kOK,
|
||||||
neteq_mono_->InsertPacket(rtp_header_mono_, encoded_,
|
neteq_mono_->InsertPacket(rtp_header_mono_,
|
||||||
payload_size_bytes_,
|
rtc::ArrayView<const uint8_t>(
|
||||||
|
encoded_, payload_size_bytes_),
|
||||||
next_arrival_time));
|
next_arrival_time));
|
||||||
// Insert packet in multi-channel instance.
|
// Insert packet in multi-channel instance.
|
||||||
ASSERT_EQ(NetEq::kOK,
|
ASSERT_EQ(NetEq::kOK, neteq_->InsertPacket(
|
||||||
neteq_->InsertPacket(rtp_header_, encoded_multi_channel_,
|
rtp_header_, rtc::ArrayView<const uint8_t>(
|
||||||
multi_payload_size_bytes_,
|
encoded_multi_channel_,
|
||||||
next_arrival_time));
|
multi_payload_size_bytes_),
|
||||||
|
next_arrival_time));
|
||||||
// Get next input packets (mono and multi-channel).
|
// Get next input packets (mono and multi-channel).
|
||||||
do {
|
do {
|
||||||
next_send_time = GetNewPackets();
|
next_send_time = GetNewPackets();
|
||||||
|
|||||||
@ -343,10 +343,11 @@ void NetEqDecodingTest::Process(size_t* out_len) {
|
|||||||
WebRtcRTPHeader rtp_header;
|
WebRtcRTPHeader rtp_header;
|
||||||
packet_->ConvertHeader(&rtp_header);
|
packet_->ConvertHeader(&rtp_header);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(
|
ASSERT_EQ(0, neteq_->InsertPacket(
|
||||||
rtp_header, packet_->payload(),
|
rtp_header,
|
||||||
packet_->payload_length_bytes(),
|
rtc::ArrayView<const uint8_t>(
|
||||||
static_cast<uint32_t>(
|
packet_->payload(), packet_->payload_length_bytes()),
|
||||||
packet_->time_ms() * (output_sample_rate_ / 1000))));
|
static_cast<uint32_t>(packet_->time_ms() *
|
||||||
|
(output_sample_rate_ / 1000))));
|
||||||
}
|
}
|
||||||
// Get next packet.
|
// Get next packet.
|
||||||
packet_.reset(rtp_source_->NextPacket());
|
packet_.reset(rtp_source_->NextPacket());
|
||||||
@ -495,17 +496,14 @@ TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
|
|||||||
const size_t kSamples = 10 * 16;
|
const size_t kSamples = 10 * 16;
|
||||||
const size_t kPayloadBytes = kSamples * 2;
|
const size_t kPayloadBytes = kSamples * 2;
|
||||||
for (size_t i = 0; i < num_frames; ++i) {
|
for (size_t i = 0; i < num_frames; ++i) {
|
||||||
uint16_t payload[kSamples] = {0};
|
const uint8_t payload[kPayloadBytes] = {0};
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
rtp_info.header.sequenceNumber = i;
|
rtp_info.header.sequenceNumber = i;
|
||||||
rtp_info.header.timestamp = i * kSamples;
|
rtp_info.header.timestamp = i * kSamples;
|
||||||
rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC.
|
rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC.
|
||||||
rtp_info.header.payloadType = 94; // PCM16b WB codec.
|
rtp_info.header.payloadType = 94; // PCM16b WB codec.
|
||||||
rtp_info.header.markerBit = 0;
|
rtp_info.header.markerBit = 0;
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
rtp_info,
|
|
||||||
reinterpret_cast<uint8_t*>(payload),
|
|
||||||
kPayloadBytes, 0));
|
|
||||||
}
|
}
|
||||||
// Pull out all data.
|
// Pull out all data.
|
||||||
for (size_t i = 0; i < num_frames; ++i) {
|
for (size_t i = 0; i < num_frames; ++i) {
|
||||||
@ -549,7 +547,7 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
|
|||||||
uint8_t payload[kPayloadBytes] = {0};
|
uint8_t payload[kPayloadBytes] = {0};
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info);
|
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++frame_index;
|
++frame_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,7 +578,7 @@ TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) {
|
|||||||
uint8_t payload[kPayloadBytes] = {0};
|
uint8_t payload[kPayloadBytes] = {0};
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info);
|
PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++frame_index;
|
++frame_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,7 +621,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
|||||||
uint8_t payload[kPayloadBytes] = {0};
|
uint8_t payload[kPayloadBytes] = {0};
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kSamples;
|
timestamp += kSamples;
|
||||||
next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor;
|
next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor;
|
||||||
@ -649,7 +647,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
|||||||
size_t payload_len;
|
size_t payload_len;
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(
|
||||||
|
rtp_info,
|
||||||
|
rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kCngPeriodSamples;
|
timestamp += kCngPeriodSamples;
|
||||||
next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor;
|
next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor;
|
||||||
@ -696,7 +696,9 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
|||||||
size_t payload_len;
|
size_t payload_len;
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(
|
||||||
|
rtp_info,
|
||||||
|
rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kCngPeriodSamples;
|
timestamp += kCngPeriodSamples;
|
||||||
next_input_time_ms += kCngPeriodMs * drift_factor;
|
next_input_time_ms += kCngPeriodMs * drift_factor;
|
||||||
@ -712,7 +714,7 @@ void NetEqDecodingTest::LongCngWithClockDrift(double drift_factor,
|
|||||||
uint8_t payload[kPayloadBytes] = {0};
|
uint8_t payload[kPayloadBytes] = {0};
|
||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kSamples;
|
timestamp += kSamples;
|
||||||
next_input_time_ms += kFrameSizeMs * drift_factor;
|
next_input_time_ms += kFrameSizeMs * drift_factor;
|
||||||
@ -823,8 +825,7 @@ TEST_F(NetEqDecodingTest, UnknownPayloadType) {
|
|||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(0, 0, &rtp_info);
|
PopulateRtpInfo(0, 0, &rtp_info);
|
||||||
rtp_info.header.payloadType = 1; // Not registered as a decoder.
|
rtp_info.header.payloadType = 1; // Not registered as a decoder.
|
||||||
EXPECT_EQ(NetEq::kFail,
|
EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
|
||||||
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
|
EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -840,7 +841,7 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) {
|
|||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
PopulateRtpInfo(0, 0, &rtp_info);
|
PopulateRtpInfo(0, 0, &rtp_info);
|
||||||
rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid.
|
rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid.
|
||||||
EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
NetEqOutputType type;
|
NetEqOutputType type;
|
||||||
// Set all of |out_data_| to 1, and verify that it was set to 0 by the call
|
// Set all of |out_data_| to 1, and verify that it was set to 0 by the call
|
||||||
// to GetAudio.
|
// to GetAudio.
|
||||||
@ -947,9 +948,9 @@ class NetEqBgnTest : public NetEqDecodingTest {
|
|||||||
|
|
||||||
number_channels = 0;
|
number_channels = 0;
|
||||||
samples_per_channel = 0;
|
samples_per_channel = 0;
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, rtc::ArrayView<const uint8_t>(
|
||||||
neteq_->InsertPacket(rtp_info, payload, enc_len_bytes,
|
payload, enc_len_bytes),
|
||||||
receive_timestamp));
|
receive_timestamp));
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0,
|
||||||
neteq_->GetAudio(kBlockSize32kHz,
|
neteq_->GetAudio(kBlockSize32kHz,
|
||||||
output,
|
output,
|
||||||
@ -1108,8 +1109,7 @@ TEST_F(NetEqDecodingTest, IF_ISAC(SyncPacketInsert)) {
|
|||||||
// Payload length of 10 ms PCM16 16 kHz.
|
// Payload length of 10 ms PCM16 16 kHz.
|
||||||
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t);
|
||||||
uint8_t payload[kPayloadBytes] = {0};
|
uint8_t payload[kPayloadBytes] = {0};
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
rtp_info, payload, kPayloadBytes, receive_timestamp));
|
|
||||||
|
|
||||||
// Next packet. Last packet contained 10 ms audio.
|
// Next packet. Last packet contained 10 ms audio.
|
||||||
rtp_info.header.sequenceNumber++;
|
rtp_info.header.sequenceNumber++;
|
||||||
@ -1171,8 +1171,7 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
|
|||||||
size_t samples_per_channel;
|
size_t samples_per_channel;
|
||||||
uint32_t receive_timestamp = 0;
|
uint32_t receive_timestamp = 0;
|
||||||
for (int n = 0; n < 100; ++n) {
|
for (int n = 0; n < 100; ++n) {
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
receive_timestamp));
|
|
||||||
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
||||||
&samples_per_channel, &num_channels,
|
&samples_per_channel, &num_channels,
|
||||||
&output_type));
|
&output_type));
|
||||||
@ -1207,8 +1206,7 @@ TEST_F(NetEqDecodingTest, SyncPacketDecode) {
|
|||||||
// We insert regular packets, if sync packet are not correctly buffered then
|
// We insert regular packets, if sync packet are not correctly buffered then
|
||||||
// network statistics would show some packet loss.
|
// network statistics would show some packet loss.
|
||||||
for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) {
|
for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) {
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
receive_timestamp));
|
|
||||||
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
||||||
&samples_per_channel, &num_channels,
|
&samples_per_channel, &num_channels,
|
||||||
&output_type));
|
&output_type));
|
||||||
@ -1250,8 +1248,7 @@ TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
|
|||||||
uint32_t receive_timestamp = 0;
|
uint32_t receive_timestamp = 0;
|
||||||
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
|
int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1;
|
||||||
for (int n = 0; n < algorithmic_frame_delay; ++n) {
|
for (int n = 0; n < algorithmic_frame_delay; ++n) {
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
receive_timestamp));
|
|
||||||
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded,
|
||||||
&samples_per_channel, &num_channels,
|
&samples_per_channel, &num_channels,
|
||||||
&output_type));
|
&output_type));
|
||||||
@ -1283,8 +1280,7 @@ TEST_F(NetEqDecodingTest, SyncPacketBufferSizeAndOverridenByNetworkPackets) {
|
|||||||
|
|
||||||
// Insert.
|
// Insert.
|
||||||
for (int n = 0; n < kNumSyncPackets; ++n) {
|
for (int n = 0; n < kNumSyncPackets; ++n) {
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes,
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
receive_timestamp));
|
|
||||||
rtp_info.header.sequenceNumber++;
|
rtp_info.header.sequenceNumber++;
|
||||||
rtp_info.header.timestamp += kBlockSize16kHz;
|
rtp_info.header.timestamp += kBlockSize16kHz;
|
||||||
receive_timestamp += kBlockSize16kHz;
|
receive_timestamp += kBlockSize16kHz;
|
||||||
@ -1336,8 +1332,7 @@ void NetEqDecodingTest::WrapTest(uint16_t start_seq_no,
|
|||||||
if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) {
|
if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) {
|
||||||
// This sequence number was not in the set to drop. Insert it.
|
// This sequence number was not in the set to drop. Insert it.
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0,
|
||||||
neteq_->InsertPacket(rtp_info, payload, kPayloadBytes,
|
neteq_->InsertPacket(rtp_info, payload, receive_timestamp));
|
||||||
receive_timestamp));
|
|
||||||
++packets_inserted;
|
++packets_inserted;
|
||||||
}
|
}
|
||||||
NetEqNetworkStatistics network_stats;
|
NetEqNetworkStatistics network_stats;
|
||||||
@ -1425,7 +1420,7 @@ void NetEqDecodingTest::DuplicateCng() {
|
|||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kSamples;
|
timestamp += kSamples;
|
||||||
|
|
||||||
@ -1444,7 +1439,9 @@ void NetEqDecodingTest::DuplicateCng() {
|
|||||||
size_t payload_len;
|
size_t payload_len;
|
||||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||||
// This is the first time this CNG packet is inserted.
|
// This is the first time this CNG packet is inserted.
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
ASSERT_EQ(
|
||||||
|
0, neteq_->InsertPacket(
|
||||||
|
rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
|
||||||
|
|
||||||
// Pull audio once and make sure CNG is played.
|
// Pull audio once and make sure CNG is played.
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0,
|
||||||
@ -1456,7 +1453,9 @@ void NetEqDecodingTest::DuplicateCng() {
|
|||||||
|
|
||||||
// Insert the same CNG packet again. Note that at this point it is old, since
|
// Insert the same CNG packet again. Note that at this point it is old, since
|
||||||
// we have already decoded the first copy of it.
|
// we have already decoded the first copy of it.
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
ASSERT_EQ(
|
||||||
|
0, neteq_->InsertPacket(
|
||||||
|
rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
|
||||||
|
|
||||||
// Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since
|
// Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since
|
||||||
// we have already pulled out CNG once.
|
// we have already pulled out CNG once.
|
||||||
@ -1474,7 +1473,7 @@ void NetEqDecodingTest::DuplicateCng() {
|
|||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kCngPeriodSamples;
|
timestamp += kCngPeriodSamples;
|
||||||
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
|
|
||||||
// Pull audio once and verify that the output is speech again.
|
// Pull audio once and verify that the output is speech again.
|
||||||
ASSERT_EQ(0,
|
ASSERT_EQ(0,
|
||||||
@ -1509,8 +1508,10 @@ TEST_F(NetEqDecodingTest, CngFirst) {
|
|||||||
WebRtcRTPHeader rtp_info;
|
WebRtcRTPHeader rtp_info;
|
||||||
|
|
||||||
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len);
|
||||||
ASSERT_EQ(NetEq::kOK,
|
ASSERT_EQ(
|
||||||
neteq_->InsertPacket(rtp_info, payload, payload_len, 0));
|
NetEq::kOK,
|
||||||
|
neteq_->InsertPacket(
|
||||||
|
rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kCngPeriodSamples;
|
timestamp += kCngPeriodSamples;
|
||||||
|
|
||||||
@ -1526,7 +1527,7 @@ TEST_F(NetEqDecodingTest, CngFirst) {
|
|||||||
// Insert some speech packets.
|
// Insert some speech packets.
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
PopulateRtpInfo(seq_no, timestamp, &rtp_info);
|
||||||
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0));
|
ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0));
|
||||||
++seq_no;
|
++seq_no;
|
||||||
timestamp += kSamples;
|
timestamp += kSamples;
|
||||||
|
|
||||||
|
|||||||
@ -33,14 +33,12 @@ void NetEqExternalDecoderTest::Init() {
|
|||||||
decoder_, codec_, kPayloadType, sample_rate_hz_));
|
decoder_, codec_, kPayloadType, sample_rate_hz_));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetEqExternalDecoderTest::InsertPacket(WebRtcRTPHeader rtp_header,
|
void NetEqExternalDecoderTest::InsertPacket(
|
||||||
const uint8_t* payload,
|
WebRtcRTPHeader rtp_header,
|
||||||
size_t payload_size_bytes,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
uint32_t receive_timestamp) {
|
uint32_t receive_timestamp) {
|
||||||
ASSERT_EQ(
|
ASSERT_EQ(NetEq::kOK,
|
||||||
NetEq::kOK,
|
neteq_->InsertPacket(rtp_header, payload, receive_timestamp));
|
||||||
neteq_->InsertPacket(
|
|
||||||
rtp_header, payload, payload_size_bytes, receive_timestamp));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t NetEqExternalDecoderTest::GetOutputAudio(size_t max_length,
|
size_t NetEqExternalDecoderTest::GetOutputAudio(size_t max_length,
|
||||||
|
|||||||
@ -36,8 +36,8 @@ class NetEqExternalDecoderTest {
|
|||||||
// |payload_size_bytes| bytes. The |receive_timestamp| is an indication
|
// |payload_size_bytes| bytes. The |receive_timestamp| is an indication
|
||||||
// of the time when the packet was received, and should be measured with
|
// of the time when the packet was received, and should be measured with
|
||||||
// the same tick rate as the RTP timestamp of the current payload.
|
// the same tick rate as the RTP timestamp of the current payload.
|
||||||
virtual void InsertPacket(WebRtcRTPHeader rtp_header, const uint8_t* payload,
|
virtual void InsertPacket(WebRtcRTPHeader rtp_header,
|
||||||
size_t payload_size_bytes,
|
rtc::ArrayView<const uint8_t> payload,
|
||||||
uint32_t receive_timestamp);
|
uint32_t receive_timestamp);
|
||||||
|
|
||||||
// Get 10 ms of audio data. The data is written to |output|, which can hold
|
// Get 10 ms of audio data. The data is written to |output|, which can hold
|
||||||
|
|||||||
@ -68,7 +68,7 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
|||||||
uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
|
uint8_t input_payload[kInputBlockSizeSamples * sizeof(int16_t)];
|
||||||
size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(),
|
size_t payload_len = WebRtcPcm16b_Encode(input_samples.data(),
|
||||||
input_samples.size(), input_payload);
|
input_samples.size(), input_payload);
|
||||||
assert(payload_len == kInputBlockSizeSamples * sizeof(int16_t));
|
RTC_CHECK_EQ(sizeof(input_payload), payload_len);
|
||||||
|
|
||||||
// Main loop.
|
// Main loop.
|
||||||
webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock();
|
webrtc::Clock* clock = webrtc::Clock::GetRealTimeClock();
|
||||||
@ -82,9 +82,9 @@ int64_t NetEqPerformanceTest::Run(int runtime_ms,
|
|||||||
}
|
}
|
||||||
if (!lost) {
|
if (!lost) {
|
||||||
// Insert packet.
|
// Insert packet.
|
||||||
int error = neteq->InsertPacket(
|
int error =
|
||||||
rtp_header, input_payload, payload_len,
|
neteq->InsertPacket(rtp_header, input_payload,
|
||||||
packet_input_time_ms * kSampRateHz / 1000);
|
packet_input_time_ms * kSampRateHz / 1000);
|
||||||
if (error != NetEq::kOK)
|
if (error != NetEq::kOK)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -377,9 +377,10 @@ int NetEqQualityTest::Transmit() {
|
|||||||
<< " ms ";
|
<< " ms ";
|
||||||
if (payload_size_bytes_ > 0) {
|
if (payload_size_bytes_ > 0) {
|
||||||
if (!PacketLost()) {
|
if (!PacketLost()) {
|
||||||
int ret = neteq_->InsertPacket(rtp_header_, &payload_[0],
|
int ret = neteq_->InsertPacket(
|
||||||
payload_size_bytes_,
|
rtp_header_,
|
||||||
packet_input_time_ms * in_sampling_khz_);
|
rtc::ArrayView<const uint8_t>(payload_.get(), payload_size_bytes_),
|
||||||
|
packet_input_time_ms * in_sampling_khz_);
|
||||||
if (ret != NetEq::kOK)
|
if (ret != NetEq::kOK)
|
||||||
return -1;
|
return -1;
|
||||||
Log() << "was sent.";
|
Log() << "was sent.";
|
||||||
|
|||||||
@ -547,7 +547,7 @@ int main(int argc, char* argv[]) {
|
|||||||
payload_ptr = payload.get();
|
payload_ptr = payload.get();
|
||||||
}
|
}
|
||||||
int error = neteq->InsertPacket(
|
int error = neteq->InsertPacket(
|
||||||
rtp_header, payload_ptr, payload_len,
|
rtp_header, rtc::ArrayView<const uint8_t>(payload_ptr, payload_len),
|
||||||
static_cast<uint32_t>(packet->time_ms() * sample_rate_hz / 1000));
|
static_cast<uint32_t>(packet->time_ms() * sample_rate_hz / 1000));
|
||||||
if (error != NetEq::kOK) {
|
if (error != NetEq::kOK) {
|
||||||
if (neteq->LastError() == NetEq::kUnknownRtpPayloadType) {
|
if (neteq->LastError() == NetEq::kUnknownRtpPayloadType) {
|
||||||
|
|||||||
Reference in New Issue
Block a user