libgpac
Documentation of the core library of GPAC
DownloaderCache

HTTP Downloader Cache. More...

+ Collaboration diagram for DownloaderCache:

Typedefs

typedef struct __DownloadedCacheEntryStruct * DownloadedCacheEntry
 
typedef struct __CacheReaderStruct * GF_CacheReader
 

Functions

GF_Err gf_cache_delete_entry (const DownloadedCacheEntry entry)
 
const char * gf_cache_get_etag_on_server (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_set_etag_on_disk (const DownloadedCacheEntry entry, const char *eTag)
 
GF_Err gf_cache_set_etag_on_server (const DownloadedCacheEntry entry, const char *eTag)
 
const char * gf_cache_get_mime_type (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_set_mime_type (const DownloadedCacheEntry entry, const char *mime_type)
 
const char * gf_cache_get_url (const DownloadedCacheEntry entry)
 
Bool gf_cache_can_be_cached (const DownloadedCacheEntry entry)
 
const char * gf_cache_get_last_modified_on_server (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_set_last_modified_on_disk (const DownloadedCacheEntry entry, const char *newLastModified)
 
GF_Err gf_cache_set_last_modified_on_server (const DownloadedCacheEntry entry, const char *newLastModified)
 
const char * gf_cache_get_cache_filename (const DownloadedCacheEntry entry)
 
u32 gf_cache_get_cache_filesize (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_flush_disk_cache (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_set_content_length (const DownloadedCacheEntry entry, u32 length)
 
u32 gf_cache_get_content_length (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_get_http_headers (const DownloadedCacheEntry entry, const char **etag, const char **last_modif)
 
u64 gf_cache_get_size (const char *directory)
 
GF_Err gf_cache_delete_all_cached_files (const char *directory)
 
Bool gf_cache_check_if_cache_file_is_corrupted (const DownloadedCacheEntry entry)
 
void gf_cache_entry_set_delete_files_when_deleted (const DownloadedCacheEntry entry)
 
Bool gf_cache_entry_is_delete_files_when_deleted (const DownloadedCacheEntry entry)
 
u32 gf_cache_get_sessions_count_for_cache_entry (const DownloadedCacheEntry entry)
 
u64 gf_cache_get_start_range (const DownloadedCacheEntry entry)
 
u64 gf_cache_get_end_range (const DownloadedCacheEntry entry)
 
Bool gf_cache_are_headers_processed (const DownloadedCacheEntry entry)
 
GF_Err gf_cache_set_headers_processed (const DownloadedCacheEntry entry)
 

Detailed Description

This section documents the file HTTP caching tools the GPAC framework.

Typedef Documentation

◆ DownloadedCacheEntry

typedef struct __DownloadedCacheEntryStruct* DownloadedCacheEntry

Handle for Cache Entries. You can use the gf_cache_get_* functions to get the cache properties

◆ GF_CacheReader

typedef struct __CacheReaderStruct* GF_CacheReader

cache object

Function Documentation

◆ gf_cache_delete_entry()

GF_Err gf_cache_delete_entry ( const DownloadedCacheEntry  entry)

Free The DownloadedCacheEntry handle

Parameters
entryThe entry to delete
Returns
GF_OK

◆ gf_cache_get_etag_on_server()

const char* gf_cache_get_etag_on_server ( const DownloadedCacheEntry  entry)

Get the ETag associated with this cache entry if any

Parameters
entryThe entry
Returns
The ETag if any was defined, NULL otherwise

◆ gf_cache_set_etag_on_disk()

GF_Err gf_cache_set_etag_on_disk ( const DownloadedCacheEntry  entry,
const char *  eTag 
)

Set the eTag in the cache. Data is duplicated, so original string can be freed by caller.

Parameters
entryThe entry
eTagThe eTag to set
Returns
GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise

◆ gf_cache_set_etag_on_server()

GF_Err gf_cache_set_etag_on_server ( const DownloadedCacheEntry  entry,
const char *  eTag 
)

Set the eTag in the cache. Data is duplicated, so original string can be freed by caller.

Parameters
entryThe entry
eTagThe eTag to set
Returns
GF_OK if entry and eTag are valid, GF_BAD_PARAM otherwise

◆ gf_cache_get_mime_type()

const char* gf_cache_get_mime_type ( const DownloadedCacheEntry  entry)

Get the Mime-Type associated with this cache entry.

Parameters
entryThe entry
Returns
The Mime-Type (never NULL if entry is valid)

◆ gf_cache_set_mime_type()

GF_Err gf_cache_set_mime_type ( const DownloadedCacheEntry  entry,
const char *  mime_type 
)

Set the Mime-Type in the cache. Data is duplicated, so original string can be freed by caller.

Parameters
entryThe entry
mime_typeThe mime-type to set
Returns
GF_OK if entry and mime-type are valid, GF_BAD_PARAM otherwise

◆ gf_cache_get_url()

const char* gf_cache_get_url ( const DownloadedCacheEntry  entry)

Get the URL associated with this cache entry.

Parameters
entryThe entry
Returns
The Hash key (never NULL if entry is valid)

◆ gf_cache_can_be_cached()

Bool gf_cache_can_be_cached ( const DownloadedCacheEntry  entry)

Tells whether a cache entry should be cached safely (no

Parameters
entryThe entry
Returns
1 if entry should be cached

◆ gf_cache_get_last_modified_on_server()

const char* gf_cache_get_last_modified_on_server ( const DownloadedCacheEntry  entry)

Get the Last-Modified information associated with this cache entry.

Parameters
entryThe entry
Returns
The Last-Modified header (can be NULL)

◆ gf_cache_set_last_modified_on_disk()

GF_Err gf_cache_set_last_modified_on_disk ( const DownloadedCacheEntry  entry,
const char *  newLastModified 
)

Set the Last-Modified header for this cache entry

Parameters
entryThe entry
newLastModifiedThe new value to set, will be duplicated
Returns
GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL

◆ gf_cache_set_last_modified_on_server()

GF_Err gf_cache_set_last_modified_on_server ( const DownloadedCacheEntry  entry,
const char *  newLastModified 
)

Set the Last-Modified header for this cache entry

Parameters
entryThe entry
newLastModifiedThe new value to set, will be duplicated
Returns
GF_OK if everything went alright, GF_BAD_PARAM if entry is NULL

◆ gf_cache_get_cache_filename()

const char* gf_cache_get_cache_filename ( const DownloadedCacheEntry  entry)

Get the file name of cache associated with this cache entry.

Parameters
entryThe entry
Returns
The Cache file (never NULL if entry is valid)

◆ gf_cache_get_cache_filesize()

u32 gf_cache_get_cache_filesize ( const DownloadedCacheEntry  entry)

Get the real file size of the cache entry

Parameters
entryThe entry
Returns
the file size

◆ gf_cache_flush_disk_cache()

GF_Err gf_cache_flush_disk_cache ( const DownloadedCacheEntry  entry)

Flushes The disk cache for this entry (by persisting the property file

Parameters
entryThe entry
Returns
error if any

◆ gf_cache_set_content_length()

GF_Err gf_cache_set_content_length ( const DownloadedCacheEntry  entry,
u32  length 
)

Set content length of resource

Parameters
entryThe entry
lengthsize of the content in bytes
Returns
error if any

◆ gf_cache_get_content_length()

u32 gf_cache_get_content_length ( const DownloadedCacheEntry  entry)

Get content length of resource

Parameters
entryThe entry
Returns
size of the content in bytes

◆ gf_cache_get_http_headers()

GF_Err gf_cache_get_http_headers ( const DownloadedCacheEntry  entry,
const char **  etag,
const char **  last_modif 
)

Get directives headers associated with the cache

Parameters
entryThe entry of cache to use
etagset to etag value or NULL if no cache
last_modifset to last modif value or NULL if no cache
Returns
GF_OK if everything went fine, GF_BAD_PARAM if parameters are wrong

◆ gf_cache_get_size()

u64 gf_cache_get_size ( const char *  directory)

Computes the size of the cache elements in directory

Parameters
directorycontaining cache files
Returns
size in bytes

◆ gf_cache_delete_all_cached_files()

GF_Err gf_cache_delete_all_cached_files ( const char *  directory)

Delete all cached files in given directory starting with startpattern

Parameters
directoryto clean up
Returns
GF_OK if everything went fine

◆ gf_cache_check_if_cache_file_is_corrupted()

Bool gf_cache_check_if_cache_file_is_corrupted ( const DownloadedCacheEntry  entry)

Check if a given cache entry is corrupted (incomplete)

Parameters
entryThe entry
Returns
GF_TRUE if resource is corrupted

◆ gf_cache_entry_set_delete_files_when_deleted()

void gf_cache_entry_set_delete_files_when_deleted ( const DownloadedCacheEntry  entry)

Mark associated files as "to be deleted" when the cache entry is removed

Parameters
entryThe entry

◆ gf_cache_entry_is_delete_files_when_deleted()

Bool gf_cache_entry_is_delete_files_when_deleted ( const DownloadedCacheEntry  entry)

Check if associated files is marked as "to be deleted" when the cache entry is removed

Parameters
entryThe entry
Returns
GF_TRUE if cache entry is flaged as "to be deleted"

◆ gf_cache_get_sessions_count_for_cache_entry()

u32 gf_cache_get_sessions_count_for_cache_entry ( const DownloadedCacheEntry  entry)

Get the number of sessions for a cache entry

Parameters
entryThe entry
Returns
the number of sessions using this cache entry

◆ gf_cache_get_start_range()

u64 gf_cache_get_start_range ( const DownloadedCacheEntry  entry)

Get the start range of a cache entry

Parameters
entryThe entry
Returns
the start range in bytes

◆ gf_cache_get_end_range()

u64 gf_cache_get_end_range ( const DownloadedCacheEntry  entry)

Get the end range of a cache entry

Parameters
entryThe entry
Returns
the end range in bytes

◆ gf_cache_are_headers_processed()

Bool gf_cache_are_headers_processed ( const DownloadedCacheEntry  entry)

Check if the entry is marked as "headers processed" (reply headers have been parsed)

Parameters
entryThe entry
Returns
GF_TRUE if the entry is marked

◆ gf_cache_set_headers_processed()

GF_Err gf_cache_set_headers_processed ( const DownloadedCacheEntry  entry)

Mark the entry as "headers processed"

Parameters
entryThe entry
Returns
error if any