Changeset 653 for pjproject/trunk/pjmedia/src/pjmedia/echo_port.c
- Timestamp:
- Aug 6, 2006 12:07:13 PM (18 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/echo_port.c
r652 r653 17 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 18 */ 19 #include <pjmedia/ aec_port.h>20 #include <pjmedia/ aec.h>19 #include <pjmedia/echo_port.h> 20 #include <pjmedia/echo.h> 21 21 #include <pjmedia/errno.h> 22 22 #include <pj/assert.h> … … 25 25 26 26 27 #define THIS_FILE " aec_port.c"28 #define SIGNATURE PJMEDIA_PORT_SIGNATURE(' A', 'E', 'C', '')27 #define THIS_FILE "ec_port.c" 28 #define SIGNATURE PJMEDIA_PORT_SIGNATURE('E', 'C', 'H', 'O') 29 29 #define BUF_COUNT 32 30 30 31 struct aec31 struct ec 32 32 { 33 pjmedia_port 34 pjmedia_port 35 pjmedia_ aec *aec;33 pjmedia_port base; 34 pjmedia_port *dn_port; 35 pjmedia_echo_state *ec; 36 36 }; 37 37 38 38 39 static pj_status_t aec_put_frame(pjmedia_port *this_port,40 41 static pj_status_t aec_get_frame(pjmedia_port *this_port,42 43 static pj_status_t aec_on_destroy(pjmedia_port *this_port);39 static pj_status_t ec_put_frame(pjmedia_port *this_port, 40 const pjmedia_frame *frame); 41 static pj_status_t ec_get_frame(pjmedia_port *this_port, 42 pjmedia_frame *frame); 43 static pj_status_t ec_on_destroy(pjmedia_port *this_port); 44 44 45 45 46 PJ_DEF(pj_status_t) pjmedia_ aec_port_create(pj_pool_t *pool,46 PJ_DEF(pj_status_t) pjmedia_echo_port_create(pj_pool_t *pool, 47 47 pjmedia_port *dn_port, 48 48 unsigned tail_ms, 49 unsigned options, 49 50 pjmedia_port **p_port ) 50 51 { 51 const pj_str_t AEC = { " AEC", 3};52 struct aec *aec;52 const pj_str_t AEC = { "EC", 2 }; 53 struct ec *ec; 53 54 pj_status_t status; 54 55 … … 58 59 59 60 /* Create the port and the AEC itself */ 60 aec = pj_pool_zalloc(pool, sizeof(struct aec));61 ec = pj_pool_zalloc(pool, sizeof(struct ec)); 61 62 62 pjmedia_port_info_init(& aec->base.info, &AEC, SIGNATURE,63 pjmedia_port_info_init(&ec->base.info, &AEC, SIGNATURE, 63 64 dn_port->info.clock_rate, 64 65 dn_port->info.channel_count, … … 66 67 dn_port->info.samples_per_frame); 67 68 68 status = pjmedia_ aec_create(pool, dn_port->info.clock_rate,69 dn_port->info.samples_per_frame,70 tail_ms, 0, &aec->aec);69 status = pjmedia_echo_create(pool, dn_port->info.clock_rate, 70 dn_port->info.samples_per_frame, 71 tail_ms, options, &ec->ec); 71 72 if (status != PJ_SUCCESS) 72 73 return status; 73 74 74 75 /* More init */ 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;76 ec->dn_port = dn_port; 77 ec->base.get_frame = &ec_get_frame; 78 ec->base.put_frame = &ec_put_frame; 79 ec->base.on_destroy = &ec_on_destroy; 79 80 80 81 /* Done */ 81 *p_port = & aec->base;82 *p_port = &ec->base; 82 83 83 84 return PJ_SUCCESS; … … 85 86 86 87 87 static pj_status_t aec_put_frame(pjmedia_port *this_port,88 static pj_status_t ec_put_frame( pjmedia_port *this_port, 88 89 const pjmedia_frame *frame) 89 90 { 90 struct aec *aec = (struct aec*)this_port;91 struct ec *ec = (struct ec*)this_port; 91 92 92 93 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 93 94 94 95 if (frame->type == PJMEDIA_FRAME_TYPE_NONE ) { 95 return pjmedia_port_put_frame( aec->dn_port, frame);96 return pjmedia_port_put_frame(ec->dn_port, frame); 96 97 } 97 98 … … 99 100 PJ_EINVAL); 100 101 101 pjmedia_ aec_capture(aec->aec, frame->buf, 0);102 pjmedia_echo_capture(ec->ec, frame->buf, 0); 102 103 103 return pjmedia_port_put_frame( aec->dn_port, frame);104 return pjmedia_port_put_frame(ec->dn_port, frame); 104 105 } 105 106 106 107 107 static pj_status_t aec_get_frame( pjmedia_port *this_port,108 108 static pj_status_t ec_get_frame( pjmedia_port *this_port, 109 pjmedia_frame *frame) 109 110 { 110 struct aec *aec = (struct aec*)this_port;111 struct ec *ec = (struct ec*)this_port; 111 112 pj_status_t status; 112 113 113 114 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 114 115 115 status = pjmedia_port_get_frame( aec->dn_port, frame);116 status = pjmedia_port_get_frame(ec->dn_port, frame); 116 117 if (status!=PJ_SUCCESS || frame->type!=PJMEDIA_FRAME_TYPE_AUDIO) { 117 118 pjmedia_zero_samples(frame->buf, this_port->info.samples_per_frame); 118 119 } 119 120 120 pjmedia_ aec_playback(aec->aec, frame->buf);121 pjmedia_echo_playback(ec->ec, frame->buf); 121 122 122 123 return status; … … 124 125 125 126 126 static pj_status_t aec_on_destroy(pjmedia_port *this_port)127 static pj_status_t ec_on_destroy(pjmedia_port *this_port) 127 128 { 128 struct aec *aec = (struct aec*)this_port;129 struct ec *ec = (struct ec*)this_port; 129 130 130 131 PJ_ASSERT_RETURN(this_port->info.signature == SIGNATURE, PJ_EINVAL); 131 132 132 pjmedia_ aec_destroy(aec->aec);133 pjmedia_echo_destroy(ec->ec); 133 134 134 135 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.