AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
alexaClientSDK::captions Namespace Reference

Namespaces

 test
 

Classes

struct  CaptionData
 
class  CaptionFrame
 
class  CaptionFrameParseListenerInterface
 
struct  CaptionLine
 
class  CaptionManager
 
class  CaptionManagerInterface
 
class  CaptionParserInterface
 
class  CaptionPresenterInterface
 
class  CaptionTimingAdapter
 
class  CaptionTimingAdapterInterface
 
class  DelayInterface
 
class  LibwebvttParserAdapter
 
struct  Style
 
class  SystemClockDelay
 
struct  TextStyle
 
class  TimingAdapterFactory
 

Typedefs

using CaptionsComponent = acsdkManufactory::Component< std::shared_ptr< CaptionManagerInterface >, acsdkManufactory::Import< std::shared_ptr< acsdkShutdownManagerInterfaces::ShutdownNotifierInterface > >>
 

Enumerations

enum  CaptionFormat { CaptionFormat::WEBVTT, CaptionFormat::UNKNOWN }
 

Functions

CaptionsComponent getComponent ()
 
static const std::string TAG ("CaptionsComponent")
 String to identify log entries originating from this file. More...
 
static std::shared_ptr< CaptionManagerInterfacecreateCaptionManagerInterface (const std::shared_ptr< ShutdownNotifierInterface > &shutdownNotifier)
 
static const std::string TAG ("LibwebvttParserAdapter")
 String to identify log entries originating from this file. More...
 
void buildStyles (std::stringstream &cleanText, std::vector< TextStyle > &styles, const webvtt_node &node)
 
void WEBVTT_CALLBACK onCueParsed (void *userdata, webvtt_cue *cue)
 
int WEBVTT_CALLBACK onParseError (void *userdata, webvtt_uint line, webvtt_uint col, webvtt_error errcode)
 
CaptionFormat avsStringToCaptionFormat (const std::string &text)
 
std::ostream & operator<< (std::ostream &stream, const CaptionFormat &format)
 
std::ostream & operator<< (std::ostream &stream, const CaptionFrame &frame)
 
std::ostream & operator<< (std::ostream &stream, const CaptionLine &line)
 
std::ostream & operator<< (std::ostream &stream, const Style &style)
 
std::ostream & operator<< (std::ostream &stream, const TextStyle &textStyle)
 
static const std::string TAG ("CaptionLine")
 String to identify log entries originating from this file. More...
 

Variables

static const std::string TAG = "CaptionManager"
 String to identify log entries originating from this file. More...
 
static const std::string TAG = "CaptionTimingAdapter"
 String to identify log entries originating from this file. More...
 
static const int WEBVTT_CALLBACK_ERROR = -1
 Return value indicating an error occurred during parsing. More...
 
static std::shared_ptr< CaptionFrameParseListenerInterfaceg_parseListener
 The object to receive parsed caption frames. More...
 
static std::vector< CaptionFrame::MediaPlayerSourceIdg_captionSourceIds
 A vector which maintains a reference to every MediaPlayerSourceId passed through this adapter. More...
 
static std::map< CaptionFrame::MediaPlayerSourceId, std::chrono::milliseconds > g_captionIdsToLastEndTime
 A mapping of the last known end time for every caption ID, for calculating frame delays. More...
 
static std::shared_ptr< LibwebvttParserAdapterm_libwebvttParserAdapterInstance
 The singleton instance returned by LibwebvttParserAdapter::getInstance();. More...
 
static std::mutex g_mutex
 Global mutex for guarding access to the singleton instance and the maps. More...
 
static const int LINE_WRAP_LIMIT = 200
 The maximum number of acceptable line wraps that can occur for a single CaptionFrame. More...
 

Typedef Documentation

◆ CaptionsComponent

Definition of a Manufactory component for Captions.

Enumeration Type Documentation

◆ CaptionFormat

An enumeration of caption formats supported by the SDK.

Enumerator
WEBVTT 

WebVTT formatted plain text, see https://www.w3.org/TR/webvtt1/.

UNKNOWN 

Unknown or unsupported format.

Function Documentation

◆ avsStringToCaptionFormat()

CaptionFormat alexaClientSDK::captions::avsStringToCaptionFormat ( const std::string &  text)
inline

Convert an AVS-compliant string to a CaptionFormat.

Parameters
textThe AVS-compliant string to convert.
Returns
The converted CaptionFormat if a match is found, otherwise CaptionFormat::UNKNOWN.

◆ buildStyles()

void alexaClientSDK::captions::buildStyles ( std::stringstream &  cleanText,
std::vector< TextStyle > &  styles,
const webvtt_node &  node 
)

Recursively walk the tree structure returned by libwebvtt, extracting the styles and text.

Note
The node may contain sensitive information, so certain data elements will only be printed if ACSDK_EMIT_SENSITIVE_LOGS is ON.
Parameters
cleanTextThe std::stringstream where the final text will be placed as output of this function.
stylesThe std::vector of TextStyle objects where the parsed styles will be placed.
nodeThe tree structure provided by the libwebvtt library, containing the parsed styles and text.

