diff --git a/branches/2.0/doubango/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h b/branches/2.0/doubango/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h index 2b941939..c3888900 100644 --- a/branches/2.0/doubango/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h +++ b/branches/2.0/doubango/tinyDAV/include/tinydav/codecs/speex/tdav_codec_speex.h @@ -71,6 +71,8 @@ typedef struct tdav_codec_speex_s tdav_codec_speex_t; TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_speex_nb_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_speex_wb_plugin_def_t; +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_speex_uwb_plugin_def_t; TDAV_END_DECLS diff --git a/branches/2.0/doubango/tinyDAV/src/codecs/speex/tdav_codec_speex.c b/branches/2.0/doubango/tinyDAV/src/codecs/speex/tdav_codec_speex.c index 52fea190..da84d9f9 100644 --- a/branches/2.0/doubango/tinyDAV/src/codecs/speex/tdav_codec_speex.c +++ b/branches/2.0/doubango/tinyDAV/src/codecs/speex/tdav_codec_speex.c @@ -34,6 +34,9 @@ #include "tsk_memory.h" #include "tsk_debug.h" +#define SPEEX_BUFFER_MAX_SIZE 1024 +#define SPEEX_DEFAULT_QUALITY 6 + /* ============ Common ================= */ int tdav_codec_speex_init(tdav_codec_speex_t* self, tdav_codec_speex_type_t type); int tdav_codec_speex_deinit(tdav_codec_speex_t* self); @@ -44,34 +47,41 @@ int tdav_codec_speex_deinit(tdav_codec_speex_t* self); int tdav_codec_speex_open(tmedia_codec_t* self) { - static int quality = 6; + static int quality = SPEEX_DEFAULT_QUALITY; tdav_codec_speex_t* speex = (tdav_codec_speex_t*)self; - // tsk_size_t size = 0; switch(speex->type){ case tdav_codec_speex_type_nb: speex->encoder.state = speex_encoder_init(&speex_nb_mode); speex->decoder.state = speex_decoder_init(&speex_nb_mode); - - speex_decoder_ctl(speex->decoder.state, SPEEX_GET_FRAME_SIZE, &speex->decoder.size); - speex->decoder.size = (speex->decoder.size ? speex->decoder.size : 160) * sizeof(spx_int16_t); - if(!(speex->decoder.buffer = tsk_calloc(speex->decoder.size, 1))){ - speex->decoder.size = 0; - TSK_DEBUG_ERROR("Failed to allocate new buffer"); - return -3; - } - - speex_encoder_ctl(speex->encoder.state, SPEEX_SET_QUALITY, &quality); - speex_encoder_ctl(speex->encoder.state, SPEEX_GET_FRAME_SIZE, &speex->encoder.size); - if(!speex->encoder.size){ - speex->encoder.size = 20; - } + break; + case tdav_codec_speex_type_wb: + speex->encoder.state = speex_encoder_init(&speex_wb_mode); + speex->decoder.state = speex_decoder_init(&speex_wb_mode); + break; + case tdav_codec_speex_type_uwb: + speex->encoder.state = speex_encoder_init(&speex_uwb_mode); + speex->decoder.state = speex_decoder_init(&speex_uwb_mode); break; default: TSK_DEBUG_ERROR("Not implemented"); return -2; } + speex_decoder_ctl(speex->decoder.state, SPEEX_GET_FRAME_SIZE, &speex->decoder.size); + speex->decoder.size = (speex->decoder.size ? speex->decoder.size : SPEEX_BUFFER_MAX_SIZE) * sizeof(spx_int16_t); + if(!(speex->decoder.buffer = tsk_calloc(speex->decoder.size, 1))){ + speex->decoder.size = 0; + TSK_DEBUG_ERROR("Failed to allocate new buffer"); + return -3; + } + + speex_encoder_ctl(speex->encoder.state, SPEEX_SET_QUALITY, &quality); + speex_encoder_ctl(speex->encoder.state, SPEEX_GET_FRAME_SIZE, &speex->encoder.size); + if(!speex->encoder.size){ + speex->encoder.size = SPEEX_BUFFER_MAX_SIZE; + } + speex_bits_init(&speex->encoder.bits); speex_bits_init(&speex->decoder.bits); speex_bits_reset(&speex->encoder.bits); @@ -170,71 +180,69 @@ tsk_bool_t tdav_codec_speex_fmtp_match(const tmedia_codec_t* codec, const char* // -// Speex Narrow Band Plugin definition +// Speex Codec Object definition // +#define SPEEX_OBJECT_DEFINITION(mode,name,description,format,rate) \ + static tsk_object_t* tdav_codec_speex_##mode##_ctor(tsk_object_t * self, va_list * app) \ + { \ + tdav_codec_speex_t *speex = self; \ + if(speex){ \ + tdav_codec_speex_init(speex, tdav_codec_speex_type_##mode); \ + } \ + return self; \ + } \ + static tsk_object_t* tdav_codec_speex_##mode##_dtor(tsk_object_t * self) \ + { \ + tdav_codec_speex_t *speex = self; \ + if(speex){ \ + /* deinit base */ \ + tmedia_codec_audio_deinit(speex); \ + /* deinit self */ \ + tdav_codec_speex_deinit(speex); \ + } \ + \ + return self; \ + } \ + static const tsk_object_def_t tdav_codec_speex_##mode##_def_s = \ + { \ + sizeof(tdav_codec_speex_t), \ + tdav_codec_speex_##mode##_ctor, \ + tdav_codec_speex_##mode##_dtor, \ + tmedia_codec_cmp, \ + }; \ + static const tmedia_codec_plugin_def_t tdav_codec_speex_##mode##_plugin_def_s = \ + { \ + &tdav_codec_speex_##mode##_def_s, \ + \ + tmedia_audio, \ + name, \ + description, \ + format, \ + tsk_true, \ + rate, /* rate*/ \ + \ + { /* audio */ \ + 1, /* channels*/ \ + 20 /* ptime*/ \ + }, \ + \ + /* video */ \ + {0}, \ + \ + tdav_codec_speex_open, \ + tdav_codec_speex_close, \ + tdav_codec_speex_encode, \ + tdav_codec_speex_decode, \ + tdav_codec_speex_fmtp_match, \ + tdav_codec_speex_fmtp_get, \ + tdav_codec_speex_fmtp_set \ + }; \ + const tmedia_codec_plugin_def_t *tdav_codec_speex_##mode##_plugin_def_t = &tdav_codec_speex_##mode##_plugin_def_s; -/* constructor */ -static tsk_object_t* tdav_codec_speex_nb_ctor(tsk_object_t * self, va_list * app) -{ - tdav_codec_speex_t *speex = self; - if(speex){ - /* init base: called by tmedia_codec_create() */ - /* init self */ - tdav_codec_speex_init(speex, tdav_codec_speex_type_nb); - } - return self; -} -/* destructor */ -static tsk_object_t* tdav_codec_speex_nb_dtor(tsk_object_t * self) -{ - tdav_codec_speex_t *speex = self; - if(speex){ - /* deinit base */ - tmedia_codec_audio_deinit(speex); - /* deinit self */ - tdav_codec_speex_deinit(speex); - } - - return self; -} -/* object definition */ -static const tsk_object_def_t tdav_codec_speex_nb_def_s = -{ - sizeof(tdav_codec_speex_t), - tdav_codec_speex_nb_ctor, - tdav_codec_speex_nb_dtor, - tmedia_codec_cmp, -}; -/* plugin definition*/ -static const tmedia_codec_plugin_def_t tdav_codec_speex_nb_plugin_def_s = -{ - &tdav_codec_speex_nb_def_s, - - tmedia_audio, - "SPEEX", - "Speex Narrow Band Codec", - TMEDIA_CODEC_FORMAT_SPEEX_NB, - tsk_true, - 8000, // rate - - { /* audio */ - 1, // channels - 20 // ptime - }, - - /* video */ - {0}, - - tdav_codec_speex_open, - tdav_codec_speex_close, - tdav_codec_speex_encode, - tdav_codec_speex_decode, - tdav_codec_speex_fmtp_match, - tdav_codec_speex_fmtp_get, - tdav_codec_speex_fmtp_set -}; -const tmedia_codec_plugin_def_t *tdav_codec_speex_nb_plugin_def_t = &tdav_codec_speex_nb_plugin_def_s; +SPEEX_OBJECT_DEFINITION(nb,"SPEEX","Speex-NB Codec",TMEDIA_CODEC_FORMAT_SPEEX_NB,8000); +SPEEX_OBJECT_DEFINITION(wb,"SPEEX","Speex-WB Codec",TMEDIA_CODEC_FORMAT_SPEEX_WB,16000); +SPEEX_OBJECT_DEFINITION(uwb,"SPEEX","Speex-UWB Codec",TMEDIA_CODEC_FORMAT_SPEEX_UWB,32000); // // Common functions diff --git a/branches/2.0/doubango/tinyDAV/src/tdav.c b/branches/2.0/doubango/tinyDAV/src/tdav.c index 6ddde8a3..f7ab846a 100644 --- a/branches/2.0/doubango/tinyDAV/src/tdav.c +++ b/branches/2.0/doubango/tinyDAV/src/tdav.c @@ -163,6 +163,8 @@ int tdav_init() #endif #if HAVE_LIB_SPEEX tmedia_codec_plugin_register(tdav_codec_speex_nb_plugin_def_t); + tmedia_codec_plugin_register(tdav_codec_speex_wb_plugin_def_t); + tmedia_codec_plugin_register(tdav_codec_speex_uwb_plugin_def_t); #endif #if HAVE_G729 tmedia_codec_plugin_register(tdav_codec_g729ab_plugin_def_t); @@ -267,6 +269,8 @@ void tdav_set_codecs(tdav_codec_id_t codecs) #endif #if HAVE_LIB_SPEEX { tdav_codec_id_speex_nb, &tdav_codec_speex_nb_plugin_def_t }, + { tdav_codec_id_speex_wb, &tdav_codec_speex_wb_plugin_def_t }, + { tdav_codec_id_speex_uwb, &tdav_codec_speex_uwb_plugin_def_t }, #endif #if HAVE_G729 { tdav_codec_id_g729ab, &tdav_codec_g729ab_plugin_def_t }, @@ -328,6 +332,8 @@ tsk_bool_t tdav_codec_is_supported(tdav_codec_id_t codec) #endif case tdav_codec_id_speex_nb: + case tdav_codec_id_speex_wb: + case tdav_codec_id_speex_uwb: #if HAVE_LIB_SPEEX return tsk_true; #else @@ -377,8 +383,6 @@ tsk_bool_t tdav_codec_is_supported(tdav_codec_id_t codec) case tdav_codec_id_amr_wb_oa: case tdav_codec_id_amr_wb_be: - case tdav_codec_id_speex_wb: - case tdav_codec_id_speex_uwb: case tdav_codec_id_bv32: case tdav_codec_id_evrc: default: @@ -430,6 +434,8 @@ int tdav_deinit() #endif #if HAVE_LIB_SPEEX tmedia_codec_plugin_unregister(tdav_codec_speex_nb_plugin_def_t); + tmedia_codec_plugin_unregister(tdav_codec_speex_wb_plugin_def_t); + tmedia_codec_plugin_unregister(tdav_codec_speex_uwb_plugin_def_t); #endif #if HAVE_G729 tmedia_codec_plugin_unregister(tdav_codec_g729ab_plugin_def_t); diff --git a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSConsumer.cxx b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSConsumer.cxx index b70e67bc..3000ac29 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSConsumer.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSConsumer.cxx @@ -218,7 +218,7 @@ static tsk_object_t* tdshow_consumer_ctor(tsk_object_t * self, va_list * app) /* init self */ TMEDIA_CONSUMER(consumer)->video.fps = 15; - TMEDIA_CONSUMER(consumer)->video.display.width = 320; + TMEDIA_CONSUMER(consumer)->video.display.width = 352; TMEDIA_CONSUMER(consumer)->video.display.height = 288; TMEDIA_CONSUMER(consumer)->video.display.auto_resize = tsk_true; diff --git a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx index f658337e..754133b1 100644 --- a/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx +++ b/branches/2.0/doubango/tinyDSHOW/src/plugin/DSProducer.cxx @@ -89,8 +89,8 @@ int tdshow_producer_prepare(tmedia_producer_t* self, const tmedia_codec_t* codec TMEDIA_PRODUCER(producer)->video.fps = TMEDIA_CODEC_VIDEO(codec)->out.fps; // FIXME - TMEDIA_PRODUCER(producer)->video.width = 320;//TMEDIA_CODEC_VIDEO(codec)->out.width; - TMEDIA_PRODUCER(producer)->video.height = 240;//TMEDIA_CODEC_VIDEO(codec)->out.height; + TMEDIA_PRODUCER(producer)->video.width = TMEDIA_CODEC_VIDEO(codec)->out.width; + TMEDIA_PRODUCER(producer)->video.height = TMEDIA_CODEC_VIDEO(codec)->out.height; return 0; }