main/file: Add the ability to play media in the media cache

This patch allows applications/APIs that access media through the core file
APIs to play media in the media cache. Prior to determining if a 'filename'
exists, the filename is passed to the media cache's retrieve API call. If
that call succeeds, the local file specified passed back by the API is
opened for streaming. When used in this fashion, the 'filename' is actually
a URI that the media cache process and understand.

ASTERISK-25654 #close

Change-Id: I73b6e2e90c3e91b8500581c45cdf9c0dc785f5f0
This commit is contained in:
Matt Jordan
2015-12-26 15:29:04 -06:00
committed by Joshua Colp
parent 01962a3932
commit ca14b99e6e
2 changed files with 31 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ ASTERISK_REGISTER_FILE()
#include "asterisk/stasis.h"
#include "asterisk/json.h"
#include "asterisk/stasis_system.h"
#include "asterisk/media_cache.h"
/*! \brief
* The following variable controls the layout of localized sound files.
@@ -644,6 +645,10 @@ static int fileexists_test(const char *filename, const char *fmt, const char *la
return 0;
}
if (!ast_media_cache_retrieve(filename, NULL, buf, buflen)) {
return filehelper(buf, result_cap, NULL, ACTION_EXISTS);
}
if (ast_language_is_prefix && !is_absolute_path(filename)) { /* new layout */
if (lang) {
snprintf(buf, buflen, "%s/%s", lang, filename);