diff --git a/webrtc/common_audio/lapped_transform.h b/webrtc/common_audio/lapped_transform.h index 9f6b302832..d299bceb71 100644 --- a/webrtc/common_audio/lapped_transform.h +++ b/webrtc/common_audio/lapped_transform.h @@ -57,6 +57,14 @@ class LappedTransform { // |out_chunk|. Both buffers are caller-owned. void ProcessChunk(const float* const* in_chunk, float* const* out_chunk); + // Get the chunk length. + // + // The chunk length is the number of samples per channel that must be passed + // to ProcessChunk via the parameter in_chunk. + // + // Returns the same chunk_length passed to the LappedTransform constructor. + int get_chunk_length() const { return chunk_length_; } + private: // Internal middleware callback, given to the blocker. Transforms each block // and hands it over to the processing method given at construction time. diff --git a/webrtc/common_audio/lapped_transform_unittest.cc b/webrtc/common_audio/lapped_transform_unittest.cc index 1bfb3b4b65..ac24a0dd41 100644 --- a/webrtc/common_audio/lapped_transform_unittest.cc +++ b/webrtc/common_audio/lapped_transform_unittest.cc @@ -177,5 +177,27 @@ TEST(LappedTransformTest, Callbacks) { ASSERT_EQ(kChunkLength / kBlockLength, call.block_num()); } -} // namespace webrtc +TEST(LappedTransformTest, get_chunk_length) { + const int kBlockLength = 64; + FftCheckerCallback call; + const float window[kBlockLength] = {}; + // Make sure that get_chunk_length returns the same value passed to the + // LappedTransform constructor. + { + const int kExpectedChunkLength = 512; + const LappedTransform trans(1, 1, kExpectedChunkLength, window, + kBlockLength, kBlockLength, &call); + + EXPECT_EQ(kExpectedChunkLength, trans.get_chunk_length()); + } + { + const int kExpectedChunkLength = 160; + const LappedTransform trans(1, 1, kExpectedChunkLength, window, + kBlockLength, kBlockLength, &call); + + EXPECT_EQ(kExpectedChunkLength, trans.get_chunk_length()); + } +} + +} // namespace webrtc