[Freeswitch-svn] [commit] r13859 - in freeswitch/trunk/libs/unimrcp: build/vsprops libs/mpf/include libs/mpf/src plugins/mrcp-cepstral/src tests/mpftest/src
FreeSWITCH SVN
mikej at freeswitch.org
Thu Jun 18 20:57:04 PDT 2009
Author: mikej
Date: Thu Jun 18 22:57:04 2009
New Revision: 13859
Log:
Added LPCM (16-bit linear PCM) codec, which is used internally in host order;
while L16 is RFC3551 defined 16-bit linear PCM codec in network order.
Using LPCM to specify linear PCM codec in host byte order
Merged upstream revisions through r991
Modified:
freeswitch/trunk/libs/unimrcp/build/vsprops/unimrcpplugin.vsprops
freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec.h
freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h
freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c
freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c
freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_engine.c
freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_termination.c
freeswitch/trunk/libs/unimrcp/plugins/mrcp-cepstral/src/mrcp_swift.c
freeswitch/trunk/libs/unimrcp/tests/mpftest/src/mpf_suite.c
Modified: freeswitch/trunk/libs/unimrcp/build/vsprops/unimrcpplugin.vsprops
==============================================================================
--- freeswitch/trunk/libs/unimrcp/build/vsprops/unimrcpplugin.vsprops (original)
+++ freeswitch/trunk/libs/unimrcp/build/vsprops/unimrcpplugin.vsprops Thu Jun 18 22:57:04 2009
@@ -12,6 +12,6 @@
<Tool
Name="VCLinkerTool"
AdditionalLibraryDirectories=""$(SolutionDir)$(ConfigurationName)\bin""
- AdditionalDependencies="mrcpengine.lib mrcp.lib mpf.lib aprtoolkit.lib libaprutil-1.lib libapr-1.lib"
+ AdditionalDependencies="mrcpengine.lib mrcp.lib mpf.lib aprtoolkit.lib libaprutil-1.lib libapr-1.lib ws2_32.lib"
/>
</VisualStudioPropertySheet>
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec.h
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec.h (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec.h Thu Jun 18 22:57:04 2009
@@ -82,7 +82,7 @@
}
/**
- * Close codec.
+ * Clone codec.
* @param src_codec the source (original) codec to clone
* @param pool the pool to allocate memory from
*/
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/include/mpf_codec_manager.h Thu Jun 18 22:57:04 2009
@@ -39,6 +39,9 @@
/** Get (allocate) codec by codec descriptor */
MPF_DECLARE(mpf_codec_t*) mpf_codec_manager_codec_get(const mpf_codec_manager_t *codec_manager, mpf_codec_descriptor_t *descriptor, apr_pool_t *pool);
+/** Get (allocate) default codec */
+MPF_DECLARE(mpf_codec_t*) mpf_codec_manager_default_codec_get(const mpf_codec_manager_t *codec_manager, apr_pool_t *pool);
+
/** Get (allocate) list of available codecs */
MPF_DECLARE(apt_bool_t) mpf_codec_manager_codec_list_get(const mpf_codec_manager_t *codec_manager, mpf_codec_list_t *codec_list, apr_pool_t *pool);
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_linear.c Thu Jun 18 22:57:04 2009
@@ -16,20 +16,75 @@
#include "mpf_codec.h"
+/* linear 16-bit PCM (host horder) */
+#define LPCM_CODEC_NAME "LPCM"
+#define LPCM_CODEC_NAME_LENGTH (sizeof(LPCM_CODEC_NAME)-1)
+
+/* linear 16-bit PCM (RFC3551) */
#define L16_CODEC_NAME "L16"
#define L16_CODEC_NAME_LENGTH (sizeof(L16_CODEC_NAME)-1)
+
+static apt_bool_t l16_open(mpf_codec_t *codec)
+{
+ return TRUE;
+}
+
+static apt_bool_t l16_close(mpf_codec_t *codec)
+{
+ return TRUE;
+}
+
+static apt_bool_t l16_encode(mpf_codec_t *codec, const mpf_codec_frame_t *frame_in, mpf_codec_frame_t *frame_out)
+{
+ apr_uint32_t i;
+ const short *buf_in = frame_in->buffer;
+ short *buf_out = frame_out->buffer;
+
+ frame_out->size = frame_in->size;
+
+ for(i=0; i<frame_in->size; ) {
+ buf_out[i] = htons(buf_in[i]);
+ i += sizeof(short);
+ }
+
+ return TRUE;
+}
+
+static apt_bool_t l16_decode(mpf_codec_t *codec, const mpf_codec_frame_t *frame_in, mpf_codec_frame_t *frame_out)
+{
+ apr_uint32_t i;
+ const short *buf_in = frame_in->buffer;
+ short *buf_out = frame_out->buffer;
+
+ frame_out->size = frame_in->size;
+
+ for(i=0; i<frame_in->size; ) {
+ buf_out[i] = ntohs(buf_in[i]);
+ i += sizeof(short);
+ }
+
+ return TRUE;
+}
+
+
+
+static const mpf_codec_vtable_t lpcm_vtable = {
+ NULL
+};
+
static const mpf_codec_vtable_t l16_vtable = {
+ l16_open,
+ l16_close,
+ l16_encode,
+ l16_decode,
NULL
};
-static const mpf_codec_descriptor_t l16_descriptor = {
- 96, /* not specified */
- {L16_CODEC_NAME, L16_CODEC_NAME_LENGTH},
- 8000,
- 1,
- NULL,
- TRUE
+static const mpf_codec_attribs_t lpcm_attribs = {
+ {LPCM_CODEC_NAME, LPCM_CODEC_NAME_LENGTH}, /* codec name */
+ 16, /* bits per sample */
+ MPF_SAMPLE_RATE_8000 | MPF_SAMPLE_RATE_16000 /* sampling rates */
};
static const mpf_codec_attribs_t l16_attribs = {
@@ -38,12 +93,24 @@
MPF_SAMPLE_RATE_8000 | MPF_SAMPLE_RATE_16000 /* sampling rates */
};
-mpf_codec_t* mpf_codec_l16_create(apr_pool_t *pool)
+mpf_codec_descriptor_t* mpf_codec_lpcm_descriptor_create(apr_uint16_t sampling_rate, apr_byte_t channel_count, apr_pool_t *pool)
{
- return mpf_codec_create(&l16_vtable,&l16_attribs,NULL,pool);
+ mpf_codec_descriptor_t *descriptor = apr_palloc(pool,sizeof(mpf_codec_descriptor_t));
+ mpf_codec_descriptor_init(descriptor);
+ descriptor->payload_type = 96;
+ descriptor->name.buf = LPCM_CODEC_NAME;
+ descriptor->name.length = LPCM_CODEC_NAME_LENGTH;
+ descriptor->sampling_rate = sampling_rate;
+ descriptor->channel_count = channel_count;
+ return descriptor;
}
-const mpf_codec_descriptor_t* l16_descriptor_get()
+mpf_codec_t* mpf_codec_lpcm_create(apr_pool_t *pool)
{
- return &l16_descriptor;
+ return mpf_codec_create(&lpcm_vtable,&lpcm_attribs,NULL,pool);
+}
+
+mpf_codec_t* mpf_codec_l16_create(apr_pool_t *pool)
+{
+ return mpf_codec_create(&l16_vtable,&l16_attribs,NULL,pool);
}
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_codec_manager.c Thu Jun 18 22:57:04 2009
@@ -28,6 +28,8 @@
};
+mpf_codec_descriptor_t* mpf_codec_lpcm_descriptor_create(apr_uint16_t sampling_rate, apr_byte_t channel_count, apr_pool_t *pool);
+
MPF_DECLARE(mpf_codec_manager_t*) mpf_codec_manager_create(apr_size_t codec_count, apr_pool_t *pool)
{
mpf_codec_manager_t *codec_manager = apr_palloc(pool,sizeof(mpf_codec_manager_t));
@@ -93,6 +95,14 @@
return ret_codec;
}
+MPF_DECLARE(mpf_codec_t*) mpf_codec_manager_default_codec_get(const mpf_codec_manager_t *codec_manager, apr_pool_t *pool)
+{
+ mpf_codec_t *codec;
+ mpf_codec_descriptor_t *descriptor = mpf_codec_lpcm_descriptor_create(8000,1,pool);
+ codec = mpf_codec_manager_codec_get(codec_manager,descriptor,pool);
+ return codec;
+}
+
MPF_DECLARE(apt_bool_t) mpf_codec_manager_codec_list_get(const mpf_codec_manager_t *codec_manager, mpf_codec_list_t *codec_list, apr_pool_t *pool)
{
const mpf_codec_descriptor_t *static_descriptor;
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_engine.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_engine.c (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_engine.c Thu Jun 18 22:57:04 2009
@@ -48,6 +48,7 @@
static apt_bool_t mpf_engine_contexts_destroy(mpf_engine_t *engine);
+mpf_codec_t* mpf_codec_lpcm_create(apr_pool_t *pool);
mpf_codec_t* mpf_codec_l16_create(apr_pool_t *pool);
mpf_codec_t* mpf_codec_g711u_create(apr_pool_t *pool);
mpf_codec_t* mpf_codec_g711a_create(apr_pool_t *pool);
@@ -287,6 +288,9 @@
mpf_codec_manager_t *codec_manager = mpf_codec_manager_create(3,pool);
if(codec_manager) {
mpf_codec_t *codec;
+ codec = mpf_codec_lpcm_create(pool);
+ mpf_codec_manager_codec_register(codec_manager,codec);
+
codec = mpf_codec_g711u_create(pool);
mpf_codec_manager_codec_register(codec_manager,codec);
Modified: freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_termination.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_termination.c (original)
+++ freeswitch/trunk/libs/unimrcp/libs/mpf/src/mpf_termination.c Thu Jun 18 22:57:04 2009
@@ -18,8 +18,6 @@
#include "mpf_stream.h"
#include "mpf_codec_manager.h"
-const mpf_codec_descriptor_t* l16_descriptor_get();
-
MPF_DECLARE(mpf_termination_t*) mpf_termination_base_create(
mpf_termination_factory_t *termination_factory,
void *obj,
@@ -69,20 +67,6 @@
return TRUE;
}
-static mpf_codec_t* mpf_termination_default_codec_create(mpf_termination_t *termination)
-{
- mpf_codec_t *codec;
- const mpf_codec_descriptor_t *default_descriptor = l16_descriptor_get();
- mpf_codec_descriptor_t *descriptor = apr_palloc(termination->pool,sizeof(mpf_codec_descriptor_t));
- mpf_codec_descriptor_init(descriptor);
- *descriptor = *default_descriptor;
- codec = mpf_codec_manager_codec_get(
- termination->codec_manager,
- descriptor,
- termination->pool);
- return codec;
-}
-
MPF_DECLARE(apt_bool_t) mpf_termination_validate(mpf_termination_t *termination)
{
mpf_audio_stream_t *audio_stream;
@@ -96,12 +80,16 @@
}
if((audio_stream->mode & STREAM_MODE_RECEIVE) == STREAM_MODE_RECEIVE) {
if(!audio_stream->rx_codec) {
- audio_stream->rx_codec = mpf_termination_default_codec_create(termination);
+ audio_stream->rx_codec = mpf_codec_manager_default_codec_get(
+ termination->codec_manager,
+ termination->pool);
}
}
if((audio_stream->mode & STREAM_MODE_SEND) == STREAM_MODE_SEND) {
if(!audio_stream->tx_codec) {
- audio_stream->tx_codec = mpf_termination_default_codec_create(termination);
+ audio_stream->tx_codec = mpf_codec_manager_default_codec_get(
+ termination->codec_manager,
+ termination->pool);
}
}
}
Modified: freeswitch/trunk/libs/unimrcp/plugins/mrcp-cepstral/src/mrcp_swift.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/plugins/mrcp-cepstral/src/mrcp_swift.c (original)
+++ freeswitch/trunk/libs/unimrcp/plugins/mrcp-cepstral/src/mrcp_swift.c Thu Jun 18 22:57:04 2009
@@ -195,7 +195,7 @@
mpf_codec_descriptor_init(codec_descriptor);
codec_descriptor->channel_count = 1;
codec_descriptor->payload_type = 96;
- apt_string_set(&codec_descriptor->name,"L16");
+ apt_string_set(&codec_descriptor->name,"LPCM");
codec_descriptor->sampling_rate = 8000;
params = swift_params_new(NULL);
Modified: freeswitch/trunk/libs/unimrcp/tests/mpftest/src/mpf_suite.c
==============================================================================
--- freeswitch/trunk/libs/unimrcp/tests/mpftest/src/mpf_suite.c (original)
+++ freeswitch/trunk/libs/unimrcp/tests/mpftest/src/mpf_suite.c Thu Jun 18 22:57:04 2009
@@ -348,8 +348,8 @@
descriptor->write_handle = NULL;
codec_descriptor = &descriptor->codec_descriptor;
- codec_descriptor->payload_type = 11;
- apt_string_set(&codec_descriptor->name,"L16");
+ codec_descriptor->payload_type = 96;
+ apt_string_set(&codec_descriptor->name,"LPCM");
codec_descriptor->sampling_rate = 8000;
codec_descriptor->channel_count = 1;
return descriptor;
@@ -366,8 +366,8 @@
descriptor->read_handle = NULL;
codec_descriptor = &descriptor->codec_descriptor;
- codec_descriptor->payload_type = 11;
- apt_string_set(&codec_descriptor->name,"L16");
+ codec_descriptor->payload_type = 96;
+ apt_string_set(&codec_descriptor->name,"LPCM");
codec_descriptor->sampling_rate = 8000;
codec_descriptor->channel_count = 1;
return descriptor;
More information about the Freeswitch-svn
mailing list