diff --git a/channels/chan_brcm.c b/channels/chan_brcm.c index 9ba1b2ee45d61ff3728d653d83b95b9fc21e4904..71841732fc4222d0a72cf2456f593855362c9602 100644 --- a/channels/chan_brcm.c +++ b/channels/chan_brcm.c @@ -20,20 +20,13 @@ * * \author Benjamin Larsson <benjamin@southpole.se> * \author Jonas Höglund <jonash@southpole.se> + * \author Yalu Zhang <yalu.zhang@iopsys.eu> * * \ingroup channel_drivers */ // #define BRCM_LOCK_DEBUG /* If defined we will log lock events to the asterisk debug channel */ -/* TODO: - * Prefered codec order mulaw/alaw/g729/g723.1/g726_24/g726_32 - * Enable T38 support - * Enable V18 support - */ - - - #include "asterisk.h" #include <math.h> @@ -67,7 +60,6 @@ #include "asterisk/format_cache.h" #include "asterisk/logger.h" #include "asterisk/bridge.h" - #include "asterisk/stasis_system.h" #include "asterisk/stasis_channels.h" @@ -200,15 +192,16 @@ static pthread_t packet_thread = AST_PTHREADT_NULL; static pthread_t ubus_thread = AST_PTHREADT_NULL; static struct ubus_context *ctx; -static struct ubus_event_handler ObjAddListener; // Event handler for new ubus object events -static struct ubus_event_handler ObjRmListener; // Event handler for removed ubus object events +static struct ubus_event_handler ObjAddListener; // Event handler for new ubus object events +static struct ubus_event_handler ObjRmListener; // Event handler for removed ubus object events + static int base; static volatile uint32_t endpt_id = 0; static const char endpt_ubus_path[] = "endpt"; static const char audio_rx_str[] = "/tmp/endpt_audio_tx"; static const char audio_tx_str[] = "/tmp/endpt_audio_rx"; -static const char ubusStrObjAdd[] = "ubus.object.add"; // UBUS objects added to global context -static const char ubusStrObjRm[] = "ubus.object.remove"; // UBUS objects added removed from global context +static const char ubusStrObjAdd[] = "ubus.object.add"; // UBUS objects added to global context +static const char ubusStrObjRm[] = "ubus.object.remove"; // UBUS objects added removed from global context static int audio_rx_fd = 0, audio_tx_fd = 0; static pe_bus_t *audio_rx_bus, *audio_tx_bus; static pe_stream_t *audio_rx_stream; @@ -399,10 +392,11 @@ static int pvt_unlock_silent(struct brcm_pvt *pvt) // Get the endptmngr ubus address. It's dynamically updated // by another thread without locking. -static uint32_t get_ubus_endpt_id(void) { +static uint32_t get_ubus_endpt_id(int log) { if (!endpt_id) { if (ubus_lookup_id(ctx, endpt_ubus_path, &endpt_id) != UBUS_STATUS_OK) { - ast_log(LOG_ERROR, "failed to look up endpoint's ubus path\n"); + if (log) + ast_log(LOG_ERROR, "Failed to look up endptmngr's UBUS path\n"); return 0; } } @@ -435,7 +429,7 @@ static void endpt_signal(int line, char *signal, char *state, char *data) { //ast_debug(5, "line = %d, signal = %s, state = %s, data = %s\n", line, signal, state, data); - local_endpt_id = get_ubus_endpt_id(); + local_endpt_id = get_ubus_endpt_id(1); if (local_endpt_id) { memset(&bb, 0, sizeof(bb)); @@ -471,7 +465,7 @@ static void endpt_connection(int line, int id, char *action) { uint32_t local_endpt_id; int res; - local_endpt_id = get_ubus_endpt_id(); + local_endpt_id = get_ubus_endpt_id(1); if (local_endpt_id) { memset(&bb, 0, sizeof(bb)); @@ -3203,7 +3197,6 @@ static const struct blobmsg_policy endpt_count_policy[__MAX_ENDPOINTS] = { [NUM_DECT_ENDPOINTS] = { .name = "num_dect_endpoints", .type = BLOBMSG_TYPE_INT32 }, }; - // Reception of event // { "ubus.object.add": {"id":123, "path":"foo"} } static void ubus_event_new_obj(struct ubus_context *ctx __attribute__((unused)), struct ubus_event_handler *ev __attribute__((unused)), @@ -3214,25 +3207,30 @@ static void ubus_event_new_obj(struct ubus_context *ctx __attribute__((unused)), uint32_t objId; // Tokenize message key/value paris into an array - if(blobmsg_parse(new_obj_policy, ARRAY_SIZE(new_obj_policy), + if (blobmsg_parse(new_obj_policy, ARRAY_SIZE(new_obj_policy), keys, blob_data(blob), blob_len(blob))) { return; } - if(!type || !keys[OBJ_ID] || !keys[OBJ_PATH]) return; // Did we get all arguments we need? + if (!type || !keys[OBJ_ID] || !keys[OBJ_PATH]) + return; // Did we get all arguments we need? objId = blobmsg_get_u32(keys[OBJ_ID]); objPath = blobmsg_get_string(keys[OBJ_PATH]); - if(strcmp(type, ubusStrObjAdd) == 0) { // Object added to global context - if(strcmp(objPath, endpt_ubus_path) == 0) endpt_id = objId; // Endptmngr has started up - } - else if(strcmp(type, ubusStrObjRm) == 0) { // Object removed from global context - if(strcmp(objPath, endpt_ubus_path) == 0) endpt_id = 0; // Endptmngr has closed down + if(strcmp(type, ubusStrObjAdd) == 0) { // Object added to global context + if(strcmp(objPath, endpt_ubus_path) == 0) { + ast_log(LOG_DEBUG, "%s: the UBUS object %s has been added\n", __func__, endpt_ubus_path); + endpt_id = objId; + } + } else if(strcmp(type, ubusStrObjRm) == 0) { // Object removed from global context + if(strcmp(objPath, endpt_ubus_path) == 0) { + ast_log(LOG_DEBUG, "%s: the UBUS object %s has been removed\n", __func__, endpt_ubus_path); + endpt_id = 0; + } } } - static void endpt_get_count_cb(struct ubus_request *req, int type, struct blob_attr *msg) { struct blob_attr *tb[__MAX_ENDPOINTS]; @@ -3252,7 +3250,7 @@ static int endpt_get_count(void) { uint32_t local_endpt_id; struct blob_buf bb; - local_endpt_id = get_ubus_endpt_id(); + local_endpt_id = get_ubus_endpt_id(0); if(!local_endpt_id) return -1; @@ -3425,13 +3423,16 @@ static int load_module(void) goto err; } - for(try = 0; try < 20 && num_endpoints == -1; try++) { + for (try = 0; try < 20 && num_endpoints == -1; try++) { if(endpt_get_count()) { - ast_log(LOG_ERROR, "Waiting for endptmngr...\n"); + ast_log(LOG_DEBUG, "Waiting for endptmngr...\n"); sleep(1); } } - if(num_endpoints == -1) goto err; + if (num_endpoints == -1) { + ast_log(LOG_ERROR, "endptmngr is not up and running.\n"); + goto err; + } registration_change_sub = calloc(num_endpoints, sizeof(struct stasis_subscription *)); diff --git a/res/res_pjsip/config_system.c b/res/res_pjsip/config_system.c index e16738f610532860cc5040c053565220f69d873c..eb8fd12d125145a8a5cdb63cfa19661d5c11d82c 100644 --- a/res/res_pjsip/config_system.c +++ b/res/res_pjsip/config_system.c @@ -259,12 +259,12 @@ static int system_create_resolver_and_set_nameservers(void *data) discovered_nameservers = ast_dns_get_nameservers(); if (!discovered_nameservers) { - ast_log(LOG_ERROR, "Could not retrieve local system nameservers, resorting to system resolution\n"); + ast_log(LOG_NOTICE, "Could not retrieve local system nameservers, resorting to system resolution\n"); return 0; } if (!ao2_container_count(discovered_nameservers)) { - ast_log(LOG_ERROR, "There are no local system nameservers configured, resorting to system resolution\n"); + ast_log(LOG_NOTICE, "There are no local system nameservers configured, resorting to system resolution\n"); ao2_ref(discovered_nameservers, -1); return -1; }