* switch.h -- Main Library Header
*
*/
-/*! \file switch.h\r
- \brief Main Library Header\r
-*/\r
+/*! \file switch.h
+ \brief Main Library Header
+*/
#ifndef SWITCH_H
#define SWITCH_H
#include <switch_channel.h>
#include <switch_buffer.h>
#include <switch_event.h>
-
+#include <switch_resample.h>
#ifdef __cplusplus
}
#endif
* switch_core.h -- Core Library
*
*/
-/*! \file switch_core.h\r
- \brief Core Library\r
+/*! \file switch_core.h
+ \brief Core Library
*/
#ifndef SWITCH_CORE_H
* switch_frame.h -- Media Frame Structure
*
*/
-/*! \file switch_frame.h\r
- \brief Media Frame Structure\r
+/*! \file switch_frame.h
+ \brief Media Frame Structure
*/
#ifndef SWITCH_FRAME_H
* switch_module_interfaces.h -- Module Interface Definitions
*
*/
-/*! \file switch_module_interfaces.h\r
- \brief Module Interface Definitions\r
+/*! \file switch_module_interfaces.h
+ \brief Module Interface Definitions
*/
#ifndef SWITCH_MODULE_INTERFACES_H
#define SWITCH_MODULE_INTERFACES_H
--- /dev/null
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct@yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthmct@yahoo.com>
+ *
+ *
+ * switch_caller.h -- Caller Identification
+ *
+ */
+/*! \file switch_resample.h
+ \brief Audio Resample Code
+*/
+
+#ifndef SWITCH_RESAMPLE_H
+#define SWITCH_RESAMPLE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct switch_audio_resampler {
+ void *resampler;
+ int from_rate;
+ int to_rate;
+ double factor;
+ float *from;
+ int from_len;
+ size_t from_size;
+ float *to;
+ int to_len;
+ size_t to_size;
+};
+
+#include <switch.h>
+SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
+ int from_rate,
+ size_t from_size,
+ int to_rate,
+ size_t to_size,
+ switch_memory_pool *pool);
+
+SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last);
+
+SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len);
+SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len);
+SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len);
+SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len);
+SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
+SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
+
} switch_event_t;
-
+typedef struct switch_audio_resampler switch_audio_resampler;
typedef struct switch_event_header switch_event_header;
typedef struct switch_event switch_event;
typedef struct switch_event_subclass switch_event_subclass;
SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen);
SWITCH_DECLARE(switch_status) switch_socket_create_pollfd(switch_pollfd_t *poll, switch_socket_t *sock, unsigned int flags, switch_memory_pool *pool);
SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms);
-SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len);
SWITCH_DECLARE(char *) switch_cut_path(char *in);
-SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len);
-SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len);
-SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len);
-SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len);
+
#if !defined(switch_strdupa) && defined(__GNUC__)
# define switch_strdupa(s) \
static const char modname[] = "mod_rawaudio";
-#ifndef MIN
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-#endif
-
-#define QUALITY 1
-
-struct raw_resampler {
- void *resampler;
- int from;
- int to;
- double factor;
- float *buf;
- int buf_len;
- int buf_size;
- float *new_buf;
- int new_buf_len;
- int new_buf_size;
-};
-
-struct raw_context {
- struct raw_resampler *enc;
- struct raw_resampler *dec;
-};
-
-
-static int resample(void *handle, double factor, float *src, int srclen, float *dst, int dstlen, int last)
-{
- int o=0, srcused=0, srcpos=0, out=0;
-
- for(;;) {
- int srcBlock = MIN(srclen-srcpos, srclen);
- int lastFlag = (last && (srcBlock == srclen-srcpos));
- o = resample_process(handle, factor, &src[srcpos], srcBlock, lastFlag, &srcused, &dst[out], dstlen-out);
- //printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
-
- srcpos += srcused;
- if (o >= 0) {
- out += o;
- }
- if (o < 0 || (o == 0 && srcpos == srclen)) {
- break;
- }
- }
- return out;
-}
-
static switch_status switch_raw_init(switch_codec *codec, switch_codec_flag flags, const struct switch_codec_settings *codec_settings)
{
if (!(encoding || decoding)) {
return SWITCH_STATUS_FALSE;
} else {
- if (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context)))) {
- return SWITCH_STATUS_MEMERR;
- }
- codec->private = context;
return SWITCH_STATUS_SUCCESS;
}
}
int *encoded_rate,
unsigned int *flag)
{
- struct raw_context *context = codec->private;
-
- /* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.
- TBD Support varying number of channels
- */
- //printf("encode %d->%d (%d)\n", other_codec->implementation->samples_per_second, codec->implementation->samples_per_second, decoded_rate);
-
- if (other_codec &&
- codec->implementation->samples_per_second != other_codec->implementation->samples_per_second &&
- decoded_rate != other_codec->implementation->samples_per_second) {
- const short *ddp = decoded_data;
- short *edp = encoded_data;
- size_t ddplen = decoded_data_len / 2;
-
- if (!context->enc) {
-
- if (!(context->enc = switch_core_alloc(codec->memory_pool, sizeof(struct raw_resampler)))) {
- return SWITCH_STATUS_MEMERR;
- }
-
- context->enc->from = other_codec->implementation->samples_per_second;
- context->enc->to = codec->implementation->samples_per_second;
- context->enc->factor = ((double)context->enc->to / (double)context->enc->from);
-
- context->enc->resampler = resample_open(QUALITY, context->enc->factor, context->enc->factor);
- switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Encode Resample %d->%d %f\n", context->enc->from, context->enc->to, context->enc->factor);
- context->enc->buf_size = codec->implementation->bytes_per_frame * 10;
- context->enc->buf = (float *) switch_core_alloc(codec->memory_pool, context->enc->buf_size);
- context->enc->new_buf_size = codec->implementation->bytes_per_frame * 10;
- context->enc->new_buf = (float *) switch_core_alloc(codec->memory_pool, context->enc->new_buf_size);
- }
-
- if (context->enc) {
- context->enc->buf_len = switch_short_to_float(decoded_data, context->enc->buf, (int)ddplen);
- context->enc->new_buf_len = resample(context->enc->resampler,
- context->enc->factor,
- context->enc->buf,
- context->enc->buf_len,
- context->enc->new_buf,
- context->enc->new_buf_size,
- 0);
- switch_float_to_short(context->enc->new_buf, edp, decoded_data_len * 2);
- *encoded_data_len = context->enc->new_buf_len * 2;
- *encoded_rate = context->enc->to;
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_GENERR;
+
+ /* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.*/
+ if (decoded_rate != codec->implementation->samples_per_second) {
+ memcpy(encoded_data, decoded_data, decoded_data_len);
+ *encoded_data_len = decoded_data_len;
+ return SWITCH_STATUS_RESAMPLE;
}
-
return SWITCH_STATUS_NOOP;
}
int *decoded_rate,
unsigned int *flag)
{
- struct raw_context *context = codec->private;
-
- //printf("decode %d->%d (%d)\n", other_codec->implementation->samples_per_second, codec->implementation->samples_per_second, encoded_rate);
-
-
- if (other_codec &&
- codec->implementation->samples_per_second != other_codec->implementation->samples_per_second &&
- encoded_rate != other_codec->implementation->samples_per_second) {
- short *ddp = decoded_data;
- const short *edp = encoded_data;
- size_t edplen = encoded_data_len / 2;
-
- if (!context->dec) {
- if (!(context->dec = switch_core_alloc(codec->memory_pool, sizeof(struct raw_resampler)))) {
- return SWITCH_STATUS_MEMERR;
- }
-
-
- context->dec->from = other_codec->implementation->samples_per_second;
- context->dec->to = codec->implementation->samples_per_second;
- context->dec->factor = ((double)context->dec->from / (double)context->dec->to);
-
- context->dec->resampler = resample_open(QUALITY, context->dec->factor, context->dec->factor);
- switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Decode Resample %d->%d %f\n", context->dec->from, context->dec->to, context->dec->factor);
-
- context->dec->buf_size = codec->implementation->bytes_per_frame * 10;
- context->dec->buf = (float *) switch_core_alloc(codec->memory_pool, context->dec->buf_size);
- context->dec->new_buf_size = codec->implementation->bytes_per_frame * 10;
- context->dec->new_buf = (float *) switch_core_alloc(codec->memory_pool, context->dec->new_buf_size);
- }
-
- if (context->dec) {
- context->dec->buf_len = switch_short_to_float(encoded_data, context->dec->buf, (int)edplen);
- context->dec->new_buf_len = resample(context->dec->resampler,
- context->dec->factor,
- context->dec->buf,
- context->dec->buf_len,
- context->dec->new_buf,
- context->dec->new_buf_size,
- 0);
- switch_float_to_short(context->dec->new_buf, ddp, (int)edplen);
- *decoded_data_len = context->dec->new_buf_len * 2;
- *decoded_rate = context->dec->to;
- return SWITCH_STATUS_SUCCESS;
- }
-
- return SWITCH_STATUS_GENERR;
+ if (encoded_rate != other_codec->implementation->samples_per_second) {
+ memcpy(decoded_data, encoded_data, encoded_data_len);
+ *decoded_data_len = encoded_data_len;
+ return SWITCH_STATUS_RESAMPLE;
}
-
-
return SWITCH_STATUS_NOOP;
}
static switch_status switch_raw_destroy(switch_codec *codec)
{
- struct raw_context *context = codec->private;
-
- if (context->enc && context->enc->resampler){
- resample_close(context->enc->resampler);
- }
-
- if (context->dec && context->dec->resampler){
- resample_close(context->dec->resampler);
- }
-
+
return SWITCH_STATUS_SUCCESS;
}
unsigned char *raw_read_buf[3200];
unsigned char *enc_read_buf[3200];
+
+ switch_audio_resampler *read_resampler;
+ switch_audio_resampler *write_resampler;
+
switch_mutex_t *mutex;
switch_thread_cond_t *cond;
if (status == SWITCH_STATUS_SUCCESS && need_codec) {
switch_frame *enc_frame, *read_frame = *frame;
- if (read_frame->codec->codec_interface == session->read_codec->codec_interface) {
- status = SWITCH_STATUS_SUCCESS;
- } else if (read_frame->codec) {
+ if (read_frame->codec) {
unsigned int flag = 0;
session->raw_read_frame.datalen = session->raw_read_frame.buflen;
status = switch_core_codec_decode(read_frame->codec,
&flag);
switch (status) {
+ case SWITCH_STATUS_RESAMPLE:
+ if (!session->read_resampler) {
+ switch_resample_create(&session->read_resampler,
+ read_frame->codec->implementation->samples_per_second,
+ read_frame->codec->implementation->bytes_per_frame * 10,
+ session->read_codec->implementation->samples_per_second,
+ session->read_codec->implementation->bytes_per_frame * 10,
+ session->pool);
+ }
case SWITCH_STATUS_SUCCESS:
read_frame = &session->raw_read_frame;
break;
break;
}
}
+ if (session->read_resampler) {
+ short *data = read_frame->data;
+
+ session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int)read_frame->datalen / 2 );
+ session->read_resampler->to_len = switch_resample_process(session->read_resampler,
+ session->read_resampler->from,
+ session->read_resampler->from_len,
+ session->read_resampler->to,
+ (int)session->read_resampler->to_size,
+ 0);
+ switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
+ read_frame->samples = session->read_resampler->to_len;
+ read_frame->datalen = session->read_resampler->to_len * 2;
+ read_frame->rate = session->read_resampler->to_rate;
+ }
if (session->read_codec) {
if ((*frame)->datalen == session->read_codec->implementation->bytes_per_frame) {
}
if (need_codec) {
-
- if (frame->codec->codec_interface == session->write_codec->codec_interface) {
- write_frame = frame;
- status = SWITCH_STATUS_SUCCESS;
- } else if (frame->codec) {
+ if (frame->codec) {
session->raw_write_frame.datalen = session->raw_write_frame.buflen;
status = switch_core_codec_decode(frame->codec,
session->write_codec,
&flag);
switch (status) {
-
+ case SWITCH_STATUS_RESAMPLE:
+ write_frame = &session->raw_write_frame;
+ if (!session->write_resampler) {
+ status = switch_resample_create(&session->write_resampler,
+ frame->codec->implementation->samples_per_second,
+ frame->codec->implementation->bytes_per_frame * 10,
+ session->write_codec->implementation->samples_per_second,
+ session->write_codec->implementation->bytes_per_frame * 10,
+ session->pool);
+ }
+ break;
case SWITCH_STATUS_SUCCESS:
write_frame = &session->raw_write_frame;
break;
break;
}
}
-
+ if (session->write_resampler) {
+ short *data = write_frame->data;
+
+ session->write_resampler->from_len = switch_short_to_float(data, session->write_resampler->from, (int)write_frame->datalen / 2);
+ session->write_resampler->to_len = switch_resample_process(session->write_resampler,
+ session->write_resampler->from,
+ session->write_resampler->from_len,
+ session->write_resampler->to,
+ (int)session->write_resampler->to_size,
+ 0);
+ switch_float_to_short(session->write_resampler->to, data, write_frame->datalen);
+ write_frame->samples = session->write_resampler->to_len;
+ write_frame->datalen = session->write_resampler->to_len * 2;
+ write_frame->rate = session->write_resampler->to_rate;
+ }
if (session->write_codec) {
if (write_frame->datalen == session->write_codec->implementation->bytes_per_frame) {
perfect = TRUE;
--- /dev/null
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct@yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Anthony Minessale II <anthmct@yahoo.com>
+ *
+ *
+ * switch_caller.c -- Caller Identification
+ *
+ */
+#include <switch_resample.h>
+#include <libresample.h>
+#define NORMFACT (float)0x8000
+#define MAXSAMPLE (float)0x7FFF
+#define MAXSAMPLEC (char)0x7F
+#define QUALITY 1
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a) > (b) ? (a) : (b))
+#endif
+
+
+
+SWITCH_DECLARE(switch_status) switch_resample_create(switch_audio_resampler **new_resampler,
+ int from_rate,
+ size_t from_size,
+ int to_rate,
+ size_t to_size,
+ switch_memory_pool *pool)
+{
+ switch_audio_resampler *resampler;
+
+ if (!(resampler = switch_core_alloc(pool, sizeof(*resampler)))) {
+ return SWITCH_STATUS_MEMERR;
+ }
+
+ resampler->from_rate = from_rate;
+ resampler->to_rate = to_rate;
+ resampler->factor = ((double)resampler->to_rate / (double)resampler->from_rate);
+
+ resampler->resampler = resample_open(QUALITY, resampler->factor, resampler->factor);
+ switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Resampler %d->%d %f\n", resampler->from_rate, resampler->to_rate, resampler->factor);
+ resampler->from_size = from_size;
+ resampler->from = (float *) switch_core_alloc(pool, resampler->from_size);
+ resampler->to_size = to_size;
+ resampler->to = (float *) switch_core_alloc(pool, resampler->to_size);
+
+ *new_resampler = resampler;
+ return SWITCH_STATUS_SUCCESS;
+}
+
+
+SWITCH_DECLARE(int) switch_resample_process(switch_audio_resampler *resampler, float *src, int srclen, float *dst, int dstlen, int last)
+{
+ int o=0, srcused=0, srcpos=0, out=0;
+
+ for(;;) {
+ int srcBlock = MIN(srclen-srcpos, srclen);
+ int lastFlag = (last && (srcBlock == srclen-srcpos));
+ o = resample_process(resampler->resampler, resampler->factor, &src[srcpos], srcBlock, lastFlag, &srcused, &dst[out], dstlen-out);
+ //printf("resampling %d/%d (%d) %d %f\n", srcpos, srclen, MIN(dstlen-out, dstlen), srcused, factor);
+
+ srcpos += srcused;
+ if (o >= 0) {
+ out += o;
+ }
+ if (o < 0 || (o == 0 && srcpos == srclen)) {
+ break;
+ }
+ }
+ return out;
+}
+
+SWITCH_DECLARE(void) switch_resample_destroy(switch_audio_resampler *resampler)
+{
+ resample_close(resampler->resampler);
+}
+
+
+SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len)
+{
+ size_t i;
+ float ft;
+ for(i=0;i<len;i++) {
+ ft = f[i] * NORMFACT;
+ if(ft >= 0) {
+ s[i] = (short)(ft+0.5);
+ } else {
+ s[i] = (short)(ft-0.5);
+ }
+ if (s[i] > (short)MAXSAMPLE) s[i] = (short)MAXSAMPLE;
+ if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;
+ }
+ return len;
+}
+
+SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)
+{
+ int i;
+
+ if (len % 2) {
+ return(-1);
+ }
+
+ for(i=1;i<len;i+=2) {
+ f[(int)(i/2)] = (float)(((c[i])*0x100) + c[i-1]);
+ f[(int)(i/2)] /= NORMFACT;
+ if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;
+ if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;
+ }
+ return len/2;
+}
+
+SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len)
+{
+ int i;
+ float ft;
+ long l;
+ for(i=0;i<len;i++) {
+ ft = f[i] * NORMFACT;
+ if (ft >= 0) {
+ l = (long)(ft+0.5);
+ } else {
+ l = (long)(ft-0.5);
+ }
+ c[i*2] = (unsigned char)((l)&0xff);
+ c[i*2+1] = (unsigned char)(((l)>>8)&0xff);
+ }
+ return len*2;
+}
+
+SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len)
+{
+ int i;
+
+ for(i=0;i<len;i++) {
+ f[i] = (float)(s[i]) / NORMFACT;
+ //f[i] = (float) s[i];
+ }
+ return len;
+}
+
+
+SWITCH_DECLARE(char *) switch_cut_path(char *in)
+{
+ char *p, *ret = in;
+ char delims[] = "/\\";
+ char *i;
+
+ for(i = delims; *i; i++) {
+ p = in;
+ while((p = strchr(p, *i))) {
+ ret = ++p;
+ }
+ }
+ return ret;
+}
+
+
+SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
+{
+ int i;
+ for (i = 0; i < len; i++) {
+ buf[i] = ((buf[i] >> 8) & 0x00ff) | ((buf[i] << 8) & 0xff00);
+ }
+}
\ No newline at end of file
*
*/
#include <switch_utils.h>
-#define NORMFACT (float)0x8000
-#define MAXSAMPLE (float)0x7FFF
-#define MAXSAMPLEC (char)0x7F
-
-
-SWITCH_DECLARE(size_t) switch_float_to_short(float *f, short *s, size_t len)
-{
- size_t i;
- float ft;
- for(i=0;i<len;i++) {
- ft = f[i] * NORMFACT;
- if(ft >= 0) {
- s[i] = (short)(ft+0.5);
- } else {
- s[i] = (short)(ft-0.5);
- }
- if (s[i] > (short)MAXSAMPLE) s[i] = (short)MAXSAMPLE;
- if (s[i] < (short)-MAXSAMPLE) s[i] = (short)-MAXSAMPLE;
- }
- return len;
-}
-
-SWITCH_DECLARE(int) switch_char_to_float(char *c, float *f, int len)
-{
- int i;
-
- if (len % 2) {
- return(-1);
- }
-
- for(i=1;i<len;i+=2) {
- f[(int)(i/2)] = (float)(((c[i])*0x100) + c[i-1]);
- f[(int)(i/2)] /= NORMFACT;
- if (f[(int)(i/2)] > MAXSAMPLE) f[(int)(i/2)] = MAXSAMPLE;
- if (f[(int)(i/2)] < -MAXSAMPLE) f[(int)(i/2)] = -MAXSAMPLE;
- }
- return len/2;
-}
-
-SWITCH_DECLARE(int) switch_float_to_char(float *f, char *c, int len)
-{
- int i;
- float ft;
- long l;
- for(i=0;i<len;i++) {
- ft = f[i] * NORMFACT;
- if (ft >= 0) {
- l = (long)(ft+0.5);
- } else {
- l = (long)(ft-0.5);
- }
- c[i*2] = (unsigned char)((l)&0xff);
- c[i*2+1] = (unsigned char)(((l)>>8)&0xff);
- }
- return len*2;
-}
-
-SWITCH_DECLARE(int) switch_short_to_float(short *s, float *f, int len)
-{
- int i;
-
- for(i=0;i<len;i++) {
- f[i] = (float)(s[i]) / NORMFACT;
- //f[i] = (float) s[i];
- }
- return len;
-}
-
-
-SWITCH_DECLARE(char *) switch_cut_path(char *in)
-{
- char *p, *ret = in;
- char delims[] = "/\\";
- char *i;
-
- for(i = delims; *i; i++) {
- p = in;
- while((p = strchr(p, *i))) {
- ret = ++p;
- }
- }
- return ret;
-}
-
-
-SWITCH_DECLARE(void) switch_swap_linear(int16_t *buf, int len)
-{
- int i;
- for (i = 0; i < len; i++) {
- buf[i] = ((buf[i] >> 8) & 0x00ff) | ((buf[i] << 8) & 0xff00);
- }
-}
-
SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char **array, int arraylen)
{
Name="VCCLCompilerTool"\r
Optimization="0"\r
AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include"\r
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;APR_DECLARE_EXPORT;APU_DECLARE_EXPORT;API_DECLARE_EXPORT"\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;APR_DECLARE_EXPORT;APU_DECLARE_EXPORT;API_DECLARE_EXPORT;_CRT_SECURE_NO_DEPRECATE"\r
MinimalRebuild="true"\r
BasicRuntimeChecks="3"\r
RuntimeLibrary="3"\r
/>\r
<Tool\r
Name="VCLinkerTool"\r
+ AdditionalOptions="/NODEFAULTLIB:LIBCMTD"\r
AdditionalDependencies="Ws2_32.lib Mswsock.lib apr-1.lib sqlite.lib apriconv-1.lib aprutil-1.lib xml.lib Rpcrt4.lib libresampled.lib"\r
OutputFile="$(OutDir)/FreeSwitch.dll"\r
LinkIncremental="2"\r
<Tool\r
Name="VCCLCompilerTool"\r
AdditionalIncludeDirectories="..\..\src\include;..\..\libs\include"\r
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;APR_DECLARE_EXPORT;APU_DECLARE_EXPORT;API_DECLARE_EXPORT"\r
+ PreprocessorDefinitions=" WIN32;NDEBUG;_WINDOWS;_USRDLL;FREESWITCHCORE_EXPORTS;APR_DECLARE_EXPORT;APU_DECLARE_EXPORT;API_DECLARE_EXPORT;_CRT_SECURE_NO_DEPRECATE"\r
RuntimeLibrary="2"\r
UsePrecompiledHeader="0"\r
WarningLevel="3"\r
/>\r
<Tool\r
Name="VCLinkerTool"\r
+ AdditionalOptions="/NODEFAULTLIB:LIBCMTD"\r
AdditionalDependencies="Ws2_32.lib Mswsock.lib apr-1.lib sqlite.lib apriconv-1.lib aprutil-1.lib xml.lib Rpcrt4.lib libresample.lib"\r
OutputFile="$(OutDir)/FreeSwitch.dll"\r
LinkIncremental="1"\r
RelativePath="..\..\src\switch_mutex.c"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\switch_resample.c"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\src\switch_utils.c"\r
>\r
RelativePath="..\..\src\include\switch_platform.h"\r
>\r
</File>\r
+ <File\r
+ RelativePath="..\..\src\include\switch_resample.h"\r
+ >\r
+ </File>\r
<File\r
RelativePath="..\..\src\include\switch_sqlite.h"\r
>\r