Chromium Code Reviews| Index: webrtc/modules/audio_coding/test/PCMFile.cc |
| diff --git a/webrtc/modules/audio_coding/test/PCMFile.cc b/webrtc/modules/audio_coding/test/PCMFile.cc |
| index 0466e0222c1dbf90a9cbfba9a11f5205114abed6..d50a34740f00330368179d5b5b903a2e337a8cea 100644 |
| --- a/webrtc/modules/audio_coding/test/PCMFile.cc |
| +++ b/webrtc/modules/audio_coding/test/PCMFile.cc |
| @@ -8,7 +8,7 @@ |
| * be found in the AUTHORS file in the root of the source tree. |
| */ |
| -#include "PCMFile.h" |
| +#include "webrtc/modules/audio_coding/test/PCMFile.h" |
| #include <ctype.h> |
| #include <stdio.h> |
| @@ -29,7 +29,8 @@ PCMFile::PCMFile() |
| auto_rewind_(false), |
| rewinded_(false), |
| read_stereo_(false), |
| - save_stereo_(false) { |
| + save_stereo_(false), |
| + num_10ms_blocks_to_read_(rtc::Optional<int>()) { |
|
ivoc
2015/12/10 12:23:57
Can this be initialized in the .h file as well? Or
hlundin-webrtc
2015/12/10 12:49:59
In fact, it's not needed at all. The default ctor
|
| timestamp_ = (((uint32_t) rand() & 0x0000FFFF) << 16) | |
| ((uint32_t) rand() & 0x0000FFFF); |
| } |
| @@ -42,7 +43,8 @@ PCMFile::PCMFile(uint32_t timestamp) |
| auto_rewind_(false), |
| rewinded_(false), |
| read_stereo_(false), |
| - save_stereo_(false) { |
| + save_stereo_(false), |
| + num_10ms_blocks_to_read_(rtc::Optional<int>()) { |
| timestamp_ = timestamp; |
| } |
| @@ -137,6 +139,9 @@ int32_t PCMFile::Read10MsData(AudioFrame& audio_frame) { |
| audio_frame.num_channels_ = channels; |
| audio_frame.timestamp_ = timestamp_; |
| timestamp_ += samples_10ms_; |
| + ++blocks_read_; |
| + if (num_10ms_blocks_to_read_ && blocks_read_ >= *num_10ms_blocks_to_read_) |
| + end_of_file_ = true; |
| return samples_10ms_; |
| } |
| @@ -182,11 +187,21 @@ void PCMFile::Write10MsData(int16_t* playout_buffer, size_t length_smpls) { |
| void PCMFile::Close() { |
| fclose(pcm_file_); |
| pcm_file_ = NULL; |
| + blocks_read_ = 0; |
| +} |
| + |
| +void PCMFile::FastForward(int num_10ms_blocks) { |
| + const int channels = read_stereo_ ? 2 : 1; |
| + size_t num_bytes_to_move = |
| + num_10ms_blocks * sizeof(int16_t) * samples_10ms_ * channels; |
| + int error = fseek(pcm_file_, num_bytes_to_move, SEEK_CUR); |
| + RTC_DCHECK_EQ(error, 0); |
| } |
| void PCMFile::Rewind() { |
| rewind(pcm_file_); |
| end_of_file_ = false; |
| + blocks_read_ = 0; |
| } |
| bool PCMFile::Rewinded() { |
| @@ -201,4 +216,8 @@ void PCMFile::ReadStereo(bool is_stereo) { |
| read_stereo_ = is_stereo; |
| } |
| +void PCMFile::SetNum10MsBlocksToRead(int value) { |
| + num_10ms_blocks_to_read_ = rtc::Optional<int>(value); |
| +} |
| + |
| } // namespace webrtc |