Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2425)

Side by Side Diff: webrtc/modules/utility/source/file_recorder.cc

Issue 2038513002: FileRecorderImpl and FilePlayerImpl don't need their own .h and .cc files (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@remove2
Patch Set: rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 #include "webrtc/modules/utility/include/file_recorder.h"
12
13 #include <list>
14
15 #include "webrtc/base/platform_thread.h"
16 #include "webrtc/common_audio/resampler/include/resampler.h"
17 #include "webrtc/common_types.h"
11 #include "webrtc/engine_configurations.h" 18 #include "webrtc/engine_configurations.h"
19 #include "webrtc/engine_configurations.h"
20 #include "webrtc/modules/include/module_common_types.h"
12 #include "webrtc/modules/media_file/media_file.h" 21 #include "webrtc/modules/media_file/media_file.h"
13 #include "webrtc/modules/utility/source/file_recorder_impl.h" 22 #include "webrtc/modules/media_file/media_file.h"
23 #include "webrtc/modules/media_file/media_file_defines.h"
24 #include "webrtc/modules/utility/source/coder.h"
25 #include "webrtc/system_wrappers/include/event_wrapper.h"
14 #include "webrtc/system_wrappers/include/logging.h" 26 #include "webrtc/system_wrappers/include/logging.h"
27 #include "webrtc/typedefs.h"
15 28
16 namespace webrtc { 29 namespace webrtc {
17 FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID,
18 FileFormats fileFormat) {
19 return new FileRecorderImpl(instanceID, fileFormat);
20 }
21 30
22 void FileRecorder::DestroyFileRecorder(FileRecorder* recorder) { 31 namespace {
23 delete recorder; 32
24 } 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 };
25 74
26 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat) 75 FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat)
27 : _instanceID(instanceID), 76 : _instanceID(instanceID),
28 _fileFormat(fileFormat), 77 _fileFormat(fileFormat),
29 _moduleFile(MediaFile::CreateMediaFile(_instanceID)), 78 _moduleFile(MediaFile::CreateMediaFile(_instanceID)),
30 codec_info_(), 79 codec_info_(),
31 _audioBuffer(), 80 _audioBuffer(),
32 _audioEncoder(instanceID), 81 _audioEncoder(instanceID),
33 _audioResampler() {} 82 _audioResampler() {}
34 83
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 return -1; 245 return -1;
197 } 246 }
198 codecInst = codec_info_; 247 codecInst = codec_info_;
199 return 0; 248 return 0;
200 } 249 }
201 250
202 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer, 251 int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer,
203 size_t bufferLength) { 252 size_t bufferLength) {
204 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength); 253 return _moduleFile->IncomingAudioData(audioBuffer, bufferLength);
205 } 254 }
255
256 } // namespace
257
258 FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID,
259 FileFormats fileFormat) {
260 return new FileRecorderImpl(instanceID, fileFormat);
261 }
262
263 void FileRecorder::DestroyFileRecorder(FileRecorder* recorder) {
264 delete recorder;
265 }
266
206 } // namespace webrtc 267 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/utility/source/file_player_impl.cc ('k') | webrtc/modules/utility/source/file_recorder_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698