From ca14b99e6e7a80f648521ec81512cbadab2ed6cd Mon Sep 17 00:00:00 2001 From: Matt Jordan Date: Sat, 26 Dec 2015 15:29:04 -0600 Subject: 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 --- main/file.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'main/file.c') diff --git a/main/file.c b/main/file.c index f0f826a4f..654937a58 100644 --- a/main/file.c +++ b/main/file.c @@ -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); -- cgit v1.2.3