Changeset 646
- Timestamp:
- Aug 4, 2006 11:08:00 AM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 5 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/build/pjmedia.dsp
r642 r646 92 92 # Begin Source File 93 93 94 SOURCE=..\src\pjmedia\aec_speex.c 95 # End Source File 96 # Begin Source File 97 94 98 SOURCE=..\src\pjmedia\alaw_ulaw.c 99 # End Source File 100 # Begin Source File 101 102 SOURCE=..\src\pjmedia\bidirectional.c 95 103 # End Source File 96 104 # Begin Source File … … 232 240 # Begin Source File 233 241 242 SOURCE=..\include\pjmedia\aec.h 243 # End Source File 244 # Begin Source File 245 234 246 SOURCE=..\include\pjmedia\aec_port.h 247 # End Source File 248 # Begin Source File 249 250 SOURCE=..\include\pjmedia\bidirectional.h 235 251 # End Source File 236 252 # Begin Source File -
pjproject/trunk/pjmedia/include/pjmedia.h
r642 r646 26 26 27 27 #include <pjmedia/types.h> 28 #include <pjmedia/aec.h> 28 29 #include <pjmedia/aec_port.h> 30 #include <pjmedia/bidirectional.h> 29 31 #include <pjmedia/clock.h> 30 32 #include <pjmedia/codec.h> -
pjproject/trunk/pjmedia/src/pjmedia/aec_port.c
r643 r646 18 18 */ 19 19 #include <pjmedia/aec_port.h> 20 #include "../pjmedia-codec/speex/speex_echo.h"20 #include <pjmedia/aec.h> 21 21 #include <pjmedia/errno.h> 22 22 #include <pj/assert.h> … … 27 27 #define THIS_FILE "aec_port.c" 28 28 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('A', 'E', 'C', ' ') 29 #define BUF_COUNT 32 29 30 30 31 struct aec_port 31 struct aec 32 32 { 33 33 pjmedia_port base; 34 34 pjmedia_port *dn_port; 35 SpeexEchoState *state; 36 pj_int16_t *tmp_frame; 37 pj_bool_t has_frame; 38 pj_int16_t *last_frame; 35 pjmedia_aec *aec; 39 36 }; 40 37 … … 53 50 { 54 51 const pj_str_t AEC = { "AEC", 3 }; 55 struct aec _port *aec_port;56 int sampling_rate;52 struct aec *aec; 53 pj_status_t status; 57 54 58 55 PJ_ASSERT_RETURN(pool && dn_port && p_port, PJ_EINVAL); … … 60 57 PJ_EINVAL); 61 58 62 /* Create and initialize the port*/63 aec _port = pj_pool_zalloc(pool, sizeof(struct aec_port));59 /* Create the port and the AEC itself */ 60 aec = pj_pool_zalloc(pool, sizeof(struct aec)); 64 61 65 pjmedia_port_info_init(&aec _port->base.info, &AEC, SIGNATURE,62 pjmedia_port_info_init(&aec->base.info, &AEC, SIGNATURE, 66 63 dn_port->info.clock_rate, 67 64 dn_port->info.channel_count, … … 69 66 dn_port->info.samples_per_frame); 70 67 71 aec_port->state = speex_echo_state_init(dn_port->info.samples_per_frame, 72 tail_length); 73 74 /* Set sampling rate */ 75 sampling_rate = 0; 76 speex_echo_ctl(aec_port->state, SPEEX_ECHO_GET_SAMPLING_RATE, 77 &sampling_rate); 78 sampling_rate = dn_port->info.clock_rate; 79 speex_echo_ctl(aec_port->state, SPEEX_ECHO_SET_SAMPLING_RATE, 80 &sampling_rate); 68 status = pjmedia_aec_create(pool, dn_port->info.clock_rate, 69 dn_port->info.samples_per_frame, 70 tail_length, 0, &aec->aec); 71 if (status != PJ_SUCCESS) 72 return status; 81 73 82 74 /* More init */ 83 aec_port->dn_port = dn_port; 84 aec_port->base.get_frame = &aec_get_frame; 85 aec_port->base.put_frame = &aec_put_frame; 86 aec_port->base.on_destroy = &aec_on_destroy; 87 88 aec_port->last_frame = pj_pool_zalloc(pool, sizeof(pj_int16_t) * 89 dn_port->info.samples_per_frame); 90 aec_port->tmp_frame = pj_pool_zalloc(pool, sizeof(pj_int16_t) * 91 dn_port->info.samples_per_frame); 75 aec->dn_port = dn_port; 76 aec->base.get_frame = &aec_get_frame; 77 aec->base.put_frame = &aec_put_frame; 78 aec->base.on_destroy = &aec_on_destroy; 92 79 93 80 /* Done */ 94 *p_port = &aec _port->base;81 *p_port = &aec->base; 95 82 96 PJ_LOG(4,(THIS_FILE, "AEC created for port %.*s, clock_rate=%d, "97 "samples per frame=%d, tail length=%d ms",98 (int)dn_port->info.name.slen,99 dn_port->info.name.ptr,100 dn_port->info.clock_rate,101 dn_port->info.samples_per_frame,102 tail_length * 1000 / dn_port->info.clock_rate));103 83 return PJ_SUCCESS; 104 84 } … … 108 88 const pjmedia_frame *frame) 109 89 { 110 struct aec _port *aec_port = (struct aec_port*)this_port;90 struct aec *aec = (struct aec*)this_port; 111 91 112 92 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 113 93 114 if (frame->type == PJMEDIA_FRAME_TYPE_NONE || !aec_port->has_frame) {115 return pjmedia_port_put_frame(aec _port->dn_port, frame);94 if (frame->type == PJMEDIA_FRAME_TYPE_NONE ) { 95 return pjmedia_port_put_frame(aec->dn_port, frame); 116 96 } 117 97 … … 119 99 PJ_EINVAL); 120 100 121 speex_echo_cancel(aec_port->state, 122 (const spx_int16_t*)frame->buf, 123 (const spx_int16_t*)aec_port->last_frame, 124 (spx_int16_t*)aec_port->tmp_frame, 125 NULL); 101 pjmedia_aec_capture(aec->aec, frame->buf, 0); 126 102 127 pjmedia_copy_samples(frame->buf, aec_port->tmp_frame, 128 this_port->info.samples_per_frame); 129 130 return pjmedia_port_put_frame(aec_port->dn_port, frame); 103 return pjmedia_port_put_frame(aec->dn_port, frame); 131 104 } 132 105 … … 135 108 pjmedia_frame *frame) 136 109 { 137 struct aec _port *aec_port = (struct aec_port*)this_port;110 struct aec *aec = (struct aec*)this_port; 138 111 pj_status_t status; 139 112 140 113 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 141 114 142 status = pjmedia_port_get_frame(aec_port->dn_port, frame); 143 if (status==PJ_SUCCESS && frame->type==PJMEDIA_FRAME_TYPE_AUDIO) { 144 aec_port->has_frame = PJ_TRUE; 145 pjmedia_copy_samples(aec_port->tmp_frame, frame->buf, 146 this_port->info.samples_per_frame); 147 } else { 148 aec_port->has_frame = PJ_FALSE; 115 status = pjmedia_port_get_frame(aec->dn_port, frame); 116 if (status!=PJ_SUCCESS || frame->type!=PJMEDIA_FRAME_TYPE_AUDIO) { 117 pjmedia_zero_samples(frame->buf, this_port->info.samples_per_frame); 149 118 } 119 120 pjmedia_aec_playback(aec->aec, frame->buf); 150 121 151 122 return status; … … 155 126 static pj_status_t aec_on_destroy(pjmedia_port *this_port) 156 127 { 157 struct aec _port *aec_port = (struct aec_port*)this_port;128 struct aec *aec = (struct aec*)this_port; 158 129 159 130 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 160 131 161 speex_echo_state_destroy(aec_port->state);132 pjmedia_aec_destroy(aec->aec); 162 133 163 134 return PJ_SUCCESS; -
pjproject/trunk/pjmedia/src/pjmedia/sound_port.c
r582 r646 18 18 */ 19 19 #include <pjmedia/sound_port.h> 20 #include <pjmedia/aec.h> 20 21 #include <pjmedia/errno.h> 21 22 #include <pjmedia/plc.h> … … 25 26 #include <pj/string.h> /* pj_memset() */ 26 27 28 #ifndef PJMEDIA_SOUND_HAS_AEC 29 # define PJMEDIA_SOUND_HAS_AEC 1 30 #endif 31 32 #if defined(PJMEDIA_SOUND_HAS_AEC) && PJMEDIA_SOUND_HAS_AEC!=0 33 # include <speex/speex_echo.h> 34 #endif 27 35 28 36 //#define SIMULATE_LOST_PCT 20 29 37 #define AEC_TAIL 500 /* in ms */ 30 38 31 39 #define THIS_FILE "sound_port.c" … … 49 57 unsigned options; 50 58 59 pjmedia_aec *aec; 51 60 pjmedia_plc *plc; 52 61 … … 105 114 if (snd_port->plc) 106 115 pjmedia_plc_save(snd_port->plc, output); 116 117 if (snd_port->aec) { 118 pjmedia_aec_playback(snd_port->aec, output); 119 } 120 107 121 108 122 return PJ_SUCCESS; … … 122 136 123 137 138 if (snd_port->aec) { 139 pjmedia_aec_playback(snd_port->aec, output); 140 } 141 124 142 return PJ_SUCCESS; 125 143 } … … 132 150 static pj_status_t rec_cb(/* in */ void *user_data, 133 151 /* in */ pj_uint32_t timestamp, 134 /* in */ constvoid *input,152 /* in */ void *input, 135 153 /* in*/ unsigned size) 136 154 { … … 138 156 pjmedia_port *port; 139 157 pjmedia_frame frame; 158 159 /* Cancel echo */ 160 if (snd_port->aec) { 161 pjmedia_aec_capture(snd_port->aec, input, 0); 162 } 140 163 141 164 /* We're risking accessing the port without holding any mutex. … … 228 251 } 229 252 253 /* Create AEC only when direction is full duplex */ 254 if (snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) { 255 status = pjmedia_aec_create(pool, snd_port->clock_rate, 256 snd_port->samples_per_frame, 257 snd_port->clock_rate * AEC_TAIL / 1000, 258 0, &snd_port->aec); 259 if (status != PJ_SUCCESS) 260 snd_port->aec = NULL; 261 } 262 230 263 /* Start sound stream. */ 231 264 status = pjmedia_snd_stream_start(snd_port->snd_stream); … … 251 284 pjmedia_snd_stream_close(snd_port->snd_stream); 252 285 snd_port->snd_stream = NULL; 286 } 287 288 /* Destroy AEC */ 289 if (snd_port->aec) { 290 pjmedia_aec_destroy(snd_port->aec); 291 snd_port->aec = NULL; 253 292 } 254 293 -
pjproject/trunk/pjsip-apps/build
- Property svn:ignore
-
old new 8 8 *.suo 9 9 *.pdb 10 *.wav 10 11 activex-pjsua_p.c 11 12 dlldata.c
-
- Property svn:ignore
-
pjproject/trunk/pjsip-apps/build/samples.dsp
r585 r646 87 87 # Begin Source File 88 88 89 SOURCE=..\src\samples\aectest.c 90 # End Source File 91 # Begin Source File 92 89 93 SOURCE=..\src\samples\confbench.c 90 94 # End Source File -
pjproject/trunk/pjsip-apps/src/samples/debug.c
r601 r646 28 28 * #include "playfile.c" 29 29 */ 30 #include " pjsip-perf.c"30 #include "aectest.c" 31 31
Note: See TracChangeset
for help on using the changeset viewer.