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/interface/file_wrapper.h" | 15 #include "webrtc/system_wrappers/interface/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 uint32_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 { |
28 public: | 28 public: |
29 AudioDeviceBuffer(); | 29 AudioDeviceBuffer(); |
30 virtual ~AudioDeviceBuffer(); | 30 virtual ~AudioDeviceBuffer(); |
31 | 31 |
32 void SetId(uint32_t id); | 32 void SetId(uint32_t id); |
(...skipping 10 matching lines...) Expand all Loading... |
43 virtual int32_t SetRecordingChannels(uint8_t channels); | 43 virtual int32_t SetRecordingChannels(uint8_t channels); |
44 virtual int32_t SetPlayoutChannels(uint8_t channels); | 44 virtual int32_t SetPlayoutChannels(uint8_t channels); |
45 uint8_t RecordingChannels() const; | 45 uint8_t RecordingChannels() const; |
46 uint8_t PlayoutChannels() const; | 46 uint8_t PlayoutChannels() const; |
47 int32_t SetRecordingChannel( | 47 int32_t SetRecordingChannel( |
48 const AudioDeviceModule::ChannelType channel); | 48 const AudioDeviceModule::ChannelType channel); |
49 int32_t RecordingChannel( | 49 int32_t RecordingChannel( |
50 AudioDeviceModule::ChannelType& channel) const; | 50 AudioDeviceModule::ChannelType& channel) const; |
51 | 51 |
52 virtual int32_t SetRecordedBuffer(const void* audioBuffer, | 52 virtual int32_t SetRecordedBuffer(const void* audioBuffer, |
53 uint32_t nSamples); | 53 size_t nSamples); |
54 int32_t SetCurrentMicLevel(uint32_t level); | 54 int32_t SetCurrentMicLevel(uint32_t level); |
55 virtual void SetVQEData(int playDelayMS, | 55 virtual void SetVQEData(int playDelayMS, |
56 int recDelayMS, | 56 int recDelayMS, |
57 int clockDrift); | 57 int clockDrift); |
58 virtual int32_t DeliverRecordedData(); | 58 virtual int32_t DeliverRecordedData(); |
59 uint32_t NewMicLevel() const; | 59 uint32_t NewMicLevel() const; |
60 | 60 |
61 virtual int32_t RequestPlayoutData(uint32_t nSamples); | 61 virtual int32_t RequestPlayoutData(size_t nSamples); |
62 virtual int32_t GetPlayoutData(void* audioBuffer); | 62 virtual int32_t GetPlayoutData(void* audioBuffer); |
63 | 63 |
64 int32_t StartInputFileRecording( | 64 int32_t StartInputFileRecording( |
65 const char fileName[kAdmMaxFileNameSize]); | 65 const char fileName[kAdmMaxFileNameSize]); |
66 int32_t StopInputFileRecording(); | 66 int32_t StopInputFileRecording(); |
67 int32_t StartOutputFileRecording( | 67 int32_t StartOutputFileRecording( |
68 const char fileName[kAdmMaxFileNameSize]); | 68 const char fileName[kAdmMaxFileNameSize]); |
69 int32_t StopOutputFileRecording(); | 69 int32_t StopOutputFileRecording(); |
70 | 70 |
71 int32_t SetTypingStatus(bool typingStatus); | 71 int32_t SetTypingStatus(bool typingStatus); |
72 | 72 |
73 private: | 73 private: |
74 int32_t _id; | 74 int32_t _id; |
75 CriticalSectionWrapper& _critSect; | 75 CriticalSectionWrapper& _critSect; |
76 CriticalSectionWrapper& _critSectCb; | 76 CriticalSectionWrapper& _critSectCb; |
77 | 77 |
78 AudioTransport* _ptrCbAudioTransport; | 78 AudioTransport* _ptrCbAudioTransport; |
79 | 79 |
80 uint32_t _recSampleRate; | 80 uint32_t _recSampleRate; |
81 uint32_t _playSampleRate; | 81 uint32_t _playSampleRate; |
82 | 82 |
83 uint8_t _recChannels; | 83 uint8_t _recChannels; |
84 uint8_t _playChannels; | 84 uint8_t _playChannels; |
85 | 85 |
86 // selected recording channel (left/right/both) | 86 // selected recording channel (left/right/both) |
87 AudioDeviceModule::ChannelType _recChannel; | 87 AudioDeviceModule::ChannelType _recChannel; |
88 | 88 |
89 // 2 or 4 depending on mono or stereo | 89 // 2 or 4 depending on mono or stereo |
90 uint8_t _recBytesPerSample; | 90 size_t _recBytesPerSample; |
91 uint8_t _playBytesPerSample; | 91 size_t _playBytesPerSample; |
92 | 92 |
93 // 10ms in stereo @ 96kHz | 93 // 10ms in stereo @ 96kHz |
94 int8_t _recBuffer[kMaxBufferSizeBytes]; | 94 int8_t _recBuffer[kMaxBufferSizeBytes]; |
95 | 95 |
96 // one sample <=> 2 or 4 bytes | 96 // one sample <=> 2 or 4 bytes |
97 uint32_t _recSamples; | 97 size_t _recSamples; |
98 uint32_t _recSize; // in bytes | 98 size_t _recSize; // in bytes |
99 | 99 |
100 // 10ms in stereo @ 96kHz | 100 // 10ms in stereo @ 96kHz |
101 int8_t _playBuffer[kMaxBufferSizeBytes]; | 101 int8_t _playBuffer[kMaxBufferSizeBytes]; |
102 | 102 |
103 // one sample <=> 2 or 4 bytes | 103 // one sample <=> 2 or 4 bytes |
104 uint32_t _playSamples; | 104 size_t _playSamples; |
105 uint32_t _playSize; // in bytes | 105 size_t _playSize; // in bytes |
106 | 106 |
107 FileWrapper& _recFile; | 107 FileWrapper& _recFile; |
108 FileWrapper& _playFile; | 108 FileWrapper& _playFile; |
109 | 109 |
110 uint32_t _currentMicLevel; | 110 uint32_t _currentMicLevel; |
111 uint32_t _newMicLevel; | 111 uint32_t _newMicLevel; |
112 | 112 |
113 bool _typingStatus; | 113 bool _typingStatus; |
114 | 114 |
115 int _playDelayMS; | 115 int _playDelayMS; |
116 int _recDelayMS; | 116 int _recDelayMS; |
117 int _clockDrift; | 117 int _clockDrift; |
118 int high_delay_counter_; | 118 int high_delay_counter_; |
119 }; | 119 }; |
120 | 120 |
121 } // namespace webrtc | 121 } // namespace webrtc |
122 | 122 |
123 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H | 123 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_BUFFER_H |
OLD | NEW |