Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / webrtc / modules / audio_device / include / audio_device_defines.h
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
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.
9  */
10
11 #ifndef WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H
12 #define WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H
13
14 #include "webrtc/typedefs.h"
15
16 namespace webrtc {
17
18 static const int kAdmMaxDeviceNameSize = 128;
19 static const int kAdmMaxFileNameSize = 512;
20 static const int kAdmMaxGuidSize = 128;
21
22 static const int kAdmMinPlayoutBufferSizeMs = 10;
23 static const int kAdmMaxPlayoutBufferSizeMs = 250;
24
25 // ----------------------------------------------------------------------------
26 //  AudioDeviceObserver
27 // ----------------------------------------------------------------------------
28
29 class AudioDeviceObserver
30 {
31 public:
32     enum ErrorCode
33     {
34         kRecordingError = 0,
35         kPlayoutError = 1
36     };
37     enum WarningCode
38     {
39         kRecordingWarning = 0,
40         kPlayoutWarning = 1
41     };
42
43     virtual void OnErrorIsReported(const ErrorCode error) = 0;
44     virtual void OnWarningIsReported(const WarningCode warning) = 0;
45
46 protected:
47     virtual ~AudioDeviceObserver() {}
48 };
49
50 // ----------------------------------------------------------------------------
51 //  AudioTransport
52 // ----------------------------------------------------------------------------
53
54 class AudioTransport
55 {
56 public:
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;   
67
68     virtual int32_t NeedMorePlayData(const uint32_t nSamples,
69                                      const uint8_t nBytesPerSample,
70                                      const uint8_t nChannels,
71                                      const uint32_t samplesPerSec,
72                                      void* audioSamples,
73                                      uint32_t& nSamplesOut) = 0;
74
75     // Method to pass captured data directly and unmixed to network channels.
76     // |channel_ids| contains a list of VoE channels which are the
77     // sinks to the capture data. |audio_delay_milliseconds| is the sum of
78     // recording delay and playout delay of the hardware. |current_volume| is
79     // in the range of [0, 255], representing the current microphone analog
80     // volume. |key_pressed| is used by the typing detection.
81     // |need_audio_processing| specify if the data needs to be processed by APM.
82     // Currently WebRtc supports only one APM, and Chrome will make sure only
83     // one stream goes through APM. When |need_audio_processing| is false, the
84     // values of |audio_delay_milliseconds|, |current_volume| and |key_pressed|
85     // will be ignored.
86     // The return value is the new microphone volume, in the range of |0, 255].
87     // When the volume does not need to be updated, it returns 0.
88     // TODO(xians): Remove this interface after Chrome and Libjingle switches
89     // to OnData().
90     virtual int OnDataAvailable(const int voe_channels[],
91                                 int number_of_voe_channels,
92                                 const int16_t* audio_data,
93                                 int sample_rate,
94                                 int number_of_channels,
95                                 int number_of_frames,
96                                 int audio_delay_milliseconds,
97                                 int current_volume,
98                                 bool key_pressed,
99                                 bool need_audio_processing) { return 0; }
100
101     // Method to pass the captured audio data to the specific VoE channel.
102     // |voe_channel| is the id of the VoE channel which is the sink to the
103     // capture data.
104     // TODO(xians): Make the interface pure virtual after libjingle
105     // has its implementation.
106     virtual void OnData(int voe_channel, const void* audio_data,
107                         int bits_per_sample, int sample_rate,
108                         int number_of_channels,
109                         int number_of_frames) {}
110
111 protected:
112     virtual ~AudioTransport() {}
113 };
114
115 }  // namespace webrtc
116
117 #endif  // WEBRTC_AUDIO_DEVICE_AUDIO_DEVICE_DEFINES_H