File: audio_device_template.h

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (423 lines) | stat: -rw-r--r-- 10,366 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
/*
 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

#ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
#define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_

#include "webrtc/modules/audio_device/audio_device_generic.h"

#include "webrtc/system_wrappers/interface/trace.h"

namespace webrtc {

// InputType/OutputType can be any class that implements the capturing/rendering
// part of the AudioDeviceGeneric API.
template <class InputType, class OutputType>
class AudioDeviceTemplate : public AudioDeviceGeneric {
 public:
  static int32_t SetAndroidAudioDeviceObjects(void* javaVM,
                                       void* env,
                                       void* context) {
    if (OutputType::SetAndroidAudioDeviceObjects(javaVM, env, context) == -1) {
      return -1;
    }
    return InputType::SetAndroidAudioDeviceObjects(javaVM, env, context);
  }

  static void ClearAndroidAudioDeviceObjects() {
    OutputType::ClearAndroidAudioDeviceObjects();
    InputType::ClearAndroidAudioDeviceObjects();
  }

  explicit AudioDeviceTemplate(const int32_t id)
      : output_(id),
        input_(id, &output_) {
  }

  virtual ~AudioDeviceTemplate() {
  }

  int32_t ActiveAudioLayer(
      AudioDeviceModule::AudioLayer& audioLayer) const { // NOLINT
    audioLayer = AudioDeviceModule::kPlatformDefaultAudio;
    return 0;
  }

  int32_t Init() {
    return output_.Init() | input_.Init();
  }

  int32_t Terminate()  {
    return output_.Terminate() | input_.Terminate();
  }

  bool Initialized() const {
    return output_.Initialized() && input_.Initialized();
  }

  int16_t PlayoutDevices() {
    return output_.PlayoutDevices();
  }

  int16_t RecordingDevices() {
    return input_.RecordingDevices();
  }

  int32_t PlayoutDeviceName(
      uint16_t index,
      char name[kAdmMaxDeviceNameSize],
      char guid[kAdmMaxGuidSize]) {
    return output_.PlayoutDeviceName(index, name, guid);
  }

  int32_t RecordingDeviceName(
      uint16_t index,
      char name[kAdmMaxDeviceNameSize],
      char guid[kAdmMaxGuidSize]) {
    return input_.RecordingDeviceName(index, name, guid);
  }

  int32_t SetPlayoutDevice(uint16_t index) {
    return output_.SetPlayoutDevice(index);
  }

  int32_t SetPlayoutDevice(
      AudioDeviceModule::WindowsDeviceType device) {
    return output_.SetPlayoutDevice(device);
  }

  int32_t SetRecordingDevice(uint16_t index) {
    return input_.SetRecordingDevice(index);
  }

  int32_t SetRecordingDevice(
      AudioDeviceModule::WindowsDeviceType device) {
    return input_.SetRecordingDevice(device);
  }

  int32_t PlayoutIsAvailable(
      bool& available) {  // NOLINT
    return output_.PlayoutIsAvailable(available);
  }

  int32_t InitPlayout() {
    return output_.InitPlayout();
  }

  bool PlayoutIsInitialized() const {
    return output_.PlayoutIsInitialized();
  }

  int32_t RecordingIsAvailable(
      bool& available) {  // NOLINT
    return input_.RecordingIsAvailable(available);
  }

  int32_t InitRecording() {
    return input_.InitRecording();
  }

  bool RecordingIsInitialized() const {
    return input_.RecordingIsInitialized();
  }

  int32_t StartPlayout() {
    return output_.StartPlayout();
  }

  int32_t StopPlayout() {
    return output_.StopPlayout();
  }

  bool Playing() const {
    return output_.Playing();
  }

  int32_t StartRecording() {
    return input_.StartRecording();
  }

  int32_t StopRecording() {
    return input_.StopRecording();
  }

  bool Recording() const {
    return input_.Recording() ;
  }

  int32_t SetAGC(bool enable) {
    return input_.SetAGC(enable);
  }

  bool AGC() const {
    return input_.AGC();
  }

  int32_t SetWaveOutVolume(uint16_t volumeLeft,
                           uint16_t volumeRight) {
    WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, 0,
                 "  API call not supported on this platform");
    return -1;
  }

  int32_t WaveOutVolume(
      uint16_t& volumeLeft,           // NOLINT
      uint16_t& volumeRight) const {  // NOLINT
    WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, 0,
                 "  API call not supported on this platform");
    return -1;
  }

  int32_t InitSpeaker() {
    return output_.InitSpeaker();
  }

  bool SpeakerIsInitialized() const {
    return output_.SpeakerIsInitialized();
  }

  int32_t InitMicrophone() {
    return input_.InitMicrophone();
  }

  bool MicrophoneIsInitialized() const {
    return input_.MicrophoneIsInitialized();
  }

  int32_t SpeakerVolumeIsAvailable(
      bool& available) {  // NOLINT
    return output_.SpeakerVolumeIsAvailable(available);
  }

  int32_t SetSpeakerVolume(uint32_t volume) {
    return output_.SetSpeakerVolume(volume);
  }

  int32_t SpeakerVolume(
      uint32_t& volume) const {  // NOLINT
    return output_.SpeakerVolume(volume);
  }

  int32_t MaxSpeakerVolume(
      uint32_t& maxVolume) const {  // NOLINT
    return output_.MaxSpeakerVolume(maxVolume);
  }

  int32_t MinSpeakerVolume(
      uint32_t& minVolume) const {  // NOLINT
    return output_.MinSpeakerVolume(minVolume);
  }

  int32_t SpeakerVolumeStepSize(
      uint16_t& stepSize) const {  // NOLINT
    return output_.SpeakerVolumeStepSize(stepSize);
  }

  int32_t MicrophoneVolumeIsAvailable(
      bool& available) {  // NOLINT
    return input_.MicrophoneVolumeIsAvailable(available);
  }

  int32_t SetMicrophoneVolume(uint32_t volume) {
    return input_.SetMicrophoneVolume(volume);
  }

  int32_t MicrophoneVolume(
      uint32_t& volume) const {  // NOLINT
    return input_.MicrophoneVolume(volume);
  }

  int32_t MaxMicrophoneVolume(
      uint32_t& maxVolume) const {  // NOLINT
    return input_.MaxMicrophoneVolume(maxVolume);
  }

  int32_t MinMicrophoneVolume(
      uint32_t& minVolume) const {  // NOLINT
    return input_.MinMicrophoneVolume(minVolume);
  }

  int32_t MicrophoneVolumeStepSize(
      uint16_t& stepSize) const {  // NOLINT
    return input_.MicrophoneVolumeStepSize(stepSize);
  }

  int32_t SpeakerMuteIsAvailable(
      bool& available) {  // NOLINT
    return output_.SpeakerMuteIsAvailable(available);
  }

  int32_t SetSpeakerMute(bool enable) {
    return output_.SetSpeakerMute(enable);
  }

  int32_t SpeakerMute(
      bool& enabled) const {  // NOLINT
    return output_.SpeakerMute(enabled);
  }

  int32_t MicrophoneMuteIsAvailable(
      bool& available) {  // NOLINT
    return input_.MicrophoneMuteIsAvailable(available);
  }

  int32_t SetMicrophoneMute(bool enable) {
    return input_.SetMicrophoneMute(enable);
  }

  int32_t MicrophoneMute(
      bool& enabled) const {  // NOLINT
    return input_.MicrophoneMute(enabled);
  }

  int32_t MicrophoneBoostIsAvailable(
      bool& available) {  // NOLINT
    return input_.MicrophoneBoostIsAvailable(available);
  }

  int32_t SetMicrophoneBoost(bool enable) {
    return input_.SetMicrophoneBoost(enable);
  }

  int32_t MicrophoneBoost(
      bool& enabled) const {  // NOLINT
    return input_.MicrophoneBoost(enabled);
  }

  int32_t StereoPlayoutIsAvailable(
      bool& available) {  // NOLINT
    return output_.StereoPlayoutIsAvailable(available);
  }

  int32_t SetStereoPlayout(bool enable) {
    return output_.SetStereoPlayout(enable);
  }

  int32_t StereoPlayout(
      bool& enabled) const {  // NOLINT
    return output_.StereoPlayout(enabled);
  }

  int32_t StereoRecordingIsAvailable(
      bool& available) {  // NOLINT
    return input_.StereoRecordingIsAvailable(available);
  }

  int32_t SetStereoRecording(bool enable) {
    return input_.SetStereoRecording(enable);
  }

  int32_t StereoRecording(
      bool& enabled) const {  // NOLINT
    return input_.StereoRecording(enabled);
  }

  int32_t SetPlayoutBuffer(
      const AudioDeviceModule::BufferType type,
      uint16_t sizeMS) {
    return output_.SetPlayoutBuffer(type, sizeMS);
  }

  int32_t PlayoutBuffer(
      AudioDeviceModule::BufferType& type,
      uint16_t& sizeMS) const {  // NOLINT
    return output_.PlayoutBuffer(type, sizeMS);
  }

  int32_t PlayoutDelay(
      uint16_t& delayMS) const {  // NOLINT
    return output_.PlayoutDelay(delayMS);
  }

  int32_t RecordingDelay(
      uint16_t& delayMS) const {  // NOLINT
    return input_.RecordingDelay(delayMS);
  }

  int32_t CPULoad(
      uint16_t& load) const {  // NOLINT
    WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, 0,
                 "  API call not supported on this platform");
    return -1;
  }

  bool PlayoutWarning() const {
    return output_.PlayoutWarning();
  }

  bool PlayoutError() const {
    return output_.PlayoutError();
  }

  bool RecordingWarning() const {
    return input_.RecordingWarning();
  }

  bool RecordingError() const {
    return input_.RecordingError();
  }

  void ClearPlayoutWarning() {
    return output_.ClearPlayoutWarning();
  }

  void ClearPlayoutError() {
    return output_.ClearPlayoutError();
  }

  void ClearRecordingWarning() {
    return input_.ClearRecordingWarning();
  }

  void ClearRecordingError() {
    return input_.ClearRecordingError();
  }

  void AttachAudioBuffer(
      AudioDeviceBuffer* audioBuffer) {
    output_.AttachAudioBuffer(audioBuffer);
    input_.AttachAudioBuffer(audioBuffer);
  }

  int32_t SetRecordingSampleRate(
      const uint32_t samplesPerSec) {
    return input_.SetRecordingSampleRate(samplesPerSec);
  }

  int32_t SetPlayoutSampleRate(
      const uint32_t samplesPerSec) {
    return output_.SetPlayoutSampleRate(samplesPerSec);
  }

  int32_t SetLoudspeakerStatus(bool enable) {
    return output_.SetLoudspeakerStatus(enable);
  }

  int32_t GetLoudspeakerStatus(
      bool& enable) const {  // NOLINT
    return output_.GetLoudspeakerStatus(enable);
  }

  bool BuiltInAECIsAvailable() const {
    return input_.BuiltInAECIsAvailable();
  }

  int32_t EnableBuiltInAEC(bool enable) {
    return input_.EnableBuiltInAEC(enable);
  }

 private:
  OutputType output_;
  InputType input_;
};

}  // namespace webrtc

#endif  // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_