RDK Documentation (Open Sourced RDK Components)
AampCacheHandler Class Reference

Handles Aamp Cahe operations. More...

#include <AampCacheHandler.h>

Collaboration diagram for AampCacheHandler:
Collaboration graph

Public Member Functions

 AampCacheHandler (AampLogManager *logObj)
 Default Constructor.
 
 ~AampCacheHandler ()
 Destructor Function.
 
void StartPlaylistCache ()
 Start playlist caching. More...
 
void StopPlaylistCache ()
 Stop playlist caching. More...
 
void InsertToPlaylistCache (const std::string url, const GrowableBuffer *buffer, std::string effectiveUrl, bool trackLiveStatus, MediaType fileType=eMEDIATYPE_DEFAULT)
 Retrieve playlist from cache
More...
 
bool RetrieveFromPlaylistCache (const std::string url, GrowableBuffer *buffer, std::string &effectiveUrl)
 Retrieve playlist from cache. More...
 
void RemoveFromPlaylistCache (const std::string url)
 Remove specific playlist cache. More...
 
void SetMaxPlaylistCacheSize (int maxPlaylistCacheSz)
 SetMaxPlaylistCacheSize - Set Max Cache Size. More...
 
int GetMaxPlaylistCacheSize ()
 
bool IsUrlCached (std::string)
 IsUrlCached - Check if URL is already cached. More...
 
void InsertToInitFragCache (const std::string url, const GrowableBuffer *buffer, std::string effectiveUrl, MediaType fileType)
 Insert init fragment into cache table. More...
 
bool RetrieveFromInitFragCache (const std::string url, GrowableBuffer *buffer, std::string &effectiveUrl)
 Retrieve init fragment from cache. More...
 
void SetMaxInitFragCacheSize (int maxInitFragCacheSz)
 SetMaxInitFragCacheSize - Set Max Cache Size. More...
 
int GetMaxInitFragCacheSize ()
 GetMaxPlaylistCacheSize - Get present CacheSize. More...
 
 AampCacheHandler (const AampCacheHandler &)=delete
 Copy constructor disabled. More...
 
AampCacheHandleroperator= (const AampCacheHandler &)=delete
 assignment operator disabled More...
 

Private Types

typedef std::unordered_map< std::string, PlayListCachedData * > PlaylistCache
 
typedef std::unordered_map< std::string, PlayListCachedData * >::iterator PlaylistCacheIter
 
typedef std::unordered_map< std::string, InitFragCacheStruct * > InitFragCache
 
typedef std::unordered_map< std::string, InitFragCacheStruct * >::iterator InitFragCacheIter
 
typedef std::unordered_map< MediaType, InitFragTrackStruct *, std::hash< int > > CacheTrackQueue
 
typedef std::unordered_map< MediaType, InitFragTrackStruct *, std::hash< int > >::iterator CacheTrackQueueIter
 

Private Member Functions

void Init ()
 Initialization Function.
 
void ClearCacheHandler ()
 Clear Cache Handler. Exit clean up thread.
 
void AsyncCacheCleanUpTask ()
 Thread function for Async Cache clean. More...
 
void ClearPlaylistCache ()
 Clear playlist cache. More...
 
bool AllocatePlaylistCacheSlot (MediaType fileType, size_t newLen)
 AllocatePlaylistCacheSlot Allocate Slot for adding new playlist. More...
 
void ClearInitFragCache ()
 Clear init fragment cache & track queue table. More...
 
void RemoveInitFragCacheEntry (MediaType fileType)
 Removes very first inserted entry ( and duplicate entry, if present) of given filetype from fragment cache table in FIFO order, also removes the corresponding url from track queue. More...
 

Static Private Member Functions

static void * AampCacheThreadFunction (void *This)
 Thread entry function. More...
 

Private Attributes

PlaylistCache mPlaylistCache
 
int mCacheStoredSize
 
bool mInitialized
 
bool mCacheActive
 
bool mAsyncCacheCleanUpThread
 
bool mAsyncThreadStartedFlag
 
int mMaxPlaylistCacheSize
 
pthread_mutex_t mMutex
 
pthread_mutex_t mCondVarMutex
 
pthread_cond_t mCondVar
 
pthread_t mAsyncCleanUpTaskThreadId
 
AampLogManagermLogObj
 
InitFragCache umInitFragCache
 
CacheTrackQueue umCacheTrackQ
 
pthread_mutex_t mInitFragMutex
 
bool bInitFragCache
 
int MaxInitCacheSlot
 

yes

Handles Aamp Cahe operations.

Definition at line 110 of file AampCacheHandler.h.

Constructor & Destructor Documentation

◆ AampCacheHandler()

AampCacheHandler::AampCacheHandler ( const AampCacheHandler )
delete

Copy constructor disabled.

Member Function Documentation

◆ AsyncCacheCleanUpTask()

AampCacheHandler::AsyncCacheCleanUpTask ( )
private

Thread function for Async Cache clean.

Returns
void

Definition at line 369 of file AampCacheHandler.cpp.

◆ AampCacheThreadFunction()

static void* AampCacheHandler::AampCacheThreadFunction ( void *  This)
inlinestaticprivate

Thread entry function.

Returns
void

Definition at line 161 of file AampCacheHandler.h.

◆ ClearPlaylistCache()

AampCacheHandler::ClearPlaylistCache ( )
private

Clear playlist cache.

