summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-08-07 10:24:52 +0000
committerBenny Prijono <bennylp@teluu.com>2006-08-07 10:24:52 +0000
commitc14e6bf7c11fb28266cab45ccaa477a54fe3fd59 (patch)
treef05279a71b587759964bb0c16fee5259422f2c43 /pjmedia
parent7786b1e99d249798e0e394bf473b954b3a612072 (diff)
Change set_ec_tail() API to set_ec() in sound port, also change suppressor to reduce mic signal by division rather than zeroing the signal. Also moved out VAD and EC settings to config.h.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@658 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/include/pjmedia/config.h31
-rw-r--r--pjmedia/include/pjmedia/silencedet.h7
-rw-r--r--pjmedia/include/pjmedia/sound_port.h8
-rw-r--r--pjmedia/src/pjmedia/echo_suppress.c18
-rw-r--r--pjmedia/src/pjmedia/sound_port.c17
5 files changed, 57 insertions, 24 deletions
diff --git a/pjmedia/include/pjmedia/config.h b/pjmedia/include/pjmedia/config.h
index 871177ae..344ef2c2 100644
--- a/pjmedia/include/pjmedia/config.h
+++ b/pjmedia/include/pjmedia/config.h
@@ -161,6 +161,16 @@
/**
+ * Suggested or default threshold to be set for fixed silence detection
+ * or as starting threshold for adaptive silence detection. The threshold
+ * has the range from zero to 255.
+ */
+#ifndef PJMEDIA_SILENCE_DET_THRESHOLD
+# define PJMEDIA_SILENCE_DET_THRESHOLD 4
+#endif
+
+
+/**
* G.711 Appendix I Packet Lost Concealment (PLC).
* Enabled only when floating point is enabled.
*/
@@ -179,6 +189,27 @@
/**
+ * Initial signal threshold to be applied to echo suppressor. When
+ * playback signal level is greater than this threshold, the microphone
+ * signal will be reduced or cut.
+ */
+#ifndef PJMEDIA_ECHO_SUPPRESS_THRESHOLD
+# define PJMEDIA_ECHO_SUPPRESS_THRESHOLD PJMEDIA_SILENCE_DET_THRESHOLD
+#endif
+
+
+/**
+ * The signal reduction factor to be applied into the microphone signal
+ * when the mic signal needs to be reduced. Valid values are [1-16], where
+ * 1 will leave signal as it is (thus probably transmitting the echo) and
+ * 16 will effectively zero the signal.
+ */
+#ifndef PJMEDIA_ECHO_SUPPRESS_FACTOR
+# define PJMEDIA_ECHO_SUPPRESS_FACTOR 4
+#endif
+
+
+/**
* Support for sending and decoding RTCP port in SDP (RFC 3605).
* Default is yes.
*/
diff --git a/pjmedia/include/pjmedia/silencedet.h b/pjmedia/include/pjmedia/silencedet.h
index 15cb8460..c4cfbaa8 100644
--- a/pjmedia/include/pjmedia/silencedet.h
+++ b/pjmedia/include/pjmedia/silencedet.h
@@ -44,13 +44,6 @@ PJ_BEGIN_DECL
typedef struct pjmedia_silence_det pjmedia_silence_det;
-/**
- * Suggested or default threshold to be set for fixed silence detection
- * or as starting threshold for adaptive silence detection. The threshold
- * has the range from zero to 255.
- */
-#define PJMEDIA_SILENCE_DET_THRESHOLD 4
-
/**
* Create voice activity detector with default settings. The default settings
diff --git a/pjmedia/include/pjmedia/sound_port.h b/pjmedia/include/pjmedia/sound_port.h
index 7653c35c..c65a11dc 100644
--- a/pjmedia/include/pjmedia/sound_port.h
+++ b/pjmedia/include/pjmedia/sound_port.h
@@ -197,12 +197,14 @@ PJ_DECL(pjmedia_snd_stream*) pjmedia_snd_port_get_snd_stream(
* @param tail_ms Maximum echo tail length to be supported, in
* miliseconds. If zero is specified, the EC would
* be disabled.
+ * @param options The options to be passed to #pjmedia_echo_create().
*
* @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec_tail(pjmedia_snd_port *snd_port,
- pj_pool_t *pool,
- unsigned tail_ms);
+PJ_DECL(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+ pj_pool_t *pool,
+ unsigned tail_ms,
+ unsigned options);
/**
diff --git a/pjmedia/src/pjmedia/echo_suppress.c b/pjmedia/src/pjmedia/echo_suppress.c
index a3bf4bfb..39b59a64 100644
--- a/pjmedia/src/pjmedia/echo_suppress.c
+++ b/pjmedia/src/pjmedia/echo_suppress.c
@@ -27,7 +27,6 @@
#define THIS_FILE "echo_suppress.c"
-#define PJMEDIA_ECHO_SUPPRESS_THRESHOLD PJMEDIA_SILENCE_DET_THRESHOLD
/*
@@ -159,7 +158,15 @@ PJ_DEF(pj_status_t) echo_supp_capture( void *state,
delay_ms = PJ_TIME_VAL_MSEC(now);
if (delay_ms < ec->tail_ms) {
+#if defined(PJMEDIA_ECHO_SUPPRESS_FACTOR) && PJMEDIA_ECHO_SUPPRESS_FACTOR!=0
+ unsigned i;
+ for (i=0; i<ec->samples_per_frame; ++i) {
+ rec_frm[i] = (pj_int16_t)(rec_frm[i] >>
+ PJMEDIA_ECHO_SUPPRESS_FACTOR);
+ }
+#else
pjmedia_zero_samples(rec_frm, ec->samples_per_frame);
+#endif
}
return PJ_SUCCESS;
@@ -185,10 +192,17 @@ PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
ec->samples_per_frame, NULL);
if (!silence) {
+#if defined(PJMEDIA_ECHO_SUPPRESS_FACTOR) && PJMEDIA_ECHO_SUPPRESS_FACTOR!=0
+ unsigned i;
+ for (i=0; i<ec->samples_per_frame; ++i) {
+ rec_frm[i] = (pj_int16_t)(rec_frm[i] >>
+ PJMEDIA_ECHO_SUPPRESS_FACTOR);
+ }
+#else
pjmedia_zero_samples(rec_frm, ec->samples_per_frame);
+#endif
}
return PJ_SUCCESS;
}
-
diff --git a/pjmedia/src/pjmedia/sound_port.c b/pjmedia/src/pjmedia/sound_port.c
index dd08a338..ee60dbd9 100644
--- a/pjmedia/src/pjmedia/sound_port.c
+++ b/pjmedia/src/pjmedia/sound_port.c
@@ -249,14 +249,6 @@ static pj_status_t start_sound_device( pj_pool_t *pool,
}
}
- /* Create AEC only when direction is full duplex */
- if (snd_port->dir == PJMEDIA_DIR_CAPTURE_PLAYBACK) {
- status = pjmedia_snd_port_set_ec_tail(snd_port, pool, AEC_TAIL);
- if (status != PJ_SUCCESS) {
- PJ_LOG(4,(THIS_FILE, "Unable to create AEC"));
- snd_port->ec_state = NULL;
- }
- }
/* Start sound stream. */
status = pjmedia_snd_stream_start(snd_port->snd_stream);
@@ -432,9 +424,10 @@ PJ_DEF(pjmedia_snd_stream*) pjmedia_snd_port_get_snd_stream(
/*
* Enable AEC
*/
-PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec_tail(pjmedia_snd_port *snd_port,
- pj_pool_t *pool,
- unsigned tail_ms)
+PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec( pjmedia_snd_port *snd_port,
+ pj_pool_t *pool,
+ unsigned tail_ms,
+ unsigned options)
{
pj_status_t status;
@@ -454,7 +447,7 @@ PJ_DEF(pj_status_t) pjmedia_snd_port_set_ec_tail(pjmedia_snd_port *snd_port,
if (tail_ms != 0) {
status = pjmedia_echo_create(pool, snd_port->clock_rate,
snd_port->samples_per_frame,
- tail_ms, 0, &snd_port->ec_state);
+ tail_ms, options, &snd_port->ec_state);
if (status != PJ_SUCCESS)
snd_port->ec_state = NULL;
} else {