Replace scoped_ptr with unique_ptr in webrtc/modules/audio_coding/codecs/
BUG=webrtc:5520 Review URL: https://codereview.webrtc.org/1696853004 Cr-Commit-Position: refs/heads/master@{#11613}
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include "webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <limits>
|
||||
|
||||
namespace webrtc {
|
||||
@ -19,12 +20,13 @@ namespace {
|
||||
|
||||
const int kMaxFrameSizeMs = 60;
|
||||
|
||||
rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> CreateCngInst(
|
||||
std::unique_ptr<CNG_enc_inst, CngInstDeleter> CreateCngInst(
|
||||
int sample_rate_hz,
|
||||
int sid_frame_interval_ms,
|
||||
int num_cng_coefficients) {
|
||||
rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> cng_inst;
|
||||
RTC_CHECK_EQ(0, WebRtcCng_CreateEnc(cng_inst.accept()));
|
||||
CNG_enc_inst* ci;
|
||||
RTC_CHECK_EQ(0, WebRtcCng_CreateEnc(&ci));
|
||||
std::unique_ptr<CNG_enc_inst, CngInstDeleter> cng_inst(ci);
|
||||
RTC_CHECK_EQ(0,
|
||||
WebRtcCng_InitEnc(cng_inst.get(), sample_rate_hz,
|
||||
sid_frame_interval_ms, num_cng_coefficients));
|
||||
@ -55,7 +57,7 @@ AudioEncoderCng::AudioEncoderCng(const Config& config)
|
||||
num_cng_coefficients_(config.num_cng_coefficients),
|
||||
sid_frame_interval_ms_(config.sid_frame_interval_ms),
|
||||
last_frame_active_(true),
|
||||
vad_(config.vad ? rtc_make_scoped_ptr(config.vad)
|
||||
vad_(config.vad ? std::unique_ptr<Vad>(config.vad)
|
||||
: CreateVad(config.vad_mode)) {
|
||||
RTC_CHECK(config.IsOk()) << "Invalid configuration.";
|
||||
cng_inst_ = CreateCngInst(SampleRateHz(), sid_frame_interval_ms_,
|
||||
|
||||
@ -11,16 +11,17 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_CNG_AUDIO_ENCODER_CNG_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/constructormagic.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/webrtc_cng.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Deleter for use with scoped_ptr.
|
||||
// Deleter for use with unique_ptr.
|
||||
struct CngInstDeleter {
|
||||
void operator()(CNG_enc_inst* ptr) const { WebRtcCng_FreeEnc(ptr); }
|
||||
};
|
||||
@ -84,8 +85,8 @@ class AudioEncoderCng final : public AudioEncoder {
|
||||
std::vector<int16_t> speech_buffer_;
|
||||
std::vector<uint32_t> rtp_timestamps_;
|
||||
bool last_frame_active_;
|
||||
rtc::scoped_ptr<Vad> vad_;
|
||||
rtc::scoped_ptr<CNG_enc_inst, CngInstDeleter> cng_inst_;
|
||||
std::unique_ptr<Vad> vad_;
|
||||
std::unique_ptr<CNG_enc_inst, CngInstDeleter> cng_inst_;
|
||||
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderCng);
|
||||
};
|
||||
|
||||
@ -8,10 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#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/audio_encoder_cng.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
|
||||
@ -185,7 +185,7 @@ class AudioEncoderCngTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
AudioEncoderCng::Config config_;
|
||||
rtc::scoped_ptr<AudioEncoderCng> cng_;
|
||||
std::unique_ptr<AudioEncoderCng> cng_;
|
||||
MockAudioEncoder mock_encoder_;
|
||||
MockVad* mock_vad_; // Ownership is transferred to |cng_|.
|
||||
uint32_t timestamp_;
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -11,8 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_AUDIO_ENCODER_G722_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_G722_AUDIO_ENCODER_G722_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g722/g722_interface.h"
|
||||
|
||||
@ -51,7 +52,7 @@ class AudioEncoderG722 final : public AudioEncoder {
|
||||
// The encoder state for one channel.
|
||||
struct EncoderState {
|
||||
G722EncInst* encoder;
|
||||
rtc::scoped_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
|
||||
std::unique_ptr<int16_t[]> speech_buffer; // Queued up for encoding.
|
||||
rtc::Buffer encoded_buffer; // Already encoded.
|
||||
EncoderState();
|
||||
~EncoderState();
|
||||
@ -64,7 +65,7 @@ class AudioEncoderG722 final : public AudioEncoder {
|
||||
const size_t num_10ms_frames_per_packet_;
|
||||
size_t num_10ms_frames_buffered_;
|
||||
uint32_t first_timestamp_in_buffer_;
|
||||
const rtc::scoped_ptr<EncoderState[]> encoders_;
|
||||
const std::unique_ptr<EncoderState[]> encoders_;
|
||||
rtc::Buffer interleave_buffer_;
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderG722);
|
||||
};
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ILBC_AUDIO_ENCODER_ILBC_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/ilbc/ilbc.h"
|
||||
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h"
|
||||
|
||||
|
||||
@ -8,9 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h"
|
||||
|
||||
@ -31,7 +32,7 @@ class AudioEncoderOpusTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
CodecInst codec_inst_ = kOpusSettings;
|
||||
rtc::scoped_ptr<AudioEncoderOpus> encoder_;
|
||||
std::unique_ptr<AudioEncoderOpus> encoder_;
|
||||
};
|
||||
|
||||
TEST_F(AudioEncoderOpusTest, DefaultApplicationModeMono) {
|
||||
|
||||
@ -8,9 +8,10 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
|
||||
@ -61,9 +62,9 @@ class OpusFecTest : public TestWithParam<coding_param> {
|
||||
|
||||
string in_filename_;
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> in_data_;
|
||||
rtc::scoped_ptr<int16_t[]> out_data_;
|
||||
rtc::scoped_ptr<uint8_t[]> bit_stream_;
|
||||
std::unique_ptr<int16_t[]> in_data_;
|
||||
std::unique_ptr<int16_t[]> out_data_;
|
||||
std::unique_ptr<uint8_t[]> bit_stream_;
|
||||
};
|
||||
|
||||
void OpusFecTest::SetUp() {
|
||||
|
||||
@ -7,6 +7,8 @@
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
@ -636,7 +638,7 @@ TEST_P(OpusTest, OpusDecodeRepacketized) {
|
||||
|
||||
// Encode & decode.
|
||||
int16_t audio_type;
|
||||
rtc::scoped_ptr<int16_t[]> output_data_decode(
|
||||
std::unique_ptr<int16_t[]> output_data_decode(
|
||||
new int16_t[kPackets * kOpus20msFrameSamples * channels_]);
|
||||
OpusRepacketizer* rp = opus_repacketizer_create();
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_PCM16B_AUDIO_ENCODER_PCM16B_H_
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -8,11 +8,11 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/red/audio_encoder_copy_red.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
|
||||
|
||||
@ -68,7 +68,7 @@ class AudioEncoderCopyRedTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
MockAudioEncoder mock_encoder_;
|
||||
rtc::scoped_ptr<AudioEncoderCopyRed> red_;
|
||||
std::unique_ptr<AudioEncoderCopyRed> red_;
|
||||
uint32_t timestamp_;
|
||||
int16_t audio_[kMaxNumSamples];
|
||||
const int sample_rate_hz_;
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_TOOLS_AUDIO_CODEC_SPEED_TEST_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_TOOLS_AUDIO_CODEC_SPEED_TEST_H_
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -61,11 +61,11 @@ class AudioCodecSpeedTest : public testing::TestWithParam<coding_param> {
|
||||
// Expected output number of samples-per-channel in a frame.
|
||||
size_t output_length_sample_;
|
||||
|
||||
rtc::scoped_ptr<int16_t[]> in_data_;
|
||||
rtc::scoped_ptr<int16_t[]> out_data_;
|
||||
std::unique_ptr<int16_t[]> in_data_;
|
||||
std::unique_ptr<int16_t[]> out_data_;
|
||||
size_t data_pointer_;
|
||||
size_t loop_length_samples_;
|
||||
rtc::scoped_ptr<uint8_t[]> bit_stream_;
|
||||
std::unique_ptr<uint8_t[]> bit_stream_;
|
||||
|
||||
// Maximum number of bytes in output bitstream for a frame of audio.
|
||||
size_t max_bytes_;
|
||||
|
||||
Reference in New Issue
Block a user