summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-02-25 02:04:42 +0000
committerBenny Prijono <bennylp@teluu.com>2006-02-25 02:04:42 +0000
commite5290641d50566a9aff8eae9bec8d585f79077de (patch)
tree4987d6239ad1a40eb558667b7c6a81fc21b82e40
parentd5b883d52b22b6fa6ea17d99a9aed46edb3c5b56 (diff)
Synched with documentation
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@228 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjlib/include/pj/os.h24
-rw-r--r--pjlib/include/pj/types.h24
-rw-r--r--pjmedia/build/pjmedia.dsp12
-rw-r--r--pjmedia/include/pjmedia/jbuf.h3
-rw-r--r--pjmedia/include/pjmedia/silencedet.h (renamed from pjmedia/include/pjmedia/vad.h)62
-rw-r--r--pjmedia/src/pjmedia/conference.c18
-rw-r--r--pjmedia/src/pjmedia/jbuf.c3
-rw-r--r--pjmedia/src/pjmedia/silencedet.c (renamed from pjmedia/src/pjmedia/vad.c)166
-rw-r--r--pjmedia/src/pjmedia/stream.c19
-rw-r--r--pjsip/include/pjsip-simple/evsub.h14
10 files changed, 182 insertions, 163 deletions
diff --git a/pjlib/include/pj/os.h b/pjlib/include/pj/os.h
index 8c04364d..991dacd0 100644
--- a/pjlib/include/pj/os.h
+++ b/pjlib/include/pj/os.h
@@ -892,30 +892,6 @@ PJ_DECL(pj_color_t) pj_term_get_color(void);
#if defined(PJ_HAS_HIGH_RES_TIMER) && PJ_HAS_HIGH_RES_TIMER != 0
/**
- * This structure represents high resolution (64bit) time value. The time
- * values represent time in cycles, which is retrieved by calling
- * #pj_get_timestamp().
- */
-typedef union pj_timestamp
-{
- struct
- {
-#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
- pj_uint32_t lo; /**< Low 32-bit value of the 64-bit value. */
- pj_uint32_t hi; /**< high 32-bit value of the 64-bit value. */
-#else
- pj_uint32_t hi; /**< high 32-bit value of the 64-bit value. */
- pj_uint32_t lo; /**< Low 32-bit value of the 64-bit value. */
-#endif
- } u32; /**< The 64-bit value as two 32-bit values. */
-
-#if PJ_HAS_INT64
- pj_uint64_t u64; /**< The whole 64-bit value, where available. */
-#endif
-} pj_timestamp;
-
-
-/**
* Acquire high resolution timer value. The time value are stored
* in cycles.
*
diff --git a/pjlib/include/pj/types.h b/pjlib/include/pj/types.h
index 69d440a9..6f86895e 100644
--- a/pjlib/include/pj/types.h
+++ b/pjlib/include/pj/types.h
@@ -120,6 +120,30 @@ struct pj_str_t
pj_ssize_t slen;
};
+/**
+ * This structure represents high resolution (64bit) time value. The time
+ * values represent time in cycles, which is retrieved by calling
+ * #pj_get_timestamp().
+ */
+typedef union pj_timestamp
+{
+ struct
+ {
+#if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN!=0
+ pj_uint32_t lo; /**< Low 32-bit value of the 64-bit value. */
+ pj_uint32_t hi; /**< high 32-bit value of the 64-bit value. */
+#else
+ pj_uint32_t hi; /**< high 32-bit value of the 64-bit value. */
+ pj_uint32_t lo; /**< Low 32-bit value of the 64-bit value. */
+#endif
+ } u32; /**< The 64-bit value as two 32-bit values. */
+
+#if PJ_HAS_INT64
+ pj_uint64_t u64; /**< The whole 64-bit value, where available. */
+#endif
+} pj_timestamp;
+
+
/**
* The opaque data type for linked list, which is used as arguments throughout
diff --git a/pjmedia/build/pjmedia.dsp b/pjmedia/build/pjmedia.dsp
index 963a85b8..7edaa90e 100644
--- a/pjmedia/build/pjmedia.dsp
+++ b/pjmedia/build/pjmedia.dsp
@@ -161,11 +161,11 @@ SOURCE=..\src\pjmedia\session.c
# End Source File
# Begin Source File
-SOURCE=..\src\pjmedia\stream.c
+SOURCE=..\src\pjmedia\silencedet.c
# End Source File
# Begin Source File
-SOURCE=..\src\pjmedia\vad.c
+SOURCE=..\src\pjmedia\stream.c
# End Source File
# End Group
# Begin Group "Header Files"
@@ -237,19 +237,19 @@ SOURCE=..\include\pjmedia\session.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjmedia\sound.h
+SOURCE=..\include\pjmedia\silencedet.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjmedia\stream.h
+SOURCE=..\include\pjmedia\sound.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjmedia\types.h
+SOURCE=..\include\pjmedia\stream.h
# End Source File
# Begin Source File
-SOURCE=..\include\pjmedia\vad.h
+SOURCE=..\include\pjmedia\types.h
# End Source File
# Begin Source File
diff --git a/pjmedia/include/pjmedia/jbuf.h b/pjmedia/include/pjmedia/jbuf.h
index d4cfebcc..9a0d5c6a 100644
--- a/pjmedia/include/pjmedia/jbuf.h
+++ b/pjmedia/include/pjmedia/jbuf.h
@@ -16,6 +16,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/*
+ * Based on implementation kindly contributed by Switchlab, Ltd.
+ */
#ifndef __PJMEDIA_JBUF_H__
#define __PJMEDIA_JBUF_H__
diff --git a/pjmedia/include/pjmedia/vad.h b/pjmedia/include/pjmedia/silencedet.h
index fc7f3b2f..91da8597 100644
--- a/pjmedia/include/pjmedia/vad.h
+++ b/pjmedia/include/pjmedia/silencedet.h
@@ -16,13 +16,13 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef __PJMEDIA_VAD_H__
-#define __PJMEDIA_VAD_H__
+#ifndef __PJMEDIA_SILENCE_DET_H__
+#define __PJMEDIA_SILENCE_DET_H__
/**
- * @file vad.h
- * @brief Simple, adaptive silence detector.
+ * @file silencedet.h
+ * @brief Adaptive silence detector.
*/
#include <pjmedia/types.h>
@@ -30,9 +30,9 @@ PJ_BEGIN_DECL
/**
- * @see pjmedia_vad
+ * Opaque declaration for silence detector.
*/
-typedef struct pjmedia_vad pjmedia_vad;
+typedef struct pjmedia_silence_det pjmedia_silence_det;
/**
@@ -41,47 +41,47 @@ typedef struct pjmedia_vad pjmedia_vad;
* dynamically based on current input level.
*
* @param pool Pool for allocating the structure.
- * @param p_vad Pointer to receive the VAD instance.
+ * @param p_sd Pointer to receive the silence detector instance.
*
* @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_status_t) pjmedia_vad_create( pj_pool_t *pool,
- pjmedia_vad **p_vad );
+PJ_DECL(pj_status_t) pjmedia_silence_det_create( pj_pool_t *pool,
+ pjmedia_silence_det **p_sd );
/**
- * Set the vad to operate in adaptive mode.
+ * Set the sd to operate in adaptive mode.
*
- * @param vad The vad
- * @param frame_size Number of samplse per frame.
+ * @param sd The silence detector
+ * @param frame_size Number of samples per frame.
*
- * @return PJ_SUCCESS on success.
+ * @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_status_t) pjmedia_vad_set_adaptive( pjmedia_vad *vad,
- unsigned frame_size);
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_adaptive( pjmedia_silence_det *sd,
+ unsigned frame_size);
/**
- * Set the vad to operate in fixed threshold mode.
+ * Set the sd to operate in fixed threshold mode.
*
- * @param vad The vad
+ * @param sd The silence detector
* @param frame_size Number of samplse per frame.
* @param threshold The silence threshold.
*
* @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_status_t) pjmedia_vad_set_fixed( pjmedia_vad *vad,
- unsigned frame_size,
- unsigned threshold );
+PJ_DECL(pj_status_t) pjmedia_silence_det_set_fixed( pjmedia_silence_det *sd,
+ unsigned frame_size,
+ unsigned threshold );
/**
- * Disable the vad.
+ * Disable the silence detector.
*
- * @param vad The vad
+ * @param sd The silence detector
*
* @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_status_t) pjmedia_vad_disable( pjmedia_vad *vad );
+PJ_DECL(pj_status_t) pjmedia_silence_det_disable( pjmedia_silence_det *sd );
/**
@@ -93,14 +93,14 @@ PJ_DECL(pj_status_t) pjmedia_vad_disable( pjmedia_vad *vad );
* @return The average signal level, which simply is total level
* divided by number of samples.
*/
-PJ_DECL(pj_int32_t) pjmedia_vad_calc_avg_signal( const pj_int16_t samples[],
- pj_size_t count );
+PJ_DECL(pj_int32_t) pjmedia_silence_det_calc_avg_signal( const pj_int16_t samples[],
+ pj_size_t count );
/**
* Perform voice activity detection on the given input samples.
*
- * @param vad The VAD instance.
+ * @param sd The silence detector instance.
* @param samples Pointer to 16-bit PCM input samples.
* @param count Number of samples in the input.
* @param p_level Optional pointer to receive average signal level
@@ -108,13 +108,13 @@ PJ_DECL(pj_int32_t) pjmedia_vad_calc_avg_signal( const pj_int16_t samples[],
*
* @return PJ_SUCCESS on success.
*/
-PJ_DECL(pj_bool_t) pjmedia_vad_detect_silence( pjmedia_vad *vad,
- const pj_int16_t samples[],
- pj_size_t count,
- pj_int32_t *p_level);
+PJ_DECL(pj_bool_t) pjmedia_silence_det_detect_silence( pjmedia_silence_det *sd,
+ const pj_int16_t samples[],
+ pj_size_t count,
+ pj_int32_t *p_level);
PJ_END_DECL
-#endif /* __PJMEDIA_VAD_H__ */
+#endif /* __PJMEDIA_SILENCE_DET_H__ */
diff --git a/pjmedia/src/pjmedia/conference.c b/pjmedia/src/pjmedia/conference.c
index ba29a602..0db3ccad 100644
--- a/pjmedia/src/pjmedia/conference.c
+++ b/pjmedia/src/pjmedia/conference.c
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pjmedia/conference.h>
-#include <pjmedia/vad.h>
+#include <pjmedia/silencedet.h>
#include <pjmedia/stream.h>
#include <pjmedia/sound.h>
#include <pjmedia/errno.h>
@@ -55,7 +55,7 @@ struct conf_port
pjmedia_port_op tx_setting; /**< Can we transmit to this port */
int listener_cnt; /**< Number of listeners. */
pj_bool_t *listeners; /**< Array of listeners. */
- pjmedia_vad *vad; /**< VAD for this port. */
+ pjmedia_silence_det *vad; /**< VAD for this port. */
/* Tx buffer contains the frame to be "transmitted" to this port
* (i.e. for put_frame()).
@@ -139,11 +139,11 @@ static pj_status_t create_conf_port( pj_pool_t *pool,
/* Create and init vad. */
- status = pjmedia_vad_create( pool, &conf_port->vad);
+ status = pjmedia_silence_det_create( pool, &conf_port->vad);
if (status != PJ_SUCCESS)
return status;
- pjmedia_vad_set_adaptive(conf_port->vad, conf->samples_per_frame);
+ pjmedia_silence_det_set_adaptive(conf_port->vad, conf->samples_per_frame);
/* Create TX buffers. */
@@ -738,10 +738,10 @@ static pj_status_t play_cb( /* in */ void *user_data,
continue;
/* Do we have signal? */
- silence = pjmedia_vad_detect_silence(conf_port->vad,
- output,
- conf->samples_per_frame,
- &level);
+ silence = pjmedia_silence_det_detect_silence(conf_port->vad,
+ output,
+ conf->samples_per_frame,
+ &level);
/* Skip if we don't have signal. */
if (silence) {
@@ -789,7 +789,7 @@ static pj_status_t play_cb( /* in */ void *user_data,
frame.type = PJMEDIA_FRAME_TYPE_NONE;
frame.buf = NULL;
frame.size = 0;
-
+
if (conf_port->port)
pjmedia_port_put_frame(conf_port->port, &frame);
diff --git a/pjmedia/src/pjmedia/jbuf.c b/pjmedia/src/pjmedia/jbuf.c
index 436585db..e40b1ef5 100644
--- a/pjmedia/src/pjmedia/jbuf.c
+++ b/pjmedia/src/pjmedia/jbuf.c
@@ -16,6 +16,9 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+/*
+ * Based on implementation kindly contributed by Switchlab, Ltd.
+ */
#include <pjmedia/jbuf.h>
#include <pjmedia/errno.h>
#include <pj/pool.h>
diff --git a/pjmedia/src/pjmedia/vad.c b/pjmedia/src/pjmedia/silencedet.c
index 645f3fe6..2c7583b0 100644
--- a/pjmedia/src/pjmedia/vad.c
+++ b/pjmedia/src/pjmedia/silencedet.c
@@ -16,26 +16,26 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <pjmedia/vad.h>
+#include <pjmedia/silencedet.h>
#include <pjmedia/errno.h>
#include <pj/assert.h>
#include <pj/log.h>
#include <pj/pool.h>
-#define THIS_FILE "vad.c"
+#define THIS_FILE "silencedet.c"
-typedef enum pjmedia_vad_mode {
+typedef enum pjmedia_silence_det_mode {
VAD_MODE_NONE,
VAD_MODE_FIXED,
VAD_MODE_ADAPTIVE
-} pjmedia_vad_mode;
+} pjmedia_silence_det_mode;
/**
- * This structure holds the vad state.
+ * This structure holds the silence detector state.
*/
-struct pjmedia_vad
+struct pjmedia_silence_det
{
int mode; /**< VAD mode. */
unsigned frame_size; /**< Samples per frame. */
@@ -59,68 +59,68 @@ struct pjmedia_vad
unsigned char linear2ulaw(int pcm_val);
-PJ_DEF(pj_status_t) pjmedia_vad_create( pj_pool_t *pool,
- pjmedia_vad **p_vad)
+PJ_DEF(pj_status_t) pjmedia_silence_det_create( pj_pool_t *pool,
+ pjmedia_silence_det **p_sd)
{
- pjmedia_vad *vad;
+ pjmedia_silence_det *sd;
- PJ_ASSERT_RETURN(pool && p_vad, PJ_EINVAL);
+ PJ_ASSERT_RETURN(pool && p_sd, PJ_EINVAL);
- vad = pj_pool_zalloc(pool, sizeof(struct pjmedia_vad));
+ sd = pj_pool_zalloc(pool, sizeof(struct pjmedia_silence_det));
- vad->weakest_signal = 0xFFFFFFFFUL;
- vad->loudest_silence = 0;
- vad->signal_cnt = 0;
- vad->silence_cnt = 0;
+ sd->weakest_signal = 0xFFFFFFFFUL;
+ sd->loudest_silence = 0;
+ sd->signal_cnt = 0;
+ sd->silence_cnt = 0;
/* Restart in adaptive, silent mode */
- vad->in_talk = PJ_FALSE;
- pjmedia_vad_set_adaptive( vad, 160 );
+ sd->in_talk = PJ_FALSE;
+ pjmedia_silence_det_set_adaptive( sd, 160 );
- *p_vad = vad;
+ *p_sd = sd;
return PJ_SUCCESS;
}
-PJ_DEF(pj_status_t) pjmedia_vad_set_adaptive( pjmedia_vad *vad,
- unsigned frame_size)
+PJ_DEF(pj_status_t) pjmedia_silence_det_set_adaptive( pjmedia_silence_det *sd,
+ unsigned frame_size)
{
- PJ_ASSERT_RETURN(vad && frame_size, PJ_EINVAL);
+ PJ_ASSERT_RETURN(sd && frame_size, PJ_EINVAL);
- vad->frame_size = frame_size;
- vad->mode = VAD_MODE_ADAPTIVE;
- vad->min_signal_cnt = 10;
- vad->min_silence_cnt = 64;
- vad->recalc_cnt = 250;
- vad->cur_threshold = 20;
+ sd->frame_size = frame_size;
+ sd->mode = VAD_MODE_ADAPTIVE;
+ sd->min_signal_cnt = 10;
+ sd->min_silence_cnt = 64;
+ sd->recalc_cnt = 250;
+ sd->cur_threshold = 20;
return PJ_SUCCESS;
}
-PJ_DEF(pj_status_t) pjmedia_vad_set_fixed( pjmedia_vad *vad,
- unsigned frame_size,
- unsigned threshold )
+PJ_DEF(pj_status_t) pjmedia_silence_det_set_fixed( pjmedia_silence_det *sd,
+ unsigned frame_size,
+ unsigned threshold )
{
- PJ_ASSERT_RETURN(vad && frame_size, PJ_EINVAL);
+ PJ_ASSERT_RETURN(sd && frame_size, PJ_EINVAL);
- vad->mode = VAD_MODE_FIXED;
- vad->frame_size = frame_size;
- vad->cur_threshold = threshold;
+ sd->mode = VAD_MODE_FIXED;
+ sd->frame_size = frame_size;
+ sd->cur_threshold = threshold;
return PJ_SUCCESS;
}
-PJ_DEF(pj_status_t) pjmedia_vad_disable( pjmedia_vad *vad )
+PJ_DEF(pj_status_t) pjmedia_silence_det_disable( pjmedia_silence_det *sd )
{
- PJ_ASSERT_RETURN(vad, PJ_EINVAL);
+ PJ_ASSERT_RETURN(sd, PJ_EINVAL);
- vad->mode = VAD_MODE_NONE;
+ sd->mode = VAD_MODE_NONE;
return PJ_SUCCESS;
}
-PJ_DEF(pj_int32_t) pjmedia_vad_calc_avg_signal(const pj_int16_t samples[],
- pj_size_t count)
+PJ_DEF(pj_int32_t) pjmedia_silence_det_calc_avg_signal(const pj_int16_t samples[],
+ pj_size_t count)
{
pj_uint32_t sum = 0;
@@ -140,23 +140,23 @@ PJ_DEF(pj_int32_t) pjmedia_vad_calc_avg_signal(const pj_int16_t samples[],
return (pj_int32_t)(sum / count);
}
-PJ_DEF(pj_bool_t) pjmedia_vad_detect_silence( pjmedia_vad *vad,
- const pj_int16_t samples[],
- pj_size_t count,
- pj_int32_t *p_level)
+PJ_DEF(pj_bool_t) pjmedia_silence_det_detect_silence( pjmedia_silence_det *sd,
+ const pj_int16_t samples[],
+ pj_size_t count,
+ pj_int32_t *p_level)
{
pj_uint32_t level;
pj_bool_t have_signal;
/* Always return false if VAD is disabled */
- if (vad->mode == VAD_MODE_NONE) {
+ if (sd->mode == VAD_MODE_NONE) {
if (p_level)
*p_level = -1;
return PJ_FALSE;
}
/* Calculate average signal level. */
- level = pjmedia_vad_calc_avg_signal(samples, count);
+ level = pjmedia_silence_det_calc_avg_signal(samples, count);
/* Report to caller, if required. */
if (p_level)
@@ -166,104 +166,104 @@ PJ_DEF(pj_bool_t) pjmedia_vad_detect_silence( pjmedia_vad *vad,
level = linear2ulaw(level) ^ 0xff;
/* Do we have signal? */
- have_signal = level > vad->cur_threshold;
+ have_signal = level > sd->cur_threshold;
/* We we're in transition between silence and signel, increment the
* current frame counter. We will only switch mode when we have enough
* frames.
*/
- if (vad->in_talk != have_signal) {
+ if (sd->in_talk != have_signal) {
unsigned limit;
- vad->cur_cnt++;
+ sd->cur_cnt++;
- limit = (vad->in_talk ? vad->min_silence_cnt :
- vad->min_signal_cnt);
+ limit = (sd->in_talk ? sd->min_silence_cnt :
+ sd->min_signal_cnt);
- if (vad->cur_cnt > limit) {
+ if (sd->cur_cnt > limit) {
/* Swap mode */
- vad->in_talk = !vad->in_talk;
+ sd->in_talk = !sd->in_talk;
/* Restart adaptive cur_threshold measurements */
- vad->weakest_signal = 0xFFFFFFFFUL;
- vad->loudest_silence = 0;
- vad->signal_cnt = 0;
- vad->silence_cnt = 0;
+ sd->weakest_signal = 0xFFFFFFFFUL;
+ sd->loudest_silence = 0;
+ sd->signal_cnt = 0;
+ sd->silence_cnt = 0;
}
} else {
/* Reset frame count */
- vad->cur_cnt = 0;
+ sd->cur_cnt = 0;
}
- /* For fixed threshold vad, everything is done. */
- if (vad->mode == VAD_MODE_FIXED) {
- return !vad->in_talk;
+ /* For fixed threshold sd, everything is done. */
+ if (sd->mode == VAD_MODE_FIXED) {
+ return !sd->in_talk;
}
/* Count the number of silent and signal frames and calculate min/max */
if (have_signal) {
- if (level < vad->weakest_signal)
- vad->weakest_signal = level;
- vad->signal_cnt++;
+ if (level < sd->weakest_signal)
+ sd->weakest_signal = level;
+ sd->signal_cnt++;
}
else {
- if (level > vad->loudest_silence)
- vad->loudest_silence = level;
- vad->silence_cnt++;
+ if (level > sd->loudest_silence)
+ sd->loudest_silence = level;
+ sd->silence_cnt++;
}
/* See if we have had enough frames to look at proportions of
* silence/signal frames.
*/
- if ((vad->signal_cnt + vad->silence_cnt) > vad->recalc_cnt) {
+ if ((sd->signal_cnt + sd->silence_cnt) > sd->recalc_cnt) {
/* Adjust silence threshold by looking at the proportions of
* signal and silence frames.
*/
- if (vad->signal_cnt >= vad->recalc_cnt) {
+ if (sd->signal_cnt >= sd->recalc_cnt) {
/* All frames where signal frames.
* Increase silence threshold.
*/
- vad->cur_threshold += (vad->weakest_signal - vad->cur_threshold)/4;
+ sd->cur_threshold += (sd->weakest_signal - sd->cur_threshold)/4;
PJ_LOG(6,(THIS_FILE, "Vad cur_threshold increased to %d",
- vad->cur_threshold));
+ sd->cur_threshold));
}
- else if (vad->silence_cnt >= vad->recalc_cnt) {
+ else if (sd->silence_cnt >= sd->recalc_cnt) {
/* All frames where silence frames.
* Decrease silence threshold.
*/
- vad->cur_threshold = (vad->cur_threshold+vad->loudest_silence)/2+1;
+ sd->cur_threshold = (sd->cur_threshold+sd->loudest_silence)/2+1;
PJ_LOG(6,(THIS_FILE, "Vad cur_threshold decreased to %d",
- vad->cur_threshold));
+ sd->cur_threshold));
}
else {
pj_bool_t updated = PJ_TRUE;
/* Adjust according to signal/silence proportions. */
- if (vad->signal_cnt > vad->silence_cnt * 2)
- vad->cur_threshold++;
- else if (vad->silence_cnt > vad->signal_cnt* 2)
- vad->cur_threshold--;
+ if (sd->signal_cnt > sd->silence_cnt * 2)
+ sd->cur_threshold++;
+ else if (sd->silence_cnt > sd->signal_cnt* 2)
+ sd->cur_threshold--;
else
updated = PJ_FALSE;
if (updated) {
PJ_LOG(6,(THIS_FILE,
"Vad cur_threshold updated to %d",
- vad->cur_threshold));
+ sd->cur_threshold));
}
}
/* Reset. */
- vad->weakest_signal = 0xFFFFFFFFUL;
- vad->loudest_silence = 0;
- vad->signal_cnt = 0;
- vad->silence_cnt = 0;
+ sd->weakest_signal = 0xFFFFFFFFUL;
+ sd->loudest_silence = 0;
+ sd->signal_cnt = 0;
+ sd->silence_cnt = 0;
}
- return !vad->in_talk;
+ return !sd->in_talk;
}
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index 14f46d2b..cbeaa2b7 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -116,6 +116,12 @@ struct pjmedia_stream
};
+/* RFC 2833 digit */
+static const char digitmap[16] = { '0', '1', '2', '3',
+ '4', '5', '6', '7',
+ '8', '9', '*', '#',
+ 'A', 'B', 'C', 'D'};
+
/*
* Print error.
*/
@@ -230,8 +236,17 @@ static void create_dtmf_payload(pjmedia_stream *stream,
stream->tx_dtmf_buf[0].start_ts = cur_ts;
pj_mutex_unlock(stream->jb_mutex);
+
+ if (stream->tx_dtmf_count)
+ PJ_LOG(5,(THIS_FILE,"Sending DTMF digit id %c",
+ digitmap[stream->tx_dtmf_buf[0].event]));
+
+ } else if (duration == 0) {
+ PJ_LOG(5,(THIS_FILE,"Sending DTMF digit id %c",
+ digitmap[digit->event]));
}
+
frame_out->size = 4;
}
@@ -367,10 +382,6 @@ static void dump_bin(const char *buf, unsigned len)
static void handle_incoming_dtmf( pjmedia_stream *stream,
const void *payload, unsigned payloadlen)
{
- static const char digitmap[16] = { '0', '1', '2', '3',
- '4', '5', '6', '7',
- '8', '9', '*', '#',
- 'A', 'B', 'C', 'D'};
const pjmedia_rtp_dtmf_event *event = payload;
/* Check compiler packing. */
diff --git a/pjsip/include/pjsip-simple/evsub.h b/pjsip/include/pjsip-simple/evsub.h
index 1977ee44..ba1dd0a6 100644
--- a/pjsip/include/pjsip-simple/evsub.h
+++ b/pjsip/include/pjsip-simple/evsub.h
@@ -173,9 +173,9 @@ struct pjsip_evsub_user
* This callback is called when it is time for the client to refresh
* the subscription.
*
- * This callback is OPTIONAL. When it is not implemented, the default
- * behavior is to refresh subscription by sending SUBSCRIBE with the
- * interval set to current/last interval.
+ * This callback is OPTIONAL when PJSIP package such as presence or
+ * refer is used; the event package will refresh subscription by sending
+ * SUBSCRIBE with the interval set to current/last interval.
*
* @param sub The subscription instance.
*/
@@ -185,8 +185,9 @@ struct pjsip_evsub_user
* This callback is called when server doesn't receive subscription
* refresh after the specified subscription interval.
*
- * This callback is OPTIONAL. When it is not implemented, the default
- * behavior is to send NOTIFY to terminate the subscription.
+ * This callback is OPTIONAL when PJSIP package such as presence or
+ * refer is used; the event package send NOTIFY to terminate the
+ * subscription.
*/
void (*on_server_timeout)(pjsip_evsub *sub);
@@ -399,7 +400,8 @@ PJ_DECL(pj_status_t) pjsip_evsub_send_request( pjsip_evsub *sub,
/**
- * Get the event subscription instance in the transaction.
+ * Get the event subscription instance associated with the specified
+ * transaction.
*
* @param tsx The transaction.
*