media cache: Add a core API and facade for a backend agnostic media cache

This patch adds a new API to the Asterisk core that acts as a media
cache. The core API itself is mostly a thin wrapper around some bucket
API provided implementation that itself acts as the mechanism of
retrieval for media. The media cache API in the core provides the
following:
 * A very thin in-memory cache of the active bucket_file items. Unlike a
   more traditional cache, it provides no expiration mechanisms. Most
   queries that hit the in-memory cache will also call into the bucket
   implementations as well. The bucket implementations are responsible
   for determining whether or not the active record is active and valid.
   This makes sense for the most likely implementation of a media cache
   backend, i.e., HTTP. The HTTP layer itself is the actual arbiter of
   whether or not a record is truly active; as such, the in-memory cache
   in the core has to defer to it.
 * The ability to create new items in the media cache from local
   resources. This allows for re-creation of items in the cache on
   restart.
 * Synchronization of items in the media cache to the AstDB. This
   also includes various pieces of important metadata.

The API provides sufficient access that higher level APIs, such as the
file or app APIs, do not have to worry about the semantics of the bucket
APIs when needing to playback a resource.

In addition, this patch provides unit tests for the media cache API. The
unit tests use a fake bucket backend to verify correctness.

Change-Id: I11227abbf14d8929eeb140ddd101dd5c3820391e
This commit is contained in:
Matthew Jordan
2015-01-29 14:38:23 +00:00
committed by Matt Jordan
parent 887945d410
commit 3ea0d38396
6 changed files with 1094 additions and 3 deletions

View File

@@ -248,6 +248,7 @@ int daemon(int, int); /* defined in libresolv of all places */
#include "asterisk/endpoints.h"
#include "asterisk/codec.h"
#include "asterisk/format_cache.h"
#include "asterisk/media_cache.h"
#include "../defaults.h"
@@ -4606,6 +4607,16 @@ int main(int argc, char *argv[])
exit(moduleresult == -2 ? 2 : 1);
}
/*
* This has to load after the dynamic modules load, as items in the media
* cache can't be constructed from items in the AstDB without their
* bucket backends.
*/
if (ast_media_cache_init()) {
printf("Failed: ast_media_cache_init\n%s", term_quit());
exit(1);
}
/* loads the cli_permissoins.conf file needed to implement cli restrictions. */
ast_cli_perms_init(0);