[asterisk-commits] pcadach: branch pcadach/chan_h323-live r42083 -
/team/pcadach/chan_h323-live/...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Sep 5 23:04:28 MST 2006
Author: pcadach
Date: Wed Sep 6 01:04:28 2006
New Revision: 42083
URL: http://svn.digium.com/view/asterisk?rev=42083&view=rev
Log:
Separate RTP creation to simplify handling of bindaddr
Modified:
team/pcadach/chan_h323-live/channels/chan_h323.c
Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=42083&r1=42082&r2=42083&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Wed Sep 6 01:04:28 2006
@@ -186,6 +186,7 @@
int jointcapability; /* Common capabilities for local and remote side */
int dtmf_pt; /* Payload code used for RFC2833 messages */
int curDTMF; /* DTMF tone being generated */
+ int update_rtp_info; /* Configuration of fd's array is pending */
struct oh323_pvt *next; /* Next channel in list */
} *iflist = NULL;
@@ -323,6 +324,14 @@
}
ast_queue_frame(c, &f);
pvt->newdigit = -1;
+ }
+ if (pvt->update_rtp_info > 0) {
+ ast_jb_configure(c, &global_jbconf);
+ if (pvt->rtp) {
+ c->fds[0] = ast_rtp_fd(pvt->rtp);
+ c->fds[1] = ast_rtcp_fd(pvt->rtp);
+ }
+ pvt->update_rtp_info = -1;
}
}
@@ -841,6 +850,40 @@
return 0;
}
+static int __oh323_rtp_create(struct oh323_pvt *pvt)
+{
+ if (pvt->rtp)
+ return 0;
+
+ pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
+ if (!pvt->rtp) {
+ ast_mutex_unlock(&pvt->lock);
+ ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno));
+ return -1;
+ }
+ if (h323debug)
+ ast_log(LOG_DEBUG, "Created RTP channel\n");
+
+ ast_rtp_settos(pvt->rtp, tos);
+
+ if (h323debug)
+ ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
+ ast_rtp_setnat(pvt->rtp, pvt->options.nat);
+
+ if (pvt->dtmf_pt > 0)
+ ast_rtp_set_rtpmap_type(pvt->rtp, pvt->dtmf_pt, "audio", "telephone-event", 0);
+
+ if (pvt->owner && !ast_channel_trylock(pvt->owner)) {
+ ast_jb_configure(pvt->owner, &global_jbconf);
+ pvt->owner->fds[0] = ast_rtp_fd(pvt->rtp);
+ pvt->owner->fds[1] = ast_rtcp_fd(pvt->rtp);
+ ast_channel_unlock(pvt->owner);
+ } else
+ pvt->update_rtp_info = 1;
+
+ return 0;
+}
+
/* Private structure should be locked on a call */
static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const char *host)
{
@@ -865,8 +908,10 @@
ch->rawwriteformat = fmt;
ch->readformat = fmt;
ch->rawreadformat = fmt;
+#if 0
ch->fds[0] = ast_rtp_fd(pvt->rtp);
ch->fds[1] = ast_rtcp_fd(pvt->rtp);
+#endif
#ifdef VIDEO_SUPPORT
if (pvt->vrtp) {
ch->fds[2] = ast_rtp_fd(pvt->vrtp);
@@ -885,7 +930,7 @@
if (pvt->options.dtmfmode & H323_DTMF_INBAND) {
pvt->vad = ast_dsp_new();
ast_dsp_set_features(pvt->vad, DSP_FEATURE_DTMF_DETECT);
- }
+ }
/* Register channel functions. */
ch->tech_pvt = pvt;
/* Set the owner of this channel */
@@ -917,8 +962,10 @@
ch->cid.cid_dnid = strdup(pvt->exten);
}
ast_setstate(ch, state);
+#if 0
if (pvt->rtp)
ast_jb_configure(ch, &global_jbconf);
+#endif
if (state != AST_STATE_DOWN) {
if (ast_pbx_start(ch)) {
ast_log(LOG_WARNING, "Unable to start PBX on %s\n", ch->name);
@@ -942,6 +989,7 @@
return NULL;
}
memset(pvt, 0, sizeof(struct oh323_pvt));
+#if 0
pvt->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0,bindaddr.sin_addr);
if (!pvt->rtp) {
ast_log(LOG_WARNING, "Unable to create RTP session: %s\n", strerror(errno));
@@ -949,6 +997,7 @@
return NULL;
}
ast_rtp_settos(pvt->rtp, tos);
+#endif
/* Ensure the call token is allocated for outgoing call */
if (!callid) {
if ((pvt->cd).call_token == NULL) {
@@ -971,7 +1020,7 @@
pvt->nonCodecCapability &= ~AST_RTP_DTMF;
}
strncpy(pvt->context, default_context, sizeof(pvt->context) - 1);
- pvt->newstate = pvt->newcontrol = pvt->newdigit = -1;
+ pvt->newstate = pvt->newcontrol = pvt->newdigit = pvt->update_rtp_info = -1;
ast_mutex_init(&pvt->lock);
/* Add to interface list */
ast_mutex_lock(&iflock);
@@ -1430,10 +1479,12 @@
found++;
memcpy(&pvt->options, &p->options, sizeof(pvt->options));
pvt->jointcapability = pvt->options.capability;
+#if 0
if (pvt->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
}
+#endif
if (pvt->options.dtmfmode) {
if (pvt->options.dtmfmode & H323_DTMF_RFC2833) {
pvt->nonCodecCapability |= AST_RTP_DTMF;
@@ -1465,10 +1516,12 @@
if (p) {
ASTOBJ_UNREF(p, oh323_destroy_peer);
}
+#if 0
if (pvt->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
}
+#endif
if (pvt->options.dtmfmode) {
if (pvt->options.dtmfmode & H323_DTMF_RFC2833) {
pvt->nonCodecCapability |= AST_RTP_DTMF;
@@ -1537,10 +1590,12 @@
else {
memcpy(&pvt->options, &global_options, sizeof(pvt->options));
pvt->jointcapability = pvt->options.capability;
+#if 0
if (pvt->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", pvt->options.nat);
ast_rtp_setnat(pvt->rtp, pvt->options.nat);
}
+#endif
if (pvt->options.dtmfmode) {
if (pvt->options.dtmfmode & H323_DTMF_RFC2833) {
pvt->nonCodecCapability |= AST_RTP_DTMF;
@@ -1652,6 +1707,14 @@
ast_log(LOG_ERROR, "Unable to find call %s(%d)\n", token, call_reference);
return NULL;
}
+ if (!pvt->rtp)
+ __oh323_rtp_create(pvt);
+ if (!pvt->rtp) {
+ ast_mutex_unlock(&pvt->lock);
+ free(info);
+ ast_log(LOG_ERROR, "No RTP stream is available for call %s (%d)", token, call_reference);
+ return NULL;
+ }
/* figure out our local RTP port and tell the H.323 stack about it */
ast_rtp_get_us(pvt->rtp, &us);
ast_mutex_unlock(&pvt->lock);
@@ -1697,10 +1760,13 @@
ast_mutex_unlock(&pvt->lock);
return;
}
+
+ if (!pvt->rtp)
+ __oh323_rtp_create(pvt);
/* Change native format to reflect information taken from OLC/OLCAck */
nativeformats_changed = 0;
- if (pt != 128) { /* Payload type is invalid, so try to use previously decided */
+ if (pt != 128 && pvt->rtp) { /* Payload type is invalid, so try to use previously decided */
rtptype = ast_rtp_lookup_pt(pvt->rtp, pt);
if (h323debug)
ast_log(LOG_DEBUG, "Native format is set to %d from %d by RTP payload type %d\n", rtptype.code, pvt->nativeformats, pt);
More information about the asterisk-commits
mailing list