AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
OpusEncoderContext.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_OPUSENCODERCONTEXT_INCLUDE_SPEECHENCODER_OPUSENCODERCONTEXT_H_
17 #define ALEXA_CLIENT_SDK_SPEECHENCODER_OPUSENCODERCONTEXT_INCLUDE_SPEECHENCODER_OPUSENCODERCONTEXT_H_
18 
19 #include <memory>
20 
22 
23 // We don't want to expose OPUS related structure type for user who utilize this class.
24 // (And those types are only used in private fields anyway.)
25 #ifdef OPUS_H
26 // Only an implementation file should know about the actual type.
27 #define OPUS_ENCODER OpusEncoder
28 #else
29 // Otherwise keep it general void pointer, to avoid opus.h dependency.
30 #define OPUS_ENCODER void
31 #endif
32 
33 namespace alexaClientSDK {
34 namespace speechencoder {
35 
40 public:
46  static std::shared_ptr<EncoderContext> createEncoderContext();
47 
52 
57 
67  bool init(alexaClientSDK::avsCommon::utils::AudioFormat inputFormat) override;
68 
74  size_t getInputFrameSize() override;
75 
81  size_t getOutputFrameSize() override;
82 
89  bool requiresFullyRead() override;
90 
97 
104  std::string getAVSFormatName() override;
105 
111  bool start() override;
112 
123  ssize_t processSamples(void* samples, size_t numberOfWords, uint8_t* buffer) override;
124 
128  void close() override;
129 
130 private:
136  bool configureEncoder();
137 
139  OPUS_ENCODER* m_encoder = NULL;
140 
143 
146 };
147 
148 } // namespace speechencoder
149 } // namespace alexaClientSDK
150 
151 #endif // ALEXA_CLIENT_SDK_SPEECHENCODER_OPUSENCODERCONTEXT_INCLUDE_SPEECHENCODER_OPUSENCODERCONTEXT_H_
alexaClientSDK::speechencoder::OpusEncoderContext::OpusEncoderContext
OpusEncoderContext()
Definition: OpusEncoderContext.cpp:194
alexaClientSDK::speechencoder::OpusEncoderContext::init
bool init(alexaClientSDK::avsCommon::utils::AudioFormat inputFormat) override
Definition: OpusEncoderContext.cpp:75
alexaClientSDK::avsCommon::utils::AudioFormat
Definition: AudioFormat.h:31
alexaClientSDK::speechencoder::OpusEncoderContext::getAudioFormat
alexaClientSDK::avsCommon::utils::AudioFormat getAudioFormat() override
Definition: OpusEncoderContext.cpp:108
alexaClientSDK::speechencoder::OpusEncoderContext::getOutputFrameSize
size_t getOutputFrameSize() override
Definition: OpusEncoderContext.cpp:100
alexaClientSDK::speechencoder::OpusEncoderContext::createEncoderContext
static std::shared_ptr< EncoderContext > createEncoderContext()
Definition: OpusEncoderContext.cpp:67
EncoderContext.h
alexaClientSDK::speechencoder::OpusEncoderContext
Definition: OpusEncoderContext.h:39
alexaClientSDK::speechencoder::OpusEncoderContext::getInputFrameSize
size_t getInputFrameSize() override
Definition: OpusEncoderContext.cpp:96
OPUS_ENCODER
#define OPUS_ENCODER
Definition: OpusEncoderContext.h:30
alexaClientSDK
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
alexaClientSDK::speechencoder::EncoderContext
Definition: EncoderContext.h:30
alexaClientSDK::speechencoder::OpusEncoderContext::start
bool start() override
Definition: OpusEncoderContext.cpp:143
alexaClientSDK::speechencoder::OpusEncoderContext::processSamples
ssize_t processSamples(void *samples, size_t numberOfWords, uint8_t *buffer) override
Definition: OpusEncoderContext.cpp:172
alexaClientSDK::speechencoder::OpusEncoderContext::~OpusEncoderContext
~OpusEncoderContext()
Definition: OpusEncoderContext.cpp:71
alexaClientSDK::speechencoder::OpusEncoderContext::getAVSFormatName
std::string getAVSFormatName() override
Definition: OpusEncoderContext.cpp:112
alexaClientSDK::speechencoder::OpusEncoderContext::close
void close() override
Definition: OpusEncoderContext.cpp:187
alexaClientSDK::speechencoder::OpusEncoderContext::requiresFullyRead
bool requiresFullyRead() override
Definition: OpusEncoderContext.cpp:104

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