struct io_context *io;
void *data;
ast_rtp_callback callback;
+#ifdef P2P_INTENSE
ast_mutex_t bridge_lock;
+#endif
struct rtpPayloadType current_RTP_PT[MAX_RTP_PT];
int rtp_lookup_code_cache_isAstFormat; /*!< a cache for the result of rtp_lookup_code(): */
int rtp_lookup_code_cache_code;
ast_set2_flag(rtp, stun_enable ? 1 : 0, FLAG_HAS_STUN);
}
+static void rtp_bridge_lock(struct ast_rtp *rtp)
+{
+#ifdef P2P_INTENSE
+ ast_mutex_lock(&rtp->bridge_lock);
+#endif
+ return;
+}
+
+static void rtp_bridge_unlock(struct ast_rtp *rtp)
+{
+#ifdef P2P_INTENSE
+ ast_mutex_unlock(&rtp->bridge_lock);
+#endif
+ return;
+}
+
static struct ast_frame *send_dtmf(struct ast_rtp *rtp, enum ast_frame_type type)
{
if (((ast_test_flag(rtp, FLAG_DTMF_COMPENSATE) && type == AST_FRAME_DTMF_END) ||
if (!rtp)
return;
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
for (i = 0; i < MAX_RTP_PT; ++i) {
rtp->current_RTP_PT[i].isAstFormat = 0;
rtp->rtp_lookup_code_cache_code = 0;
rtp->rtp_lookup_code_cache_result = 0;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
}
void ast_rtp_pt_default(struct ast_rtp* rtp)
{
int i;
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
/* Initialize to default payload types */
for (i = 0; i < MAX_RTP_PT; ++i) {
rtp->rtp_lookup_code_cache_code = 0;
rtp->rtp_lookup_code_cache_result = 0;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
}
void ast_rtp_pt_copy(struct ast_rtp *dest, struct ast_rtp *src)
{
unsigned int i;
- ast_mutex_lock(&dest->bridge_lock);
- ast_mutex_lock(&src->bridge_lock);
+ rtp_bridge_lock(dest);
+ rtp_bridge_lock(src);
for (i=0; i < MAX_RTP_PT; ++i) {
dest->current_RTP_PT[i].isAstFormat =
dest->rtp_lookup_code_cache_code = 0;
dest->rtp_lookup_code_cache_result = 0;
- ast_mutex_unlock(&src->bridge_lock);
- ast_mutex_unlock(&dest->bridge_lock);
+ rtp_bridge_unlock(src);
+ rtp_bridge_unlock(dest);
}
/*! \brief Get channel driver interface structure */
if (pt < 0 || pt > MAX_RTP_PT || static_RTP_PT[pt].code == 0)
return; /* bogus payload type */
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
rtp->current_RTP_PT[pt] = static_RTP_PT[pt];
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
}
/*! \brief Make a note of a RTP payload type (with MIME type) that was seen in
if (pt < 0 || pt > MAX_RTP_PT)
return; /* bogus payload type */
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
for (i = 0; i < sizeof(mimeTypes)/sizeof(mimeTypes[0]); ++i) {
if (strcasecmp(mimeSubtype, mimeTypes[i].subtype) == 0 &&
}
}
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return;
}
{
int pt;
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
*astFormats = *nonAstFormats = 0;
for (pt = 0; pt < MAX_RTP_PT; ++pt) {
*nonAstFormats |= rtp->current_RTP_PT[pt].code;
}
}
-
- ast_mutex_unlock(&rtp->bridge_lock);
+
+ rtp_bridge_unlock(rtp);
return;
}
return result; /* bogus payload type */
/* Start with negotiated codecs */
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
result = rtp->current_RTP_PT[pt];
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
/* If it doesn't exist, check our static RTP type list, just in case */
if (!result.code)
{
int pt = 0;
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
if (isAstFormat == rtp->rtp_lookup_code_cache_isAstFormat &&
code == rtp->rtp_lookup_code_cache_code) {
/* Use our cached mapping, to avoid the overhead of the loop below */
pt = rtp->rtp_lookup_code_cache_result;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return pt;
}
rtp->rtp_lookup_code_cache_isAstFormat = isAstFormat;
rtp->rtp_lookup_code_cache_code = code;
rtp->rtp_lookup_code_cache_result = pt;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return pt;
}
}
rtp->rtp_lookup_code_cache_isAstFormat = isAstFormat;
rtp->rtp_lookup_code_cache_code = code;
rtp->rtp_lookup_code_cache_result = pt;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return pt;
}
}
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return -1;
}
*/
void ast_rtp_new_init(struct ast_rtp *rtp)
{
+#ifdef P2P_INTENSE
ast_mutex_init(&rtp->bridge_lock);
+#endif
rtp->them.sin_family = AF_INET;
rtp->us.sin_family = AF_INET;
{
struct ast_rtp *bridged = NULL;
- ast_mutex_lock(&rtp->bridge_lock);
+ rtp_bridge_lock(rtp);
bridged = rtp->bridged;
- ast_mutex_unlock(&rtp->bridge_lock);
+ rtp_bridge_unlock(rtp);
return bridged;
}
free(rtp->rtcp);
rtp->rtcp=NULL;
}
-
+#ifdef P2P_INTENSE
ast_mutex_destroy(&rtp->bridge_lock);
-
+#endif
free(rtp);
}
/*! \brief Helper function that sets what an RTP structure is bridged to */
static void p2p_set_bridge(struct ast_rtp *rtp0, struct ast_rtp *rtp1)
{
- ast_mutex_lock(&rtp0->bridge_lock);
+ rtp_bridge_lock(rtp0);
rtp0->bridged = rtp1;
- ast_mutex_unlock(&rtp0->bridge_lock);
+ rtp_bridge_unlock(rtp0);
return;
}