AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Public Member Functions | Public Attributes | List of all members
alexaClientSDK::mediaPlayer::test::MockAttachmentReader Class Reference
Inheritance diagram for alexaClientSDK::mediaPlayer::test::MockAttachmentReader:
Inheritance graph
Collaboration diagram for alexaClientSDK::mediaPlayer::test::MockAttachmentReader:
Collaboration graph

Public Member Functions

 MockAttachmentReader (int iterations=1, std::vector< size_t > receiveSizes={std::numeric_limits< size_t >::max()})
size_t read (void *buf, std::size_t numBytes, ReadStatus *readStatus, std::chrono::milliseconds timeoutMs) override
void close (ClosePoint closePoint) override
bool seek (uint64_t offset) override
uint64_t getNumUnreadBytes () override
size_t receiveBytes (char *buf, std::size_t size)
- Public Member Functions inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentReader
virtual ~AttachmentReader ()=default

Public Attributes

int m_iterationsLeft
 The number of iterations of reading the input file that are left before this reader returns closed. More...
std::vector< size_t > m_receiveTotals
std::chrono::steady_clock::time_point m_startTime
 The start of time for reading from this AttachmentReader. More...
size_t m_totalRead
 The number of bytes returned so far by read(). More...
std::unique_ptr< std::ifstream > m_stream
 The current ifstream (if any) from which to read the attachment. More...

Additional Inherited Members

- Public Types inherited from alexaClientSDK::avsCommon::avs::attachment::AttachmentReader
enum  ReadStatus {
  ReadStatus::OK, ReadStatus::OK_WOULDBLOCK, ReadStatus::OK_TIMEDOUT, ReadStatus::OK_OVERRUN_RESET,
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...

Detailed Description

Mock AttachmentReader.

Constructor & Destructor Documentation

◆ MockAttachmentReader()

alexaClientSDK::mediaPlayer::test::MockAttachmentReader::MockAttachmentReader ( int  iterations = 1,
std::vector< size_t >  receiveSizes = {std::numeric_limits<size_t>::max()} 


iterationsThe number of times this AttachmentReader will (re)read the input file before read will return a CLOSED status.
receiveSizesAn vector of sizes (in bytes) that this AttachmentReceiver will simulate receiving. Each successive element in the vector corresponds to a successive 100 millisecond interval starting from the time this MockAttachmentReader was created.

Member Function Documentation

◆ close()

void alexaClientSDK::mediaPlayer::test::MockAttachmentReader::close ( ClosePoint  closePoint)

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

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

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ getNumUnreadBytes()

uint64_t alexaClientSDK::mediaPlayer::test::MockAttachmentReader::getNumUnreadBytes ( )

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

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

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ read()

size_t alexaClientSDK::mediaPlayer::test::MockAttachmentReader::read ( void *  buf,
std::size_t  numBytes,
ReadStatus readStatus,
std::chrono::milliseconds  timeoutMs 

The read function.

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.
The number of bytes read as a result of this call.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

◆ receiveBytes()

size_t alexaClientSDK::mediaPlayer::test::MockAttachmentReader::receiveBytes ( char *  buf,
std::size_t  size 

Receive bytes from the test file.

bufThe buffer to receive the bytes.
sizeThe number of bytes to receive.
The number of bytes received.

◆ seek()

bool alexaClientSDK::mediaPlayer::test::MockAttachmentReader::seek ( uint64_t  offset)

The seek function.

offsetThe offset to seek to within the Attachment.
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.

Implements alexaClientSDK::avsCommon::avs::attachment::AttachmentReader.

Member Data Documentation

◆ m_iterationsLeft

int alexaClientSDK::mediaPlayer::test::MockAttachmentReader::m_iterationsLeft

The number of iterations of reading the input file that are left before this reader returns closed.

◆ m_receiveTotals

std::vector<size_t> alexaClientSDK::mediaPlayer::test::MockAttachmentReader::m_receiveTotals

The total number of bytes that are supposed to have been received (and made available) by this AttachmentReader at 100 millisecond increments from m_startTime.

◆ m_startTime

std::chrono::steady_clock::time_point alexaClientSDK::mediaPlayer::test::MockAttachmentReader::m_startTime

The start of time for reading from this AttachmentReader.

◆ m_stream

std::unique_ptr<std::ifstream> alexaClientSDK::mediaPlayer::test::MockAttachmentReader::m_stream

The current ifstream (if any) from which to read the attachment.

◆ m_totalRead

size_t alexaClientSDK::mediaPlayer::test::MockAttachmentReader::m_totalRead

The number of bytes returned so far by read().

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

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