AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Types | Public Member Functions | List of all members
alexaClientSDK::avsCommon::avs::attachment::AttachmentReader Class Referenceabstract

#include <AttachmentReader.h>

Inheritance diagram for alexaClientSDK::avsCommon::avs::attachment::AttachmentReader:
Inheritance graph
[legend]

Public Types

enum  ReadStatus {
  ReadStatus::OK, ReadStatus::OK_WOULDBLOCK, ReadStatus::OK_TIMEDOUT, ReadStatus::OK_OVERRUN_RESET,
  ReadStatus::CLOSED, ReadStatus::ERROR_OVERRUN, ReadStatus::ERROR_BYTES_LESS_THAN_WORD_SIZE, ReadStatus::ERROR_INTERNAL
}
 
enum  ClosePoint { ClosePoint::IMMEDIATELY, ClosePoint::AFTER_DRAINING_CURRENT_BUFFER }
 An enum class to indicate when the read() function should stop returning data after a call to close(). More...
 

Public Member Functions

virtual ~AttachmentReader ()=default
 
virtual std::size_t read (void *buf, std::size_t numBytes, ReadStatus *readStatus, std::chrono::milliseconds timeoutMs=std::chrono::milliseconds(0))=0
 
virtual bool seek (uint64_t offset)=0
 
virtual uint64_t getNumUnreadBytes ()=0
 
virtual void close (ClosePoint closePoint=ClosePoint::AFTER_DRAINING_CURRENT_BUFFER)=0
 

Detailed Description

A class that provides functionality to read data from an Attachment.

Member Enumeration Documentation

◆ ClosePoint

An enum class to indicate when the read() function should stop returning data after a call to close().

Enumerator
IMMEDIATELY 

Stop returning data immediately after the close() call.

AFTER_DRAINING_CURRENT_BUFFER 

Stop returning data when all of the data in the buffer at the time close() was called has been read.

◆ ReadStatus

An enum class to communicate the possible states following a read() call.

Enumerator
OK 

Things are ok.

OK_WOULDBLOCK 

On a request for n bytes, less than n bytes were available on a non-blocking read.

OK_TIMEDOUT 

On a request for n bytes, less than n bytes were available on a blocking read.

OK_OVERRUN_RESET 

The writer has overwritten the new data on reader's current position. Reader position is reset to current writer position.

CLOSED 

The underlying data representation is no longer readable.

ERROR_OVERRUN 

The writer has corrupted the reader data. The attachment is no longer valid.

ERROR_BYTES_LESS_THAN_WORD_SIZE 

The number of bytes in the request is smaller than the word-size of the underlying data representation.

ERROR_INTERNAL 

A non-specified error occurred.

Constructor & Destructor Documentation

◆ ~AttachmentReader()

virtual alexaClientSDK::avsCommon::avs::attachment::AttachmentReader::~AttachmentReader ( )
virtualdefault

Member Function Documentation

◆ close()

virtual void alexaClientSDK::avsCommon::avs::attachment::AttachmentReader::close ( ClosePoint  closePoint = ClosePoint::AFTER_DRAINING_CURRENT_BUFFER)
pure virtual

The close function. An implementation will take care of any resource management when a reader no longer needs to use an attachment.

Parameters
closePointThe point at which the reader should stop reading from the attachment.

Implemented in alexaClientSDK::mediaPlayer::test::MockAttachmentReader, alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader, and alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >.

◆ getNumUnreadBytes()

virtual uint64_t alexaClientSDK::avsCommon::avs::attachment::AttachmentReader::getNumUnreadBytes ( )
pure virtual

Utility function to return the number of bytes in an attachment.

Returns
Number of unread bytes in the attachment by this attachment reader.

Implemented in alexaClientSDK::mediaPlayer::test::MockAttachmentReader, alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader, and alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >.

◆ read()

virtual std::size_t alexaClientSDK::avsCommon::avs::attachment::AttachmentReader::read ( void *  buf,
std::size_t  numBytes,
ReadStatus readStatus,
std::chrono::milliseconds  timeoutMs = std::chrono::milliseconds(0) 
)
pure virtual

The read function.

Parameters
bufThe buffer where data should be copied to.
numBytesThe size of the buffer in bytes.
[out]readStatusThe out-parameter where the resulting state of the read will be expressed.
timeoutMsThe timeout for this read call in milliseconds. This value is only used for the BLOCKING reader policy. If this parameter is zero, there is no timeout and blocking reads will wait forever.
Returns
The number of bytes read as a result of this call.

Implemented in alexaClientSDK::mediaPlayer::test::MockAttachmentReader, alexaClientSDK::mediaPlayer::android::test::MockAttachmentReader, alexaClientSDK::mediaPlayer::android::test::MockEmptyAttachmentReader, alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader, alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >, and alexaClientSDK::mediaPlayer::android::test::MockAttachmentReader.

◆ seek()

virtual bool alexaClientSDK::avsCommon::avs::attachment::AttachmentReader::seek ( uint64_t  offset)
pure virtual

The seek function.

Parameters
offsetThe offset to seek to within the Attachment.
Returns
true if the specified position points at unexpired data, or false otherwise. Note that it is valid to seek into a future index that has not been written to yet.

Implemented in alexaClientSDK::mediaPlayer::test::MockAttachmentReader, alexaClientSDK::avsCommon::avs::attachment::InProcessAttachmentReader, and alexaClientSDK::avsCommon::avs::attachment::DefaultAttachmentReader< SDSType >.


The documentation for this class was generated from the following file:

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