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 |
11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H |
12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H |
13 | 13 |
14 #include "webrtc/modules/audio_device/include/audio_device.h" | 14 #include "webrtc/modules/audio_device/include/audio_device.h" |
15 #include "webrtc/system_wrappers/include/file_wrapper.h" | 15 #include "webrtc/system_wrappers/include/file_wrapper.h" |
16 #include "webrtc/typedefs.h" | 16 #include "webrtc/typedefs.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 class CriticalSectionWrapper; | 19 class CriticalSectionWrapper; |
20 | 20 |
21 const uint32_t kPulsePeriodMs = 1000; | 21 const uint32_t kPulsePeriodMs = 1000; |
22 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz | 22 const size_t kMaxBufferSizeBytes = 3840; // 10ms in stereo @ 96kHz |
23 | 23 |
24 class AudioDeviceObserver; | 24 class AudioDeviceObserver; |
25 | 25 |
26 class AudioDeviceBuffer | 26 class AudioDeviceBuffer { |
27 { | 27 public: |
28 public: | 28 AudioDeviceBuffer(); |
29 AudioDeviceBuffer(); | 29 virtual ~AudioDeviceBuffer(); |
30 virtual ~AudioDeviceBuffer(); | |
31 | 30 |
32 void SetId(uint32_t id); | 31 void SetId(uint32_t id); |
33 int32_t RegisterAudioCallback(AudioTransport* audioCallback); | 32 int32_t RegisterAudioCallback(AudioTransport* audioCallback); |
34 | 33 |
35 int32_t InitPlayout(); | 34 int32_t InitPlayout(); |
36 int32_t InitRecording(); | 35 int32_t InitRecording(); |
37 | 36 |
38 virtual int32_t SetRecordingSampleRate(uint32_t fsHz); | 37 virtual int32_t SetRecordingSampleRate(uint32_t fsHz); |
39 virtual int32_t SetPlayoutSampleRate(uint32_t fsHz); | 38 virtual int32_t SetPlayoutSampleRate(uint32_t fsHz); |
40 int32_t RecordingSampleRate() const; | 39 int32_t RecordingSampleRate() const; |
41 int32_t PlayoutSampleRate() const; | 40 int32_t PlayoutSampleRate() const; |
42 | 41 |
43 virtual int32_t SetRecordingChannels(size_t channels); | 42 virtual int32_t SetRecordingChannels(size_t channels); |
44 virtual int32_t SetPlayoutChannels(size_t channels); | 43 virtual int32_t SetPlayoutChannels(size_t channels); |
45 size_t RecordingChannels() const; | 44 size_t RecordingChannels() const; |
46 size_t PlayoutChannels() const; | 45 size_t PlayoutChannels() const; |
47 int32_t SetRecordingChannel( | 46 int32_t SetRecordingChannel(const AudioDeviceModule::ChannelType channel); |
48 const AudioDeviceModule::ChannelType channel); | 47 int32_t RecordingChannel(AudioDeviceModule::ChannelType& channel) const; |
49 int32_t RecordingChannel( | |
50 AudioDeviceModule::ChannelType& channel) const; | |
51 | 48 |
52 virtual int32_t SetRecordedBuffer(const void* audioBuffer, | 49 virtual int32_t SetRecordedBuffer(const void* audioBuffer, size_t nSamples); |
53 size_t nSamples); | 50 int32_t SetCurrentMicLevel(uint32_t level); |
54 int32_t SetCurrentMicLevel(uint32_t level); | 51 virtual void SetVQEData(int playDelayMS, int recDelayMS, int clockDrift); |
55 virtual void SetVQEData(int playDelayMS, | 52 virtual int32_t DeliverRecordedData(); |
56 int recDelayMS, | 53 uint32_t NewMicLevel() const; |
57 int clockDrift); | |
58 virtual int32_t DeliverRecordedData(); | |
59 uint32_t NewMicLevel() const; | |
60 | 54 |
61 virtual int32_t RequestPlayoutData(size_t nSamples); | 55 virtual int32_t RequestPlayoutData(size_t nSamples); |
62 virtual int32_t GetPlayoutData(void* audioBuffer); | 56 virtual int32_t GetPlayoutData(void* audioBuffer); |
63 | 57 |
64 int32_t StartInputFileRecording( | 58 int32_t StartInputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
65 const char fileName[kAdmMaxFileNameSize]); | 59 int32_t StopInputFileRecording(); |
66 int32_t StopInputFileRecording(); | 60 int32_t StartOutputFileRecording(const char fileName[kAdmMaxFileNameSize]); |
67 int32_t StartOutputFileRecording( | 61 int32_t StopOutputFileRecording(); |
68 const char fileName[kAdmMaxFileNameSize]); | |
69 int32_t StopOutputFileRecording(); | |
70 | 62 |
71 int32_t SetTypingStatus(bool typingStatus); | 63 int32_t SetTypingStatus(bool typingStatus); |
72 | 64 |
73 private: | 65 private: |
74 int32_t _id; | 66 int32_t _id; |
75 CriticalSectionWrapper& _critSect; | 67 CriticalSectionWrapper& _critSect; |
76 CriticalSectionWrapper& _critSectCb; | 68 CriticalSectionWrapper& _critSectCb; |
77 | 69 |
78 AudioTransport* _ptrCbAudioTransport; | 70 AudioTransport* _ptrCbAudioTransport; |
79 | 71 |
80 uint32_t _recSampleRate; | 72 uint32_t _recSampleRate; |
magjed_webrtc
2016/07/04 10:04:25
Will you fix variable names to follow the style gu
| |
81 uint32_t _playSampleRate; | 73 uint32_t _playSampleRate; |
82 | 74 |
83 size_t _recChannels; | 75 size_t _recChannels; |
84 size_t _playChannels; | 76 size_t _playChannels; |
85 | 77 |
86 // selected recording channel (left/right/both) | 78 // selected recording channel (left/right/both) |
87 AudioDeviceModule::ChannelType _recChannel; | 79 AudioDeviceModule::ChannelType _recChannel; |
88 | 80 |
89 // 2 or 4 depending on mono or stereo | 81 // 2 or 4 depending on mono or stereo |
90 size_t _recBytesPerSample; | 82 size_t _recBytesPerSample; |
91 size_t _playBytesPerSample; | 83 size_t _playBytesPerSample; |
92 | 84 |
93 // 10ms in stereo @ 96kHz | 85 // 10ms in stereo @ 96kHz |
94 int8_t _recBuffer[kMaxBufferSizeBytes]; | 86 int8_t _recBuffer[kMaxBufferSizeBytes]; |
95 | 87 |
96 // one sample <=> 2 or 4 bytes | 88 // one sample <=> 2 or 4 bytes |
97 size_t _recSamples; | 89 size_t _recSamples; |
98 size_t _recSize; // in bytes | 90 size_t _recSize; // in bytes |
99 | 91 |
100 // 10ms in stereo @ 96kHz | 92 // 10ms in stereo @ 96kHz |
101 int8_t _playBuffer[kMaxBufferSizeBytes]; | 93 int8_t _playBuffer[kMaxBufferSizeBytes]; |
102 | 94 |
103 // one sample <=> 2 or 4 bytes | 95 // one sample <=> 2 or 4 bytes |
104 size_t _playSamples; | 96 size_t _playSamples; |
105 size_t _playSize; // in bytes | 97 size_t _playSize; // in bytes |
106 | 98 |
107 FileWrapper& _recFile; | 99 FileWrapper& _recFile; |
108 FileWrapper& _playFile; | 100 FileWrapper& _playFile; |
109 | 101 |
110 uint32_t _currentMicLevel; | 102 uint32_t _currentMicLevel; |
111 uint32_t _newMicLevel; | 103 uint32_t _newMicLevel; |
112 | 104 |
113 bool _typingStatus; | 105 bool _typingStatus; |
114 | 106 |
115 int _playDelayMS; | 107 int _playDelayMS; |
116 int _recDelayMS; | 108 int _recDelayMS; |
117 int _clockDrift; | 109 int _clockDrift; |
118 int high_delay_counter_; | 110 int high_delay_counter_; |
119 }; | 111 }; |
120 | 112 |
121 } // namespace webrtc | 113 } // namespace webrtc |
122 | 114 |
123 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 115 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H |
OLD | NEW |