AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AudioProvider.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOPROVIDER_H_
17 #define ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOPROVIDER_H_
18 
21 #include "ASRProfile.h"
22 
23 namespace alexaClientSDK {
24 namespace capabilityAgents {
25 namespace aip {
26 
31 struct AudioProvider {
45  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
48  bool alwaysReadable,
49  bool canOverride,
50  bool canBeOverridden);
51 
60  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
61  const avsCommon::utils::AudioFormat& format);
62 
71  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
72  const avsCommon::utils::AudioFormat& format);
73 
82  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
83  const avsCommon::utils::AudioFormat& format);
84 
90  static const AudioProvider& null();
91 
98  operator bool() const;
99 
101  std::shared_ptr<avsCommon::avs::AudioInputStream> stream;
102 
105 
108 
111 
114 
117 };
118 
120  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
123  bool alwaysReadable,
124  bool canOverride,
125  bool canBeOverridden)
126  // Note: There is an issue with braced initialization of an aggregate type in GCC 4.8, so parentheses are used
127  // below to initialize format.
128  :
129  stream{stream},
130  format(format),
131  profile{profile},
135 }
136 
138  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
140  bool alwaysReadable = true;
141  bool canOverride = true;
142  bool canBeOverridden = true;
144 
145  return tapProvider;
146 }
147 
149  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
151  bool alwaysReadable = true;
152  bool canOverride = false;
153  bool canBeOverridden = true;
156 
157  return WakeAudioProvider;
158 }
159 
161  std::shared_ptr<avsCommon::avs::AudioInputStream> stream,
163  bool alwaysReadable = false;
164  bool canOverride = true;
165  bool canBeOverridden = false;
166  AudioProvider HoldProvider{stream, format, ASRProfile::CLOSE_TALK, alwaysReadable, canOverride, canBeOverridden};
167 
168  return HoldProvider;
169 }
170 
172  static AudioProvider nullAudioProvider{nullptr,
175  0,
176  0,
177  0,
178  true,
181  false,
182  false,
183  false};
184  return nullAudioProvider;
185 }
186 
187 inline AudioProvider::operator bool() const {
188  return stream != nullptr;
189 }
190 
191 } // namespace aip
192 } // namespace capabilityAgents
193 } // namespace alexaClientSDK
194 
195 #endif // ALEXA_CLIENT_SDK_CAPABILITYAGENTS_AIP_INCLUDE_AIP_AUDIOPROVIDER_H_
static AudioProvider HoldAudioProvider(std::shared_ptr< avsCommon::avs::AudioInputStream > stream, const avsCommon::utils::AudioFormat &format)
Definition: AudioProvider.h:160
AudioProvider(std::shared_ptr< avsCommon::avs::AudioInputStream > stream, const avsCommon::utils::AudioFormat &format, ASRProfile profile, bool alwaysReadable, bool canOverride, bool canBeOverridden)
Definition: AudioProvider.h:119
bool canBeOverridden
Whether this AudioProvider should allow another AudioProvider to interrupt it.
Definition: AudioProvider.h:116
avsCommon::utils::AudioFormat format
The AudioFormat of the data in byteStream.
Definition: AudioProvider.h:104
Non-Interleaved : The L and R are separated in different streams.
static const AudioProvider & null()
Definition: AudioProvider.h:171
bool canOverride
Whether this AudioProvider should be allowed to interrupt/override another AudioProvider.
Definition: AudioProvider.h:113
Represents LPCM (Linear pulse code modulation) encoding.
static AudioProvider WakeAudioProvider(std::shared_ptr< avsCommon::avs::AudioInputStream > stream, const avsCommon::utils::AudioFormat &format)
Definition: AudioProvider.h:148
ASRProfile profile
The ASRProfile describing the acoustic environment for the audio input.
Definition: AudioProvider.h:107
bool alwaysReadable
Whether new audio data can be read at any time from byteStream.
Definition: AudioProvider.h:110
ASRProfile
Definition: ASRProfile.h:31
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::shared_ptr< avsCommon::avs::AudioInputStream > stream
The ByteStream to use for audio input.
Definition: AudioProvider.h:101
Cloud determines end of user speech (0 to 5 ft).
Client determines end of user speech (0 to 2.5 ft).
static AudioProvider TapAudioProvider(std::shared_ptr< avsCommon::avs::AudioInputStream > stream, const avsCommon::utils::AudioFormat &format)
Definition: AudioProvider.h:137

AlexaClientSDK 3.0.0 - Copyright 2016-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0