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_VOICE_ENGINE_FILE_RECORDER_IMPL_H_ | |
16 #define WEBRTC_VOICE_ENGINE_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/system_wrappers/include/event_wrapper.h" | |
28 #include "webrtc/typedefs.h" | |
29 #include "webrtc/voice_engine/coder.h" | |
30 #include "webrtc/voice_engine/file_recorder.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 { | |
42 public: | |
43 FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat); | |
44 virtual ~FileRecorderImpl(); | |
45 | |
46 // FileRecorder functions. | |
47 int32_t RegisterModuleFileCallback(FileCallback* callback) override; | |
48 FileFormats RecordingFileFormat() const override; | |
49 int32_t StartRecordingAudioFile( | |
50 const char* fileName, | |
51 const CodecInst& codecInst, | |
52 uint32_t notificationTimeMs) override; | |
53 int32_t StartRecordingAudioFile( | |
54 OutStream& destStream, | |
55 const CodecInst& codecInst, | |
56 uint32_t notificationTimeMs) override; | |
57 int32_t StopRecording() override; | |
58 bool IsRecording() const override; | |
59 int32_t codec_info(CodecInst& codecInst) const override; | |
60 int32_t RecordAudioToFile(const AudioFrame& frame) override; | |
61 | |
62 protected: | |
63 int32_t WriteEncodedAudioData(const int8_t* audioBuffer, | |
64 size_t bufferLength); | |
65 | |
66 int32_t SetUpAudioEncoder(); | |
67 | |
68 uint32_t _instanceID; | |
69 FileFormats _fileFormat; | |
70 MediaFile* _moduleFile; | |
71 | |
72 private: | |
73 CodecInst codec_info_; | |
74 int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES]; | |
75 AudioCoder _audioEncoder; | |
76 Resampler _audioResampler; | |
77 }; | |
78 } // namespace webrtc | |
79 | |
80 #endif // WEBRTC_VOICE_ENGINE_FILE_RECORDER_IMPL_H_ | |
OLD | NEW |