AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Macros | Typedefs | Functions | Variables
AudioPlayer.cpp File Reference
#include <algorithm>
#include <cctype>
#include <regex>
#include "acsdkAudioPlayer/AudioPlayer.h"
#include "acsdkAudioPlayer/Util.h"
#include <rapidjson/stringbuffer.h>
#include <rapidjson/error/en.h>
#include <AVSCommon/AVS/CapabilityConfiguration.h>
#include <AVSCommon/AVS/EventBuilder.h>
#include <AVSCommon/SDKInterfaces/Audio/MixingBehavior.h>
#include <AVSCommon/Utils/JSON/JSONGenerator.h>
#include <AVSCommon/Utils/JSON/JSONUtils.h>
#include <AVSCommon/Utils/Metrics/MetricEventBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointStringBuilder.h>
#include <AVSCommon/Utils/Metrics/DataPointCounterBuilder.h>
Include dependency graph for AudioPlayer.cpp:

Namespaces

 alexaClientSDK
 Whether or not curl logs should be emitted.
 
 alexaClientSDK::acsdkAudioPlayer
 

Macros

#define LX(event)   alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
 

Typedefs

using alexaClientSDK::acsdkAudioPlayer::MediaPlayerState = avsCommon::utils::mediaPlayer::MediaPlayerState
 

Functions

static const std::string alexaClientSDK::acsdkAudioPlayer::TAG ("AudioPlayer")
 String to identify log entries originating from this file. More...
 
static const std::chrono::seconds alexaClientSDK::acsdkAudioPlayer::LOCAL_STOP_DEFAULT_PIPELINE_OPEN_TIME (900)
 Time to keep the pipeline open after a local pause. More...
 
static bool alexaClientSDK::acsdkAudioPlayer::compareUrlNotQuery (const std::string &url1, const std::string &url2)
 
static std::shared_ptr< avsCommon::avs::CapabilityConfiguration > alexaClientSDK::acsdkAudioPlayer::getAudioPlayerCapabilityConfiguration (Fingerprint fingerprint)
 
static void alexaClientSDK::acsdkAudioPlayer::submitMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &metricActivityName, const DataPoint &dataPoint, const std::string &msgId, const std::string &trackId, const std::string &requesterType="", const std::string &trackProtection="", const std::string &trackPlaylistType="", const std::string &trackDomainNameHash="")
 
static void alexaClientSDK::acsdkAudioPlayer::submitAnnotatedMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &baseMetric, const std::string &annotation)
 
static void alexaClientSDK::acsdkAudioPlayer::submitInstanceMetric (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &segmentId, const std::string &name, const std::map< std::string, std::string > &metadata={})
 
static void alexaClientSDK::acsdkAudioPlayer::createAssociation (const std::shared_ptr< MetricRecorderInterface > &metricRecorder, const std::string &associateFrom, const std::string &associateTo)
 
bool alexaClientSDK::acsdkAudioPlayer::messageSentSuccessfully (MessageRequestObserverInterface::Status status)
 
static audio::MixingBehavior alexaClientSDK::acsdkAudioPlayer::getMixingBehavior (const std::string &messageID, const rapidjson::Value &payload, const std::shared_ptr< MetricRecorderInterface > &metricRecorder)
 

Variables

static const std::string alexaClientSDK::acsdkAudioPlayer::AUDIOPLAYER_CAPABILITY_INTERFACE_TYPE = "AlexaInterface"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::AUDIOPLAYER_CAPABILITY_INTERFACE_NAME = "AudioPlayer"
 AudioPlayer interface name. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::AUDIOPLAYER_CAPABILITY_INTERFACE_VERSION = "1.5"
 AudioPlayer interface version. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::FINGERPRINT_KEY = "fingerprint"
 The fingerprint key used in AudioPlayer configurations. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::PACKAGE_KEY = "package"
 The package key used in AudioPlayer fingerprint. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::BUILD_TYPE_KEY = "buildType"
 The buildType key used in AudioPlayer fingerprint. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::VERSION_NUMBER_KEY = "versionNumber"
 The versionNumber key used in AudioPlayer fingerprint. More...
 
static const AudioPlayer::SourceId alexaClientSDK::acsdkAudioPlayer::ERROR_SOURCE_ID = MediaPlayerInterface::ERROR
 A link to MediaPlayerInterface::ERROR. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::CHANNEL_NAME = FocusManagerInterface::CONTENT_CHANNEL_NAME
 The name of the FocusManager channel used by AudioPlayer. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::NAMESPACE = "AudioPlayer"
 The namespace for this capability agent. More...
 
