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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/utility/source/file_recorder.cc
diff --git a/webrtc/modules/utility/source/file_recorder_impl.cc b/webrtc/modules/utility/source/file_recorder.cc
similarity index 77%
rename from webrtc/modules/utility/source/file_recorder_impl.cc
rename to webrtc/modules/utility/source/file_recorder.cc
index 53f79948fcfa449752fa6706b181c3ef46cae971..63d2f1be094d6eee8a4f7f079e5f7183254f79f3 100644
--- a/webrtc/modules/utility/source/file_recorder_impl.cc
+++ b/webrtc/modules/utility/source/file_recorder.cc
@@ -8,20 +8,69 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/modules/utility/include/file_recorder.h"
+
+#include <list>
+
+#include "webrtc/base/platform_thread.h"
+#include "webrtc/common_audio/resampler/include/resampler.h"
+#include "webrtc/common_types.h"
#include "webrtc/engine_configurations.h"
+#include "webrtc/engine_configurations.h"
+#include "webrtc/modules/include/module_common_types.h"
+#include "webrtc/modules/media_file/media_file.h"
#include "webrtc/modules/media_file/media_file.h"
-#include "webrtc/modules/utility/source/file_recorder_impl.h"
+#include "webrtc/modules/media_file/media_file_defines.h"
+#include "webrtc/modules/utility/source/coder.h"
+#include "webrtc/system_wrappers/include/event_wrapper.h"
#include "webrtc/system_wrappers/include/logging.h"
+#include "webrtc/typedefs.h"
namespace webrtc {
-FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID,
- FileFormats fileFormat) {
- return new FileRecorderImpl(instanceID, fileFormat);
-}
-void FileRecorder::DestroyFileRecorder(FileRecorder* recorder) {
- delete recorder;
-}
+namespace {
+
+// The largest decoded frame size in samples (60ms with 32kHz sample rate).
+enum { MAX_AUDIO_BUFFER_IN_SAMPLES = 60 * 32 };
+enum { MAX_AUDIO_BUFFER_IN_BYTES = MAX_AUDIO_BUFFER_IN_SAMPLES * 2 };
+enum { kMaxAudioBufferQueueLength = 100 };
+
+class CriticalSectionWrapper;
+
+class FileRecorderImpl : public FileRecorder {
+ public:
+ FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat);
+ virtual ~FileRecorderImpl();
+
+ // FileRecorder functions.
+ int32_t RegisterModuleFileCallback(FileCallback* callback) override;
+ FileFormats RecordingFileFormat() const override;
+ int32_t StartRecordingAudioFile(const char* fileName,
+ const CodecInst& codecInst,
+ uint32_t notificationTimeMs) override;
+ int32_t StartRecordingAudioFile(OutStream& destStream,
+ const CodecInst& codecInst,
+ uint32_t notificationTimeMs) override;
+ int32_t StopRecording() override;
+ bool IsRecording() const override;
+ int32_t codec_info(CodecInst& codecInst) const override;
+ int32_t RecordAudioToFile(const AudioFrame& frame) override;
+
+ protected:
+ int32_t WriteEncodedAudioData(const int8_t* audioBuffer, size_t bufferLength);
+
+ int32_t SetUpAudioEncoder();
+
+ uint32_t _instanceID;
+ FileFormats _fileFormat;
+ MediaFile* _moduleFile;
+
+ private:
+ CodecInst codec_info_;
+ int8_t _audioBuffer[MAX_AUDIO_BUFFER_IN_BYTES];
+ AudioCoder _audioEncoder;
+ Resampler _audioResampler;
+};
FileRecorderImpl::FileRecorderImpl(uint32_t instanceID, FileFormats fileFormat)
: _instanceID(instanceID),
@@ -203,4 +252,16 @@ int32_t FileRecorderImpl::WriteEncodedAudioData(const int8_t* audioBuffer,
size_t bufferLength) {
return _moduleFile->IncomingAudioData(audioBuffer, bufferLength);
}
+
+} // namespace
+
+FileRecorder* FileRecorder::CreateFileRecorder(uint32_t instanceID,
+ FileFormats fileFormat) {
+ return new FileRecorderImpl(instanceID, fileFormat);
+}
+
+void FileRecorder::DestroyFileRecorder(FileRecorder* recorder) {
+ delete recorder;
+}
+
} // namespace webrtc
« 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