RDK Documentation (Open Sourced RDK Components)
AampCacheHandler.cpp
1 /*
2  * If not stated otherwise in this file or this component's license file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2018 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 /**************************************
21 * @file AampCacheHandler.cpp
22 * @brief Cache handler operations for AAMP
23 **************************************/
24 
25 #include "AampCacheHandler.h"
26 
27 
28 /**
29  * @brief Retrieve playlist from cache
30  */
31 void AampCacheHandler::InsertToPlaylistCache(const std::string url, const GrowableBuffer* buffer, std::string effectiveUrl,bool trackLiveStatus,MediaType fileType)
32 {
33  PlayListCachedData *tmpData,*newtmpData;
34  pthread_mutex_lock(&mMutex);
35 
36  //Initialize AampCacheHandler
37  Init();
38 
39  // First check point , Caching is allowed only if its VOD and for Main Manifest(HLS) for both VOD/Live
40  // For Main manifest , fileType will bypass storing for live content
41  if(trackLiveStatus==false || fileType==eMEDIATYPE_MANIFEST)
42  {
43 
44  PlaylistCacheIter it = mPlaylistCache.find(url);
45  if (it != mPlaylistCache.end())
46  {
47  AAMPLOG_INFO("playlist %s already present in cache", url.c_str());
48  }
49  // insert only if buffer size is less than Max size
50  else
51  {
52  if(fileType==eMEDIATYPE_MANIFEST && mPlaylistCache.size())
53  {
54  // If new Manifest is inserted which is not present in the cache , flush out other playlist files related with old manifest,
56  }
57  // Dont check for CacheSize if Max is configured as unlimited
58  if(mMaxPlaylistCacheSize == PLAYLIST_CACHE_SIZE_UNLIMITED || (mMaxPlaylistCacheSize != PLAYLIST_CACHE_SIZE_UNLIMITED && buffer->len < mMaxPlaylistCacheSize))
59  {
60  // Before inserting into cache, need to check if max cache size will exceed or not on adding new data
61  // if more , need to pop out some from same type of playlist
62  bool cacheStoreReady = true;
63  if(mMaxPlaylistCacheSize != PLAYLIST_CACHE_SIZE_UNLIMITED && ((mCacheStoredSize + buffer->len) > mMaxPlaylistCacheSize))
64  {
65  AAMPLOG_WARN("Count[%lu]Avail[%d]Needed[%zu] Reached max cache size", mPlaylistCache.size(),mCacheStoredSize,buffer->len);
66  cacheStoreReady = AllocatePlaylistCacheSlot(fileType,buffer->len);
67  }
68  if(cacheStoreReady)
69  {
70  tmpData = new PlayListCachedData();
71  tmpData->mCachedBuffer = new GrowableBuffer();
72  memset (tmpData->mCachedBuffer, 0, sizeof(GrowableBuffer));
73  aamp_AppendBytes(tmpData->mCachedBuffer, buffer->ptr, buffer->len );
74 
75  tmpData->mEffectiveUrl = effectiveUrl;
76  tmpData->mFileType = fileType;
77  mPlaylistCache[url] = tmpData;
78  mCacheStoredSize += buffer->len;
79  AAMPLOG_INFO("Inserted. url %s", url.c_str());
80  // There are cases where Main url and effective url will be different ( for Main manifest)
81  // Need to store both the entries with same content data
82  // When retune happens within aamp due to failure , effective url wll be asked to read from cached manifest
83  // When retune happens from JS , regular Main url will be asked to read from cached manifest.
84  // So need to have two entries in cache table but both pointing to same CachedBuffer (no space is consumed for storage)
85  {
86  // if n only there is diff in url , need to store both
87  if(url != effectiveUrl)
88  {
89  newtmpData = new PlayListCachedData();
90  // Not to allocate for Cachebuffer again , use the same buffer as above
91  newtmpData->mCachedBuffer = tmpData->mCachedBuffer;
92  newtmpData->mEffectiveUrl = effectiveUrl;
93  // This is a duplicate entry
94  newtmpData->mDuplicateEntry = true;
95  newtmpData->mFileType = fileType;
96  mPlaylistCache[effectiveUrl] = newtmpData;
97  AAMPLOG_INFO("Added an effective url entry %s", effectiveUrl.c_str());
98  }
99  }
100  }
101  }
102  }
103  }
104  pthread_mutex_unlock(&mMutex);
105 }
106 
107 
108 /**
109  * @brief Retrieve playlist from cache
110  */
111 bool AampCacheHandler::RetrieveFromPlaylistCache(const std::string url, GrowableBuffer* buffer, std::string& effectiveUrl)
112 {
113  GrowableBuffer* buf = NULL;
114  bool ret;
115  std::string eUrl;
116  pthread_mutex_lock(&mMutex);
117  PlaylistCacheIter it = mPlaylistCache.find(url);
118  if (it != mPlaylistCache.end())
119  {
120  PlayListCachedData *tmpData = it->second;
121  buf = tmpData->mCachedBuffer;
122  eUrl = tmpData->mEffectiveUrl;
123  buffer->len = 0;
124  aamp_AppendBytes(buffer, buf->ptr, buf->len );
125  effectiveUrl = eUrl;
126  AAMPLOG_TRACE("url %s found", url.c_str());
127  ret = true;
128  }
129  else
130  {
131  AAMPLOG_TRACE("url %s not found", url.c_str());
132  ret = false;
133  }
134  pthread_mutex_unlock(&mMutex);
135  return ret;
136 }
137 
138 /**
139  * @brief Remove specific playlist cache
140  */
141 void AampCacheHandler::RemoveFromPlaylistCache(const std::string url)
142 {
143  pthread_mutex_lock(&mMutex);
144  PlaylistCacheIter it = mPlaylistCache.find(url);
145  if (it != mPlaylistCache.end())
146  {
147  PlayListCachedData *tmpData = it->second;
148  if(!tmpData->mDuplicateEntry)
149  {
150  aamp_Free(tmpData->mCachedBuffer);
151  SAFE_DELETE(tmpData->mCachedBuffer);
152  }
153  SAFE_DELETE(tmpData);
154 
155  AAMPLOG_INFO("Removing Playlist URL %s from Cache", it->first.c_str());
156  mPlaylistCache.erase(it);
157  }
158  else
159  {
160  AAMPLOG_WARN("Playlist URL %s not found in cache", url.c_str());
161  }
162  pthread_mutex_unlock(&mMutex);
163 }
164 
165 /**
166  * @brief Clear playlist cache
167  */
169 {
170  AAMPLOG_INFO("cache size %d", (int)mPlaylistCache.size());
171  PlaylistCacheIter it = mPlaylistCache.begin();
172  for (;it != mPlaylistCache.end(); it++)
173  {
174  PlayListCachedData *tmpData = it->second;
175  if(!tmpData->mDuplicateEntry)
176  {
177  aamp_Free(tmpData->mCachedBuffer);
178  SAFE_DELETE(tmpData->mCachedBuffer);
179  }
180  SAFE_DELETE(tmpData);
181  }
182  mCacheStoredSize = 0;
183  mPlaylistCache.clear();
184 }
185 
186 /**
187  * @brief AllocatePlaylistCacheSlot Allocate Slot for adding new playlist
188  */
190 {
191  bool retVal = true;
192  size_t freedSize=0;
193  if(mPlaylistCache.size())
194  {
195  if(fileType == eMEDIATYPE_MANIFEST)
196  {
197  // This case cannot happen, but for safety need to handle.
198  // If for any reason Main Manifest is pushed after cache is full , better clear all the playlist cached .
199  // As per new Main Manifest ,new playlist files need to be downloaded and cached
201  }
202  else // for non main manifest
203  {
204  PlaylistCacheIter Iter = mPlaylistCache.begin();
205  // Two pass to remove the item from cache to create space for caching
206  // First pass : Search for same file type to clean, If Video need to be inserted , free another Video type
207  // if audio type to be inserted , remove older audio type . Same for iframe .
208  // Second pass : Even after removing same file type entry ,still not enough space to add new item then remove from other file type ( rare scenario)
209  while(Iter != mPlaylistCache.end())
210  {
211  PlayListCachedData *tmpData = Iter->second;
212  if(tmpData->mFileType == eMEDIATYPE_MANIFEST || tmpData->mFileType != fileType)
213  { // Not to remove main manifest file and filetype which are different
214  Iter++;
215  continue;
216  }
217  if(!tmpData->mDuplicateEntry)
218  {
219  freedSize += tmpData->mCachedBuffer->len;
220  aamp_Free(tmpData->mCachedBuffer);
221  SAFE_DELETE(tmpData->mCachedBuffer);
222  }
223  SAFE_DELETE(tmpData);
224  Iter = mPlaylistCache.erase(Iter);
225  }
226  //Second Pass - if still more cleanup required for space, remove from other playlist types
227  if(freedSize < newLen)
228  {
229  Iter = mPlaylistCache.begin();
230  while(Iter != mPlaylistCache.end())
231  {
232  PlayListCachedData *tmpData = Iter->second;
233  if(tmpData->mFileType == eMEDIATYPE_MANIFEST)
234  { // Not to remove main manifest file
235  Iter++;
236  continue;
237  }
238  if(!tmpData->mDuplicateEntry)
239  {
240  freedSize += tmpData->mCachedBuffer->len;
241  aamp_Free(tmpData->mCachedBuffer);
242  SAFE_DELETE(tmpData->mCachedBuffer);
243  }
244  SAFE_DELETE(tmpData);
245  Iter = mPlaylistCache.erase(Iter);
246  }
247  }
248  mCacheStoredSize -= freedSize;
249  // After all freeing still size is not enough to insert , better not allow to insert such huge file
250  if(freedSize < newLen)
251  retVal = false;
252  }
253  }
254  return retVal;
255 }
256 
257 
258 /**
259  * @brief Initialization Function
260  */
262 {
263  //Check if already initialized
264  if(true == mInitialized)
265  return;
266  if(0 != pthread_create(&mAsyncCleanUpTaskThreadId, NULL, &AampCacheThreadFunction, this))
267  {
268  AAMPLOG_ERR("Failed to create AampCacheHandler thread errno = %d, %s", errno, strerror(errno));
269  }
270  else
271  {
272  pthread_mutex_lock(&mCondVarMutex);
273  mAsyncThreadStartedFlag = true;
274  mAsyncCacheCleanUpThread = true;
275  pthread_mutex_unlock(&mCondVarMutex); //CID:168111 - Missing lock
276  }
277  mInitialized = true;
278 }
279 
280 /**
281  * @brief Clear Cache Handler. Exit clean up thread.
282  */
284 {
285  //Check if already uninitialized
286  if(false == mInitialized)
287  return;
288 
289  mCacheActive = true;
290  pthread_mutex_lock(&mCondVarMutex);
291  mAsyncCacheCleanUpThread = false;
292  pthread_cond_signal(&mCondVar);
293  pthread_mutex_unlock(&mCondVarMutex);
294  if(mAsyncThreadStartedFlag)
295  {
296  void *ptr = NULL;
297  int rc = pthread_join(mAsyncCleanUpTaskThreadId, &ptr);
298  if (rc != 0)
299  {
300  AAMPLOG_ERR("***pthread_join AsyncCacheCleanUpTask returned %d(%s)", rc, strerror(rc));
301  }
302  mAsyncThreadStartedFlag = false;
303  }
305 
306  //Clear init fragment & track queue
308  mInitialized = false;
309 }
310 
311 /**
312  * @brief Default Constructor
313  */
315  mCacheStoredSize(0),mAsyncThreadStartedFlag(false),mAsyncCleanUpTaskThreadId(0),mCacheActive(false),
316  mAsyncCacheCleanUpThread(false),mMutex(),mCondVarMutex(),mCondVar(),mPlaylistCache()
317  ,mMaxPlaylistCacheSize(MAX_PLAYLIST_CACHE_SIZE*1024),mInitialized(false)
318  ,mLogObj(logObj)
319  ,umInitFragCache(),umCacheTrackQ(),bInitFragCache(false),mInitFragMutex()
320  ,MaxInitCacheSlot(MAX_INIT_FRAGMENT_CACHE_PER_TRACK)
321 {
322  pthread_mutex_init(&mMutex, NULL);
323  pthread_mutex_init(&mCondVarMutex, NULL);
324  pthread_cond_init(&mCondVar, NULL);
325 
326  pthread_mutex_init(&mInitFragMutex, NULL);
327 }
328 
329 
330 /**
331  * @brief Destructor Function
332  */
334 {
335  if(true == mInitialized)
337  pthread_mutex_destroy(&mMutex);
338  pthread_mutex_destroy(&mCondVarMutex);
339  pthread_cond_destroy(&mCondVar);
340 
341  pthread_mutex_destroy(&mInitFragMutex);
342 }
343 
344 /**
345  * @brief Start playlist caching
346  */
348 {
349  mCacheActive = true;
350  pthread_mutex_lock(&mCondVarMutex);
351  pthread_cond_signal(&mCondVar);
352  pthread_mutex_unlock(&mCondVarMutex );
353 }
354 
355 /**
356  * @brief Stop playlist caching
357  */
359 {
360  mCacheActive = false;
361  pthread_mutex_lock(&mCondVarMutex);
362  pthread_cond_signal(&mCondVar);
363  pthread_mutex_unlock(&mCondVarMutex );
364 }
365 
366 /**
367  * @brief Thread function for Async Cache clean
368  */
370 {
371  pthread_mutex_lock(&mCondVarMutex);
372  while (mAsyncCacheCleanUpThread)
373  {
374  pthread_cond_wait(&mCondVar, &mCondVarMutex);
375  if(!mCacheActive)
376  {
377  struct timespec ts;
378  ts = aamp_GetTimespec(10000);
379 
380  if(ETIMEDOUT == pthread_cond_timedwait(&mCondVar, &mCondVarMutex, &ts))
381  {
382  AAMPLOG_INFO("[%p] Cacheflush timed out", this);
384 
385  //Clear init fragment & track queue
387  }
388  }
389  }
390  pthread_mutex_unlock(&mCondVarMutex);
391 }
392 
393 /**
394  * @brief SetMaxPlaylistCacheSize - Set Max Cache Size
395  */
396 void AampCacheHandler::SetMaxPlaylistCacheSize(int maxPlaylistCacheSz)
397 {
398  pthread_mutex_lock(&mMutex);
399  mMaxPlaylistCacheSize = maxPlaylistCacheSz;
400  AAMPLOG_WARN("Setting mMaxPlaylistCacheSize to :%d",maxPlaylistCacheSz);
401  pthread_mutex_unlock(&mMutex);
402 }
403 
404 /**
405  * @brief IsUrlCached - Check if URL is already cached
406  */
407 bool AampCacheHandler::IsUrlCached(std::string url)
408 {
409  bool retval = false;
410  pthread_mutex_lock(&mMutex);
411  PlaylistCacheIter it = mPlaylistCache.find(url);
412  if (it != mPlaylistCache.end())
413  retval = true;
414 
415  pthread_mutex_unlock(&mMutex);
416  return retval;
417 }
418 
419 
420 /**
421  * @brief Insert init fragment into cache table
422  */
423 void AampCacheHandler::InsertToInitFragCache(const std::string url, const GrowableBuffer* buffer,
424  std::string effectiveUrl, MediaType fileType)
425 {
426  InitFragCacheStruct *NewInitData;
427  InitFragTrackStruct *NewTrackQueueCache;
428 
429  pthread_mutex_lock(&mInitFragMutex);
430 
431  InitFragCacheIter Iter = umInitFragCache.find(url);
432  if ( Iter != umInitFragCache.end() )
433  {
434  AAMPLOG_INFO("playlist %s already present in cache", url.c_str());
435  }
436  else
437  {
438  NewInitData = new playlistcacheddata();
439  NewInitData->mCachedBuffer = new GrowableBuffer();
440  memset (NewInitData->mCachedBuffer, 0, sizeof(GrowableBuffer));
441  aamp_AppendBytes(NewInitData->mCachedBuffer, buffer->ptr, buffer->len );
442 
443  NewInitData->mEffectiveUrl = effectiveUrl;
444  NewInitData->mFileType = fileType;
445  NewInitData->mDuplicateEntry = (effectiveUrl.length() && (effectiveUrl!=url));
446 
447  /*
448  * Check if queue created for given track type, if not create a queue
449  * and add a corresponding url into a track queue.
450  */
451  CacheTrackQueueIter IterCq = umCacheTrackQ.find(fileType);
452  if(IterCq == umCacheTrackQ.end())
453  {
454  NewTrackQueueCache = new initfragtrackstruct();
455  NewTrackQueueCache->Trackqueue.push(url);
456 
457  umCacheTrackQ[fileType]=NewTrackQueueCache;
458  }
459  else
460  {
461  NewTrackQueueCache = IterCq->second;
462  NewTrackQueueCache->Trackqueue.push(url);
463  }
464 
465 
466  /*
467  * If track queue of given filetype reached maximum limit, remove the very first
468  * inserted entry & its duplicate entry from cache table.
469  */
470  if ( NewTrackQueueCache->Trackqueue.size() > MaxInitCacheSlot )
471  {
472  RemoveInitFragCacheEntry ( fileType );
473  }
474 
475  umInitFragCache[url] = NewInitData;
476  AAMPLOG_INFO("Inserted init url %s", url.c_str());
477 
478 
479  /*
480  * If current init fragment has any redirected url which is different, that must be
481  * inserted in cache table with same init fragment data of url and which will not inserted in track queue.
482  */
483  if ( NewInitData->mDuplicateEntry )
484  {
485  InitFragCacheStruct *DupInitData;
486  DupInitData = new playlistcacheddata();
487  DupInitData->mCachedBuffer = NewInitData->mCachedBuffer;
488  DupInitData->mEffectiveUrl = effectiveUrl;
489  DupInitData->mFileType = fileType;
490  umInitFragCache[effectiveUrl] = DupInitData;
491 
492  AAMPLOG_INFO("Inserted effective init url %s", url.c_str());
493  }
494 
495  AAMPLOG_INFO("Size [CacheTable:%lu,TrackQ:%lu,CurrentTrack:%lu,MaxLimit:%d]\n", umInitFragCache.size(),umCacheTrackQ.size(),
496  NewTrackQueueCache->Trackqueue.size(),
498  }
499 
500  pthread_mutex_unlock(&mInitFragMutex);
501 }
502 
503 /**
504  * @brief Retrieve init fragment from cache
505  */
507  std::string& effectiveUrl)
508 {
509  GrowableBuffer* buf = NULL;
510  bool ret;
511  std::string eUrl;
512  pthread_mutex_lock(&mInitFragMutex);
513  InitFragCacheIter it = umInitFragCache.find(url);
514  if (it != umInitFragCache.end())
515  {
516  InitFragCacheStruct *findFragData = it->second;
517  buf = findFragData->mCachedBuffer;
518  eUrl = findFragData->mEffectiveUrl;
519  buffer->len = 0;
520  aamp_AppendBytes(buffer, buf->ptr, buf->len );
521  effectiveUrl = eUrl;
522  AAMPLOG_INFO("url %s found", url.c_str());
523  ret = true;
524  }
525  else
526  {
527  AAMPLOG_INFO("url %s not found", url.c_str());
528  ret = false;
529  }
530  pthread_mutex_unlock(&mInitFragMutex);
531  return ret;
532 }
533 
534 /**
535  * @brief Removes very first inserted entry ( and duplicate entry, if present) of given filetype
536  * from fragment cache table in FIFO order, also removes the corresponding url from track queue.
537  */
539 {
540  CacheTrackQueueIter IterCq = umCacheTrackQ.find(fileType);
541  if(IterCq == umCacheTrackQ.end())
542  {
543  return;
544  }
545 
546  InitFragTrackStruct *QueperTrack = IterCq->second;
547 
548  /* Delete data in FIFO order
549  * Get url from Track Queue, which is used to
550  * remove fragment entry from cache table in FIFO order.
551  */
552  InitFragCacheIter Iter = umInitFragCache.find(QueperTrack->Trackqueue.front());
553  if (Iter != umInitFragCache.end())
554  {
555  InitFragCacheStruct *removeCacheData = Iter->second;
556 
557  /* Remove duplicate entry
558  * Check if the first inserted data has any duplicate entry, If so
559  * then delete the duplicat entry as well.
560  */
561  if ( removeCacheData->mDuplicateEntry )
562  {
563  InitFragCacheStruct *dupData;
564  InitFragCacheIter IterDup = umInitFragCache.find(removeCacheData->mEffectiveUrl);
565  if(IterDup != umInitFragCache.end())
566  {
567  dupData = IterDup->second;
568  SAFE_DELETE(dupData);
569  umInitFragCache.erase(IterDup);
570  AAMPLOG_INFO("Removed dup url:%s",removeCacheData->mEffectiveUrl.c_str());
571  }
572  }
573  aamp_Free(removeCacheData->mCachedBuffer);
574  SAFE_DELETE(removeCacheData->mCachedBuffer);
575  SAFE_DELETE(removeCacheData);
576  umInitFragCache.erase(Iter);
577  AAMPLOG_INFO("Removed main url:%s",QueperTrack->Trackqueue.front().c_str());
578 
579  // Remove the url entry from corresponding track queue.
580  QueperTrack->Trackqueue.pop();
581  }
582 }
583 
584 /**
585  * @brief Clear init fragment cache & track queue table
586  */
588 {
589  AAMPLOG_INFO("Fragment cache size %d", (int)umInitFragCache.size());
590  InitFragCacheIter it = umInitFragCache.begin();
591  for (;it != umInitFragCache.end(); it++)
592  {
593  InitFragCacheStruct *delData = it->second;
594  if(!delData->mDuplicateEntry)
595  {
596  aamp_Free(delData->mCachedBuffer);
597  SAFE_DELETE(delData->mCachedBuffer);
598  }
599  SAFE_DELETE(delData);
600  }
601  umInitFragCache.clear();
602 
603  AAMPLOG_INFO("Track queue size %d", (int)umCacheTrackQ.size());
604  CacheTrackQueueIter IterCq = umCacheTrackQ.begin();
605  for (;IterCq != umCacheTrackQ.end(); IterCq++)
606  {
607  InitFragTrackStruct *delTrack = IterCq->second;
608 
609  std::queue<std::string>().swap(delTrack->Trackqueue);
610  SAFE_DELETE(delTrack);
611  }
612  umCacheTrackQ.clear();
613 }
614 
615 /**
616  * @brief SetMaxInitFragCacheSize - Set Max Cache Size
617  */
618 void AampCacheHandler::SetMaxInitFragCacheSize(int maxInitFragCacheSz)
619 {
620  pthread_mutex_lock(&mInitFragMutex);
621  MaxInitCacheSlot = maxInitFragCacheSz;
622  AAMPLOG_WARN("Setting mMaxPlaylistCacheSize to :%d",maxInitFragCacheSz);
623  pthread_mutex_unlock(&mInitFragMutex);
624 }
aamp_Free
void aamp_Free(void *ptr)
wrapper for g_free, used for segment allocation
Definition: AampMemoryUtils.cpp:56
AampCacheHandler::AampCacheHandler
AampCacheHandler(AampLogManager *logObj)
Default Constructor.
Definition: AampCacheHandler.cpp:314
eMEDIATYPE_MANIFEST
@ eMEDIATYPE_MANIFEST
Definition: AampMediaType.h:43
AampCacheHandler::Init
void Init()
Initialization Function.
Definition: AampCacheHandler.cpp:261
AampCacheHandler::InsertToPlaylistCache
void InsertToPlaylistCache(const std::string url, const GrowableBuffer *buffer, std::string effectiveUrl, bool trackLiveStatus, MediaType fileType=eMEDIATYPE_DEFAULT)
Retrieve playlist from cache
Definition: AampCacheHandler.cpp:31
GrowableBuffer::len
size_t len
Definition: AampMemoryUtils.h:42
AampCacheHandler::StartPlaylistCache
void StartPlaylistCache()
Start playlist caching.
Definition: AampCacheHandler.cpp:347
MAX_INIT_FRAGMENT_CACHE_PER_TRACK
#define MAX_INIT_FRAGMENT_CACHE_PER_TRACK
Definition: AampDefine.h:117
AampCacheHandler::AampCacheThreadFunction
static void * AampCacheThreadFunction(void *This)
Thread entry function.
Definition: AampCacheHandler.h:161
AampLogManager
AampLogManager Class.
Definition: AampLogManager.h:150
AampCacheHandler::~AampCacheHandler
~AampCacheHandler()
Destructor Function.
Definition: AampCacheHandler.cpp:333
AampCacheHandler::RetrieveFromInitFragCache
bool RetrieveFromInitFragCache(const std::string url, GrowableBuffer *buffer, std::string &effectiveUrl)
Retrieve init fragment from cache.
Definition: AampCacheHandler.cpp:506
initfragtrackstruct
initfragtrackstruct to store init fragment url per media track in FIFO Queue.
Definition: AampCacheHandler.h:96
AampCacheHandler::RetrieveFromPlaylistCache
bool RetrieveFromPlaylistCache(const std::string url, GrowableBuffer *buffer, std::string &effectiveUrl)
Retrieve playlist from cache.
Definition: AampCacheHandler.cpp:111
MediaType
MediaType
Media types.
Definition: AampMediaType.h:37
AampCacheHandler::IsUrlCached
bool IsUrlCached(std::string)
IsUrlCached - Check if URL is already cached.
Definition: AampCacheHandler.cpp:407
aamp_GetTimespec
struct timespec aamp_GetTimespec(int timeInMs)
To get the timespec.
Definition: AampUtils.cpp:741
AampCacheHandler::MaxInitCacheSlot
int MaxInitCacheSlot
Definition: AampCacheHandler.h:136
AampCacheHandler::RemoveFromPlaylistCache
void RemoveFromPlaylistCache(const std::string url)
Remove specific playlist cache.
Definition: AampCacheHandler.cpp:141
GrowableBuffer::ptr
char * ptr
Definition: AampMemoryUtils.h:41
AampCacheHandler::InsertToInitFragCache
void InsertToInitFragCache(const std::string url, const GrowableBuffer *buffer, std::string effectiveUrl, MediaType fileType)
Insert init fragment into cache table.
Definition: AampCacheHandler.cpp:423
AampCacheHandler.h
Cache handler for AAMP.
AampCacheHandler::StopPlaylistCache
void StopPlaylistCache()
Stop playlist caching.
Definition: AampCacheHandler.cpp:358
playlistcacheddata
PlayListCachedData structure to store playlist data.
Definition: AampCacheHandler.h:38
AAMPLOG_TRACE
#define AAMPLOG_TRACE(FORMAT,...)
AAMP logging defines, this can be enabled through setLogLevel() as per the need.
Definition: AampLogManager.h:83
GrowableBuffer
Structure of GrowableBuffer.
Definition: AampMemoryUtils.h:39
aamp_AppendBytes
void aamp_AppendBytes(struct GrowableBuffer *buffer, const void *ptr, size_t len)
append data to GrowableBuffer ADT
Definition: AampMemoryUtils.cpp:108
AampCacheHandler::ClearCacheHandler
void ClearCacheHandler()
Clear Cache Handler. Exit clean up thread.
Definition: AampCacheHandler.cpp:283
AampCacheHandler::SetMaxInitFragCacheSize
void SetMaxInitFragCacheSize(int maxInitFragCacheSz)
SetMaxInitFragCacheSize - Set Max Cache Size.
Definition: AampCacheHandler.cpp:618
AampCacheHandler::SetMaxPlaylistCacheSize
void SetMaxPlaylistCacheSize(int maxPlaylistCacheSz)
SetMaxPlaylistCacheSize - Set Max Cache Size.
Definition: AampCacheHandler.cpp:396
AampCacheHandler::AllocatePlaylistCacheSlot
bool AllocatePlaylistCacheSlot(MediaType fileType, size_t newLen)
AllocatePlaylistCacheSlot Allocate Slot for adding new playlist.
Definition: AampCacheHandler.cpp:189
MAX_PLAYLIST_CACHE_SIZE
#define MAX_PLAYLIST_CACHE_SIZE
Definition: AampDefine.h:63
AampCacheHandler::ClearPlaylistCache
void ClearPlaylistCache()
Clear playlist cache.
Definition: AampCacheHandler.cpp:168
PlayListCachedData
struct playlistcacheddata PlayListCachedData
PlayListCachedData structure to store playlist data.
AampCacheHandler::RemoveInitFragCacheEntry
void RemoveInitFragCacheEntry(MediaType fileType)
Removes very first inserted entry ( and duplicate entry, if present) of given filetype from fragment ...
Definition: AampCacheHandler.cpp:538
AampCacheHandler::AsyncCacheCleanUpTask
void AsyncCacheCleanUpTask()
Thread function for Async Cache clean.
Definition: AampCacheHandler.cpp:369
AampCacheHandler::ClearInitFragCache
void ClearInitFragCache()
Clear init fragment cache & track queue table.
Definition: AampCacheHandler.cpp:587