Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Functions | Variables
res_http_media_cache.c File Reference
#include "asterisk.h"
#include <curl/curl.h>
#include "asterisk/file.h"
#include "asterisk/module.h"
#include "asterisk/bucket.h"
#include "asterisk/sorcery.h"
#include "asterisk/threadstorage.h"
#include "asterisk/uri.h"

Go to the source code of this file.

Data Structures

struct  conf
 All configuration options for http media cache. More...
 
struct  conf_general_options
 General configuration options for http media cache. More...
 
struct  curl_bucket_file_data
 Data passed to cURL callbacks. More...
 

Macros

#define MAX_HEADER_LENGTH   1023
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static AO2_GLOBAL_OBJ_STATIC (confs)
 Locking container for safe configuration access.
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int bucket_file_always_revalidate (struct ast_bucket_file *bucket_file)
 
static int bucket_file_expired (struct ast_bucket_file *bucket_file)
 
static int bucket_file_run_curl (struct ast_bucket_file *bucket_file)
 
static void bucket_file_set_expiration (struct ast_bucket_file *bucket_file)
 
static void bucket_file_set_extension (struct ast_bucket_file *bucket_file)
 
static int bucket_http_wizard_create (const struct ast_sorcery *sorcery, void *data, void *object)
 
static int bucket_http_wizard_delete (const struct ast_sorcery *sorcery, void *data, void *object)
 
static int bucket_http_wizard_is_stale (const struct ast_sorcery *sorcery, void *data, void *object)
 
static void * bucket_http_wizard_retrieve_id (const struct ast_sorcery *sorcery, void *data, const char *type, const char *id)
 
static void * conf_alloc (void)
 Creates the http media cache conf object.
 
static void conf_destructor (void *obj)
 Disposes of the http media cache conf object.
 
 CONFIG_INFO_STANDARD (cfg_info, confs, conf_alloc,.pre_apply_config=http_media_cache_config_pre_apply,.files=ACO_FILES(&conf_file))
 
static size_t curl_body_callback (void *ptr, size_t size, size_t nitems, void *data)
 
static size_t curl_header_callback (char *buffer, size_t size, size_t nitems, void *data)
 
static int derive_extension_from_mime_type (const char *mime_type, char *buffer, size_t capacity)
 
static long execute_curl_instance (CURL *curl)
 Execute the CURL.
 
static char * file_extension_from_content_type (struct ast_bucket_file *bucket_file, char *buffer, size_t capacity)
 
static char * file_extension_from_string (const char *str, char *buffer, size_t capacity)
 
static char * file_extension_from_url_path (struct ast_bucket_file *bucket_file, char *buffer, size_t capacity)
 
static CURL * get_curl_instance (struct curl_bucket_file_data *cb_data)
 
static int http_media_cache_config_pre_apply (void)
 Pre-apply callback for the config framework. More...
 
static int load_module (void)
 
static int normalize_content_type_header (char *content_type)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "HTTP Media Cache Backend" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "da6642af068ee5e6490c5b1d2cc1d238" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_curl", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct aco_file conf_file
 The conf file that's processed for the module.
 
static struct aco_type general_option
 Mapping of the http media cache conf struct's general to the general context in the config file.
 
static struct aco_typegeneral_options [] = ACO_TYPES(&general_option)
 
static struct ast_sorcery_wizard http_bucket_file_wizard
 
static struct ast_sorcery_wizard http_bucket_wizard
 
static struct ast_sorcery_wizard https_bucket_file_wizard
 
static struct ast_sorcery_wizard https_bucket_wizard
 

Detailed Description

Author
Matt Jordan <mjordan@digium.com> 

HTTP backend for the core media cache

Definition in file res_http_media_cache.c.

Function Documentation

static int http_media_cache_config_pre_apply ( void  )
static

Pre-apply callback for the config framework.

This validates that used options match the ones supported by CURL.

Definition at line 179 of file res_http_media_cache.c.

References aco_pending_config(), conf_general_options::curl_protocols, conf_general_options::curl_redir_protocols, and conf::general.

180 {
181 #ifndef AST_CURL_HAS_PROTOCOLS_STR
182  struct conf *cfg = aco_pending_config(&cfg_info);
183 
184  if (!ast_strlen_zero(cfg->general->curl_protocols)) {
185  ast_log(AST_LOG_ERROR, "'protocols' not supported by linked CURL library. Please recompile against newer CURL.\n");
186  return -1;
187  }
188 
189  if (!ast_strlen_zero(cfg->general->curl_redir_protocols)) {
190  ast_log(AST_LOG_ERROR, "'redirect_protocols' not supported by linked CURL library. Please recompile against newer CURL.\n");
191  return -1;
192  }
193 #endif
194 
195  return 0;
196 }
const ast_string_field curl_redir_protocols
Allowed protocols to use for requests. All by default.
All configuration options for http media cache.
struct conf_general_options * general
void * aco_pending_config(struct aco_info *info)
Get pending config changes.
const ast_string_field curl_protocols
Proxy to use for requests. None by default.