Remove AudioCodingModule::Process()
An earlier change moved the encoding work from Process to Add10MsData; process was just a no-op. BUG=3520 COAUTHOR=kwiberg@webrtc.org R=henrika@webrtc.org, minyue@webrtc.org, tina.legrand@webrtc.org Review URL: https://webrtc-codereview.appspot.com/43439004 Cr-Commit-Position: refs/heads/master@{#8553} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8553 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
25dd1dbb9f
commit
f56c162310
@ -96,17 +96,13 @@ class AcmReceiverTestOldApi : public AudioPacketizationCallback,
|
|||||||
frame.num_channels_ = codec.channels;
|
frame.num_channels_ = codec.channels;
|
||||||
memset(frame.data_, 0, frame.samples_per_channel_ * frame.num_channels_ *
|
memset(frame.data_, 0, frame.samples_per_channel_ * frame.num_channels_ *
|
||||||
sizeof(int16_t));
|
sizeof(int16_t));
|
||||||
int num_bytes = 0;
|
|
||||||
packet_sent_ = false;
|
packet_sent_ = false;
|
||||||
last_packet_send_timestamp_ = timestamp_;
|
last_packet_send_timestamp_ = timestamp_;
|
||||||
while (num_bytes == 0) {
|
while (!packet_sent_) {
|
||||||
frame.timestamp_ = timestamp_;
|
frame.timestamp_ = timestamp_;
|
||||||
timestamp_ += frame.samples_per_channel_;
|
timestamp_ += frame.samples_per_channel_;
|
||||||
ASSERT_EQ(0, acm_->Add10MsData(frame));
|
ASSERT_GE(acm_->Add10MsData(frame), 0);
|
||||||
num_bytes = acm_->Process();
|
|
||||||
ASSERT_GE(num_bytes, 0);
|
|
||||||
}
|
}
|
||||||
ASSERT_TRUE(packet_sent_); // Sanity check.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Last element of id should be negative.
|
// Last element of id should be negative.
|
||||||
|
@ -80,10 +80,10 @@ Packet* AcmSendTestOldApi::NextPacket() {
|
|||||||
input_frame_.num_channels_,
|
input_frame_.num_channels_,
|
||||||
input_frame_.data_);
|
input_frame_.data_);
|
||||||
}
|
}
|
||||||
CHECK_EQ(0, acm_->Add10MsData(input_frame_));
|
data_to_send_ = false;
|
||||||
|
CHECK_GE(acm_->Add10MsData(input_frame_), 0);
|
||||||
input_frame_.timestamp_ += input_block_size_samples_;
|
input_frame_.timestamp_ += input_block_size_samples_;
|
||||||
int32_t encoded_bytes = acm_->Process();
|
if (data_to_send_) {
|
||||||
if (encoded_bytes > 0) {
|
|
||||||
// Encoded packet received.
|
// Encoded packet received.
|
||||||
return CreatePacket();
|
return CreatePacket();
|
||||||
}
|
}
|
||||||
@ -106,6 +106,7 @@ int32_t AcmSendTestOldApi::SendData(
|
|||||||
timestamp_ = timestamp;
|
timestamp_ = timestamp;
|
||||||
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
|
last_payload_vec_.assign(payload_data, payload_data + payload_len_bytes);
|
||||||
assert(last_payload_vec_.size() == payload_len_bytes);
|
assert(last_payload_vec_.size() == payload_len_bytes);
|
||||||
|
data_to_send_ = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,7 @@ class AcmSendTestOldApi : public AudioPacketizationCallback,
|
|||||||
uint32_t timestamp_;
|
uint32_t timestamp_;
|
||||||
uint16_t sequence_number_;
|
uint16_t sequence_number_;
|
||||||
std::vector<uint8_t> last_payload_vec_;
|
std::vector<uint8_t> last_payload_vec_;
|
||||||
|
bool data_to_send_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi);
|
DISALLOW_COPY_AND_ASSIGN(AcmSendTestOldApi);
|
||||||
};
|
};
|
||||||
|
@ -145,7 +145,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
|
|||||||
aux_rtp_header_(NULL),
|
aux_rtp_header_(NULL),
|
||||||
receiver_initialized_(false),
|
receiver_initialized_(false),
|
||||||
first_10ms_data_(false),
|
first_10ms_data_(false),
|
||||||
last_encode_value_(0),
|
|
||||||
callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||||
packetization_callback_(NULL),
|
packetization_callback_(NULL),
|
||||||
vad_callback_(NULL) {
|
vad_callback_(NULL) {
|
||||||
@ -218,11 +217,6 @@ AudioCodingModuleImpl::~AudioCodingModuleImpl() {
|
|||||||
"Destroyed");
|
"Destroyed");
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t AudioCodingModuleImpl::Process() {
|
|
||||||
CriticalSectionScoped lock(acm_crit_sect_);
|
|
||||||
return last_encode_value_;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t AudioCodingModuleImpl::Encode() {
|
int32_t AudioCodingModuleImpl::Encode() {
|
||||||
// Make room for 1 RED payload.
|
// Make room for 1 RED payload.
|
||||||
uint8_t stream[2 * MAX_PAYLOAD_SIZE_BYTE];
|
uint8_t stream[2 * MAX_PAYLOAD_SIZE_BYTE];
|
||||||
@ -752,15 +746,7 @@ int AudioCodingModuleImpl::RegisterTransportCallback(
|
|||||||
// Add 10MS of raw (PCM) audio data to the encoder.
|
// Add 10MS of raw (PCM) audio data to the encoder.
|
||||||
int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
|
int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
|
||||||
int r = Add10MsDataInternal(audio_frame);
|
int r = Add10MsDataInternal(audio_frame);
|
||||||
if (r < 0) {
|
return r < 0 ? r : Encode();
|
||||||
CriticalSectionScoped lock(acm_crit_sect_);
|
|
||||||
last_encode_value_ = -1;
|
|
||||||
} else {
|
|
||||||
int r_encode = Encode();
|
|
||||||
CriticalSectionScoped lock(acm_crit_sect_);
|
|
||||||
last_encode_value_ = r_encode;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame) {
|
int AudioCodingModuleImpl::Add10MsDataInternal(const AudioFrame& audio_frame) {
|
||||||
@ -1563,10 +1549,9 @@ const CodecInst* AudioCodingImpl::GetSenderCodecInst() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) {
|
int AudioCodingImpl::Add10MsAudio(const AudioFrame& audio_frame) {
|
||||||
if (acm_old_->Add10MsData(audio_frame) != 0) {
|
if (acm_old_->Add10MsDataInternal(audio_frame) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
return acm_old_->Encode();
|
||||||
return acm_old_->Process();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ReceiverInfo* AudioCodingImpl::GetReceiverInfo() const {
|
const ReceiverInfo* AudioCodingImpl::GetReceiverInfo() const {
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class CriticalSectionWrapper;
|
class CriticalSectionWrapper;
|
||||||
|
class AudioCodingImpl;
|
||||||
|
|
||||||
namespace acm2 {
|
namespace acm2 {
|
||||||
|
|
||||||
@ -32,12 +33,11 @@ class ACMGenericCodec;
|
|||||||
|
|
||||||
class AudioCodingModuleImpl : public AudioCodingModule {
|
class AudioCodingModuleImpl : public AudioCodingModule {
|
||||||
public:
|
public:
|
||||||
|
friend webrtc::AudioCodingImpl;
|
||||||
|
|
||||||
explicit AudioCodingModuleImpl(const AudioCodingModule::Config& config);
|
explicit AudioCodingModuleImpl(const AudioCodingModule::Config& config);
|
||||||
~AudioCodingModuleImpl();
|
~AudioCodingModuleImpl();
|
||||||
|
|
||||||
// Process any pending tasks such as timeouts.
|
|
||||||
virtual int32_t Process() OVERRIDE;
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Sender
|
// Sender
|
||||||
//
|
//
|
||||||
@ -335,7 +335,6 @@ class AudioCodingModuleImpl : public AudioCodingModule {
|
|||||||
|
|
||||||
AudioFrame preprocess_frame_ GUARDED_BY(acm_crit_sect_);
|
AudioFrame preprocess_frame_ GUARDED_BY(acm_crit_sect_);
|
||||||
bool first_10ms_data_ GUARDED_BY(acm_crit_sect_);
|
bool first_10ms_data_ GUARDED_BY(acm_crit_sect_);
|
||||||
int last_encode_value_ GUARDED_BY(acm_crit_sect_);
|
|
||||||
|
|
||||||
CriticalSectionWrapper* callback_crit_sect_;
|
CriticalSectionWrapper* callback_crit_sect_;
|
||||||
AudioPacketizationCallback* packetization_callback_
|
AudioPacketizationCallback* packetization_callback_
|
||||||
|
@ -193,15 +193,15 @@ class AudioCodingModuleTestOldApi : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void InsertAudio() {
|
virtual void InsertAudio() {
|
||||||
ASSERT_EQ(0, acm_->Add10MsData(input_frame_));
|
ASSERT_GE(acm_->Add10MsData(input_frame_), 0);
|
||||||
|
VerifyEncoding();
|
||||||
input_frame_.timestamp_ += kNumSamples10ms;
|
input_frame_.timestamp_ += kNumSamples10ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Encode() {
|
virtual void VerifyEncoding() {
|
||||||
int32_t encoded_bytes = acm_->Process();
|
int last_length = packet_cb_.last_payload_len_bytes();
|
||||||
// Expect to get one packet with two bytes per sample, or no packet at all,
|
EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0)
|
||||||
// depending on how many 10 ms blocks go into |codec_.pacsize|.
|
<< "Last encoded packet was " << last_length << " bytes.";
|
||||||
EXPECT_TRUE(encoded_bytes == 2 * codec_.pacsize || encoded_bytes == 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int id_;
|
const int id_;
|
||||||
@ -316,7 +316,6 @@ TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) {
|
|||||||
if (packet_cb_.num_calls() > 0)
|
if (packet_cb_.num_calls() > 0)
|
||||||
EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type());
|
EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type());
|
||||||
InsertAudio();
|
InsertAudio();
|
||||||
Encode();
|
|
||||||
}
|
}
|
||||||
EXPECT_EQ(kLoops / k10MsBlocksPerPacket, packet_cb_.num_calls());
|
EXPECT_EQ(kLoops / k10MsBlocksPerPacket, packet_cb_.num_calls());
|
||||||
EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type());
|
EXPECT_EQ(kAudioFrameSpeech, packet_cb_.last_frame_type());
|
||||||
@ -330,13 +329,6 @@ TEST_F(AudioCodingModuleTestOldApi, TransportCallbackIsInvokedForEachPacket) {
|
|||||||
class AudioCodingModuleTestWithComfortNoiseOldApi
|
class AudioCodingModuleTestWithComfortNoiseOldApi
|
||||||
: public AudioCodingModuleTestOldApi {
|
: public AudioCodingModuleTestOldApi {
|
||||||
protected:
|
protected:
|
||||||
void Encode() override {
|
|
||||||
int32_t encoded_bytes = acm_->Process();
|
|
||||||
// Expect either one packet with 9 comfort noise parameters, or no packet
|
|
||||||
// at all.
|
|
||||||
EXPECT_TRUE(encoded_bytes == 9 || encoded_bytes == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RegisterCngCodec(int rtp_payload_type) {
|
void RegisterCngCodec(int rtp_payload_type) {
|
||||||
CodecInst codec;
|
CodecInst codec;
|
||||||
AudioCodingModule::Codec("CN", &codec, kSampleRateHz, 1);
|
AudioCodingModule::Codec("CN", &codec, kSampleRateHz, 1);
|
||||||
@ -345,6 +337,12 @@ class AudioCodingModuleTestWithComfortNoiseOldApi
|
|||||||
ASSERT_EQ(0, acm_->RegisterSendCodec(codec));
|
ASSERT_EQ(0, acm_->RegisterSendCodec(codec));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VerifyEncoding() override {
|
||||||
|
int last_length = packet_cb_.last_payload_len_bytes();
|
||||||
|
EXPECT_TRUE(last_length == 9 || last_length == 0)
|
||||||
|
<< "Last encoded packet was " << last_length << " bytes.";
|
||||||
|
}
|
||||||
|
|
||||||
void DoTest(int blocks_per_packet, int cng_pt) {
|
void DoTest(int blocks_per_packet, int cng_pt) {
|
||||||
const int kLoops = 40;
|
const int kLoops = 40;
|
||||||
// This array defines the expected frame types, and when they should arrive.
|
// This array defines the expected frame types, and when they should arrive.
|
||||||
@ -371,7 +369,6 @@ class AudioCodingModuleTestWithComfortNoiseOldApi
|
|||||||
int num_calls_before = packet_cb_.num_calls();
|
int num_calls_before = packet_cb_.num_calls();
|
||||||
EXPECT_EQ(i / blocks_per_packet, num_calls_before);
|
EXPECT_EQ(i / blocks_per_packet, num_calls_before);
|
||||||
InsertAudio();
|
InsertAudio();
|
||||||
Encode();
|
|
||||||
int num_calls = packet_cb_.num_calls();
|
int num_calls = packet_cb_.num_calls();
|
||||||
if (num_calls == num_calls_before + 1) {
|
if (num_calls == num_calls_before + 1) {
|
||||||
EXPECT_EQ(expectation[num_calls - 1].ix, i);
|
EXPECT_EQ(expectation[num_calls - 1].ix, i);
|
||||||
@ -493,7 +490,6 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
|||||||
}
|
}
|
||||||
++send_count_;
|
++send_count_;
|
||||||
InsertAudio();
|
InsertAudio();
|
||||||
Encode();
|
|
||||||
if (TestDone()) {
|
if (TestDone()) {
|
||||||
test_complete_->Set();
|
test_complete_->Set();
|
||||||
}
|
}
|
||||||
@ -586,7 +582,6 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
|
|||||||
int loop_counter = 0;
|
int loop_counter = 0;
|
||||||
while (packet_cb_.last_payload_len_bytes() == 0) {
|
while (packet_cb_.last_payload_len_bytes() == 0) {
|
||||||
InsertAudio();
|
InsertAudio();
|
||||||
Encode();
|
|
||||||
ASSERT_LT(loop_counter++, 10);
|
ASSERT_LT(loop_counter++, 10);
|
||||||
}
|
}
|
||||||
// Set |last_packet_number_| to one less that |num_calls| so that the packet
|
// Set |last_packet_number_| to one less that |num_calls| so that the packet
|
||||||
@ -632,7 +627,9 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
|
|||||||
AudioCodingModuleTestOldApi::InsertAudio();
|
AudioCodingModuleTestOldApi::InsertAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Encode() { ASSERT_GE(acm_->Process(), 0); }
|
// Override the verification function with no-op, since iSAC produces variable
|
||||||
|
// payload sizes.
|
||||||
|
void VerifyEncoding() override {}
|
||||||
|
|
||||||
// This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but
|
// This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but
|
||||||
// here it is using the constants defined in this class (i.e., shorter test
|
// here it is using the constants defined in this class (i.e., shorter test
|
||||||
|
@ -101,8 +101,6 @@ class AudioCodingModule {
|
|||||||
static AudioCodingModule* Create(int id, Clock* clock);
|
static AudioCodingModule* Create(int id, Clock* clock);
|
||||||
virtual ~AudioCodingModule() {};
|
virtual ~AudioCodingModule() {};
|
||||||
|
|
||||||
virtual int32_t Process() = 0;
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// Utility functions
|
// Utility functions
|
||||||
//
|
//
|
||||||
@ -317,9 +315,12 @@ class AudioCodingModule {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// int32_t Add10MsData()
|
// int32_t Add10MsData()
|
||||||
// Add 10MS of raw (PCM) audio data to the encoder. If the sampling
|
// Add 10MS of raw (PCM) audio data and encode it. If the sampling
|
||||||
// frequency of the audio does not match the sampling frequency of the
|
// frequency of the audio does not match the sampling frequency of the
|
||||||
// current encoder ACM will resample the audio.
|
// current encoder ACM will resample the audio. If an encoded packet was
|
||||||
|
// produced, it will be delivered via the callback object registered using
|
||||||
|
// RegisterTransportCallback, and the return value from this function will
|
||||||
|
// be the number of bytes encoded.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// -audio_frame : the input audio frame, containing raw audio
|
// -audio_frame : the input audio frame, containing raw audio
|
||||||
@ -328,10 +329,8 @@ class AudioCodingModule {
|
|||||||
// AudioFrame.
|
// AudioFrame.
|
||||||
//
|
//
|
||||||
// Return value:
|
// Return value:
|
||||||
// 0 successfully added the frame.
|
// >= 0 number of bytes encoded.
|
||||||
// -1 some error occurred and data is not added.
|
// -1 some error occurred.
|
||||||
// < -1 to add the frame to the buffer n samples had to be
|
|
||||||
// overwritten, -n is the return value in this case.
|
|
||||||
//
|
//
|
||||||
virtual int32_t Add10MsData(const AudioFrame& audio_frame) = 0;
|
virtual int32_t Add10MsData(const AudioFrame& audio_frame) = 0;
|
||||||
|
|
||||||
|
@ -411,33 +411,11 @@ bool APITest::PushAudioRunB() {
|
|||||||
|
|
||||||
bool APITest::ProcessRunA() {
|
bool APITest::ProcessRunA() {
|
||||||
_processEventA->Wait(100);
|
_processEventA->Wait(100);
|
||||||
if (_acmA->Process() < 0) {
|
|
||||||
// do not print error message if there is no encoder
|
|
||||||
bool thereIsEncoder;
|
|
||||||
{
|
|
||||||
ReadLockScoped rl(_apiTestRWLock);
|
|
||||||
thereIsEncoder = _thereIsEncoderA;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (thereIsEncoder) {
|
|
||||||
fprintf(stderr, "\n>>>>> Process Failed at A <<<<<\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APITest::ProcessRunB() {
|
bool APITest::ProcessRunB() {
|
||||||
_processEventB->Wait(100);
|
_processEventB->Wait(100);
|
||||||
if (_acmB->Process() < 0) {
|
|
||||||
bool thereIsEncoder;
|
|
||||||
{
|
|
||||||
ReadLockScoped rl(_apiTestRWLock);
|
|
||||||
thereIsEncoder = _thereIsEncoderB;
|
|
||||||
}
|
|
||||||
if (thereIsEncoder) {
|
|
||||||
fprintf(stderr, "\n>>>>> Process Failed at B <<<<<\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +100,8 @@ bool Sender::Add10MsData() {
|
|||||||
if (!_pcmFile.EndOfFile()) {
|
if (!_pcmFile.EndOfFile()) {
|
||||||
EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
|
EXPECT_GT(_pcmFile.Read10MsData(_audioFrame), 0);
|
||||||
int32_t ok = _acm->Add10MsData(_audioFrame);
|
int32_t ok = _acm->Add10MsData(_audioFrame);
|
||||||
EXPECT_EQ(0, ok);
|
EXPECT_GE(ok, 0);
|
||||||
if (ok != 0) {
|
return ok >= 0 ? true : false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -114,7 +111,6 @@ void Sender::Run() {
|
|||||||
if (!Add10MsData()) {
|
if (!Add10MsData()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
EXPECT_GT(_acm->Process(), -1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,9 +171,6 @@ void SpatialAudio::EncodeDecode(const double leftPanning,
|
|||||||
}
|
}
|
||||||
CHECK_ERROR(_acmRight->Add10MsData(audioFrame));
|
CHECK_ERROR(_acmRight->Add10MsData(audioFrame));
|
||||||
|
|
||||||
CHECK_ERROR(_acmLeft->Process());
|
|
||||||
CHECK_ERROR(_acmRight->Process());
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
|
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
|
||||||
_outFile.Write10MsData(audioFrame);
|
_outFile.Write10MsData(audioFrame);
|
||||||
}
|
}
|
||||||
@ -190,8 +187,6 @@ void SpatialAudio::EncodeDecode() {
|
|||||||
_inFile.Read10MsData(audioFrame);
|
_inFile.Read10MsData(audioFrame);
|
||||||
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
|
CHECK_ERROR(_acmLeft->Add10MsData(audioFrame));
|
||||||
|
|
||||||
CHECK_ERROR(_acmLeft->Process());
|
|
||||||
|
|
||||||
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
|
CHECK_ERROR(_acmReceiver->PlayoutData10Ms(outFileSampFreq, &audioFrame));
|
||||||
_outFile.Write10MsData(audioFrame);
|
_outFile.Write10MsData(audioFrame);
|
||||||
}
|
}
|
||||||
|
@ -434,9 +434,6 @@ void TestAllCodecs::Run(TestPack* channel) {
|
|||||||
infile_a_.Read10MsData(audio_frame);
|
infile_a_.Read10MsData(audio_frame);
|
||||||
CHECK_ERROR(acm_a_->Add10MsData(audio_frame));
|
CHECK_ERROR(acm_a_->Add10MsData(audio_frame));
|
||||||
|
|
||||||
// Run sender side of ACM.
|
|
||||||
CHECK_ERROR(acm_a_->Process());
|
|
||||||
|
|
||||||
// Verify that the received packet size matches the settings.
|
// Verify that the received packet size matches the settings.
|
||||||
receive_size = channel->payload_size();
|
receive_size = channel->payload_size();
|
||||||
if (receive_size) {
|
if (receive_size) {
|
||||||
|
@ -311,8 +311,7 @@ void TestRedFec::Run() {
|
|||||||
|
|
||||||
while (!_inFileA.EndOfFile()) {
|
while (!_inFileA.EndOfFile()) {
|
||||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||||
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
|
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||||
EXPECT_GT(_acmA->Process(), -1);
|
|
||||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||||
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
||||||
msecPassed += 10;
|
msecPassed += 10;
|
||||||
|
@ -779,10 +779,7 @@ void TestStereo::Run(TestPackStereo* channel, int in_channels, int out_channels,
|
|||||||
}
|
}
|
||||||
in_file_stereo_->Read10MsData(audio_frame);
|
in_file_stereo_->Read10MsData(audio_frame);
|
||||||
}
|
}
|
||||||
EXPECT_EQ(0, acm_a_->Add10MsData(audio_frame));
|
EXPECT_GE(acm_a_->Add10MsData(audio_frame), 0);
|
||||||
|
|
||||||
// Run sender side of ACM
|
|
||||||
EXPECT_GT(acm_a_->Process(), -1);
|
|
||||||
|
|
||||||
// Verify that the received packet size matches the settings.
|
// Verify that the received packet size matches the settings.
|
||||||
rec_size = channel->payload_size();
|
rec_size = channel->payload_size();
|
||||||
|
@ -242,8 +242,7 @@ void TestVADDTX::Run() {
|
|||||||
_inFileA.Read10MsData(audioFrame);
|
_inFileA.Read10MsData(audioFrame);
|
||||||
audioFrame.timestamp_ = timestampA;
|
audioFrame.timestamp_ = timestampA;
|
||||||
timestampA += SamplesIn10MsecA;
|
timestampA += SamplesIn10MsecA;
|
||||||
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
|
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||||
EXPECT_GT(_acmA->Process(), -1);
|
|
||||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
EXPECT_EQ(0, _acmB->PlayoutData10Ms(outFreqHzB, &audioFrame));
|
||||||
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
_outFileB.Write10MsData(audioFrame.data_, audioFrame.samples_per_channel_);
|
||||||
}
|
}
|
||||||
|
@ -282,32 +282,21 @@ void TwoWayCommunication::Perform() {
|
|||||||
// and B, APIs will be called, like ResetEncoder(), and the code should
|
// and B, APIs will be called, like ResetEncoder(), and the code should
|
||||||
// continue to run, and be able to recover.
|
// continue to run, and be able to recover.
|
||||||
bool expect_error_add = false;
|
bool expect_error_add = false;
|
||||||
bool expect_error_process = false;
|
|
||||||
while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) {
|
while (!_inFileA.EndOfFile() && !_inFileB.EndOfFile()) {
|
||||||
msecPassed += 10;
|
msecPassed += 10;
|
||||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||||
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
|
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||||
EXPECT_EQ(0, _acmRefA->Add10MsData(audioFrame));
|
EXPECT_GE(_acmRefA->Add10MsData(audioFrame), 0);
|
||||||
|
|
||||||
EXPECT_GT(_inFileB.Read10MsData(audioFrame), 0);
|
EXPECT_GT(_inFileB.Read10MsData(audioFrame), 0);
|
||||||
|
|
||||||
// Expect call to pass except for the time when no send codec is registered.
|
// Expect call to pass except for the time when no send codec is registered.
|
||||||
if (!expect_error_add) {
|
if (!expect_error_add) {
|
||||||
EXPECT_EQ(0, _acmB->Add10MsData(audioFrame));
|
EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
|
||||||
} else {
|
} else {
|
||||||
EXPECT_EQ(-1, _acmB->Add10MsData(audioFrame));
|
EXPECT_EQ(-1, _acmB->Add10MsData(audioFrame));
|
||||||
}
|
}
|
||||||
// Expect to pass except for the time when there either is no send codec
|
EXPECT_GE(_acmRefB->Add10MsData(audioFrame), 0);
|
||||||
// registered, or no receive codec.
|
|
||||||
if (!expect_error_process) {
|
|
||||||
EXPECT_GT(_acmB->Process(), -1);
|
|
||||||
} else {
|
|
||||||
EXPECT_EQ(_acmB->Process(), -1);
|
|
||||||
}
|
|
||||||
EXPECT_EQ(0, _acmRefB->Add10MsData(audioFrame));
|
|
||||||
EXPECT_GT(_acmA->Process(), -1);
|
|
||||||
EXPECT_GT(_acmRefA->Process(), -1);
|
|
||||||
EXPECT_GT(_acmRefB->Process(), -1);
|
|
||||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
EXPECT_EQ(0, _acmA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
||||||
_outFileA.Write10MsData(audioFrame);
|
_outFileA.Write10MsData(audioFrame);
|
||||||
EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
EXPECT_EQ(0, _acmRefA->PlayoutData10Ms(outFreqHzA, &audioFrame));
|
||||||
@ -328,14 +317,12 @@ void TwoWayCommunication::Perform() {
|
|||||||
EXPECT_EQ(0, _acmA->ResetEncoder());
|
EXPECT_EQ(0, _acmA->ResetEncoder());
|
||||||
EXPECT_EQ(0, _acmB->InitializeSender());
|
EXPECT_EQ(0, _acmB->InitializeSender());
|
||||||
expect_error_add = true;
|
expect_error_add = true;
|
||||||
expect_error_process = true;
|
|
||||||
}
|
}
|
||||||
// Re-register send codec on side B.
|
// Re-register send codec on side B.
|
||||||
if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
|
if (((secPassed % 5) == 4) && (msecPassed >= 990)) {
|
||||||
EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
|
EXPECT_EQ(0, _acmB->RegisterSendCodec(codecInst_B));
|
||||||
EXPECT_EQ(0, _acmB->SendCodec(&dummy));
|
EXPECT_EQ(0, _acmB->SendCodec(&dummy));
|
||||||
expect_error_add = false;
|
expect_error_add = false;
|
||||||
expect_error_process = false;
|
|
||||||
}
|
}
|
||||||
// Reset decoder on side B, and initialize receiver on side A.
|
// Reset decoder on side B, and initialize receiver on side A.
|
||||||
if (((secPassed % 7) == 6) && (msecPassed == 0)) {
|
if (((secPassed % 7) == 6) && (msecPassed == 0)) {
|
||||||
|
@ -209,8 +209,7 @@ class DelayTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_file_a_.Read10MsData(audio_frame);
|
in_file_a_.Read10MsData(audio_frame);
|
||||||
ASSERT_EQ(0, acm_a_->Add10MsData(audio_frame));
|
ASSERT_GE(acm_a_->Add10MsData(audio_frame), 0);
|
||||||
ASSERT_LE(0, acm_a_->Process());
|
|
||||||
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
|
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(out_freq_hz_b, &audio_frame));
|
||||||
out_file_b_.Write10MsData(
|
out_file_b_.Write10MsData(
|
||||||
audio_frame.data_,
|
audio_frame.data_,
|
||||||
|
@ -246,10 +246,8 @@ void ISACTest::Perform() {
|
|||||||
void ISACTest::Run10ms() {
|
void ISACTest::Run10ms() {
|
||||||
AudioFrame audioFrame;
|
AudioFrame audioFrame;
|
||||||
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
EXPECT_GT(_inFileA.Read10MsData(audioFrame), 0);
|
||||||
EXPECT_EQ(0, _acmA->Add10MsData(audioFrame));
|
EXPECT_GE(_acmA->Add10MsData(audioFrame), 0);
|
||||||
EXPECT_EQ(0, _acmB->Add10MsData(audioFrame));
|
EXPECT_GE(_acmB->Add10MsData(audioFrame), 0);
|
||||||
EXPECT_GT(_acmA->Process(), -1);
|
|
||||||
EXPECT_GT(_acmB->Process(), -1);
|
|
||||||
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame));
|
EXPECT_EQ(0, _acmA->PlayoutData10Ms(32000, &audioFrame));
|
||||||
_outFileA.Write10MsData(audioFrame);
|
_outFileA.Write10MsData(audioFrame);
|
||||||
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame));
|
EXPECT_EQ(0, _acmB->PlayoutData10Ms(32000, &audioFrame));
|
||||||
|
@ -145,8 +145,7 @@ class InitialPlayoutDelayTest : public ::testing::Test {
|
|||||||
while (rms < kAmp / 2) {
|
while (rms < kAmp / 2) {
|
||||||
in_audio_frame.timestamp_ = timestamp;
|
in_audio_frame.timestamp_ = timestamp;
|
||||||
timestamp += in_audio_frame.samples_per_channel_;
|
timestamp += in_audio_frame.samples_per_channel_;
|
||||||
ASSERT_EQ(0, acm_a_->Add10MsData(in_audio_frame));
|
ASSERT_GE(acm_a_->Add10MsData(in_audio_frame), 0);
|
||||||
ASSERT_LE(0, acm_a_->Process());
|
|
||||||
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(codec.plfreq, &out_audio_frame));
|
ASSERT_EQ(0, acm_b_->PlayoutData10Ms(codec.plfreq, &out_audio_frame));
|
||||||
rms = FrameRms(out_audio_frame);
|
rms = FrameRms(out_audio_frame);
|
||||||
++num_frames;
|
++num_frames;
|
||||||
|
@ -164,7 +164,7 @@ class InsertPacketWithTiming {
|
|||||||
// Push in just enough audio.
|
// Push in just enough audio.
|
||||||
for (int n = 0; n < num_10ms_in_codec_frame_; n++) {
|
for (int n = 0; n < num_10ms_in_codec_frame_; n++) {
|
||||||
pcm_in_fid_.Read10MsData(frame_);
|
pcm_in_fid_.Read10MsData(frame_);
|
||||||
EXPECT_EQ(0, send_acm_->Add10MsData(frame_));
|
EXPECT_GE(send_acm_->Add10MsData(frame_), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the parameters for the packet to be pushed in receiver ACM right
|
// Set the parameters for the packet to be pushed in receiver ACM right
|
||||||
@ -179,10 +179,6 @@ class InsertPacketWithTiming {
|
|||||||
lost = true;
|
lost = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process audio in send ACM, this should result in generation of a
|
|
||||||
// packet.
|
|
||||||
EXPECT_GT(send_acm_->Process(), 0);
|
|
||||||
|
|
||||||
if (FLAGS_verbose) {
|
if (FLAGS_verbose) {
|
||||||
if (!lost) {
|
if (!lost) {
|
||||||
std::cout << "\nInserting packet number " << seq_num
|
std::cout << "\nInserting packet number " << seq_num
|
||||||
|
@ -96,10 +96,6 @@ int32_t AudioCoder::Encode(const AudioFrame& audio,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
_encodedData = encodedData;
|
_encodedData = encodedData;
|
||||||
if(_acm->Process() == -1)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
encodedLengthInBytes = _encodedLengthInBytes;
|
encodedLengthInBytes = _encodedLengthInBytes;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3560,7 +3560,10 @@ Channel::EncodeAndSend()
|
|||||||
|
|
||||||
// The ACM resamples internally.
|
// The ACM resamples internally.
|
||||||
_audioFrame.timestamp_ = _timeStamp;
|
_audioFrame.timestamp_ = _timeStamp;
|
||||||
if (audio_coding_->Add10MsData((AudioFrame&)_audioFrame) != 0)
|
// This call will trigger AudioPacketizationCallback::SendData if encoding
|
||||||
|
// is done and payload is ready for packetization and transmission.
|
||||||
|
// Otherwise, it will return without invoking the callback.
|
||||||
|
if (audio_coding_->Add10MsData((AudioFrame&)_audioFrame) < 0)
|
||||||
{
|
{
|
||||||
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
|
WEBRTC_TRACE(kTraceError, kTraceVoice, VoEId(_instanceId,_channelId),
|
||||||
"Channel::EncodeAndSend() ACM encoding failed");
|
"Channel::EncodeAndSend() ACM encoding failed");
|
||||||
@ -3568,12 +3571,7 @@ Channel::EncodeAndSend()
|
|||||||
}
|
}
|
||||||
|
|
||||||
_timeStamp += _audioFrame.samples_per_channel_;
|
_timeStamp += _audioFrame.samples_per_channel_;
|
||||||
|
return 0;
|
||||||
// --- Encode if complete frame is ready
|
|
||||||
|
|
||||||
// This call will trigger AudioPacketizationCallback::SendData if encoding
|
|
||||||
// is done and payload is ready for packetization and transmission.
|
|
||||||
return audio_coding_->Process();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Channel::RegisterExternalMediaProcessing(
|
int Channel::RegisterExternalMediaProcessing(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user