2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H
12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H
14 #include "webrtc/typedefs.h"
18 static const int kAdmMaxDeviceNameSize = 128;
19 static const int kAdmMaxFileNameSize = 512;
20 static const int kAdmMaxGuidSize = 128;
22 static const int kAdmMinPlayoutBufferSizeMs = 10;
23 static const int kAdmMaxPlayoutBufferSizeMs = 250;
25 // ----------------------------------------------------------------------------
26 // AudioDeviceObserver
27 // ----------------------------------------------------------------------------
29 class AudioDeviceObserver
39 kRecordingWarning = 0,
43 virtual void OnErrorIsReported(const ErrorCode error) = 0;
44 virtual void OnWarningIsReported(const WarningCode warning) = 0;
47 virtual ~AudioDeviceObserver() {}
50 // ----------------------------------------------------------------------------
52 // ----------------------------------------------------------------------------
57 virtual int32_t RecordedDataIsAvailable(const void* audioSamples,
58 const uint32_t nSamples,
59 const uint8_t nBytesPerSample,
60 const uint8_t nChannels,
61 const uint32_t samplesPerSec,
62 const uint32_t totalDelayMS,
63 const int32_t clockDrift,
64 const uint32_t currentMicLevel,
65 const bool keyPressed,
66 uint32_t& newMicLevel) = 0;
68 virtual int32_t NeedMorePlayData(const uint32_t nSamples,
69 const uint8_t nBytesPerSample,
70 const uint8_t nChannels,
71 const uint32_t samplesPerSec,
73 uint32_t& nSamplesOut,
74 int64_t* elapsed_time_ms,
75 int64_t* ntp_time_ms) = 0;
77 // Method to pass captured data directly and unmixed to network channels.
78 // |channel_ids| contains a list of VoE channels which are the
79 // sinks to the capture data. |audio_delay_milliseconds| is the sum of
80 // recording delay and playout delay of the hardware. |current_volume| is
81 // in the range of [0, 255], representing the current microphone analog
82 // volume. |key_pressed| is used by the typing detection.
83 // |need_audio_processing| specify if the data needs to be processed by APM.
84 // Currently WebRtc supports only one APM, and Chrome will make sure only
85 // one stream goes through APM. When |need_audio_processing| is false, the
86 // values of |audio_delay_milliseconds|, |current_volume| and |key_pressed|
88 // The return value is the new microphone volume, in the range of |0, 255].
89 // When the volume does not need to be updated, it returns 0.
90 // TODO(xians): Remove this interface after Chrome and Libjingle switches
92 virtual int OnDataAvailable(const int voe_channels[],
93 int number_of_voe_channels,
94 const int16_t* audio_data,
96 int number_of_channels,
98 int audio_delay_milliseconds,
101 bool need_audio_processing) { return 0; }
103 // Method to pass the captured audio data to the specific VoE channel.
104 // |voe_channel| is the id of the VoE channel which is the sink to the
106 // TODO(xians): Remove this interface after Libjingle switches to
107 // PushCaptureData().
108 virtual void OnData(int voe_channel, const void* audio_data,
109 int bits_per_sample, int sample_rate,
110 int number_of_channels,
111 int number_of_frames) {}
113 // Method to push the captured audio data to the specific VoE channel.
114 // The data will not undergo audio processing.
115 // |voe_channel| is the id of the VoE channel which is the sink to the
117 // TODO(xians): Make the interface pure virtual after Libjingle
118 // has its implementation.
119 virtual void PushCaptureData(int voe_channel, const void* audio_data,
120 int bits_per_sample, int sample_rate,
121 int number_of_channels,
122 int number_of_frames) {}
124 // Method to pull mixed render audio data from all active VoE channels.
125 // The data will not be passed as reference for audio processing internally.
126 // TODO(xians): Support getting the unmixed render data from specific VoE
128 virtual void PullRenderData(int bits_per_sample, int sample_rate,
129 int number_of_channels, int number_of_frames,
131 int64_t* elapsed_time_ms,
132 int64_t* ntp_time_ms) {}
135 virtual ~AudioTransport() {}
138 } // namespace webrtc
140 #endif // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H