AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
MediaUplCalculator.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 #ifndef ALEXA_CLIENT_SDK_METRICS_UPLCALCULATOR_INCLUDE_METRICS_MEDIAUPLCALCULATOR_H_
16 #define ALEXA_CLIENT_SDK_METRICS_UPLCALCULATOR_INCLUDE_METRICS_MEDIAUPLCALCULATOR_H_
17 
22 
23 namespace alexaClientSDK {
24 namespace metrics {
25 namespace implementations {
26 
37 public:
44  static std::unique_ptr<avsCommon::utils::metrics::UplCalculatorInterface> createMediaUplCalculator(
45  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder);
46 
50  virtual ~MediaUplCalculator() = default;
51 
57  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::UplData> getUplData() const;
58 
61  void inspectMetric(
62  const std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricEvent>& metricEvent) override;
63  void setUplData(const std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::UplData>& uplData) override;
65 private:
67  enum MediaUplType {
69  STOP,
71  PLAY,
73  PLAY_AFTER_TTS
74  };
75 
81  explicit MediaUplCalculator(
82  std::shared_ptr<alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder);
83 
92  void addDuration(
94  const std::string& name,
95  const std::string& startTimepointName,
96  const std::string& endTimepointName);
97 
106  void addDuration(
108  const std::string& name,
109  const UplTimePoint& startTimepoint,
110  const UplTimePoint& endTimepoint);
111 
118  UplTimePoint getTimePointAdjustedForTtsDuration(const UplTimePoint& timepoint) const;
119 
125  void calculateMediaUpl(MediaUplType type);
126 
130  void inhibitSubmission();
131 
133  std::weak_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
134 
136  UplTimePoint m_ttsStarted;
137 
139  UplTimePoint m_ttsFinished;
140 
142  bool m_uplInhibited;
143 };
144 
145 } // namespace implementations
146 } // namespace metrics
147 } // namespace alexaClientSDK
148 
149 #endif // ALEXA_CLIENT_SDK_METRICS_UPLCALCULATOR_INCLUDE_METRICS_MEDIAUPLCALCULATOR_H_
::std::string string
Definition: gtest-port.h:1097
static std::unique_ptr< avsCommon::utils::metrics::UplCalculatorInterface > createMediaUplCalculator(std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder)
void setUplData(const std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::UplData > &uplData) override
void inspectMetric(const std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::MetricEvent > &metricEvent) override
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
std::shared_ptr< alexaClientSDK::avsCommon::utils::metrics::UplData > getUplData() const
std::chrono::steady_clock::time_point UplTimePoint
Alias for convenience.
Definition: UplCalculatorInterface.h:35
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
type
Definition: upload.py:443

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