Returns
void

Definition at line 168 of file AampCacheHandler.cpp.

◆ AllocatePlaylistCacheSlot()

AampCacheHandler::AllocatePlaylistCacheSlot ( MediaType  fileType,
size_t  newLen 
)
private

AllocatePlaylistCacheSlot Allocate Slot for adding new playlist.

Parameters
[in]fileType- Indicate the type of playlist to store/remove
[in]newLen- Size required to store new playlist
Returns
bool Success or Failure

Definition at line 189 of file AampCacheHandler.cpp.

◆ ClearInitFragCache()

AampCacheHandler::ClearInitFragCache ( )
private

Clear init fragment cache & track queue table.

Returns
void

Definition at line 587 of file AampCacheHandler.cpp.

◆ RemoveInitFragCacheEntry()

AampCacheHandler::RemoveInitFragCacheEntry ( MediaType  fileType)
private

Removes very first inserted entry ( and duplicate entry, if present) of given filetype from fragment cache table in FIFO order, also removes the corresponding url from track queue.

Parameters
fileTypetype of file format to be removed from cache table
Returns
void

Definition at line 538 of file AampCacheHandler.cpp.

◆ StartPlaylistCache()

void AampCacheHandler::StartPlaylistCache ( )

Start playlist caching.

Returns
void

Definition at line 347 of file AampCacheHandler.cpp.

◆ StopPlaylistCache()

void AampCacheHandler::StopPlaylistCache ( )

Stop playlist caching.

Returns
void

Definition at line 358 of file AampCacheHandler.cpp.

◆ InsertToPlaylistCache()

void AampCacheHandler::InsertToPlaylistCache ( const std::string  url,
const GrowableBuffer buffer,
std::string  effectiveUrl,
bool  trackLiveStatus,
MediaType  fileType = eMEDIATYPE_DEFAULT 
)

Retrieve playlist from cache

Parameters
[in]url- URL
[in]buffer- Pointer to growable buffer
[in]effectiveUrl- Final URL
[in]trackLiveStatus- Live Status of the track inserted
[in]fileType- Type of the file inserted
Returns
void

Definition at line 31 of file AampCacheHandler.cpp.

◆ RetrieveFromPlaylistCache()

bool AampCacheHandler::RetrieveFromPlaylistCache ( const std::string  url,
GrowableBuffer buffer,
std::string &  effectiveUrl 
)

Retrieve playlist from cache.

Parameters
[in]url- URL
[out]buffer- Pointer to growable buffer
[out]effectiveUrl- Final URL
Returns
true: found, false: not found

Definition at line 111 of file AampCacheHandler.cpp.

◆ RemoveFromPlaylistCache()

void AampCacheHandler::RemoveFromPlaylistCache ( const std::string  url)

Remove specific playlist cache.

Parameters
[in]url- URL

Definition at line 141 of file AampCacheHandler.cpp.

◆ SetMaxPlaylistCacheSize()

void AampCacheHandler::SetMaxPlaylistCacheSize ( int  maxPlaylistCacheSz)

SetMaxPlaylistCacheSize - Set Max Cache Size.

Parameters
[in]maxPlaylistCacheSz- CacheSize
Returns
None

Definition at line 396 of file AampCacheHandler.cpp.

◆ IsUrlCached()

bool AampCacheHandler::IsUrlCached ( std::string  url)

IsUrlCached - Check if URL is already cached.

Returns
bool - true if file found, else false

Definition at line 407 of file AampCacheHandler.cpp.

◆ InsertToInitFragCache()

AampCacheHandler::InsertToInitFragCache ( const std::string  url,
const GrowableBuffer buffer,
std::string  effectiveUrl,
MediaType  fileType 
)

Insert init fragment into cache table.

Parameters
[in]url- URL
[in]buffer- Pointer to growable buffer
[in]effectiveUrl- Final URL
[in]fileType- Type of the file inserted
Returns
void

Definition at line 423 of file AampCacheHandler.cpp.

◆ RetrieveFromInitFragCache()

AampCacheHandler::RetrieveFromInitFragCache ( const std::string  url,
GrowableBuffer buffer,
std::string &  effectiveUrl 
)

Retrieve init fragment from cache.

Parameters
[in]url- URL
[out]buffer- Pointer to growable buffer
[out]effectiveUrl- Final URL
Returns
true: found, false: not found

Definition at line 506 of file AampCacheHandler.cpp.

◆ SetMaxInitFragCacheSize()

void AampCacheHandler::SetMaxInitFragCacheSize ( int  maxInitFragCacheSz)

SetMaxInitFragCacheSize - Set Max Cache Size.

Parameters
[in]maxInitFragCacheSz- CacheSize
Returns
None

Definition at line 618 of file AampCacheHandler.cpp.

◆ GetMaxInitFragCacheSize()

int AampCacheHandler::GetMaxInitFragCacheSize ( )
inline

GetMaxPlaylistCacheSize - Get present CacheSize.

Returns
int - maxCacheSize

Definition at line 303 of file AampCacheHandler.h.

◆ operator=()

AampCacheHandler& AampCacheHandler::operator= ( const AampCacheHandler )
delete

assignment operator disabled

Field Documentation

◆ MaxInitCacheSlot

int AampCacheHandler::MaxInitCacheSlot
private

Max no of init fragment per track

Definition at line 136 of file AampCacheHandler.h.


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