summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-09-20 06:13:02 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-09-20 06:13:02 +0000
commit5af236a408105e4a2e4e47f4271afab7c137c31b (patch)
tree7bb254ba645dda789fff7474116919e9d4b76939
parent060d04b12449532413d95cbff97c966e7f768d08 (diff)
Closed #1129:
- Added run-time configuration for activating/deactivating stream keep-alive (non-codec-VAD mechanism), also added this config to account settings. - Fixed bug wrong session info pointer "si" in pjsua_media_channel_update() when call audio index is not zero. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3313 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjmedia/docs/doxygen.cfg3
-rw-r--r--pjmedia/include/pjmedia/stream.h6
-rw-r--r--pjmedia/src/pjmedia/stream.c11
-rw-r--r--pjsip/docs/doxygen.cfg3
-rw-r--r--pjsip/include/pjsua-lib/pjsua.h11
-rw-r--r--pjsip/src/pjsua-lib/pjsua_acc.c4
-rw-r--r--pjsip/src/pjsua-lib/pjsua_core.c3
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c9
8 files changed, 46 insertions, 4 deletions
diff --git a/pjmedia/docs/doxygen.cfg b/pjmedia/docs/doxygen.cfg
index 28d4d5e8..ecd5f275 100644
--- a/pjmedia/docs/doxygen.cfg
+++ b/pjmedia/docs/doxygen.cfg
@@ -853,7 +853,8 @@ PREDEFINED = PJ_DECL(x)=x PJ_DEF(x)=x PJ_IDECL(x)=x \
PJ_HAS_SEMAPHORE=1 \
PJ_HAS_EVENT_OBJ=1 \
PJ_HAS_TCP=1 \
- PJMEDIA_HAS_SRTP=1
+ PJMEDIA_HAS_SRTP=1 \
+ PJMEDIA_STREAM_ENABLE_KA=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
diff --git a/pjmedia/include/pjmedia/stream.h b/pjmedia/include/pjmedia/stream.h
index 84f6b1de..c45201ec 100644
--- a/pjmedia/include/pjmedia/stream.h
+++ b/pjmedia/include/pjmedia/stream.h
@@ -127,6 +127,12 @@ struct pjmedia_stream_info
int jb_max_pre; /**< Jitter buffer maximum prefetch
delay in msec (-1 for default). */
int jb_max; /**< Jitter buffer max delay in msec. */
+
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
+ pj_bool_t use_ka; /**< Stream keep-alive and NAT hole punch
+ (see @ref PJMEDIA_STREAM_ENABLE_KA)
+ is enabled? */
+#endif
};
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index 4436da51..8bb5fc1a 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -197,6 +197,9 @@ struct pjmedia_stream
#endif
#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
+ pj_bool_t use_ka; /**< Stream keep-alive with non-
+ codec-VAD mechanism is
+ enabled? */
pj_timestamp last_frm_ts_sent; /**< Timestamp of last sending
packet */
#endif
@@ -1123,6 +1126,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
/* If the interval since last sending packet is greater than
* PJMEDIA_STREAM_KA_INTERVAL, send keep-alive packet.
*/
+ if (stream->use_ka)
{
pj_uint32_t dtx_duration;
@@ -1973,6 +1977,10 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
stream->last_dtmf = -1;
stream->jb_last_frm = PJMEDIA_JB_NORMAL_FRAME;
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
+ stream->use_ka = info->use_ka;
+#endif
+
/* Build random RTCP CNAME. CNAME has user@host format */
stream->cname.ptr = p = (char*) pj_pool_alloc(pool, 20);
pj_create_random_string(p, 5);
@@ -2284,7 +2292,8 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
/* NAT hole punching by sending KA packet via RTP transport. */
- send_keep_alive_packet(stream);
+ if (stream->use_ka)
+ send_keep_alive_packet(stream);
#endif
#if TRACE_JB
diff --git a/pjsip/docs/doxygen.cfg b/pjsip/docs/doxygen.cfg
index fc87325d..d6c23185 100644
--- a/pjsip/docs/doxygen.cfg
+++ b/pjsip/docs/doxygen.cfg
@@ -846,7 +846,8 @@ INCLUDE_FILE_PATTERNS =
PREDEFINED = PJ_DECL(x)=x PJ_DEF(x)=x PJ_IDECL(x)=x \
PJ_IDEF(x)=x PJ_INLINE(x)=x PJ_DECL_DATA(x)=x \
- PJMEDIA_HAS_SRTP=1
+ PJMEDIA_HAS_SRTP=1 \
+ PJMEDIA_STREAM_ENABLE_KA=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 0ab24942..44f73451 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -2317,6 +2317,17 @@ typedef struct pjsua_acc_config
*/
unsigned reg_use_proxy;
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
+ /**
+ * Specify whether stream keep-alive and NAT hole punching with
+ * non-codec-VAD mechanism (see @ref PJMEDIA_STREAM_ENABLE_KA) is enabled
+ * for this account.
+ *
+ * Default: PJ_FALSE (disabled)
+ */
+ pj_bool_t use_stream_ka;
+#endif
+
} pjsua_acc_config;
diff --git a/pjsip/src/pjsua-lib/pjsua_acc.c b/pjsip/src/pjsua-lib/pjsua_acc.c
index fbda32c2..0163ed5b 100644
--- a/pjsip/src/pjsua-lib/pjsua_acc.c
+++ b/pjsip/src/pjsua-lib/pjsua_acc.c
@@ -754,6 +754,10 @@ PJ_DEF(pj_status_t) pjsua_acc_modify( pjsua_acc_id acc_id,
acc->cfg.srtp_optional_dup_offer = cfg->srtp_optional_dup_offer;
#endif
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && (PJMEDIA_STREAM_ENABLE_KA != 0)
+ acc->cfg.use_stream_ka = cfg->use_stream_ka;
+#endif
+
/* Global outbound proxy */
if (global_route_crc != acc->global_route_crc) {
unsigned i, rcnt;
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index a0e43b21..9fb0a5d0 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -185,6 +185,9 @@ PJ_DEF(void) pjsua_acc_config_default(pjsua_acc_config *cfg)
cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD;
cfg->reg_use_proxy = PJSUA_REG_USE_OUTBOUND_PROXY |
PJSUA_REG_USE_ACC_PROXY;
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
+ cfg->use_stream_ka = (PJMEDIA_STREAM_ENABLE_KA != 0);
+#endif
}
PJ_DEF(void) pjsua_buddy_config_default(pjsua_buddy_config *cfg)
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index 2eb08944..85a28ccf 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -1545,8 +1545,10 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
/* Reset session info with only one media stream */
sess_info.stream_cnt = 1;
- if (si != &sess_info.stream_info[0])
+ if (si != &sess_info.stream_info[0]) {
pj_memcpy(&sess_info.stream_info[0], si, sizeof(pjmedia_stream_info));
+ si = &sess_info.stream_info[0];
+ }
/* Check if no media is active */
if (sess_info.stream_cnt == 0 || si->dir == PJMEDIA_DIR_NONE)
@@ -1638,6 +1640,11 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id,
si->rtp_seq = call->rtp_tx_seq;
si->rtp_seq_ts_set = call->rtp_tx_seq_ts_set;
+#if defined(PJMEDIA_STREAM_ENABLE_KA) && PJMEDIA_STREAM_ENABLE_KA!=0
+ /* Enable/disable stream keep-alive and NAT hole punch. */
+ si->use_ka = pjsua_var.acc[call->acc_id].cfg.use_stream_ka;
+#endif
+
/* Create session based on session info. */
status = pjmedia_session_create( pjsua_var.med_endpt, &sess_info,
&call->med_tp,