OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // The largest decoded frame size in samples (60ms with 32kHz sample rate). | 33 // The largest decoded frame size in samples (60ms with 32kHz sample rate). |
34 enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 }; | 34 enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 }; |
35 enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; | 35 enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 }; |
36 enum { kMaxAudioBufferQueueLength = 100 }; | 36 enum { kMaxAudioBufferQueueLength = 100 }; |
37 | 37 |
38 class CriticalSectionWrapper; | 38 class CriticalSectionWrapper; |
39 | 39 |
40 class FileRecorderImpl : public FileRecorder { | 40 class FileRecorderImpl : public FileRecorder { |
41 public: | 41 public: |
42 FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat); | 42 FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat); |
43 virtual ~FileRecorderImpl(); | 43 ~FileRecorderImpl() override; |
44 | 44 |
45 // FileRecorder functions. | 45 // FileRecorder functions. |
46 int32_t RegisterModuleFileCallback(FileCallback* callback) override; | 46 int32_t RegisterModuleFileCallback(FileCallback* callback) override; |
47 FileFormats RecordingFileFormat() const override; | 47 FileFormats RecordingFileFormat() const override; |
48 int32_t StartRecordingAudioFile(const char* fileName, | 48 int32_t StartRecordingAudioFile(const char* fileName, |
49 const CodecInst& codecInst, | 49 const CodecInst& codecInst, |
50 uint32_t notificationTimeMs) override; | 50 uint32_t notificationTimeMs) override; |
51 int32_t StartRecordingAudioFile(OutStream& destStream, | 51 int32_t StartRecordingAudioFile(OutStream& destStream, |
52 const CodecInst& codecInst, | 52 const CodecInst& codecInst, |
53 uint32_t notificationTimeMs) override; | 53 uint32_t notificationTimeMs) override; |
54 int32_t StopRecording() override; | 54 int32_t StopRecording() override; |
55 bool IsRecording() const override; | 55 bool IsRecording() const override; |
56 int32_t codec_info(CodecInst& codecInst) const override; | 56 int32_t codec_info(CodecInst& codecInst) const override; |
57 int32_t RecordAudioToFile(const AudioFrame& frame) override; | 57 int32_t RecordAudioToFile(const AudioFrame& frame) override; |
58 | 58 |
59 protected: | 59 private: |
60 int32_t WriteEncodedAudioData(const int8_t* audioBuffer, size_t bufferLength); | 60 int32_t WriteEncodedAudioData(const int8_t* audioBuffer, size_t bufferLength); |
61 | 61 |
62 int32_t SetUpAudioEncoder(); | 62 int32_t SetUpAudioEncoder(); |
63 | 63 |
64 uint32_t _instanceID; | 64 uint32_t _instanceID; |
65 FileFormats _fileFormat; | 65 FileFormats _fileFormat; |
66 MediaFile* _moduleFile; | 66 MediaFile* _moduleFile; |
67 | 67 |
68 private: | |
69 CodecInst codec_info_; | 68 CodecInst codec_info_; |
70 int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES]; | 69 int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES]; |
71 AudioCoder _audioEncoder; | 70 AudioCoder _audioEncoder; |
72 Resampler _audioResampler; | 71 Resampler _audioResampler; |
73 }; | 72 }; |
74 | 73 |
75 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat) | 74 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat) |
76 : _instanceID(instanceID), | 75 : _instanceID(instanceID), |
77 _fileFormat(fileFormat), | 76 _fileFormat(fileFormat), |
78 _moduleFile(MediaFile::CreateMediaFile(_instanceID)), | 77 _moduleFile(MediaFile::CreateMediaFile(_instanceID)), |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return 0; | 247 return 0; |
249 } | 248 } |
250 | 249 |
251 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, | 250 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, |
252 size_t bufferLength) { | 251 size_t bufferLength) { |
253 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); | 252 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); |
254 } | 253 } |
255 | 254 |
256 } // namespace | 255 } // namespace |
257 | 256 |
258 FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID, | 257 std::unique_ptr<FileRecorder> FileRecorder::CreateFileRecorder( |
259 FileFormats fileFormat) { | 258 uint32_t instanceID, |
260 return new FileRecorderImpl(instanceID, fileFormat); | 259 FileFormats fileFormat) { |
261 } | 260 return std::unique_ptr<FileRecorder>( |
262 | 261 new FileRecorderImpl(instanceID, fileFormat)); |
263 void FileRecorder::DestroyFileRecorder(FileRecorder* recorder) { | |
264 delete recorder; | |
265 } | 262 } |
266 | 263 |
267 } // namespace webrtc | 264 } // namespace webrtc |
OLD | NEW |