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_
alexaClientSDK::speechencoder::SpeechEncoder::getEncodedStream
std::shared_ptr< alexaClientSDK::avsCommon::avs::AudioInputStream > getEncodedStream()
Definition: SpeechEncoder.cpp:122
Reference
Reference
Specifies a reference to measure seek()/tell()/close() offsets against.
Definition: Reader.h:51
alexaClientSDK::capabilityAgents::system::Index
Index
Index used for setting access.
Definition: StateReportGeneratorTest.cpp:41
alexaClientSDK::avsCommon::utils::AudioFormat
Definition: AudioFormat.h:31
alexaClientSDK::speechencoder::SpeechEncoder
Definition: SpeechEncoder.h:37
AudioFormat.h
EncoderContext.h
alexaClientSDK::avsCommon::utils::threading::Executor
Definition: Executor.h:40
alexaClientSDK::speechencoder::SpeechEncoder::createSpeechEncoder
static std::shared_ptr< SpeechEncoder > createSpeechEncoder(const std::shared_ptr< EncoderContext > &encoder)
Definition: SpeechEncoder.cpp:53
alexaClientSDK::speechencoder::SpeechEncoder::startEncoding
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
Executor.h
alexaClientSDK::speechencoder::SpeechEncoder::getContext
std::shared_ptr< EncoderContext > getContext()
Definition: SpeechEncoder.cpp:127
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::speechencoder::SpeechEncoder::~SpeechEncoder
~SpeechEncoder()
Definition: SpeechEncoder.cpp:63
alexaClientSDK::speechencoder::SpeechEncoder::stopEncoding
void stopEncoding(bool stopImmediately=false)
Definition: SpeechEncoder.cpp:110
alexaClientSDK::speechencoder::SpeechEncoder::SpeechEncoder
SpeechEncoder(const std::shared_ptr< EncoderContext > &encoder)
Definition: SpeechEncoder.cpp:57
AudioInputStream.h

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