From decd9306ae02f157628075311079df30d5e39c1f Mon Sep 17 00:00:00 2001 From: "kwiberg@webrtc.org" Date: Wed, 29 Oct 2014 08:38:50 +0000 Subject: [PATCH] AudioEncoder: num_10ms_frames_per_packet -> Num10MsFramesInNextPacket Rename this accessor function to reflect its new, slightly changed meaning. The reason for the change is that some codecs (iSAC) vary the number of 10 ms frames from packet to packet, and so can't return a truly constant value. BUG=3926 R=henrik.lundin@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31849004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7556 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/audio_coding/codecs/audio_encoder.h | 13 +++++++++---- .../audio_coding/codecs/g711/audio_encoder_pcm.cc | 2 +- .../codecs/g711/include/audio_encoder_pcm.h | 2 +- .../audio_coding/codecs/opus/audio_encoder_opus.cc | 2 +- .../codecs/opus/interface/audio_encoder_opus.h | 2 +- .../audio_coding/neteq/audio_decoder_unittest.cc | 2 +- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/webrtc/modules/audio_coding/codecs/audio_encoder.h b/webrtc/modules/audio_coding/codecs/audio_encoder.h index f9cbe212fa..45c0a855b7 100644 --- a/webrtc/modules/audio_coding/codecs/audio_encoder.h +++ b/webrtc/modules/audio_coding/codecs/audio_encoder.h @@ -50,12 +50,17 @@ class AudioEncoder { return ret; } - // Returns the input sample rate in Hz, the number of input channels, and the - // number of 10 ms frames the encoder puts in one output packet. These are - // constants set at instantiation time. + // Return the input sample rate in Hz and the number of input channels. + // These are constants set at instantiation time. virtual int sample_rate_hz() const = 0; virtual int num_channels() const = 0; - virtual int num_10ms_frames_per_packet() const = 0; + + // Returns the number of 10 ms frames the encoder will put in the next + // packet. This value may only change when Encode() outputs a packet; i.e., + // the encoder may vary the number of 10 ms frames from packet to packet, but + // it must decide the length of the next packet no later than when outputting + // the preceding packet. + virtual int Num10MsFramesInNextPacket() const = 0; protected: virtual bool Encode(uint32_t timestamp, 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 ef22a27718..097e11f1b5 100644 --- a/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc +++ b/webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.cc @@ -48,7 +48,7 @@ int AudioEncoderPcm::sample_rate_hz() const { int AudioEncoderPcm::num_channels() const { return num_channels_; } -int AudioEncoderPcm::num_10ms_frames_per_packet() const { +int AudioEncoderPcm::Num10MsFramesInNextPacket() const { return num_10ms_frames_per_packet_; } diff --git a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h index 8133987a92..f668296970 100644 --- a/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h +++ b/webrtc/modules/audio_coding/codecs/g711/include/audio_encoder_pcm.h @@ -32,7 +32,7 @@ class AudioEncoderPcm : public AudioEncoder { virtual int sample_rate_hz() const OVERRIDE; virtual int num_channels() const OVERRIDE; - virtual int num_10ms_frames_per_packet() const OVERRIDE; + virtual int Num10MsFramesInNextPacket() const OVERRIDE; protected: virtual bool Encode(uint32_t timestamp, diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc index 0a3661f5bd..6349b5c222 100644 --- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc +++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc @@ -67,7 +67,7 @@ int AudioEncoderOpus::num_channels() const { return num_channels_; } -int AudioEncoderOpus::num_10ms_frames_per_packet() const { +int AudioEncoderOpus::Num10MsFramesInNextPacket() const { return num_10ms_frames_per_packet_; } diff --git a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h index 7325b7e93c..e2e5c73fc3 100644 --- a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h +++ b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h @@ -32,7 +32,7 @@ class AudioEncoderOpus : public AudioEncoder { virtual int sample_rate_hz() const OVERRIDE; virtual int num_channels() const OVERRIDE; - virtual int num_10ms_frames_per_packet() const OVERRIDE; + virtual int Num10MsFramesInNextPacket() const OVERRIDE; protected: virtual bool Encode(uint32_t timestamp, diff --git a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc index b6c6ba16d4..5a31696110 100644 --- a/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/audio_decoder_unittest.cc @@ -142,7 +142,7 @@ class AudioDecoderTest : public ::testing::Test { size_t enc_len_bytes = 0; scoped_ptr interleaved_input( new int16_t[channels_ * input_len_samples]); - for (int i = 0; i < audio_encoder_->num_10ms_frames_per_packet(); ++i) { + for (int i = 0; i < audio_encoder_->Num10MsFramesInNextPacket(); ++i) { EXPECT_EQ(0u, enc_len_bytes); // Duplicate the mono input signal to however many channels the test