static const NamespaceAndName alexaClientSDK::acsdkAudioPlayer::PLAY {NAMESPACE, "Play"}
 The Play directive signature. More...
 
static const NamespaceAndName alexaClientSDK::acsdkAudioPlayer::STOP {NAMESPACE, "Stop"}
 The Stop directive signature. More...
 
static const NamespaceAndName alexaClientSDK::acsdkAudioPlayer::CLEAR_QUEUE {NAMESPACE, "ClearQueue"}
 The ClearQueue directive signature. More...
 
static const NamespaceAndName alexaClientSDK::acsdkAudioPlayer::UPDATE_PROGRESS_REPORT_INTERVAL {NAMESPACE, "UpdateProgressReportInterval"}
 The UpdateProgressReportInterval directive signature. More...
 
static const NamespaceAndName alexaClientSDK::acsdkAudioPlayer::STATE {NAMESPACE, "PlaybackState"}
 The AudioPlayer context state signature. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::CID_PREFIX {"cid:"}
 Prefix for content ID prefix in the url property of the directive payload. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::TOKEN_KEY [] = "token"
 The token key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::OFFSET_KEY [] = "offsetInMilliseconds"
 The offset key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::SEEK_START_OFFSET_KEY [] = "seekStartOffsetInMilliseconds"
 The seek start offset key used in PlaybackSeeked events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::SEEK_END_OFFSET_KEY [] = "seekEndOffsetInMilliseconds"
 The seek end offset key used in PlaybackSeeked events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::PLAYBACK_ATTRIBUTES_KEY [] = "playbackAttributes"
 The playbackAttributes key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::NAME_KEY [] = "name"
 The name key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::CODEC_KEY [] = "codec"
 The codec key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::SAMPLING_RATE_IN_HERTZ_KEY [] = "samplingRateInHertz"
 The samplingRateInHertz key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::DATA_RATE_IN_BITS_PER_SECOND_KEY [] = "dataRateInBitsPerSecond"
 The dateRateInBitsPerSecond key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::PLAYBACK_REPORTS_KEY [] = "playbackReports"
 The playbackReports key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::START_OFFSET_KEY [] = "startOffsetInMilliseconds"
 The startOffsetInMilliseconds key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::END_OFFSET_KEY [] = "endOffsetInMilliseconds"
 The endOffsetInMilliseconds key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::ACTIVITY_KEY [] = "playerActivity"
 The activity key used in AudioPlayer events. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::CAPTION_KEY [] = "caption"
 The key for the "captionData" property in the directive payload. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::CAPTION_TYPE_KEY [] = "type"
 The key under "captionData" containing the caption type. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::CAPTION_CONTENT_KEY [] = "content"
 The key under "captionData" containing the caption content. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::KEY_ANALYZERS [] = "analyzers"
 The "analyzers" key used to retrieve analyzer data from directive. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::KEY_ANALYZERS_INTERFACE [] = "interface"
 The key used to retrieve the audio analyzer name from directive. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::KEY_ANALYZERS_ENABLED [] = "enabled"
 The key used to retrieve the audio analyzer enabled state from directive. More...
 
static const char alexaClientSDK::acsdkAudioPlayer::STUTTER_DURATION_KEY [] = "stutterDurationInMilliseconds"
 The stutter key used in AudioPlayer events. More...
 
static const std::chrono::seconds alexaClientSDK::acsdkAudioPlayer::TIMEOUT {2}
 The duration to wait for a state change in onFocusChanged before failing. More...
 