◆ createCaptionManagerInterface()

static std::shared_ptr<CaptionManagerInterface> alexaClientSDK::captions::createCaptionManagerInterface ( const std::shared_ptr< ShutdownNotifierInterface > &  shutdownNotifier)
static

◆ getComponent()

CaptionsComponent alexaClientSDK::captions::getComponent ( )

Creates an manufactory component that exports a shared pointer to an implementation of CaptionManagerInterface.

Returns
A component.

◆ onCueParsed()

void WEBVTT_CALLBACK alexaClientSDK::captions::onCueParsed ( void *  userdata,
webvtt_cue *  cue 
)

The callback function that is called when libwebvtt completes the parsing of a single caption frame.

Parameters
userdataThe MediaPlayerSourceId that was sent in to the webvtt_create_parser().
cueThe object containing the parsed caption frame and style information.

◆ onParseError()

int WEBVTT_CALLBACK alexaClientSDK::captions::onParseError ( void *  userdata,
webvtt_uint  line,
webvtt_uint  col,
webvtt_error  errcode 
)

The callback function that is called when libwebvtt encounters an error during parsing.

Parameters
userdataThe MediaPlayerSourceId that was sent in to the webvtt_create_parser().
lineThe line number in userdata that sourced the error.
colThe column number in userdata that sourced the error.
errcodeThe error code describing the failure type.
Returns
The return code, unused in this implementation.

◆ operator<<() [1/5]

std::ostream& alexaClientSDK::captions::operator<< ( std::ostream &  stream,
const CaptionFormat format 
)
inline

Write a CaptionFormat value to an ostream as a string.

Parameters
streamThe stream to write the value to.
formatThe CaptionFormat value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

◆ operator<<() [2/5]

std::ostream & alexaClientSDK::captions::operator<< ( std::ostream &  stream,
const Style style 
)

Write a Style value to an ostream as a string.

Parameters
streamThe stream to write the value to.
sThe Style value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

◆ operator<<() [3/5]

std::ostream & alexaClientSDK::captions::operator<< ( std::ostream &  stream,
const CaptionLine line 
)

Write a CaptionLine value to an ostream as a string.

Parameters
streamThe stream to write the value to.
clThe caption line value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

◆ operator<<() [4/5]

std::ostream & alexaClientSDK::captions::operator<< ( std::ostream &  stream,
const TextStyle textStyle 
)

Write a TextStyle value to an ostream as a string.

Parameters
streamThe stream to write the value to.
sThe TextStyle value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

◆ operator<<() [5/5]

std::ostream & alexaClientSDK::captions::operator<< ( std::ostream &  stream,
const CaptionFrame frame 
)

Write a CaptionFrame value to an ostream as a string.

Parameters
streamThe stream to write the value to.
frameThe CaptionFrame value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

◆ TAG() [1/3]

static const std::string alexaClientSDK::captions::TAG ( "CaptionLine"  )
static

String to identify log entries originating from this file.

◆ TAG() [2/3]

static const std::string alexaClientSDK::captions::TAG ( "CaptionsComponent"  )
static

String to identify log entries originating from this file.

◆ TAG() [3/3]

static const std::string alexaClientSDK::captions::TAG ( "LibwebvttParserAdapter"  )
static

String to identify log entries originating from this file.

Variable Documentation

◆ g_captionIdsToLastEndTime

std::map<CaptionFrame::MediaPlayerSourceId, std::chrono::milliseconds> alexaClientSDK::captions::g_captionIdsToLastEndTime
static

A mapping of the last known end time for every caption ID, for calculating frame delays.

◆ g_captionSourceIds

std::vector<CaptionFrame::MediaPlayerSourceId> alexaClientSDK::captions::g_captionSourceIds
static

A vector which maintains a reference to every MediaPlayerSourceId passed through this adapter.

◆ g_mutex

std::mutex alexaClientSDK::captions::g_mutex
static

Global mutex for guarding access to the singleton instance and the maps.

◆ g_parseListener

std::shared_ptr<CaptionFrameParseListenerInterface> alexaClientSDK::captions::g_parseListener
static

The object to receive parsed caption frames.

◆ LINE_WRAP_LIMIT

const int alexaClientSDK::captions::LINE_WRAP_LIMIT = 200
static

The maximum number of acceptable line wraps that can occur for a single CaptionFrame.

◆ m_libwebvttParserAdapterInstance

std::shared_ptr<LibwebvttParserAdapter> alexaClientSDK::captions::m_libwebvttParserAdapterInstance
static

The singleton instance returned by LibwebvttParserAdapter::getInstance();.

◆ TAG [1/2]

const std::string alexaClientSDK::captions::TAG = "CaptionManager"
static

String to identify log entries originating from this file.

◆ TAG [2/2]

const std::string alexaClientSDK::captions::TAG = "CaptionTimingAdapter"
static

String to identify log entries originating from this file.

◆ WEBVTT_CALLBACK_ERROR

const int alexaClientSDK::captions::WEBVTT_CALLBACK_ERROR = -1
static

Return value indicating an error occurred during parsing.

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