| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 // This file contains a class that can write audio to file in | |
| 12 // multiple file formats. The unencoded input data is written to file in the | |
| 13 // encoded format specified. | |
| 14 | |
| 15 #ifndef WEBRTC_MODULES_UTILITY_SOURCE_FILE_RECORDER_IMPL_H_ | |
| 16 #define WEBRTC_MODULES_UTILITY_SOURCE_FILE_RECORDER_IMPL_H_ | |
| 17 | |
| 18 #include <list> | |
| 19 | |
| 20 #include "webrtc/base/platform_thread.h" | |
| 21 #include "webrtc/common_audio/resampler/include/resampler.h" | |
| 22 #include "webrtc/common_types.h" | |
| 23 #include "webrtc/engine_configurations.h" | |
| 24 #include "webrtc/modules/include/module_common_types.h" | |
| 25 #include "webrtc/modules/media_file/media_file.h" | |
| 26 #include "webrtc/modules/media_file/media_file_defines.h" | |
| 27 #include "webrtc/modules/utility/include/file_recorder.h" | |
| 28 #include "webrtc/modules/utility/source/coder.h" | |
| 29 #include "webrtc/system_wrappers/include/event_wrapper.h" | |
| 30 #include "webrtc/typedefs.h" | |
| 31 | |
| 32 namespace webrtc { | |
| 33 // The largest decoded frame size in samples (60ms with 32kHz sample rate). | |
| 34 enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 }; | |
| 35 enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; | |
| 36 enum { kMaxAudioBufferQueueLength = 100 }; | |
| 37 | |
| 38 class CriticalSectionWrapper; | |
| 39 | |
| 40 class FileRecorderImpl : public FileRecorder { | |
| 41 public: | |
| 42 FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat); | |
| 43 virtual ~FileRecorderImpl(); | |
| 44 | |
| 45 // FileRecorder functions. | |
| 46 int32_t RegisterModuleFileCallback(FileCallback* callback) override; | |
| 47 FileFormats RecordingFileFormat() const override; | |
| 48 int32_t StartRecordingAudioFile(const char* fileName, | |
| 49 const CodecInst& codecInst, | |
| 50 uint32_t notificationTimeMs) override; | |
| 51 int32_t StartRecordingAudioFile(OutStream& destStream, | |
| 52 const CodecInst& codecInst, | |
| 53 uint32_t notificationTimeMs) override; | |
| 54 int32_t StopRecording() override; | |
| 55 bool IsRecording() const override; | |
| 56 int32_t codec_info(CodecInst& codecInst) const override; | |
| 57 int32_t RecordAudioToFile(const AudioFrame& frame) override; | |
| 58 | |
| 59 protected: | |
| 60 int32_t WriteEncodedAudioData(const int8_t* audioBuffer, size_t bufferLength); | |
| 61 | |
| 62 int32_t SetUpAudioEncoder(); | |
| 63 | |
| 64 uint32_t _instanceID; | |
| 65 FileFormats _fileFormat; | |
| 66 MediaFile* _moduleFile; | |
| 67 | |
| 68 private: | |
| 69 CodecInst codec_info_; | |
| 70 int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES]; | |
| 71 AudioCoder _audioEncoder; | |
| 72 Resampler _audioResampler; | |
| 73 }; | |
| 74 } // namespace webrtc | |
| 75 #endif // WEBRTC_MODULES_UTILITY_SOURCE_FILE_RECORDER_IMPL_H_ | |
| OLD | NEW |