Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#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. More... | |
struct ast_module * | AST_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. More... | |
static void | conf_destructor (void *obj) |
Disposes of the http media cache conf object. More... | |
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. More... | |
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 = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_curl", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct aco_file | conf_file |
The conf file that's processed for the module. More... | |
static struct aco_type | general_option |
Mapping of the http media cache conf struct's general to the general context in the config file. More... | |
static struct aco_type * | general_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 |
HTTP backend for the core media cache
Definition in file res_http_media_cache.c.
#define MAX_HEADER_LENGTH 1023 |
Definition at line 80 of file res_http_media_cache.c.
|
static |
Definition at line 818 of file res_http_media_cache.c.
|
static |
Definition at line 818 of file res_http_media_cache.c.
|
static |
Locking container for safe configuration access.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 818 of file res_http_media_cache.c.
|
static |
Definition at line 434 of file res_http_media_cache.c.
References ao2_cleanup, ast_bucket_file_metadata_get(), and RAII_VAR.
Referenced by bucket_http_wizard_is_stale().
|
static |
Definition at line 455 of file res_http_media_cache.c.
References ao2_cleanup, ast_bucket_file_metadata_get(), ast_string_to_time_t(), ast_tvcmp(), ast_tvnow(), and RAII_VAR.
Referenced by bucket_http_wizard_is_stale().
|
static |
Definition at line 559 of file res_http_media_cache.c.
References ast_log, ast_sorcery_object_get_id(), curl_bucket_file_data::bucket_file, bucket_file_set_expiration(), bucket_file_set_extension(), curl_body_callback(), errno, execute_curl_instance(), get_curl_instance(), LOG_WARNING, curl_bucket_file_data::out_file, and ast_bucket_file::path.
Referenced by bucket_http_wizard_create(), and bucket_http_wizard_retrieve_id().
|
static |
Definition at line 268 of file res_http_media_cache.c.
References ao2_ref, ast_bucket_file_metadata_get(), ast_bucket_file_metadata_set(), AST_TIME_T_LEN, ast_time_t_to_string(), ast_tvnow(), and ast_bucket_metadata::value.
Referenced by bucket_file_run_curl(), and bucket_http_wizard_is_stale().
|
static |
Definition at line 417 of file res_http_media_cache.c.
References ast_bucket_file_metadata_set(), file_extension_from_content_type(), and file_extension_from_url_path().
Referenced by bucket_file_run_curl().
|
static |
Definition at line 642 of file res_http_media_cache.c.
References bucket_file_run_curl().
|
static |
Definition at line 687 of file res_http_media_cache.c.
References ast_bucket_file::path.
|
static |
Definition at line 599 of file res_http_media_cache.c.
References ao2_ref, ast_bucket_file_metadata_get(), curl_bucket_file_data::bucket_file, bucket_file_always_revalidate(), bucket_file_expired(), bucket_file_set_expiration(), execute_curl_instance(), get_curl_instance(), NULL, and ast_bucket_metadata::value.
|
static |
Definition at line 650 of file res_http_media_cache.c.
References ao2_ref, ast_bucket_file_alloc(), ast_bucket_file_temporary_create(), ast_log, ast_sorcery_delete(), ast_strlen_zero(), bucket_file_run_curl(), LOG_WARNING, NULL, sorcery, and type.
|
static |
Creates the http media cache conf object.
Definition at line 141 of file res_http_media_cache.c.
References ao2_alloc, ao2_ref, ast_string_field_init, conf_destructor(), conf::general, and NULL.
Referenced by load_module().
|
static |
Disposes of the http media cache conf object.
Definition at line 133 of file res_http_media_cache.c.
References ao2_cleanup, ast_string_field_free_memory, and conf::general.
Referenced by conf_alloc().
CONFIG_INFO_STANDARD | ( | cfg_info | , |
confs | , | ||
conf_alloc | , | ||
. | pre_apply_config = http_media_cache_config_pre_apply , |
||
. | files = ACO_FILES(&conf_file) |
||
) |
|
static |
Definition at line 255 of file res_http_media_cache.c.
References curl_bucket_file_data::out_file.
Referenced by bucket_file_run_curl().
|
static |
Definition at line 210 of file res_http_media_cache.c.
References ast_alloca, ast_bucket_file_metadata_set(), ast_log, ast_skip_blanks(), ast_str_to_lower(), ast_trim_blanks(), curl_bucket_file_data::bucket_file, LOG_WARNING, MAX_HEADER_LENGTH, and value.
Referenced by get_curl_instance().
|
static |
Definition at line 348 of file res_http_media_cache.c.
References ast_get_extension_for_mime_type(), ast_strdupa, and normalize_content_type_header().
Referenced by file_extension_from_content_type().
|
static |
Execute the CURL.
Definition at line 536 of file res_http_media_cache.c.
References ast_log, and LOG_WARNING.
Referenced by bucket_file_run_curl(), and bucket_http_wizard_is_stale().
|
static |
Definition at line 365 of file res_http_media_cache.c.
References ao2_ref, ast_bucket_file_metadata_get(), ast_debug, derive_extension_from_mime_type(), NULL, and header::value.
Referenced by bucket_file_set_extension().
|
static |
Definition at line 311 of file res_http_media_cache.c.
References ast_copy_string(), ast_debug, ast_get_format_for_file_ext(), ext, NULL, and str.
Referenced by file_extension_from_url_path().
|
static |
Definition at line 393 of file res_http_media_cache.c.
References ao2_cleanup, ast_log, ast_sorcery_object_get_id(), ast_uri_parse(), ast_uri_path(), file_extension_from_string(), LOG_ERROR, NULL, ast_uri::path, and ast_uri::uri.
Referenced by bucket_file_set_extension().
|
static |
Definition at line 477 of file res_http_media_cache.c.
References ao2_cleanup, ao2_global_obj_ref, ast_log, AST_LOG_ERROR, ast_sorcery_object_get_id(), ast_strlen_zero(), curl_bucket_file_data::bucket_file, curl_header_callback(), NULL, and RAII_VAR.
Referenced by bucket_file_run_curl(), and bucket_http_wizard_is_stale().
|
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(), ast_log, AST_LOG_ERROR, ast_strlen_zero(), conf_general_options::curl_protocols, conf_general_options::curl_redir_protocols, and conf::general.
|
static |
Definition at line 736 of file res_http_media_cache.c.
References ACO_EXACT, aco_info_destroy(), aco_info_init(), aco_option_register, aco_process_config(), ACO_PROCESS_ERROR, aco_set_defaults(), ao2_global_obj_replace_unref, ao2_ref, ast_bucket_scheme_register, AST_CURL_USER_AGENT, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, conf_alloc(), FLDSET, conf::general, general_option, general_options, http_bucket_file_wizard, http_bucket_wizard, https_bucket_file_wizard, https_bucket_wizard, LOG_ERROR, LOG_NOTICE, NULL, OPT_BOOL_T, OPT_INT_T, OPT_STRINGFIELD_T, and STRFLDSET.
|
static |
Definition at line 333 of file res_http_media_cache.c.
Referenced by derive_extension_from_mime_type().
|
static |
Definition at line 729 of file res_http_media_cache.c.
References aco_info_destroy(), and ao2_global_obj_release.
|
static |
Definition at line 818 of file res_http_media_cache.c.
|
static |
Definition at line 818 of file res_http_media_cache.c.
|
static |
The conf file that's processed for the module.
Definition at line 163 of file res_http_media_cache.c.
|
static |
Mapping of the http media cache conf struct's general to the general context in the config file.
Definition at line 122 of file res_http_media_cache.c.
Referenced by load_module().
|
static |
Definition at line 130 of file res_http_media_cache.c.
Referenced by load_module().
|
static |
Definition at line 705 of file res_http_media_cache.c.
Referenced by load_module().
|
static |
Definition at line 697 of file res_http_media_cache.c.
Referenced by load_module().
|
static |
Definition at line 721 of file res_http_media_cache.c.
Referenced by load_module().
|
static |
Definition at line 713 of file res_http_media_cache.c.
Referenced by load_module().