12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #ifndef MODULES_AUDIO_CODING_TEST_PCMFILE_H_
- #define MODULES_AUDIO_CODING_TEST_PCMFILE_H_
- #include <stdio.h>
- #include <stdlib.h>
- #include <string>
- #include "absl/types/optional.h"
- #include "api/audio/audio_frame.h"
- namespace webrtc {
- class PCMFile {
- public:
- PCMFile();
- PCMFile(uint32_t timestamp);
- ~PCMFile();
- void Open(const std::string& filename,
- uint16_t frequency,
- const char* mode,
- bool auto_rewind = false);
- int32_t Read10MsData(AudioFrame& audio_frame);
- void Write10MsData(const int16_t* playout_buffer, size_t length_smpls);
- void Write10MsData(const AudioFrame& audio_frame);
- uint16_t PayloadLength10Ms() const;
- int32_t SamplingFrequency() const;
- void Close();
- bool EndOfFile() const { return end_of_file_; }
-
-
-
- void FastForward(int num_10ms_blocks);
- void Rewind();
- static int16_t ChooseFile(std::string* file_name,
- int16_t max_len,
- uint16_t* frequency_hz);
- bool Rewinded();
- void SaveStereo(bool is_stereo = true);
- void ReadStereo(bool is_stereo = true);
-
-
-
- void SetNum10MsBlocksToRead(int value);
- private:
- FILE* pcm_file_;
- uint16_t samples_10ms_;
- int32_t frequency_;
- bool end_of_file_;
- bool auto_rewind_;
- bool rewinded_;
- uint32_t timestamp_;
- bool read_stereo_;
- bool save_stereo_;
- absl::optional<int> num_10ms_blocks_to_read_;
- int blocks_read_ = 0;
- };
- }
- #endif
|