AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
SourceConfig.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_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_SOURCECONFIG_H_
17 #define ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_SOURCECONFIG_H_
18 
19 #include <algorithm>
20 #include <chrono>
21 #include <ostream>
22 
24 
25 namespace alexaClientSDK {
26 namespace avsCommon {
27 namespace utils {
28 namespace mediaPlayer {
29 
31 static constexpr short MAX_GAIN = 100;
32 
34 static constexpr short MIN_GAIN = 0;
35 
36 /*
37  * An object that contains configuration for a source media.
38  */
39 struct SourceConfig {
40  /*
41  * Object that contains Fade-In configuration.
42  */
43  struct FadeInConfig {
45  short startGain;
46 
48  short endGain;
49 
51  std::chrono::milliseconds duration;
52 
54  bool enabled;
55  };
56 
57  /*
58  * Object that contains audio normalization configuration
59  */
61  /*
62  * Enable audio normalization.
63  * This is an optional feature and could be safely ignored
64  * if not supported by MediaPlayer implementation.
65  */
66  bool enabled;
67  };
68 
71 
74 
76  std::chrono::milliseconds endOffset;
77 
80 
88  static inline SourceConfig createWithFadeIn(
89  short startGain,
90  short endGain,
91  const std::chrono::milliseconds& duration);
92 };
93 
99  return SourceConfig{{100, 100, std::chrono::milliseconds::zero(), false},
100  {false},
101  std::chrono::milliseconds::zero(),
103 }
104 
115  short startGain,
116  short endGain,
117  const std::chrono::milliseconds& duration) {
118  short validStartGain = std::max(MIN_GAIN, std::min(MAX_GAIN, startGain));
119  short validEndGain = std::max(MIN_GAIN, std::min(MAX_GAIN, endGain));
120  return SourceConfig{{validStartGain, validEndGain, duration, true},
121  {false},
122  std::chrono::milliseconds::zero(),
124 }
125 
133 inline std::ostream& operator<<(std::ostream& stream, const SourceConfig& config) {
134  return stream << "fadeIn{"
135  << " enabled:" << config.fadeInConfig.enabled << ", start:" << config.fadeInConfig.startGain
136  << ", end:" << config.fadeInConfig.endGain
137  << ", duration(ms):" << config.fadeInConfig.duration.count() << "}"
138  << ", normalization{"
139  << " enabled: " << config.audioNormalizationConfig.enabled << "}"
140  << ", endOffset(ms): " << config.endOffset.count()
141  << ", MediaDescription: " << config.mediaDescription;
142 }
143 
144 } // namespace mediaPlayer
145 } // namespace utils
146 } // namespace avsCommon
147 } // namespace alexaClientSDK
148 
149 #endif // ALEXA_CLIENT_SDK_AVSCOMMON_UTILS_INCLUDE_AVSCOMMON_UTILS_MEDIAPLAYER_SOURCECONFIG_H_
short endGain
The ending percentage volume when the media played to the fade-in duration (range 0-100)...
Definition: SourceConfig.h:48
SourceConfig emptySourceConfig()
Definition: SourceConfig.h:98
std::chrono::milliseconds duration
The fade-in duration time.
Definition: SourceConfig.h:51
FadeInConfig fadeInConfig
Fade-In configuration.
Definition: SourceConfig.h:70
std::chrono::milliseconds endOffset
End offset for where playback should be stopped.
Definition: SourceConfig.h:76
static SourceConfig createWithFadeIn(short startGain, short endGain, const std::chrono::milliseconds &duration)
Definition: SourceConfig.h:114
bool enabled
A boolean to specify whether Fade-In is enabled.
Definition: SourceConfig.h:54
MediaDescription emptyMediaDescription()
Definition: MediaDescription.h:66
AudioNormalizationConfig audioNormalizationConfig
Audio normalization configuration.
Definition: SourceConfig.h:73
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
static constexpr short MAX_GAIN
Maximum gain supported.
Definition: SourceConfig.h:31
MediaDescription mediaDescription
Media description information.
Definition: SourceConfig.h:79
std::ostream & operator<<(std::ostream &stream, const ErrorType &errorType)
Definition: ErrorTypes.h:158
static constexpr short MIN_GAIN
Minimum gain supported.
Definition: SourceConfig.h:34
short startGain
The starting percentage volume when the media starts playing (range 0-100).
Definition: SourceConfig.h:45

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