diff options
Diffstat (limited to 'webrtc/modules/audio_coding/codecs/cng')
-rw-r--r-- | webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc | 20 | ||||
-rw-r--r-- | webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h (renamed from webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h) | 14 | ||||
-rw-r--r-- | webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc | 8 | ||||
-rw-r--r-- | webrtc/modules/audio_coding/codecs/cng/cng.gypi | 16 | ||||
-rw-r--r-- | webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h (renamed from webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h) | 8 |
5 files changed, 30 insertions, 36 deletions
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc index 121524633c..180166c40c 100644 --- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc @@ -8,7 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h" +#include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include <algorithm> #include <limits> @@ -75,7 +75,7 @@ int AudioEncoderCng::SampleRateHz() const { return speech_encoder_->SampleRateHz(); } -int AudioEncoderCng::NumChannels() const { +size_t AudioEncoderCng::NumChannels() const { return 1; } @@ -97,7 +97,7 @@ int AudioEncoderCng::GetTargetBitrate() const { AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal( uint32_t rtp_timestamp, - const int16_t* audio, + rtc::ArrayView<const int16_t> audio, size_t max_encoded_bytes, uint8_t* encoded) { RTC_CHECK_GE(max_encoded_bytes, @@ -106,9 +106,8 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeInternal( RTC_CHECK_EQ(speech_buffer_.size(), rtp_timestamps_.size() * samples_per_10ms_frame); rtp_timestamps_.push_back(rtp_timestamp); - for (size_t i = 0; i < samples_per_10ms_frame; ++i) { - speech_buffer_.push_back(audio[i]); - } + RTC_DCHECK_EQ(samples_per_10ms_frame, audio.size()); + speech_buffer_.insert(speech_buffer_.end(), audio.cbegin(), audio.cend()); const size_t frames_to_encode = speech_encoder_->Num10MsFramesInNextPacket(); if (rtp_timestamps_.size() < frames_to_encode) { return EncodedInfo(); @@ -242,9 +241,12 @@ AudioEncoder::EncodedInfo AudioEncoderCng::EncodeActive( const size_t samples_per_10ms_frame = SamplesPer10msFrame(); AudioEncoder::EncodedInfo info; for (size_t i = 0; i < frames_to_encode; ++i) { - info = speech_encoder_->Encode( - rtp_timestamps_.front(), &speech_buffer_[i * samples_per_10ms_frame], - samples_per_10ms_frame, max_encoded_bytes, encoded); + info = + speech_encoder_->Encode(rtp_timestamps_.front(), + rtc::ArrayView<const int16_t>( + &speech_buffer_[i * samples_per_10ms_frame], + samples_per_10ms_frame), + max_encoded_bytes, encoded); if (i + 1 == frames_to_encode) { RTC_CHECK_GT(info.encoded_bytes, 0u) << "Encoder didn't deliver data."; } else { diff --git a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h index 3ca9eb60f3..87383e2ac5 100644 --- a/webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h @@ -8,15 +8,15 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_INCLUDE_AUDIO_ENCODER_CNG_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_INCLUDE_AUDIO_ENCODER_CNG_H_ +#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_ +#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_ #include <vector> #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/vad/include/vad.h" #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" -#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" +#include "webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h" namespace webrtc { @@ -32,7 +32,7 @@ class AudioEncoderCng final : public AudioEncoder { struct Config { bool IsOk() const; - int num_channels = 1; + size_t num_channels = 1; int payload_type = 13; // Caller keeps ownership of the AudioEncoder object. AudioEncoder* speech_encoder = nullptr; @@ -51,13 +51,13 @@ class AudioEncoderCng final : public AudioEncoder { size_t MaxEncodedBytes() const override; int SampleRateHz() const override; - int NumChannels() const override; + size_t NumChannels() const override; int RtpTimestampRateHz() const override; size_t Num10MsFramesInNextPacket() const override; size_t Max10MsFramesInAPacket() const override; int GetTargetBitrate() const override; EncodedInfo EncodeInternal(uint32_t rtp_timestamp, - const int16_t* audio, + rtc::ArrayView<const int16_t> audio, size_t max_encoded_bytes, uint8_t* encoded) override; void Reset() override; @@ -92,4 +92,4 @@ class AudioEncoderCng final : public AudioEncoder { } // namespace webrtc -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_INCLUDE_AUDIO_ENCODER_CNG_H_ +#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_ diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc index 0b837a0f12..feb3ed1f0a 100644 --- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc +++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc @@ -13,7 +13,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "webrtc/base/scoped_ptr.h" #include "webrtc/common_audio/vad/mock/mock_vad.h" -#include "webrtc/modules/audio_coding/codecs/cng/include/audio_encoder_cng.h" +#include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h" #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" using ::testing::Return; @@ -75,8 +75,10 @@ class AudioEncoderCngTest : public ::testing::Test { void Encode() { ASSERT_TRUE(cng_) << "Must call CreateCng() first."; - encoded_info_ = cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, - encoded_.size(), &encoded_[0]); + encoded_info_ = cng_->Encode( + timestamp_, + rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms_), + encoded_.size(), &encoded_[0]); timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_); } diff --git a/webrtc/modules/audio_coding/codecs/cng/cng.gypi b/webrtc/modules/audio_coding/codecs/cng/cng.gypi index 78dc41a94f..c020f4740d 100644 --- a/webrtc/modules/audio_coding/codecs/cng/cng.gypi +++ b/webrtc/modules/audio_coding/codecs/cng/cng.gypi @@ -15,23 +15,13 @@ '<(webrtc_root)/common_audio/common_audio.gyp:common_audio', 'audio_encoder_interface', ], - 'include_dirs': [ - 'include', - '<(webrtc_root)', - ], - 'direct_dependent_settings': { - 'include_dirs': [ - 'include', - '<(webrtc_root)', - ], - }, 'sources': [ - 'include/audio_encoder_cng.h', - 'include/webrtc_cng.h', 'audio_encoder_cng.cc', - 'webrtc_cng.c', + 'audio_encoder_cng.h', 'cng_helpfuns.c', 'cng_helpfuns.h', + 'webrtc_cng.c', + 'webrtc_cng.h', ], }, ], # targets diff --git a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h index 35660c4c3c..64bea1e26f 100644 --- a/webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h +++ b/webrtc/modules/audio_coding/codecs/cng/webrtc_cng.h @@ -9,8 +9,8 @@ */ -#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INCLUDE_WEBRTC_CNG_H_ -#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INCLUDE_WEBRTC_CNG_H_ +#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_ +#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_ #include <stddef.h> #include "webrtc/typedefs.h" @@ -144,7 +144,7 @@ int16_t WebRtcCng_Generate(CNG_dec_inst* cng_inst, int16_t* outData, * WebRtcCng_GetErrorCodeEnc/Dec(...) * * This functions can be used to check the error code of a CNG instance. When - * a function returns -1 a error code will be set for that instance. The + * a function returns -1 a error code will be set for that instance. The * function below extract the code of the last error that occurred in the * specified instance. * @@ -160,4 +160,4 @@ int16_t WebRtcCng_GetErrorCodeDec(CNG_dec_inst* cng_inst); } #endif -#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_MAIN_INCLUDE_WEBRTC_CNG_H_ +#endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_WEBRTC_CNG_H_ |