update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3009 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
dcdc0cdaac
commit
071e720f87
|
@ -1,5 +1,5 @@
|
|||
CFLAGS += -I$(PREFIX)/include/amr
|
||||
LDFLAGS +=-lamrnb
|
||||
LDFLAGS +=-lamr
|
||||
|
||||
all: $(MODNAME).$(DYNAMIC_LIB_EXTEN)
|
||||
|
||||
|
|
|
@ -88,13 +88,15 @@ enum
|
|||
AMR_BITRATE_1220
|
||||
};
|
||||
|
||||
#define AMR_Mode 7
|
||||
#define AMR_Mode 7
|
||||
|
||||
static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_t flags,
|
||||
const switch_codec_settings_t *codec_settings)
|
||||
{
|
||||
struct amr_context *context = NULL;
|
||||
int encoding, decoding;
|
||||
int x, argc;
|
||||
char *argv[10];
|
||||
|
||||
encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
|
||||
decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
|
||||
|
@ -103,12 +105,31 @@ static switch_status_t switch_amr_init(switch_codec_t *codec, switch_codec_flag_
|
|||
return SWITCH_STATUS_FALSE;
|
||||
} else {
|
||||
|
||||
if (codec->fmtp_in) {
|
||||
argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
|
||||
for(x = 0; x < argc; x++) {
|
||||
char *data = argv[x];
|
||||
char *arg;
|
||||
while(*data && *data == ' ') {
|
||||
data++;
|
||||
}
|
||||
if ((arg = strchr(data, '='))) {
|
||||
*arg++ = '\0';
|
||||
|
||||
printf("Codec arg %d [%s]=[%s]\n", x, data, arg);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
codec->fmtp_out = "octet-align=0; mode-set=7";
|
||||
|
||||
context->enc_mode = AMR_Mode; /* start in mode 7 */
|
||||
context->encoder_state = NULL;
|
||||
context->decoder_state = NULL;
|
||||
|
||||
if (encoding) {
|
||||
context->encoder_state = Encoder_Interface_init(0);
|
||||
context->encoder_state = Encoder_Interface_init(1);
|
||||
}
|
||||
|
||||
if (decoding) {
|
||||
|
@ -152,8 +173,8 @@ static switch_status_t switch_amr_encode(switch_codec_t *codec,
|
|||
if (!context) {
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (void *)decoded_data, encoded_data, 0 );
|
||||
|
||||
*encoded_data_len = Encoder_Interface_Encode( context->encoder_state, context->enc_mode, (int16_t *)decoded_data, (int8_t *) encoded_data, 0);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -177,9 +198,8 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
|||
}
|
||||
|
||||
Decoder_Interface_Decode( context->decoder_state, (void *)encoded_data, (void *)decoded_data, 0 );
|
||||
|
||||
*decoded_data_len = codec->implementation->bytes_per_frame;
|
||||
|
||||
//printf("D %d/%d\n", encoded_data_len, *decoded_data_len);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -187,8 +207,9 @@ static switch_status_t switch_amr_decode(switch_codec_t *codec,
|
|||
|
||||
static const switch_codec_implementation_t amr_implementation = {
|
||||
/*.codec_type */ SWITCH_CODEC_TYPE_AUDIO,
|
||||
/*.ianacode */ 118,
|
||||
/*.ianacode */ 96,
|
||||
/*.iananame */ "AMR",
|
||||
/*.fmtp */ "octet-align=0",
|
||||
/*.samples_per_second */ 8000,
|
||||
/*.bits_per_second */ 0,
|
||||
/*.microseconds_per_frame */ 20000,
|
||||
|
|
|
@ -69,6 +69,7 @@ typedef struct private_object private_object_t;
|
|||
#include <sofia-sip/sip_protos.h>
|
||||
#include <sofia-sip/auth_module.h>
|
||||
#include <sofia-sip/su_md5.h>
|
||||
#include <sofia-sip/su_log.h>
|
||||
|
||||
static char reg_sql[] =
|
||||
"CREATE TABLE sip_registrations (\n"
|
||||
|
@ -1682,6 +1683,31 @@ static const switch_loadable_module_interface_t sofia_module_interface = {
|
|||
/*.application_interface */ NULL
|
||||
};
|
||||
|
||||
|
||||
static void logger(void *logarg, char const *fmt, va_list ap)
|
||||
{
|
||||
char *data;
|
||||
int ret;
|
||||
|
||||
if (fmt) {
|
||||
#ifdef HAVE_VASPRINTF
|
||||
ret = vasprintf(&data, fmt, ap);
|
||||
#else
|
||||
data = (char *) malloc(2048);
|
||||
vsnprintf(data, 2048, fmt, ap);
|
||||
#endif
|
||||
if (ret == -1) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (data) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, (char*) "%s: %s", __FILE__, data);
|
||||
free(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t sofia_outgoing_channel(switch_core_session_t *session, switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session, switch_memory_pool_t *pool)
|
||||
{
|
||||
|
@ -3258,6 +3284,16 @@ static switch_status_t config_sofia(int reload)
|
|||
goto done;
|
||||
}
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "global_settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||
if (!strcasecmp(var, "log-level")) {
|
||||
su_log_set_level(NULL, atoi(val));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((profiles = switch_xml_child(cfg, "profiles"))) {
|
||||
for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
|
||||
if (!(settings = switch_xml_child(xprofile, "settings"))) {
|
||||
|
@ -3564,14 +3600,15 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
|
|||
}
|
||||
|
||||
su_init();
|
||||
|
||||
|
||||
su_log_redirect(NULL, logger, NULL);
|
||||
|
||||
switch_core_hash_init(&globals.profile_hash, module_pool);
|
||||
switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
|
||||
|
||||
config_sofia(0);
|
||||
|
||||
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = &sofia_module_interface;
|
||||
|
||||
|
|
Loading…
Reference in New Issue