From c0b178bdef86e742745789500e37dc2c666059a8 Mon Sep 17 00:00:00 2001 From: Georgiewskiy Yuriy Date: Fri, 11 Dec 2009 12:18:29 +0000 Subject: [PATCH] fix rtp timer initialisation. implement alerting-indication option and channel variable. implement progress-indication option and channel variable. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15905 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_h323/changes.txt | 6 +- src/mod/endpoints/mod_h323/h323.conf.xml | 2 + src/mod/endpoints/mod_h323/mod_h323.cpp | 101 +++++++++++++++++++++-- src/mod/endpoints/mod_h323/mod_h323.h | 6 +- 4 files changed, 106 insertions(+), 9 deletions(-) diff --git a/src/mod/endpoints/mod_h323/changes.txt b/src/mod/endpoints/mod_h323/changes.txt index 2684347514..6da13d8580 100644 --- a/src/mod/endpoints/mod_h323/changes.txt +++ b/src/mod/endpoints/mod_h323/changes.txt @@ -1,5 +1,7 @@ - -fix to build with trunk changes. +fix rtp timer initialisation. +implement alerting-indication option and channel variable. +implement progress-indication option and channel variable. +fix short DTMF warnings. remove SWITCH_RTP_FLAG_AUTOADJ because its not work correctly and not do anything reliable in our cases. fix faststart in progress handling fixxxxes diff --git a/src/mod/endpoints/mod_h323/h323.conf.xml b/src/mod/endpoints/mod_h323/h323.conf.xml index 8fcd2549ff..63fc21ec21 100644 --- a/src/mod/endpoints/mod_h323/h323.conf.xml +++ b/src/mod/endpoints/mod_h323/h323.conf.xml @@ -12,6 +12,8 @@ + + diff --git a/src/mod/endpoints/mod_h323/mod_h323.cpp b/src/mod/endpoints/mod_h323/mod_h323.cpp index 7bec466125..3f96343b60 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.cpp +++ b/src/mod/endpoints/mod_h323/mod_h323.cpp @@ -1,5 +1,5 @@ /* - Version 0.0.13 + Version 0.0.16 */ #include "mod_h323.h" @@ -361,6 +361,8 @@ switch_status_t FSH323EndPoint::ReadConfig(int reload){ } switch_xml_t xmlSettings = switch_xml_child(cfg, "settings"); + m_pi = 8; + m_ai = 0; if (xmlSettings) { for (switch_xml_t xmlParam = switch_xml_child(xmlSettings, "param"); xmlParam != NULL; xmlParam = xmlParam->next) { const char *var = switch_xml_attr_soft(xmlParam, "name"); @@ -405,8 +407,11 @@ switch_status_t FSH323EndPoint::ReadConfig(int reload){ m_gkPrefixes.AppendString(val); } else if (!strcasecmp(var, "gk-retry")) { m_gkretry = atoi(val); - } - + } else if (!strcasecmp(var, "progress-indication")) { + m_pi = atoi(val); + } else if (!strcasecmp(var, "alerting-indication")) { + m_ai = atoi(val); + } } } @@ -821,6 +826,89 @@ bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PStrin return ( status == SWITCH_STATUS_SUCCESS); } +void FSH323Connection::AnsweringCall(AnswerCallResponse response){ + + PTRACE(4, "mod_h323\t======>FSH323Connection::AnsweringCall ["<<*this<<"]"); + + switch (response) { + case AnswerCallDeferredWithMedia:{ + PTRACE(2, "H323\tAnswering call: " << response); + if (!Lock()) + return; + if (!mediaWaitForConnect) { + // create a new facility PDU if doing AnswerDeferredWithMedia + H323SignalPDU want245PDU; + H225_Progress_UUIE & prog = want245PDU.BuildProgress(*this); + PBoolean sendPDU = TRUE; + + if (SendFastStartAcknowledge(prog.m_fastStart)) + prog.IncludeOptionalField(H225_Progress_UUIE::e_fastStart); + else { + // See if aborted call + if (connectionState == ShuttingDownConnection){ + Unlock(); + return; + } + // Do early H.245 start + H225_Facility_UUIE & fac = *want245PDU.BuildFacility(*this, FALSE, H225_FacilityReason::e_startH245); + earlyStart = TRUE; + if (!h245Tunneling && (controlChannel == NULL)) { + if (!StartControlChannel()){ + Unlock(); + return; + } + fac.IncludeOptionalField(H225_Facility_UUIE::e_h245Address); + controlChannel->SetUpTransportPDU(fac.m_h245Address, TRUE); + } + else + sendPDU = FALSE; + } + const char *vpi = switch_channel_get_variable(m_fsChannel, "progress-indication"); + unsigned pi = 8; + if (vpi){ + pi = atoi(vpi); + } + else pi = m_endpoint->m_pi; + if ((pi< 1) || (pi > 8)||(pi == 7)) pi = 8; + want245PDU.GetQ931().SetProgressIndicator(pi); + if (sendPDU) { + HandleTunnelPDU(&want245PDU); + WriteSignalPDU(want245PDU); + } + } + InternalEstablishedConnectionCheck(); + Unlock(); + return; + } + case AnswerCallPending :{ + if (alertingPDU != NULL) { + if (!Lock()) + return; + // send Q931 Alerting PDU + PTRACE(3, "H225\tSending Alerting PDU"); + + const char *vai = switch_channel_get_variable(m_fsChannel, "alerting-indication"); + unsigned ai = 0; + if (vai){ + ai = atoi(vai); + } + else ai = m_endpoint->m_ai; + if ((ai< 0) || (ai > 8)||(ai == 7)) ai = 8; + if (ai > 0) + (*alertingPDU).GetQ931().SetProgressIndicator(ai); + + HandleTunnelPDU(alertingPDU); + WriteSignalPDU(*alertingPDU); + alertingTime = PTime(); + InternalEstablishedConnectionCheck(); + Unlock(); + return; + } + } + default :H323Connection::AnsweringCall(response); + } +} + void FSH323Connection::OnEstablished(){ PTRACE(4, "mod_h323\t======>PFSH323Connection::OnEstablished ["<<*this<<"]"); @@ -1229,6 +1317,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){ m_switchCodec = NULL; return false; } + switch_channel_set_variable(m_fsChannel,"timer_name","soft"); } else { switch_core_session_set_video_read_codec(m_fsSession, m_switchCodec); switch_channel_set_flag(m_fsChannel, CF_VIDEO); @@ -1278,11 +1367,13 @@ PBoolean FSH323_ExternalRTPChannel::Start(){ PTRACE(4, "mod_h323\t------------------->samples_per_packet = "<implementation->samples_per_packet); PTRACE(4, "mod_h323\t------------------->actual_samples_per_second = "<implementation->actual_samples_per_second); - if (!m_conn->m_startRTP) { - flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT|SWITCH_RTP_FLAG_AUTO_CNG|SWITCH_RTP_FLAG_RAW_WRITE); + if ((!m_conn->m_startRTP)&&(GetDirection() == IsReceiver)) { + flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT|SWITCH_RTP_FLAG_AUTO_CNG|SWITCH_RTP_FLAG_RAW_WRITE); + PTRACE(4, "mod_h323\t------------------->timer_name = "<timer_name = "<rtp_session = switch_rtp_new((const char *)m_RTPlocalIP, m_RTPlocalPort, (const char *)m_RTPremoteIP, diff --git a/src/mod/endpoints/mod_h323/mod_h323.h b/src/mod/endpoints/mod_h323/mod_h323.h index a437f2cecf..570c56746c 100644 --- a/src/mod/endpoints/mod_h323/mod_h323.h +++ b/src/mod/endpoints/mod_h323/mod_h323.h @@ -126,6 +126,7 @@ struct FSListener { PString gatekeeper; }; class FSGkRegThread; + class FSH323EndPoint:public H323EndPoint { PCLASSINFO(FSH323EndPoint, H323EndPoint); @@ -156,7 +157,8 @@ class FSH323EndPoint:public H323EndPoint { } FSH323Connection * FSMakeCall(const PString & dest,void *userData); list m_listeners; - + int m_ai; + int m_pi; protected: PStringList m_gkPrefixes; switch_endpoint_interface_t *m_freeswitch; @@ -168,7 +170,6 @@ class FSH323EndPoint:public H323EndPoint { bool m_h245insetup; int m_gkretry; FSGkRegThread* m_thread; - }; @@ -219,6 +220,7 @@ class FSH323Connection:public H323Connection { void setRemoteAddress(const char* remoteIP, WORD remotePort); virtual void OnSetLocalCapabilities(); virtual bool OnAlerting(const H323SignalPDU &alertingPDU, const PString &user); + virtual void AnsweringCall(AnswerCallResponse response); virtual void OnEstablished(); bool SetLocalCapabilities(); static bool decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload = 0, PString* capabName = 0);