static const audio::MixingBehavior alexaClientSDK::acsdkAudioPlayer::DEFAULT_MIXING_BEHAVIOR = audio::MixingBehavior::BEHAVIOR_PAUSE
 default mixing behavior More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::AUDIO_PLAYER_METRIC_PREFIX = "AUDIO_PLAYER-"
 prefix for metrics emitted from the AudioPlayer CA More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::UNSUPPORTED_INTERRUPTED_BEHAVIOR = "UNSUPPORTED_INTERRUPTED_BEHAVIOR_PLAY_DIRECTIVE"
 Metric to catch unsupported/missing interruptedBehavior. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::MISSING_INTERRUPTED_BEHAVIOR = "MISSING_INTERRUPTED_BEHAVIOR_PLAY_DIRECTIVE"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::PREPARE_PLAY_DIRECTIVE_RECEIVED = "PREPARE_PLAY_DIRECTIVE_RECEIVED"
 playback metrics use for AudioPlayer UPL More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::PLAY_DIRECTIVE_RECEIVED = "PLAY_DIRECTIVE_RECEIVED"
 The directive received metric is used in place of 'first bytes' for UPL because pre-buffering may distort the metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::STOP_DIRECTIVE_RECEIVED = "STOP_DIRECTIVE_RECEIVED"
 The directive received metric is used in place of 'first bytes' for Stop UPL because there are no bytes involved. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::PLAYBACK_STARTED = "PLAYBACK_STARTED"
 Metric used to trigger UPL recording for play. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::PLAYBACK_STOPPED = "PLAYBACK_STOPPED"
 Metric used to trigger UPL recording for stop. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METADATA_UNFILTERED_ENCOUNTERED = "UnfilteredMetadataEncountered"
 Metrics for filtered and unfiltered metadata. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METADATA_FILTERED_ENCOUNTERED = "FilteredMetadataEncountered"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::AUDIO_PLAYBACK_TIME = "AudioPlaybackTime"
 Total play time metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_TO_TRACK_TIME = "AutoProgressionLatency"
 Track to Track time metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_PROGRESSION_FATAL = "TrackProgressionFatalError"
 Playback error during auto-progression. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::MID_PLAYBACK_FATAL = "PlaybackFatalError"
 Fatal error mid-playback. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_TIME_ON_QUEUE = "TrackTimeOnQueue"
 Time spent on queue. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::HANDLE_PLAY_COMMAND_TO_PLAYING = "directiveReceiveToPlaying"
 Latency between handleDirective command for a new play session and PLAYING state. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::INVALID_HEADER_RECEIVED = "InvalidHeaderReceived"
 Invalid headers metrics. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::MALICIOUS_HEADER_RECEIVED = "MaliciousHeaderReceived"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::MESSAGE_SENT_FAILED = "MessageSentFailed"
 Message sent failed metric. More...
 
static const std::vector< std::string > alexaClientSDK::acsdkAudioPlayer::METADATA_ALLOWLIST = {"title"}
 
static const std::chrono::seconds alexaClientSDK::acsdkAudioPlayer::METADATA_EVENT_RATE {1}
 Min time between metadata events. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::NORMALIZATION_LEVEL_HIGH = "HIGH"
 Normalization enabled (HIGH level) More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::NORMALIZATION_LEVEL_OFF = "OFF"
 Normalization disabled. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_PROTECTION_NAME = "TrackProtectionName"
 Track protection name, meta data sent with metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_PLAYLIST_TYPE = "TrackType"
 Track playlist type, meta data sent with metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::TRACK_DOMAIN_NAME_HASH = "TrackDomainNameHash"
 Hash of the domain name of the track url, meta data sent with metric. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_SEGMENT_ID = "segment_id"
 Keys for entry metric specific fields. More...
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ACTOR = "actor"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ENTRY_TYPE = "entry_type"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ENTRY_NAME = "entry_name"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ERROR_DESCRIPTION = "error_description"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ERROR_RECOVERABLE = "error_recoverable"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ASSOCIATE_FROM = "association_from_id"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_KEY_ASSOCIATE_TO = "association_to_id"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_INSTANCE_RECEIVE_DIRECTIVE = "ReceiveDirective"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_INSTANCE_STATE_CHANGED = "PlaybackStateChanged"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_INSTANCE_FIRST_BYTE_READ = "FirstAudioByteRead"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_META_KEY_NAMESPACE = "namespace"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_META_KEY_NAME = "name"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_META_KEY_ISPREPARE_BOOL = "isPreparePhase"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_INSTANCE_ACQUIRE_MEDIA_PLAYER_START = "AcquireMediaPlayerStart"
 
static const std::string alexaClientSDK::acsdkAudioPlayer::METRIC_INSTANCE_ACQUIRE_MEDIA_PLAYER_FINISH = "AcquireMediaPlayerFinish"
 

Macro Definition Documentation

◆ LX

#define LX (   event)    alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

Create a LogEntry using this file's TAG and the specified event string.

Parameters
Theevent string for this LogEntry.

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