OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #ifndef WEBRTC_AUDIO_DEVICE_FILE_AUDIO_DEVICE_H | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_DUMMY_FILE_AUDIO_DEVICE_H_ |
12 #define WEBRTC_AUDIO_DEVICE_FILE_AUDIO_DEVICE_H | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_DUMMY_FILE_AUDIO_DEVICE_H_ |
13 | 13 |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 #include <string> | 17 #include <string> |
18 | 18 |
| 19 #include "webrtc/base/file.h" |
19 #include "webrtc/modules/audio_device/audio_device_generic.h" | 20 #include "webrtc/modules/audio_device/audio_device_generic.h" |
20 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 21 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
21 #include "webrtc/system_wrappers/include/file_wrapper.h" | |
22 #include "webrtc/system_wrappers/include/clock.h" | 22 #include "webrtc/system_wrappers/include/clock.h" |
23 | 23 |
24 namespace rtc { | 24 namespace rtc { |
25 class PlatformThread; | 25 class PlatformThread; |
26 } // namespace rtc | 26 } // namespace rtc |
27 | 27 |
28 namespace webrtc { | 28 namespace webrtc { |
29 class EventWrapper; | 29 class EventWrapper; |
30 | 30 |
31 // This is a fake audio device which plays audio from a file as its microphone | 31 // This is a fake audio device which plays audio from a file as its microphone |
32 // and plays out into a file. | 32 // and plays out into a file. |
33 class FileAudioDevice : public AudioDeviceGeneric { | 33 class FileAudioDevice : public AudioDeviceGeneric { |
34 public: | 34 public: |
35 // Constructs a file audio device with |id|. It will read audio from | 35 // Constructs a file audio device with |id|. It will read audio from |
36 // |inputFilename| and record output audio to |outputFilename|. | 36 // |inputFilename| and record output audio to |outputFilename|. |
37 // | 37 // |
38 // The input file should be a readable 48k stereo raw file, and the output | 38 // The input file should be a readable 48k stereo raw file, and the output |
39 // file should point to a writable location. The output format will also be | 39 // file should point to a writable location. The output format will also be |
40 // 48k stereo raw audio. | 40 // 48k stereo raw audio. |
41 FileAudioDevice(const int32_t id, | 41 FileAudioDevice(const int32_t id, |
42 const char* inputFilename, | 42 const char* inputFilename, |
43 const char* outputFilename); | 43 const char* outputFilename); |
44 virtual ~FileAudioDevice(); | |
45 | 44 |
46 // Retrieve the currently utilized audio layer | 45 // Retrieve the currently utilized audio layer |
47 int32_t ActiveAudioLayer( | 46 int32_t ActiveAudioLayer( |
48 AudioDeviceModule::AudioLayer& audioLayer) const override; | 47 AudioDeviceModule::AudioLayer& audioLayer) const override; |
49 | 48 |
50 // Main initializaton and termination | 49 // Main initializaton and termination |
51 InitStatus Init() override; | 50 InitStatus Init() override; |
52 int32_t Terminate() override; | 51 int32_t Terminate() override; |
53 bool Initialized() const override; | 52 bool Initialized() const override; |
54 | 53 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 183 |
185 // TODO(pbos): Make plain members instead of pointers and stop resetting them. | 184 // TODO(pbos): Make plain members instead of pointers and stop resetting them. |
186 std::unique_ptr<rtc::PlatformThread> _ptrThreadRec; | 185 std::unique_ptr<rtc::PlatformThread> _ptrThreadRec; |
187 std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay; | 186 std::unique_ptr<rtc::PlatformThread> _ptrThreadPlay; |
188 | 187 |
189 bool _playing; | 188 bool _playing; |
190 bool _recording; | 189 bool _recording; |
191 uint64_t _lastCallPlayoutMillis; | 190 uint64_t _lastCallPlayoutMillis; |
192 uint64_t _lastCallRecordMillis; | 191 uint64_t _lastCallRecordMillis; |
193 | 192 |
194 FileWrapper& _outputFile; | 193 rtc::File _outputFile; |
195 FileWrapper& _inputFile; | 194 rtc::File _inputFile; |
196 std::string _outputFilename; | 195 std::string _outputFilename; |
197 std::string _inputFilename; | 196 std::string _inputFilename; |
198 | 197 |
199 Clock* _clock; | 198 Clock* _clock; |
200 }; | 199 }; |
201 | 200 |
202 } // namespace webrtc | 201 } // namespace webrtc |
203 | 202 |
204 #endif // WEBRTC_AUDIO_DEVICE_FILE_AUDIO_DEVICE_H | 203 #endif // WEBRTC_MODULES_AUDIO_DEVICE_DUMMY_FILE_AUDIO_DEVICE_H_ |
OLD | NEW |