16 #ifndef ALEXA_CLIENT_SDK_ACSDKALERTS_INCLUDE_ACSDKALERTS_ALERT_H_ 17 #define ALEXA_CLIENT_SDK_ACSDKALERTS_INCLUDE_ACSDKALERTS_ALERT_H_ 35 #include <unordered_map> 38 #include <rapidjson/document.h> 41 namespace acsdkAlerts {
53 ,
public std::enable_shared_from_this<Alert> {
132 std::unordered_map<std::string, Asset>
assets;
201 MISSING_REQUIRED_PROPERTY,
220 scheduledTime_ISO_8601{scheduledTime_ISO_8601} {
279 std::shared_ptr<settings::DeviceSettingsManager> settingsManager);
338 void setRenderer(std::shared_ptr<renderer::RendererInterface> renderer);
491 bool isPastDue(int64_t currentUnixTime, std::chrono::seconds timeLimit);
554 int64_t getScheduledTime_UnixLocked()
const;
561 std::string getScheduledTime_ISO_8601Locked()
const;
568 std::chrono::system_clock::time_point getScheduledTime_Utc_TimePointLocked()
const;
599 void startRenderer();
604 void startRendererLocked();
609 void onMaxTimerExpiration();
616 bool isAlertPausedLocked()
const;
625 mutable std::mutex m_mutex;
637 bool m_hasTimerExpired;
643 std::shared_ptr<renderer::RendererInterface> m_renderer;
646 m_defaultAudioFactory;
651 std::shared_ptr<settings::DeviceSettingsManager> m_settingsManager;
654 bool m_focusChangedDuringAlertActivation;
656 bool m_startRendererAgainAfterFullStop;
666 bool operator()(
const std::shared_ptr<Alert>& lhs,
const std::shared_ptr<Alert>& rhs)
const {
667 if (lhs->getScheduledTime_Unix() == rhs->getScheduledTime_Unix()) {
668 return (lhs->getToken() < rhs->getToken());
671 return (lhs->getScheduledTime_Unix() < rhs->getScheduledTime_Unix());
711 #endif // ALEXA_CLIENT_SDK_ACSDKALERTS_INCLUDE_ACSDKALERTS_ALERT_H_
std::string scheduledTime_ISO_8601
The time, in ISO-8601 format, when this alert should activate.
Definition: Alert.h:228
static std::string stateToString(Alert::State state)
static std::string stopReasonToString(Alert::StopReason stopReason)
MixingBehavior
Definition: MixingBehavior.h:25
std::string originalTime
An attribute representing the local time when the alert was originally set.
Definition: Alert.h:185
std::chrono::milliseconds loopPause
The pause time, in milliseconds, that should be taken between each loop of asset rendering.
Definition: Alert.h:141
avsCommon::utils::Optional< acsdkAlertsInterfaces::AlertObserverInterface::OriginalTime > getOriginalTime() const
std::string label
An attribute representing the content of the alert.
Definition: Alert.h:188
The alert is active, but has been asked to snooze.
std::string id
The id of the asset.
Definition: Alert.h:116
The alert has completed on its own, without user interaction.
int64_t getScheduledTime_Unix() const
DynamicData()
Definition: Alert.h:170
bool hasRenderingFailed
A flag to capture if rendering any of asset urls failed.
Definition: Alert.h:182
bool setAssetConfiguration(const AssetConfiguration &assetConfiguration)
avsCommon::utils::Optional< std::string > getLabel() const
std::string token
The AVS token for the alert.
Definition: Alert.h:156
void setRenderer(std::shared_ptr< renderer::RendererInterface > renderer)
StopReason
Definition: Alert.h:84
::std::string string
Definition: gtest-port.h:1097
std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >)> getShortAudioFactory() const
acsdkAlertsInterfaces::AlertObserverInterface::AlertInfo createAlertInfo(acsdkAlertsInterfaces::AlertObserverInterface::State state, const std::string &reason="") const
std::unordered_map< std::string, Asset > assets
A map of the custom assets, mapping from asset.id to the asset itself.
Definition: Alert.h:132
Alert::ContextInfo getContextInfo() const
Definition: AlertObserverInterface.h:31
std::vector< std::string > assetPlayOrderItems
Definition: Alert.h:137
AssetConfiguration assetConfiguration
The assets associated with this alert.
Definition: Alert.h:191
AssetConfiguration getAssetConfiguration() const
void setFocusState(avsCommon::avs::FocusState focusState, avsCommon::avs::MixingBehavior behavior)
ParseFromJsonStatus parseFromJson(const rapidjson::Value &payload, std::string *errorMessage)
MediaType
Definition: MediaType.h:29
FocusState
Definition: FocusState.h:29
The alert is active, but is now stopping due to user interaction.
std::chrono::system_clock::time_point getScheduledTime_Utc_TimePoint() const
Definition: TimePoint.h:31
The alert is set and is expected to become active at some point in the future.
The renderer is now stopped due to a snooze request.
std::string token
The AVS token identifying this alert.
Definition: Alert.h:224
Definition: Optional.h:32
std::ostream & operator<<(std::ostream &stream, const Alert::State &state)
Definition: Alert.h:682
acsdkAlertsInterfaces::AlertObserverInterface::Type getType() const
static avsCommon::utils::Optional< acsdkAlertsInterfaces::AlertObserverInterface::OriginalTime > validateOriginalTimeString(const std::string &originalTimeStr)
bool snooze(const std::string &updatedScheduledTime)
Definition: AlertObserverInterface.h:171
AssetConfiguration()
Definition: Alert.h:128
std::string getBackgroundAssetId() const
bool Value(const T &value, M matcher)
Definition: gmock-matchers.h:4347
std::chrono::milliseconds getLoopPause() const
Type
Definition: AlertObserverInterface.h:88
std::string type
The type of this alert.
Definition: Alert.h:226
std::string getToken() const
void onRendererStateChange(renderer::RendererObserverInterface::State state, const std::string &reason) override
Timer to schedule task for delayed and periodic execution.
Definition: Timer.h:39
std::string backgroundAssetId
The background asset id, if specified by AVS.
Definition: Alert.h:139
virtual std::string getTypeName() const =0
bool operator()(const std::shared_ptr< Alert > &lhs, const std::shared_ptr< Alert > &rhs) const
Definition: Alert.h:666
Alert::State getState() const
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
State
Definition: AlertObserverInterface.h:60
Rendering has been initiated, but is not yet perceivable from a user's point of view.
bool updateScheduledTime(const std::string &newScheduledTime)
The alert is ready to activate, and is waiting for the channel to be acquired.
std::string getScheduledTime_ISO_8601() const
bool isPastDue(int64_t currentUnixTime, std::chrono::seconds timeLimit)
type
Definition: upload.py:443
std::string url
The url of the asset.
Definition: Alert.h:118
StaticData()
Definition: Alert.h:153
int dbId
The database id for the alert.
Definition: Alert.h:159
ParseFromJsonStatus
Definition: Alert.h:197
State
Definition: Alert.h:58
bool setAlertData(StaticData *staticData, DynamicData *dynamicData)
Rendering has been initiated, and is perceivable from a user's point of view.
void getAlertData(StaticData *staticData, DynamicData *dynamicData) const
ContextInfo(const std::string &token, const std::string &type, const std::string &scheduledTime_ISO_8601)
Definition: Alert.h:217
Alert(std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()> defaultAudioFactory, std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >()> shortAudioFactory, std::shared_ptr< settings::DeviceSettingsManager > settingsManager)
int loopCount
The number of times the sequence of assets should be rendered.
Definition: Alert.h:179
void deactivate(StopReason reason)
The alert has stopped in response to user interaction.
avsCommon::utils::timing::TimePoint timePoint
A TimePoint reflecting the time when the alert should become active.
Definition: Alert.h:176
State state
The state of the alert.
Definition: Alert.h:173
State
Definition: RendererObserverInterface.h:33
static avsCommon::utils::Optional< std::string > validateLabelString(const std::string &label)
StopReason getStopReason() const
Definition: RendererObserverInterface.h:28
std::function< std::pair< std::unique_ptr< std::istream >, const avsCommon::utils::MediaType >)> getDefaultAudioFactory() const
void setObserver(acsdkAlertsInterfaces::AlertObserverInterface *observer)
static std::string parseFromJsonStatusToString(Alert::ParseFromJsonStatus parseFromJsonStatus)
Asset(const std::string &id, const std::string &url)
Definition: Alert.h:112