AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SpeechEncoder.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_SPEECHENCODER_INCLUDE_SPEECHENCODER_SPEECHENCODER_H_
17 #define ALEXA_CLIENT_SDK_SPEECHENCODER_INCLUDE_SPEECHENCODER_SPEECHENCODER_H_
18 
19 #include <atomic>
20 #include <memory>
21 #include <thread>
22 
26 
27 #include "EncoderContext.h"
28 
29 namespace alexaClientSDK {
30 namespace speechencoder {
31 
38 public:
44  static std::shared_ptr<SpeechEncoder> createSpeechEncoder(const std::shared_ptr<EncoderContext>& encoder);
45 
51  SpeechEncoder(const std::shared_ptr<EncoderContext>& encoder);
52 
57 
73  bool startEncoding(
74  const std::shared_ptr<alexaClientSDK::avsCommon::avs::AudioInputStream>& inputStream,
78 
88  void stopEncoding(bool stopImmediately = false);
89 
96  std::shared_ptr<alexaClientSDK::avsCommon::avs::AudioInputStream> getEncodedStream();
97 
103  std::shared_ptr<EncoderContext> getContext();
104 
105 private:
109  void encodeLoop(
112 
114  std::shared_ptr<EncoderContext> m_encoder;
115 
118 
120  std::shared_ptr<alexaClientSDK::avsCommon::avs::AudioInputStream> m_inputStream;
121 
124 
126  size_t m_maxFrameSize;
127 
129  std::shared_ptr<alexaClientSDK::avsCommon::avs::AudioInputStream> m_encodedStream;
130 
132  std::atomic<bool> m_isEncoding;
133 
135  std::atomic<bool> m_stopRequested;
136 
139 
141  std::mutex m_mutex;
142 };
143 
144 } // namespace speechencoder
145 } // namespace alexaClientSDK
146 
147 #endif // ALEXA_CLIENT_SDK_SPEECHENCODER_INCLUDE_SPEECHENCODER_SPEECHENCODER_H_
Reference
Specifies a reference to measure seek()/tell()/close() offsets against.
Definition: Reader.h:51
static std::shared_ptr< SpeechEncoder > createSpeechEncoder(const std::shared_ptr< EncoderContext > &encoder)
Definition: SpeechEncoder.cpp:53
SpeechEncoder(const std::shared_ptr< EncoderContext > &encoder)
Definition: SpeechEncoder.cpp:57
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::shared_ptr< EncoderContext > getContext()
Definition: SpeechEncoder.cpp:127
void stopEncoding(bool stopImmediately=false)
Definition: SpeechEncoder.cpp:110
std::shared_ptr< alexaClientSDK::avsCommon::avs::AudioInputStream > getEncodedStream()
Definition: SpeechEncoder.cpp:122
~SpeechEncoder()
Definition: SpeechEncoder.cpp:63
bool startEncoding(const std::shared_ptr< alexaClientSDK::avsCommon::avs::AudioInputStream > &inputStream, alexaClientSDK::avsCommon::utils::AudioFormat inputFormat, avsCommon::avs::AudioInputStream::Index begin, avsCommon::avs::AudioInputStream::Reader::Reference reference)
Definition: SpeechEncoder.cpp:68
Definition: SpeechEncoder.h:37

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