Chromium Code Reviews| Index: webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc |
| diff --git a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc |
| index ba5959dbcd5c32571e7ab53db0af2c1f4034437f..f7812b34f7db9082c6f23449df3532a52d7bc15a 100644 |
| --- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc |
| +++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc |
| @@ -19,6 +19,7 @@ |
| namespace webrtc { |
| namespace { |
| + |
| int16_t NumSamplesPerFrame(int num_channels, |
| int frame_size_ms, |
| int sample_rate_hz) { |
| @@ -27,6 +28,16 @@ int16_t NumSamplesPerFrame(int num_channels, |
| << "Frame size too large."; |
| return static_cast<int16_t>(samples_per_frame); |
| } |
| + |
| +template <typename T> |
| +typename T::Config CreateConfig(const CodecInst& codec_inst) { |
| + typename T::Config config; |
| + config.frame_size_ms = codec_inst.pacsize / 8; |
| + config.num_channels = codec_inst.channels; |
| + config.payload_type = codec_inst.pltype; |
| + return config; |
| +} |
| + |
| } // namespace |
| bool AudioEncoderPcm::Config::IsOk() const { |
| @@ -49,7 +60,10 @@ AudioEncoderPcm::AudioEncoderPcm(const Config& config, int sample_rate_hz) |
| speech_buffer_.reserve(full_frame_samples_); |
| } |
| -AudioEncoderPcm::~AudioEncoderPcm() { |
| +AudioEncoderPcm::~AudioEncoderPcm() = default; |
| + |
| +size_t AudioEncoderPcm::MaxEncodedBytes() const { |
| + return full_frame_samples_ * BytesPerSample(); |
| } |
| int AudioEncoderPcm::SampleRateHz() const { |
| @@ -60,10 +74,6 @@ int AudioEncoderPcm::NumChannels() const { |
| return num_channels_; |
| } |
| -size_t AudioEncoderPcm::MaxEncodedBytes() const { |
| - return full_frame_samples_ * BytesPerSample(); |
| -} |
| - |
| size_t AudioEncoderPcm::Num10MsFramesInNextPacket() const { |
| return num_10ms_frames_per_packet_; |
| } |
| @@ -102,6 +112,13 @@ AudioEncoder::EncodedInfo AudioEncoderPcm::EncodeInternal( |
| return info; |
| } |
| +void AudioEncoderPcm::Reset() { |
| + speech_buffer_.clear(); |
| +} |
| + |
| +AudioEncoderPcmA::AudioEncoderPcmA(const CodecInst& codec_inst) |
|
hlundin-webrtc
2015/09/07 20:00:01
With this construct, there is no way we to verify
kwiberg-webrtc
2015/09/08 10:47:45
If we wanted to handle these errors, I guess the b
hlundin-webrtc
2015/09/08 11:21:26
Acknowledged.
|
| + : AudioEncoderPcmA(CreateConfig<AudioEncoderPcmA>(codec_inst)) {} |
| + |
| size_t AudioEncoderPcmA::EncodeCall(const int16_t* audio, |
| size_t input_len, |
| uint8_t* encoded) { |
| @@ -112,6 +129,9 @@ int AudioEncoderPcmA::BytesPerSample() const { |
| return 1; |
| } |
| +AudioEncoderPcmU::AudioEncoderPcmU(const CodecInst& codec_inst) |
| + : AudioEncoderPcmU(CreateConfig<AudioEncoderPcmU>(codec_inst)) {} |
| + |
| size_t AudioEncoderPcmU::EncodeCall(const int16_t* audio, |
| size_t input_len, |
| uint8_t* encoded) { |
| @@ -122,25 +142,4 @@ int AudioEncoderPcmU::BytesPerSample() const { |
| return 1; |
| } |
| -namespace { |
| -template <typename T> |
| -typename T::Config CreateConfig(const CodecInst& codec_inst) { |
| - typename T::Config config; |
| - config.frame_size_ms = codec_inst.pacsize / 8; |
| - config.num_channels = codec_inst.channels; |
| - config.payload_type = codec_inst.pltype; |
| - return config; |
| -} |
| -} // namespace |
| - |
| -AudioEncoderMutablePcmU::AudioEncoderMutablePcmU(const CodecInst& codec_inst) |
| - : AudioEncoderMutableImpl<AudioEncoderPcmU>( |
| - CreateConfig<AudioEncoderPcmU>(codec_inst)) { |
| -} |
| - |
| -AudioEncoderMutablePcmA::AudioEncoderMutablePcmA(const CodecInst& codec_inst) |
| - : AudioEncoderMutableImpl<AudioEncoderPcmA>( |
| - CreateConfig<AudioEncoderPcmA>(codec_inst)) { |
| -} |
| - |
| } // namespace webrtc |