提交 5efe5c88 authored 作者: root's avatar root

some t.38 and lockinng improvements.

replace ptrace with switch_log_printf.
上级 beec142c
some t.38 and lockinng improvements.
replace ptrace with switch_log_printf.
initial t.38 support.
remake logical channel opening.
add missing param name in example config.
......
/*
Version 0.0.25
Version 0.0.50
*/
#include "mod_h323.h"
......@@ -111,7 +111,7 @@ static switch_state_handler_table_t h323fs_event_handlers = {
/*.on_destroy*/ on_destroy
};
static FSProcess *opal_process = NULL;
//static FSProcess *h323_process = NULL;
SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Starting loading mod_h323\n");
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
......@@ -126,7 +126,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_h323_load){
}
if (h323_process->Initialise(*module_interface)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Opal manager initialized and running\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "H323 mod initialized and running\n");
return SWITCH_STATUS_SUCCESS;
}
......@@ -300,7 +300,7 @@ FSProcess::FSProcess()
: PLibraryProcess("Test", "mod_h323", 1, 0, AlphaCode, 1)
, m_h323endpoint(NULL){
PTrace::SetLevel(10);
PTrace::SetLevel(4);
PTrace::SetOptions(PTrace::TraceLevel);
PTrace::SetStream(new FSTrace);
}
......@@ -310,14 +310,14 @@ FSProcess::~FSProcess(){
}
bool FSProcess::Initialise(switch_loadable_module_interface_t *iface){
PTRACE(4, "mod_h323\t======>FSProcess::Initialise " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "======>FSProcess::Initialise [%p]\n", this);
m_h323endpoint = new FSH323EndPoint();
return m_h323endpoint != NULL && m_h323endpoint->Initialise(iface);
}
bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
PTRACE(4, "mod_h323\t======>FSManager::Initialise " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSManager::Initialise [%p]\n",this);
ReadConfig(false);
......@@ -356,10 +356,16 @@ bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
}
}
}
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_PRE));
if (m_fax_old_asn){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_old_asn\n");
SetT38_IFP_PRE();
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_PRE));
}else{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "--->fax_asn\n");
SetCapability(0, 0, new FSH323_T38Capability(OpalT38_IFP_COR));
}
AddAllUserInputCapabilities(0,1);
PTRACE(1, "OpenPhone\tCapability Table:\n" << setprecision(4) << capabilities);
DisableFastStart(!m_faststart);
DisableH245Tunneling(!m_h245tunneling);
......@@ -372,7 +378,7 @@ bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
} else {
for (std::list < FSListener >::iterator it = m_listeners.begin(); it != m_listeners.end(); ++it) {
if (!StartListener(it->listenAddress)) {
PTRACE(3, "mod_h323\tCannot start listener for " << it->name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot start listener for %s\n", (const char*)(it->name));
}
}
}
......@@ -387,7 +393,7 @@ bool FSH323EndPoint::Initialise(switch_loadable_module_interface_t *iface){
}
switch_status_t FSH323EndPoint::ReadConfig(int reload){
PTRACE(4, "mod_h323\t======>FSH323EndPoint::ReadConfig " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::ReadConfig [%p]\n",this);
const char *cf = "h323.conf";
switch_status_t status = SWITCH_STATUS_SUCCESS;
......@@ -467,6 +473,8 @@ switch_status_t FSH323EndPoint::ReadConfig(int reload){
m_pi = atoi(val);
} else if (!strcasecmp(var, "alerting-indication")) {
m_ai = atoi(val);
} else if (!strcasecmp(var, "fax-old-asn")) {
m_fax_old_asn = switch_true(val);
}
}
}
......@@ -514,13 +522,14 @@ FSH323EndPoint::FSH323EndPoint()
,m_h245insetup(true)
,m_thread(NULL)
,m_stop_gk(false)
,m_fax_old_asn(false)
{
PTRACE(4, "mod_h323\t======>FSH323EndPoint::FSH323EndPoint [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::FSH323EndPoint [%p]\n",this);
terminalType = e_GatewayOnly;
}
FSH323EndPoint::~FSH323EndPoint(){
PTRACE(4, "mod_h323\t======>FSH323EndPoint::~FSH323EndPoint [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::~FSH323EndPoint [%p]\n",this);
StopGkClient();
ClearAllCalls(H323Connection::EndedByLocalUser,false);
}
......@@ -530,12 +539,12 @@ H323Connection *FSH323EndPoint::CreateConnection(
void* userData,
H323Transport* transport,
H323SignalPDU* setupPDU){
PTRACE(4, "mod_h323\t======>FSH323EndPoint::CreateConnection callReference = "<< callReference <<" userDate = "<<userData<<" [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::CreateConnection callReference = %u userDate = %p [%p]\n",callReference,userData,this);
if ((switch_caller_profile_t *)userData){
PTRACE(4, "mod_h323\t------> SWITCH_CALL_DIRECTION_OUTBOUND");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> SWITCH_CALL_DIRECTION_OUTBOUND\n");
} else{
PTRACE(4, "mod_h323\t------> SWITCH_CALL_DIRECTION_INBOUND");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> SWITCH_CALL_DIRECTION_INBOUND\n");
}
switch_core_session_t *fsSession = switch_core_session_request(GetSwitchInterface(),
......@@ -543,7 +552,7 @@ H323Connection *FSH323EndPoint::CreateConnection(
if (fsSession == NULL)
return NULL;
PTRACE(4, "mod_h323\t------> fsSession = "<<fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------> fsSession = %p\n",fsSession);
switch_channel_t *fsChannel = switch_core_session_get_channel(fsSession);
if (fsChannel == NULL) {
......@@ -555,9 +564,9 @@ H323Connection *FSH323EndPoint::CreateConnection(
}
bool FSH323EndPoint::OnSetGatewayPrefixes(PStringList & prefixes) const{
PTRACE(4, "mod_h323\t======>FSH323EndPoint::OnSetGatewayPrefixes " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::OnSetGatewayPrefixes [%p]\n",this);
if(m_gkPrefixes.GetSize() > 0) {
PTRACE(4, "mod_h323\tOnSetGatewayPrefixes " << m_gkPrefixes);
// PTRACE(4, "mod_h323\tOnSetGatewayPrefixes " << m_gkPrefixes);
prefixes = m_gkPrefixes;
return true;
}
......@@ -565,10 +574,11 @@ bool FSH323EndPoint::OnSetGatewayPrefixes(PStringList & prefixes) const{
}
void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface){
PTRACE(4, "mod_h323\t======>FSH323EndPoint::StartGkClient [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::StartGkClient [%p]\n",this);
while(!UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface) && retry > 0 ){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"Could not start gatekeeper: addr=\"%s\", id=\"%s\", if=\"%s\"\n",
"Could not start gatekeeper: gw name=\"%s\", addr=\"%s\", id=\"%s\", if=\"%s\"\n",
(const char *)m_endpointname,
(const char *)m_gkAddress,
(const char *)m_gkIdentifer,
(const char *)m_gkInterface);
......@@ -590,7 +600,7 @@ void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIden
}
void FSH323EndPoint::StopGkClient(){
PTRACE(4, "mod_h323\t======> FSH323EndPoint::StopGkClient [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::StopGkClient [%p]\n",this);
if (m_thread) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Stop gatekeeper thread\n");
m_stop_gk = true;
......@@ -620,8 +630,9 @@ FSH323Connection::FSH323Connection(FSH323EndPoint& endpoint, H323Transport* tran
, m_active_sessionID(0)
, m_active_chennel_fax(false)
, m_rtp_resetting(0)
, m_isRequst_fax(false){
PTRACE(4, "mod_h323\t======>FSH323Connection::FSH323Connection [" << *this<<"]");
, m_isRequst_fax(false)
, m_channel_hangup(false){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::FSH323Connection [%p]\n",this);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));
tech_pvt->me = this;
......@@ -650,19 +661,27 @@ FSH323Connection::FSH323Connection(FSH323EndPoint& endpoint, H323Transport* tran
}
FSH323Connection::~FSH323Connection(){
PTRACE(4, "mod_h323\t======>FSH323Connection::~FSH323Connection ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::~FSH323Connection [%p]\n",this);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
tech_pvt->me = NULL;
if ((m_rtp_resetting == 1)) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
tech_pvt->me = NULL;
// switch_mutex_unlock(tech_pvt->h323_mutex);
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
}
void FSH323Connection::OnSetLocalCapabilities(){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnSetLocalCapabilities() [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSetLocalCapabilities() [%p]\n",this);
H323Connection::OnSetLocalCapabilities();
SetLocalCapabilities();
}
bool FSH323Connection::SetLocalCapabilities(){
PTRACE(4, "mod_h323\t======>FSH323Connection::SetLocalCapabilities() Size local capability = "<<localCapabilities.GetSize()<<" [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::SetLocalCapabilities() Size local capability = %d [%p]\n",localCapabilities.GetSize(),this);
if (!mod_h323_globals.codec_string)
return false;
......@@ -675,11 +694,11 @@ bool FSH323Connection::SetLocalCapabilities(){
if (format) {
PString m_globalcodec = ((const char *)mod_h323_globals.codec_string);
if (m_globalcodec.Find(format) < 0) {
PTRACE(1, "mod_h323\tRemoving capability '"<<fname<<"' ("<<format<<") not in remote '"<<m_globalcodec<<"'");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Removing capability '%s' (%s) not in remote %s",(const char*)fname,format,(const char*)m_globalcodec);
changed = true;
for (PINDEX idx = 0; idx < fastStartChannels.GetSize(); idx++) {
if (fastStartChannels[idx].GetCapability() == localCapabilities[i]) {
PTRACE(1, "mod_h323\tRemoving fast start channel "<<fastStartChannels[idx].GetDirection()<<" '"<<fname<<"' ("<<format<<")");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Removing fast start channel %s '%s' (%s)\n",GetDirections[fastStartChannels[idx].GetDirection()],(const char*)fname,(const char*)format);
fastStartChannels.RemoveAt(idx--);
}
}
......@@ -689,7 +708,7 @@ bool FSH323Connection::SetLocalCapabilities(){
}
}
if (nocodecs) {
PTRACE(3, "mod_h323\tNo codecs remaining for H323 connection ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No codecs remaining for H323 connection [%p]\n",this);
changed = false;
ClearCall(EndedByCapabilityExchange);
}
......@@ -697,7 +716,7 @@ bool FSH323Connection::SetLocalCapabilities(){
}
bool FSH323Connection::decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload, PString* capabName){
PTRACE(4, "mod_h323\t======>FSH323Connection::decodeCapability");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::decodeCapability [%p]\n",this);
PString fname((const char *)capability.GetFormatName());
if (fname.Find("{sw}") == (fname.GetLength() - 4))
......@@ -716,7 +735,7 @@ bool FSH323Connection::decodeCapability(const H323Capability& capability, const
}
}
PTRACE(1, "mod_h323\tcapability '"<< fname << "' format '"<<format<<"' payload "<<pload);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"capability '%s' format '%s' %d",(const char*)fname,format,pload);
if (format) {
if (capabName)
*capabName = fname;
......@@ -731,10 +750,10 @@ bool FSH323Connection::decodeCapability(const H323Capability& capability, const
H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString &caller,
const H323SignalPDU &setupPDU, H323SignalPDU &connectPDU){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnAnswerCall caller = "<< caller<<" [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnAnswerCall caller = %s [%p]\n",(const char*)caller,this);
if (m_fsSession == NULL) {
PTRACE(1, "mod_h323\tSession request failed.");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session request failed.\n");
return H323Connection::AnswerCallDenied;
}
......@@ -742,7 +761,7 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
if (channel == NULL) {
PTRACE(1, "mod_h323\tSession does not have a channel");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Session does not have a channel\n");
return H323Connection::AnswerCallDenied;
}
......@@ -750,17 +769,17 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
const H225_Setup_UUIE& setup = setupPDU.m_h323_uu_pdu.m_h323_message_body;
const H225_ArrayOf_AliasAddress& address = setup.m_destinationAddress;
for (int i = 0; i<address.GetSize(); i++)
PTRACE(2, "mod_h323\t address index = "<<i<<" value = "<<(const char *)H323GetAliasAddressString(address[i]));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"address index = %d value = %s",i,(const char *)H323GetAliasAddressString(address[i]));
PString called;
if (address.GetSize() > 0)
called = (const char *)H323GetAliasAddressString(address[0]);
if (!called.IsEmpty())
PTRACE(2, "mod_h323\t Called number or alias = "<<called);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Called number or alias = %s\n",(const char*)called);
else {
PString callnam;
if (q931.GetCalledPartyNumber(callnam)) {
called=(const char *)callnam;
PTRACE(2, "mod_h323\t Called-Party-Number = "<<called);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Called-Party-Number = %s\n",(const char*)called);
}
}
......@@ -789,19 +808,28 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
/** destination_number */
);
if (caller_profile == NULL) {
PTRACE(1, "mod_h323\tCould not create caller profile");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not create caller profile\n");
return H323Connection::AnswerCallDenied;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Created switch caller profile:\n"
" username = %s\n"
" dialplan = %s\n"
" caller_id_name = %s\n"
" caller_id_number = %s\n"
" network_addr = %s\n"
" source = %s\n"
" context = %s\n"
" destination_number = %s\n"
,caller_profile->username
,caller_profile->dialplan
,caller_profile->caller_id_name
,caller_profile->caller_id_number
,caller_profile->network_addr
,caller_profile->source
,caller_profile->context
,caller_profile->destination_number);
PTRACE(4, "mod_h323\tCreated switch caller profile:\n"
" username = " << caller_profile->username << "\n"
" dialplan = " << caller_profile->dialplan << "\n"
" caller_id_name = " << caller_profile->caller_id_name << "\n"
" caller_id_number = " << caller_profile->caller_id_number << "\n"
" network_addr = " << caller_profile->network_addr << "\n"
" source = " << caller_profile->source << "\n"
" context = " << caller_profile->context << "\n"
" destination_number= " << caller_profile->destination_number);
switch_channel_set_caller_profile(channel, caller_profile);
char name[256] = "h323/";
......@@ -810,7 +838,7 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
switch_channel_set_state(channel, CS_INIT);
if (switch_core_session_thread_launch(m_fsSession) != SWITCH_STATUS_SUCCESS) {
PTRACE(1, "mod_h323\tCould not launch session thread");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not launch session thread\n");
return H323Connection::AnswerCallDenied;
}
......@@ -818,7 +846,7 @@ H323Connection::AnswerCallResponse FSH323Connection::OnAnswerCall(const PString
}
H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability& capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters* param, RTP_QOS * rtpqos){
PTRACE(4, "mod_h323\t======>FSH323Connection::CreateRealTimeLogicalChannel [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::CreateRealTimeLogicalChannel [%p]\n",this);
H323TransportAddress m_h323transportadd = GetSignallingChannel()->GetLocalAddress();
m_h323transportadd.GetIpAddress(m_RTPlocalIP);
......@@ -827,20 +855,26 @@ H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability
}
PBoolean FSH323Connection::OnStartLogicalChannel(H323Channel & channel){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnStartLogicalChannel chennel = "<<&channel<<" ["<<*this<<"]");
PTRACE(4, "mod_h323\t======>FSH323Connection::OnStartLogicalChannel connectionState = "<<connectionState<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel chennel = %p [%p]\n",&channel,this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnStartLogicalChannel connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
return connectionState != ShuttingDownConnection;
}
PBoolean FSH323Connection::OnCreateLogicalChannel(const H323Capability& capability, H323Channel::Directions dir, unsigned& errorCode){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnCreateLogicalChannel ('"<< (const char *)capability.GetFormatName()<<"',"<<dir<<") ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnCreateLogicalChannel ('%s',%s) [%p]\n",(const char *)capability.GetFormatName(),GetDirections[dir],this);
return H323Connection::OnCreateLogicalChannel(capability,dir,errorCode);
}
void FSH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnReceivedReleaseComplete cause = "<<pdu.GetQ931().GetCause()<<" value = "<<(switch_call_cause_t)pdu.GetQ931().GetCause());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedReleaseComplete value = %d\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
if ((tech_pvt->me != NULL) && (m_rtp_resetting == 1)) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
tech_pvt->me = NULL;
switch_channel_hangup(switch_core_session_get_channel(m_fsSession),(switch_call_cause_t)pdu.GetQ931().GetCause());
return H323Connection::OnReceivedReleaseComplete(pdu);
......@@ -848,7 +882,7 @@ void FSH323Connection::OnReceivedReleaseComplete(const H323SignalPDU & pdu){
bool FSH323Connection::OnReceivedProgress(const H323SignalPDU &pdu)
{
PTRACE(4, "mod_h323\t======>FSH323Connection::OnReceivedProgress ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedProgress [%p]\n",this);
H323Connection::OnReceivedProgress(pdu);
if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
switch_channel_mark_pre_answered(m_fsChannel);
......@@ -860,31 +894,27 @@ bool FSH323Connection::OnReceivedProgress(const H323SignalPDU &pdu)
bool FSH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnReceivedSignalSetup ["<<*this<<"]");
// Lock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedSignalSetup [%p]\n",this);
if (!H323Connection::OnReceivedSignalSetup(setupPDU)) return false;
PTRACE(4, "mod_h323\t---------> after FSH323Connection::OnReceivedSignalSetup connectionState = "<<connectionState<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> after FSH323Connection::OnReceivedSignalSetup connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
H323SignalPDU callProceedingPDU;
H225_CallProceeding_UUIE & callProceeding = callProceedingPDU.BuildCallProceeding(*this);
PTRACE(4, "mod_h323\t---------> after callProceedingPDU.BuildCallProceeding connectionState = "<<connectionState<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> after callProceedingPDU.BuildCallProceeding connectionState = %s [%p]\n",ConnectionStatesNames[connectionState],this);
if (connectionState == ShuttingDownConnection){
PTRACE(4, "mod_h323\t---------> connectionState = ShuttingDownConnection ["<<*this<<"]");
// Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---------> connectionState = ShuttingDownConnection [%p]\n",this);
return false;
}
if (SendFastStartAcknowledge(callProceeding.m_fastStart)){
callProceeding.IncludeOptionalField(H225_CallProceeding_UUIE::e_fastStart);
} else {
PTRACE(2, "H323\tSendFastStartAcknowledge = FALSE ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"SendFastStartAcknowledge = FALSE\n");
if (connectionState == ShuttingDownConnection){
// Unlock();
return true;
}
earlyStart = TRUE;
if (!h245Tunneling && (controlChannel == NULL)) {
if (!StartControlChannel()){
// Unlock();
return true;
}
callProceeding.IncludeOptionalField(H225_CallProceeding_UUIE::e_h245Address);
......@@ -892,26 +922,23 @@ bool FSH323Connection::OnReceivedSignalSetup(const H323SignalPDU & setupPDU){
}
}
if (connectionState == ShuttingDownConnection){
// Unlock();
return true;
}
if (!WriteSignalPDU(callProceedingPDU)){
// Unlock();
return false;
}
// Unlock();
return true;
}
bool FSH323Connection::OnReceivedCallProceeding(const H323SignalPDU & pdu){
PTRACE(4, "mod_h323\t======>PFSH323Connection::OnReceivedCallProceeding ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnReceivedCallProceeding [%p]\n",this);
unsigned pi;
if (!pdu.GetQ931().GetProgressIndicator(pi))
pi = 0;
PTRACE(4, "mod_h323\t----------->OnAlerting PI = "<<pi);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting PI = %u",pi);
if (pi > 0){
if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
switch_channel_mark_pre_answered(m_fsChannel);
......@@ -923,25 +950,20 @@ bool FSH323Connection::OnReceivedCallProceeding(const H323SignalPDU & pdu){
}
bool FSH323Connection::OnSendCallProceeding(H323SignalPDU & callProceedingPDU){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnSendCallProceeding fastStartState = "<<FastStartStateNames[fastStartState]<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendCallProceeding fastStartState = %s [%p]\n",FastStartStateNames[fastStartState],this);
return false;
// return true;
}
bool FSH323Connection::OnSendReleaseComplete(H323SignalPDU & pdu)
{
PTRACE(4, "mod_h323\t======>FSH323Connection::OnSendReleaseComplete cause = "<<pdu.GetQ931().GetCause()<<" value = "<<(switch_call_cause_t)pdu.GetQ931().GetCause());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnSendReleaseComplete cause = %u\n",(switch_call_cause_t)pdu.GetQ931().GetCause());
switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
return H323Connection::OnSendReleaseComplete(pdu);
}
PBoolean FSH323Connection::OpenLogicalChannel(const H323Capability& capability, unsigned sessionID, H323Channel::Directions dir){
PTRACE(4, "mod_h323\t======>FSH323Connection::OpenLogicalChannel ('"<< (const char *)capability.GetFormatName()<<"', "<< sessionID<<", "<<dir <<") "<<*this);
// if (m_rxChennel && m_txChennel)
// return true;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OpenLogicalChannel ('%s', %d, %s) [%p]\n",(const char *)capability.GetFormatName(),sessionID,GetDirections[dir],this);
return H323Connection::OpenLogicalChannel(capability,sessionID,dir);
}
......@@ -950,24 +972,24 @@ bool FSH323Connection::OnReceivedCapabilitySet(const H323Capabilities & remoteCa
const H245_MultiplexCapability * muxCap,
H245_TerminalCapabilitySetReject & reject){
PTRACE(4, "mod_h323\t======>FSH323Connection::OnReceivedCapabilitySet ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnReceivedCapabilitySet [%p]\n",this);
if (connectionState == ShuttingDownConnection)
return false;
if (!H323Connection::OnReceivedCapabilitySet(remoteCaps, muxCap, reject)) {
return false;
}
PTRACE(4, "mod_h323\t======>END H323Connection::OnReceivedCapabilitySet ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>END H323Connection::OnReceivedCapabilitySet [%p]\n",this);
for (int i = 0; i < remoteCapabilities.GetSize(); ++i) {
PTRACE(4, "mod_h323\t----> Capabilities = "<<remoteCapabilities[i]);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities = %s\n",(const char*)(remoteCapabilities[i].GetFormatName()));
}
H323Capability * cap = remoteCapabilities.FindCapability(H323Capability::e_Audio);
if (cap == NULL) {
PTRACE(4, "mod_h323\t----> Capabilities is NULL ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities is NULL \n");
return false;
}
PTRACE(4, "mod_h323\t----> Capabilities not NULL ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Capabilities not NULL \n");
return connectionState != ShuttingDownConnection;
}
......@@ -975,14 +997,14 @@ bool FSH323Connection::OnReceivedCapabilitySet(const H323Capabilities & remoteCa
bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PString &user){
PTRACE(4, "mod_h323\t======>PFSH323Connection::OnAlerting user = "<<(const char *)user<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnAlerting user = %s [%p]\n",(const char *)user,this);
unsigned pi;
switch_status_t status = switch_channel_mark_ring_ready(m_fsChannel);
PTRACE(4, "mod_h323\t----------->OnAlerting return = "<<status);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting return = %d\n",status);
if (!alertingPDU.GetQ931().GetProgressIndicator(pi))
pi = 0;
PTRACE(4, "mod_h323\t----------->OnAlerting PI = "<<pi);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----------->OnAlerting PI = %u\n",pi);
if (pi > 0){
if ((m_rxChennel && m_txChennel) || (m_ChennelProgress && m_rxChennel))
switch_channel_mark_pre_answered(m_fsChannel);
......@@ -995,19 +1017,21 @@ bool FSH323Connection::OnAlerting(const H323SignalPDU &alertingPDU, const PStrin
void FSH323Connection::AnsweringCall(AnswerCallResponse response){
PTRACE(4, "mod_h323\t======>FSH323Connection::AnsweringCall ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::AnsweringCall [%p]\n",this);
switch (response) {
case AnswerCallDeferredWithMedia:{
PTRACE(2, "H323\tAnswering call: " << response);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Answering call: %s\n",GetAnswerCallResponse[response]);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock\n");
if (!Lock())
return;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock ok\n");
if (!mediaWaitForConnect) {
// create a new facility PDU if doing AnswerDeferredWithMedia
H323SignalPDU want245PDU;
H225_Progress_UUIE & prog = want245PDU.BuildProgress(*this);
PBoolean sendPDU = TRUE;
PTRACE(2, "H323\tmediaWaitForConnect = FALSE ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"mediaWaitForConnect = FALSE\n");
/* if (SendFastStartAcknowledge(prog.m_fastStart)){
PTRACE(2, "H323\tSendFastStartAcknowledge = TRUE ");
prog.IncludeOptionalField(H225_Progress_UUIE::e_fastStart);
......@@ -1048,14 +1072,17 @@ void FSH323Connection::AnsweringCall(AnswerCallResponse response){
}
InternalEstablishedConnectionCheck();
Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->UnLock\n");
return;
}
case AnswerCallPending :{
if (alertingPDU != NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock\n");
if (!Lock())
return;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->Lock ok\n");
// send Q931 Alerting PDU
PTRACE(3, "H225\tSending Alerting PDU");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,"Sending Alerting PDU\n");
const char *vai = switch_channel_get_variable(m_fsChannel, "alerting-indication");
unsigned ai = 0;
......@@ -1072,6 +1099,7 @@ void FSH323Connection::AnsweringCall(AnswerCallResponse response){
alertingTime = PTime();
InternalEstablishedConnectionCheck();
Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->UnLock\n");
return;
}
}
......@@ -1081,12 +1109,12 @@ void FSH323Connection::AnsweringCall(AnswerCallResponse response){
void FSH323Connection::OnEstablished(){
PTRACE(4, "mod_h323\t======>PFSH323Connection::OnEstablished ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnEstablished [%p]\n",this);
if(m_startRTP)
switch_channel_mark_answered(m_fsChannel);
else m_ChennelAnswer = true;
if (m_active_chennel_fax)
RequestModeChangeT38();
RequestModeChangeT38("T.38\nT.38");
else
m_active_chennel_fax = true;
}
......@@ -1096,28 +1124,31 @@ PBoolean FSH323Connection::OnRequestModeChange(const H245_RequestMode & pdu,
PINDEX & selectedMode)
{
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
PTRACE(4, "mod_h323\t======>PFSH323Connection::OnRequestModeChange ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnRequestModeChange [%p]\n",this);
if (!m_isRequst_fax){
m_isRequst_fax = true;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return true;
}
return false;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
return false;
}
void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
PTRACE(4, "mod_h323\t======>PFSH323Connection::OnModeChanged ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnModeChanged [%p]\n",this);
for (PINDEX i = 0; i < newMode.GetSize(); i++) {
H323Capability * capability = localCapabilities.FindCapability(newMode[i]);
if (PAssertNULL(capability) != NULL) {
PTRACE(1, "mod_h323\tOpen channel after mode change: " << *capability);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Open channel after mode change: %s\n",(const char*)(capability->GetFormatName()));
if (capability->GetMainType() == H323Capability::e_Data){
PTRACE(1, "mod_h323\tcapability->GetMainType() = H323Capability::e_Data");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"capability->GetMainType() = H323Capability::e_Data\n");
H245_DataMode & type = newMode[i].m_type;
if (type.m_application.GetTag() == H245_DataMode_application::e_t38fax){
PTRACE(1, "mod_h323\ttype.m_application.GetTag() = H245_DataMode_application::e_t38fax");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"ttype.m_application.GetTag() = H245_DataMode_application::e_t38fax\n");
H245_DataMode_application_t38fax & fax = type.m_application;
H245_DataProtocolCapability & proto = fax.m_t38FaxProtocol;
const H245_T38FaxProfile & profile = fax.m_t38FaxProfile;
......@@ -1125,43 +1156,40 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
if (!t38_options) {
t38_options = (switch_t38_options_t*)switch_core_session_alloc(m_fsSession, sizeof(* t38_options));
PTRACE(1, "mod_h323\tswitch_core_session_alloc t38_options");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"switch_core_session_alloc t38_options\n");
}
// t38_options->port = 0;
// t38_options->ip = NULL;
t38_options->T38VendorInfo = "0 0 0";
t38_options->T38FaxVersion = profile.m_version;
PTRACE(1, "mod_h323\tT38FaxVersion:"<<profile.m_version);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxVersion:%lu\n",(unsigned long)profile.m_version);
t38_options->T38MaxBitRate = type.m_bitRate*100;
PTRACE(1, "mod_h323\tT38MaxBitRate:"<<t38_options->T38MaxBitRate);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38MaxBitRate:%d\n",t38_options->T38MaxBitRate);
if (profile.m_fillBitRemoval)
t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
PTRACE(1, "mod_h323\tT38FaxFillBitRemoval:"<<profile.m_fillBitRemoval);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxFillBitRemoval:%d\n",(int)profile.m_fillBitRemoval);
if (profile.m_transcodingMMR)
t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
PTRACE(1, "mod_h323\tT38FaxTranscodingMMR:"<<profile.m_transcodingMMR);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxTranscodingMMR:%d\n",(int)profile.m_transcodingMMR);
if (profile.m_transcodingJBIG)
t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
PTRACE(1, "mod_h323\tT38FaxTranscodingJBIG:"<<profile.m_transcodingJBIG);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxTranscodingJBIG:%d\n",(int)profile.m_transcodingJBIG);
if (profile.m_t38FaxRateManagement.GetTag() == H245_T38FaxRateManagement::e_transferredTCF)
t38_options->T38FaxRateManagement = "transferredTCF";
else
t38_options->T38FaxRateManagement = "localTCF";
PTRACE(1, "mod_h323\tT38FaxRateManagement:"<<t38_options->T38FaxRateManagement);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxRateManagement:%s\n",t38_options->T38FaxRateManagement);
t38_options->T38FaxMaxBuffer = profile.m_t38FaxUdpOptions.m_t38FaxMaxBuffer;
PTRACE(1, "mod_h323\tT38FaxMaxBuffer:"<<profile.m_t38FaxUdpOptions.m_t38FaxMaxBuffer);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxMaxBuffer:%lu\n",(unsigned long)profile.m_t38FaxUdpOptions.m_t38FaxMaxBuffer);
t38_options->T38FaxMaxDatagram = profile.m_t38FaxUdpOptions.m_t38FaxMaxDatagram;
PTRACE(1, "mod_h323\tT38FaxMaxDatagram:"<<profile.m_t38FaxUdpOptions.m_t38FaxMaxDatagram);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxMaxDatagram:%lu\n",(unsigned long)profile.m_t38FaxUdpOptions.m_t38FaxMaxDatagram);
if (profile.m_t38FaxUdpOptions.m_t38FaxUdpEC.GetTag() == H245_T38FaxUdpOptions_t38FaxUdpEC::e_t38UDPFEC)
t38_options->T38FaxUdpEC = "t38UDPFEC";
else
t38_options->T38FaxUdpEC = "t38UDPRedundancy";
PTRACE(1, "mod_h323\tT38FaxUdpEC:"<<t38_options->T38FaxUdpEC);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"T38FaxUdpEC:%s\n",t38_options->T38FaxUdpEC);
const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE);
if (uuid != NULL){
PTRACE(1, "mod_h323\t uuid:"<<uuid);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid);
switch_channel_set_private(switch_core_session_get_channel(switch_core_session_locate(switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE))), "t38_options", t38_options);
......@@ -1174,8 +1202,8 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
msg.from = switch_channel_get_name(m_fsChannel);
msg.message_id = SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA;
msg.numeric_arg = insist;
PTRACE(1, "mod_h323\tuuid:"<<switch_channel_get_uuid(switch_core_session_get_channel(switch_channel_get_session(m_fsChannel))));
PTRACE(1, "mod_h323\tuuid:"<<uuid);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",switch_channel_get_uuid(switch_core_session_get_channel(switch_channel_get_session(m_fsChannel))));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"uuid:%s\n",uuid);
switch_core_session_message_send(uuid,&msg);
} else {
switch_channel_set_private(m_fsChannel, "t38_options", t38_options);
......@@ -1187,66 +1215,75 @@ void FSH323Connection::OnModeChanged(const H245_ModeDescription & newMode){
H323Connection::OnModeChanged(newMode);
}
bool FSH323Connection::OnSendSignalSetup(H323SignalPDU & setupPDU){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::OnSendSignalSetup [%p]\n",this);
setupPDU.GetQ931().SetBearerCapabilities(Q931::TransferSpeech, 1);
return true;
}
void FSH323Connection::setRemoteAddress(const char* remoteIP, WORD remotePort){
PTRACE(4, "mod_h323\t======>PFSH323Connection::setRemoteAddress remoteIP ="<<remoteIP<<", remotePort = "<<remotePort<<" "<<*this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>PFSH323Connection::setRemoteAddress remoteIP = %s , remotePort = %d [%p]\n",remoteIP,remotePort,this);
if (!m_remotePort) {
PTRACE(4, "mod_h323\tGot remote RTP address "<<remoteIP<<":"<<remotePort<<" ["<<*this<<"]");
m_remotePort = remotePort;
m_remoteAddr = remoteIP;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Got remote RTP address %s:%d [%p]\n",remoteIP,remotePort,this);
m_remotePort = remotePort;
m_remoteAddr = remoteIP;
}
}
switch_status_t FSH323Connection::on_execute(){
PTRACE(4, "mod_h323\t======>FSH323Connection::on_execute [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_execute [%p]\n",this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_routing(){
PTRACE(4, "mod_h323\t======>FSH323Connection::on_routing ["<< *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_routing [%p]\n",this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::kill_channel(int sig){
PTRACE(4, "mod_h323\t======>FSH323Connection::kill_channel ["<< *this<<"]");
PTRACE(3, "mod_h323\tKill " << sig << " on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::kill_channel sig = %d [%p]\n",sig,this);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
if (!tech_pvt) {
return SWITCH_STATUS_FALSE;
}
switch (sig) {
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_rtp_break(tech_pvt->rtp_session);
}
break;
case SWITCH_SIG_KILL:
default:
m_rxAudioOpened.Signal();
m_txAudioOpened.Signal();
if (switch_rtp_ready(tech_pvt->rtp_session)) {
PTRACE(3, "mod_h323\t--->Kill soket" << *this);
switch_rtp_kill_socket(tech_pvt->rtp_session);
}
break;
case SWITCH_SIG_BREAK:
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_rtp_break(tech_pvt->rtp_session);
}
break;
case SWITCH_SIG_KILL:
default:
m_rxAudioOpened.Signal();
m_txAudioOpened.Signal();
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if ((m_rtp_resetting == 1)) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--->Kill soket [%p]\n",this);
switch_rtp_kill_socket(tech_pvt->rtp_session);
}
break;
}
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::send_dtmf(const switch_dtmf_t *dtmf){
PTRACE(4, "mod_h323\t======>FSH323Connection::send_dtmf " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::send_dtmf [%p]\n",this);
SendUserInputTone(dtmf->digit, dtmf->duration);
return SWITCH_STATUS_SUCCESS;
}
void FSH323Connection::SendUserInputTone(char tone, unsigned duration, unsigned logicalChannel, unsigned rtpTimestamp)
{
PTRACE(4, "mod_h323\t======>FSH323Connection::SendUserInputTone [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::SendUserInputTone [%p]\n",this);
H323Connection::SendUserInputTone(tone, duration);
}
......@@ -1254,7 +1291,7 @@ void FSH323Connection::OnUserInputTone(char tone, unsigned duration, unsigned lo
{
if (m_select_dtmf == 0 || m_select_dtmf == 1){
m_select_dtmf = 1;
PTRACE(4, "mod_h323\t======>FSH323Connection::OnUserInputTone [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnUserInputTone [%p]\n",this);
switch_dtmf_t dtmf = { tone, duration };
switch_channel_queue_dtmf(m_fsChannel, &dtmf);
H323Connection::OnUserInputTone( tone, duration, logicalChannel, rtpTimestamp);
......@@ -1265,7 +1302,7 @@ void FSH323Connection::OnUserInputString(const PString &value)
{
if (m_select_dtmf == 0 || m_select_dtmf == 2){
m_select_dtmf = 2;
PTRACE(4, "mod_h323\t======>FSH323Connection::OnUserInputString [" << *this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::OnUserInputString [%p]\n",this);
switch_dtmf_t dtmf = { value[0], 500 };
switch_channel_queue_dtmf(m_fsChannel, &dtmf);
H323Connection::OnUserInputString(value);
......@@ -1273,19 +1310,16 @@ void FSH323Connection::OnUserInputString(const PString &value)
}
void FSH323Connection::CleanUpOnCall(){
PTRACE(4, "mod_h323\t======>FSH323Connection::CleanUpOnCall [" << *this<<"]");
// Lock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::CleanUpOnCall [%p]\n",this);
connectionState = ShuttingDownConnection;
// Unlock();
PTRACE(4, "mod_h323\t<======FSH323Connection::CleanUpOnCall [" << *this<<"]");
}
switch_status_t FSH323Connection::receive_message(switch_core_session_message_t *msg){
PTRACE(4, "mod_h323\t======>FSH323Connection::receive_message MSG=" << msg->message_id);
// Lock();
// Unlock();
switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
switch_status_t FSH323Connection::receive_message(switch_core_session_message_t *msg){
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::receive_message MSG = %d\n",msg->message_id);
switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
switch (msg->message_id) {
case SWITCH_MESSAGE_INDICATE_BRIDGE:
case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
......@@ -1304,7 +1338,14 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
case SWITCH_MESSAGE_INDICATE_DEFLECT: {
break;
}
case SWITCH_MESSAGE_INDICATE_PROGRESS: {
case SWITCH_MESSAGE_INDICATE_PROGRESS: {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
if (m_txChennel && m_rxChennel){
m_callOnPreAnswer = true;
}
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
AnsweringCall(AnswerCallPending);
AnsweringCall(AnswerCallDeferredWithMedia);
......@@ -1315,9 +1356,9 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
} else {
m_callOnPreAnswer = true;
if (fastStartState == FastStartDisabled){
PTRACE(4, "mod_h323\t-------------------->m_txAudioOpened.Wait START" << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_txAudioOpened.Wait START [%p]\n",this);
m_txAudioOpened.Wait();
PTRACE(4, "mod_h323\t-------------------->m_rxAudioOpened.Wait STOP" << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_rxAudioOpened.Wait STOP [%p]\n",this);
}
}
break;
......@@ -1327,121 +1368,126 @@ switch_status_t FSH323Connection::receive_message(switch_core_session_message_t
return SWITCH_STATUS_FALSE;
}
AnsweringCall(H323Connection::AnswerCallNow);
PTRACE(4, "mod_h323\tMedia started on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Media started on connection [%p]\n",this);
if (m_txChennel && m_rxChennel){
if (!switch_channel_test_flag(m_fsChannel, CF_EARLY_MEDIA)) {
PTRACE(4, "mod_h323\t-------------------->switch_channel_mark_answered(m_fsChannel) " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->switch_channel_mark_answered(m_fsChannel) [%p]\n",this);
switch_channel_mark_answered(m_fsChannel);
}
} else{
m_ChennelAnswer = true;
if (fastStartState == FastStartDisabled){
PTRACE(4, "mod_h323\t-------------------->m_txAudioOpened.Wait START" << *this);
PTRACE(4, "mod_h323\t-------------------->m_rxAudioOpened.Wait START" << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_txAudioOpened.Wait START [%p]\n",this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_rxAudioOpened.Wait START [%p]\n",this);
m_txAudioOpened.Wait();
m_rxAudioOpened.Wait();
PTRACE(4, "mod_h323\t-------------------->m_txAudioOpened.Wait STOP" << *this);
PTRACE(4, "mod_h323\t-------------------->m_rxAudioOpened.Wait STOP" << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_txAudioOpened.Wait STOP [%p]\n",this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-------------------->m_rxAudioOpened.Wait STOP [%p]\n",this);
}
}
break;
}
case SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA: {
PTRACE(3, "mod_h323\tReceived message SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message SWITCH_MESSAGE_INDICATE_REQUEST_IMAGE_MEDIA on connection [%p]\n",this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
if (!m_isRequst_fax)
m_isRequst_fax = true;
m_isRequst_fax = true;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
if (m_active_chennel_fax)
RequestModeChangeT38();
RequestModeChangeT38("T.38\nT.38");
else
m_active_chennel_fax = true;
break;
}
case SWITCH_MESSAGE_INDICATE_UDPTL_MODE:{
PTRACE(3, "mod_h323\tReceived message SWITCH_MESSAGE_INDICATE_UDPTL_MODE on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message SWITCH_MESSAGE_INDICATE_UDPTL_MODE on connection [%p]\n",this);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---->switch_rtp_udptl_mode [%p]\n",this);
switch_rtp_udptl_mode(tech_pvt->rtp_session);
}
break;
}
case SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION:{
PTRACE(3, "mod_h323\tReceived message SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message SWITCH_MESSAGE_INDICATE_T38_DESCRIPTION on connection [%p]\n",this);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"---->switch_rtp_udptl_mode [%p]\n",this);
switch_rtp_udptl_mode(tech_pvt->rtp_session);
}
break;
}
default:{
PTRACE(3, "mod_h323\tReceived message " << msg->message_id << " on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Received message id = %d [%p]\n", msg->message_id,this);
}
}
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::receive_event(switch_event_t *event){
PTRACE(4, "mod_h323\t======>FSH323Connection::receive_event " << *this);
PTRACE(3, "mod_h323\tReceived event " << event->event_id << " on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::receive_event event id = %d [%p]\n",event->event_id,this);
// PTRACE(4, "mod_h323\tReceived event " << event->event_id << " on connection " << *this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::state_change(){
PTRACE(4, "mod_h323\t======>FSH323Connection::state_change " << *this);
PTRACE(3, "mod_h323\tState changed on connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::state_change [%p]\n",this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"State changed on connection [%p]\n",this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_init(){
PTRACE(4, "mod_h323\t======>FSH323Connection::on_init " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_init [%p]\n",this);
switch_channel_t *channel = switch_core_session_get_channel(m_fsSession);
if (channel == NULL) {
return SWITCH_STATUS_FALSE;
}
PTRACE(3, "mod_h323\tStarted routing for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Started routing for connection [%p]\n",this);
switch_channel_set_state(channel, CS_ROUTING);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_exchange_media(){
PTRACE(4, "mod_h323\t======>FSH323Connection::on_exchange_media " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_exchange_media [%p]\n",this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::on_soft_execute(){
PTRACE(4, "mod_h323\t======>FSH323Connection::on_soft_execute " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::on_soft_execute [%p]\n",this);
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switch_io_flag_t flags, int stream_id){
PTRACE(4, "mod_h323\t======>FSH323Connection::read_audio_frame " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame [%p]\n",this);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
tech_pvt->read_frame.flags = 0;
switch_set_flag_locked(tech_pvt, TFLAG_READING);
if (!switch_channel_ready(m_fsChannel)) {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n");
return SWITCH_STATUS_FALSE;
}
switch_mutex_lock(tech_pvt->h323_io_mutex);
if (switch_test_flag(tech_pvt, TFLAG_IO)) {
if (!switch_core_codec_ready(&tech_pvt->read_codec )) {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
return SWITCH_STATUS_FALSE;
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame ---> switch_rtp_zerocopy_read_frame start\n");
switch_status_t status = switch_rtp_zerocopy_read_frame(tech_pvt->rtp_session, &tech_pvt->read_frame, flags);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame ---> switch_rtp_zerocopy_read_frame stop\n");
if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
PTRACE(4, "mod_h323\t---------> RETURN status = "<<status);
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
return status;
}
// PTRACE(4, "mod_h323\t--------->\n source = "<<tech_pvt->read_frame.source<< "\n packetlen = "<<tech_pvt->read_frame.packetlen<<"\n datalen = "<<tech_pvt->read_frame.datalen<<"\n samples = "<<tech_pvt->read_frame.samples<<"\n rate = "<<tech_pvt->read_frame.rate<<"\n payload = "<<(int)tech_pvt->read_frame.payload<<"\n timestamp = "<<tech_pvt->read_frame.timestamp<<"\n seq = "<<tech_pvt->read_frame.seq<<"\n ssrc = "<<tech_pvt->read_frame.ssrc);
......@@ -1460,26 +1506,26 @@ switch_status_t FSH323Connection::read_audio_frame(switch_frame_t **frame, switc
}
}else{
switch_mutex_unlock(tech_pvt->h323_io_mutex);
PTRACE(4, "mod_h323\t--------->TFLAG_IO OFF");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--------->TFLAG_IO OFF\n");
switch_yield(10000);
}
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_READING);
*frame = &tech_pvt->read_frame;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_audio_frame END\n\n");
return SWITCH_STATUS_SUCCESS;
}
switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id){
PTRACE(4, "mod_h323\t======>FSH323Connection::write_audio_frame " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame [%p]\n",this);
switch_status_t status = SWITCH_STATUS_SUCCESS;
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_assert(tech_pvt != NULL);
if (!switch_channel_ready(m_fsChannel)) {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
return SWITCH_STATUS_FALSE;
}
......@@ -1487,18 +1533,18 @@ switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switc
if (switch_channel_ready(m_fsChannel)) {
switch_yield(10000);
} else {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
return SWITCH_STATUS_GENERR;
}
}
if (!switch_core_codec_ready(&tech_pvt->read_codec) || !tech_pvt->read_codec.implementation) {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
return SWITCH_STATUS_GENERR;
}
if ((frame->flags & SFF_CNG)) {
PTRACE(4, "mod_h323\t---------> RETURN");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
return SWITCH_STATUS_SUCCESS;
}
switch_set_flag_locked(tech_pvt, TFLAG_WRITING);
......@@ -1508,17 +1554,17 @@ switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switc
}
switch_clear_flag_locked(tech_pvt, TFLAG_WRITING);
PTRACE(4, "mod_h323\t---------> RETURN");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_audio_frame END\n\n");
return status;
}
switch_status_t FSH323Connection::read_video_frame(switch_frame_t **frame, switch_io_flag_t flag, int stream_id){
PTRACE(4, "mod_h323\t======>FSH323Connection::read_video_frame " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::read_video_frame [%p]\n",this);
}
switch_status_t FSH323Connection::write_video_frame(switch_frame_t *frame, switch_io_flag_t flag, int stream_id){
PTRACE(4, "mod_h323\t======>FSH323Connection::write_video_frame " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323Connection::write_video_frame [%p]\n",this);
}
///////////////////////////////////////////////////////////////////////
......@@ -1540,7 +1586,7 @@ FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
m_RTPlocalIP = (const char *)ip.AsString();
SetExternalAddress(H323TransportAddress(ip, dataPort), H323TransportAddress(ip, dataPort+1));
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID="<<sessionID<<" :"<< GetDirection()<< " addr="<< m_RTPlocalIP <<":"<< m_RTPlocalPort<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel sessionID = %d :%s addr = %s:%d [%p]\n",sessionID,GetDirections[GetDirection()],(const char*)m_RTPlocalIP,m_RTPlocalPort,this);
memset(&m_readFrame, 0, sizeof(m_readFrame));
m_readFrame.codec = m_switchCodec;
......@@ -1548,8 +1594,8 @@ FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(
m_fsChannel = switch_core_session_get_channel(m_fsSession);
//SetExternalAddress(H323TransportAddress(localIpAddress, m_RTPlocalPort), H323TransportAddress(localIpAddress, m_RTPlocalPort+1));
PTRACE(4, "mod_h323\t------->capability.GetPayloadType() return = "<<capability.GetPayloadType());
PTRACE(4, "mod_h323\t------->capability.GetFormatName() return = "<<capability.GetFormatName());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetPayloadType() return = %s\n",((capability.GetPayloadType() <= RTP_DataFrame::LastKnownPayloadType)?PayloadTypesNames[capability.GetPayloadType()]:"[pt=128]"));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->capability.GetFormatName() return = %s\n",(const char*)(capability.GetFormatName()));
PString fname((const char *)capability.GetFormatName());
......@@ -1561,70 +1607,70 @@ FSH323_ExternalRTPChannel::FSH323_ExternalRTPChannel(
OpalMediaFormat format(fname, FALSE);
m_format = &format;
payloadCode = format.GetPayloadType();
PTRACE(4, "mod_h323\t------->payloadCode = "<<(int)payloadCode);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------->payloadCode = %d\n",(int)payloadCode);
}
FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel(){
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_mutex_lock(tech_pvt->h323_mutex);
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel "<< GetDirection()<<" "<<*this);
/* if (IsRunning()){
PTRACE(4, "mod_h323\t------------->Running");
PTRACE(4, "mod_h323\t------------->m_sessionID = "<<m_sessionID<<" m_active_sessionID = "<<m_conn->m_active_sessionID);
if (switch_rtp_ready(tech_pvt->rtp_session)) {
if (m_sessionID == m_conn->m_active_sessionID ){
m_conn->m_rxChennel = false;
m_conn->m_txChennel = false;
switch_core_session_lock_codec_read(m_fsSession);
switch_core_session_lock_codec_write(m_fsSession);
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
m_conn->m_rtp_resetting = 1;
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_codec_destroy(&tech_pvt->write_codec);
switch_rtp_destroy(&tech_pvt->rtp_session);
m_conn->m_startRTP = false;
switch_core_session_unlock_codec_read(m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::~FSH323_ExternalRTPChannel %s [%p]\n",GetDirections[GetDirection()],this);
if (m_rtp_resetting) {
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
}
*/
switch_mutex_unlock(tech_pvt->h323_mutex);
}
PBoolean FSH323_ExternalRTPChannel::Start(){
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::Start() "<<*this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::Start() [%p]\n",this);
const char *err = NULL;
switch_rtp_flag_t flags;
char * timer_name = NULL;
const char *var;
PTRACE(4, "mod_h323\t------------->m_sessionID = "<<sessionID<<" m_active_sessionID = "<<m_conn->m_active_sessionID);
if (!(m_conn && H323_ExternalRTPChannel::Start())){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->m_sessionID = %d m_active_sessionID = %d\n",sessionID,m_conn->m_active_sessionID);
if (!(m_conn && H323_ExternalRTPChannel::Start())){
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
if ((tech_pvt->me == NULL)||((tech_pvt->me != NULL) && tech_pvt->me->m_channel_hangup)){
switch_mutex_unlock(tech_pvt->h323_mutex);
return FALSE;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
if ((m_conn->m_active_sessionID != 0) && (m_conn->m_active_sessionID != sessionID)){
if (switch_core_codec_ready(&tech_pvt->read_codec) || switch_core_codec_ready(&tech_pvt->write_codec)) {
PTRACE(4, "mod_h323\t------------------->Changing Codec to "<<GetH245CodecName(m_capability));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->Changing Codec to %s\n",(const char*)GetH245CodecName(m_capability));
m_conn->m_rxChennel = false;
m_conn->m_txChennel = false;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_read [%p]\n",m_fsSession);
switch_core_session_lock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_write [%p]\n",m_fsSession);
switch_core_session_lock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
m_conn->m_rtp_resetting = 1;
m_rtp_resetting = 1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_codec_read_destroy\n");
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_codec_write_destroy\n");
switch_core_codec_destroy(&tech_pvt->write_codec);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_rtp_destroy\n");
switch_rtp_destroy(&tech_pvt->rtp_session);
m_conn->m_startRTP = false;
tech_pvt->rtp_session = NULL;
}
}
m_conn->m_active_sessionID = sessionID;
......@@ -1632,17 +1678,17 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
unsigned m_codec_ms = m_capability->GetTxFramesInPacket();
switch (m_capability->GetMainType()){
case H323Capability::e_Audio:{
PTRACE(4, "mod_h323\t------------------------->H323Capability::e_Audio");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->H323Capability::e_Audio\n");
isAudio = true;
break;
}
case H323Capability::e_Video:{
PTRACE(4, "mod_h323\t------------------------->H323Capability::e_Video");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->H323Capability::e_Video\n");
isAudio = false;
break;
}
case H323Capability::e_Data:{
PTRACE(4, "mod_h323\t------------------------->H323Capability::e_Data");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->H323Capability::e_Data\n");
isAudio = true;
m_codec_ms = 20;
switch_channel_set_app_flag(m_fsChannel, CF_APP_T38);
......@@ -1652,12 +1698,12 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
H323Codec *codec = GetCodec();
PTRACE(4, "mod_h323\t------------------->GetFrameSize() return = "<<m_format->GetFrameSize());
PTRACE(4, "mod_h323\t------------------->GetFrameTime() return = "<<m_format->GetFrameTime());
PTRACE(4, "mod_h323\t------------------->payloadCode = "<<(int)payloadCode);
PTRACE(4, "mod_h323\t------------------->m_codec_ms return = "<<m_codec_ms);
PTRACE(4, "mod_h323\t------------------->m_capability->GetFormatName() return = "<<m_capability->GetFormatName());
PTRACE(4, "mod_h323\t------------------->GetH245CodecName() return = "<<GetH245CodecName(m_capability));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameSize() return = %u\n",(unsigned)m_format->GetFrameSize());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetFrameTime() return = %u\n",m_format->GetFrameTime());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->payloadCode = %d\n",(int)payloadCode);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->m_codec_ms return = %u\n",m_codec_ms);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->m_capability->GetFormatName() return = %s\n",(const char*)(m_capability->GetFormatName()));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->GetH245CodecName() return = %s\n",(const char*)GetH245CodecName(m_capability));
if (GetDirection() == IsReceiver){
m_switchCodec = isAudio ? &tech_pvt->read_codec : &tech_pvt->vid_read_codec;
......@@ -1681,19 +1727,20 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
8000, 0, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
PTRACE(1, "mod_h323\t" << switch_channel_get_name(m_fsChannel)<< " Cannot initialise " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
<< m_capability->GetMainType() << " codec " << m_capability << " for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s Cannot initialise %s %s codec for connection [%p]\n",switch_channel_get_name(m_fsChannel), ((GetDirection() == IsReceiver)? " read" : " write")
, GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
PTRACE(2, "mod_h323\t" << switch_channel_get_name(m_fsChannel)<< " Unsupported ptime of " << m_codec_ms << " on " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
<< m_capability->GetMainType() << " codec " << m_capability << " for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s Unsupported ptime of %u on %s %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),m_codec_ms,((GetDirection() == IsReceiver)? " read" : " write")
,GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
}
PTRACE(1, "mod_h323\t" << switch_channel_get_name(m_fsChannel)<< " initialise " <<
switch_channel_get_name(m_fsChannel) << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
<< m_capability->GetMainType() << " codec " << m_capability << " for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"%s initialise %s codec %s for connection [%p]\n",switch_channel_get_name(m_fsChannel),((GetDirection() == IsReceiver)? " read" : " write")
,GetMainTypes[m_capability->GetMainType()],(const char*)(m_capability->GetFormatName()),this);
if (GetDirection() == IsReceiver) {
m_readFrame.rate = tech_pvt->read_codec.implementation->actual_samples_per_second;
......@@ -1708,6 +1755,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_core_codec_destroy(m_switchCodec);
m_switchCodec = NULL;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
switch_channel_set_variable(m_fsChannel,"timer_name","soft");
......@@ -1731,6 +1779,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_core_codec_destroy(m_switchCodec);
m_switchCodec = NULL;
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return false;
}
switch_channel_set_variable(m_fsChannel,"timer_name","soft");
......@@ -1741,25 +1790,45 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
}
}
PTRACE(3, "mod_h323\tSet " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
<< m_capability->GetMainType() << " codec to << " << m_capability << " for connection " << *this);
PTRACE(4, "mod_h323\t------------->h323_mutex_lock");
// PTRACE(4, "mod_h323\tSet " << ((GetDirection() == IsReceiver)? " read" : " write") << ' '
// << m_capability->GetMainType() << " codec to << " << m_capability << " for connection " << *this);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Set %s %s codec to %s for connection [%p]\n",((GetDirection() == IsReceiver)? " read" : " write")
,GetMainTypes[m_capability->GetMainType()],(const char*)m_capability->GetFormatName(),this);
PIPSocket::Address remoteIpAddress;
GetRemoteAddress(remoteIpAddress,m_RTPremotePort);
m_RTPremoteIP = (const char *)remoteIpAddress.AsString();
PTRACE(4, "mod_h323\t------------------->tech_pvt->rtp_session = "<<tech_pvt->rtp_session);
PTRACE(4, "mod_h323\t------------------->samples_per_packet = "<<m_switchCodec->implementation->samples_per_packet);
PTRACE(4, "mod_h323\t------------------->actual_samples_per_second = "<<m_switchCodec->implementation->actual_samples_per_second);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->tech_pvt->rtp_session = [%p]\n",tech_pvt->rtp_session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->samples_per_packet = %lu\n",m_switchCodec->implementation->samples_per_packet);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->actual_samples_per_second = %lu\n",m_switchCodec->implementation->actual_samples_per_second);
bool ch_port = false;
if (tech_pvt->rtp_session != NULL){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->old remot port = %d new remote port = %d\n",switch_rtp_get_remote_port(tech_pvt->rtp_session),m_RTPremotePort);
if ((switch_rtp_get_remote_port(tech_pvt->rtp_session) != m_RTPremotePort) && (GetDirection() != IsReceiver) && (m_conn->m_rtp_resetting == 1)){
ch_port = true;
m_conn->m_startRTP = false;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_lock_codec_read [%p]\n",m_fsSession);
switch_core_session_lock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_rtp_destroy\n");
switch_rtp_destroy(&tech_pvt->rtp_session);
}
}
if ((!m_conn->m_startRTP)) {
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 = "<<switch_channel_get_variable(m_fsChannel, "timer_name"));
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->timer_name = %s\n",switch_channel_get_variable(m_fsChannel, "timer_name"));
if ((var = switch_channel_get_variable(m_fsChannel, "timer_name"))) {
timer_name = (char *) var;
}
PTRACE(4, "mod_h323\t------------------->timer_name = "<<timer_name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------->timer_name = %s\n",timer_name);
tech_pvt->rtp_session = switch_rtp_new((const char *)m_RTPlocalIP,
m_RTPlocalPort,
(const char *)m_RTPremoteIP,
......@@ -1769,7 +1838,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
m_codec_ms * 1000,
(switch_rtp_flag_t) flags, timer_name, &err,
switch_core_session_get_pool(m_fsSession));
PTRACE(4, "mod_h323\t------------------------->tech_pvt->rtp_session = "<<tech_pvt->rtp_session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->tech_pvt->rtp_session = %p\n",tech_pvt->rtp_session);
m_conn->m_startRTP = true;
if (switch_rtp_ready(tech_pvt->rtp_session)) {
switch_channel_set_flag(m_fsChannel, CF_FS_RTP);
......@@ -1777,20 +1846,41 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
switch_channel_hangup(m_fsChannel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
switch_mutex_unlock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
return SWITCH_STATUS_FALSE;
}
}
if (ch_port){
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->External RTP address %s:%u\n",(const char*)m_RTPremoteIP,m_RTPremotePort);
PTRACE(4, "mod_h323\t------------->External RTP address "<<m_RTPremoteIP<<":"<<m_RTPremotePort);
PTRACE(4, "mod_h323\t------------->h323_mutex_unlock");
if (GetDirection() == IsReceiver) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_io_mutex_unlock\n");
}
if (m_conn->m_rtp_resetting) {
if (GetDirection() == IsReceiver)
switch_core_session_unlock_codec_read(m_fsSession);
else{
switch_core_session_unlock_codec_write(m_fsSession);
if (m_conn->m_callOnPreAnswer)
if (GetDirection() == IsReceiver){
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}else{
switch_core_session_unlock_codec_write(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",m_fsSession);
if (m_conn->m_callOnPreAnswer){
switch_core_session_unlock_codec_read(m_fsSession);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",m_fsSession);
}
}
}
......@@ -1805,15 +1895,10 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_channel_mark_pre_answered(m_fsChannel);
}
PTRACE(4, "mod_h323\t------------->h323_io_mutex_lock");
switch_mutex_lock(tech_pvt->h323_io_mutex);
switch_set_flag_locked(tech_pvt, TFLAG_IO);
switch_mutex_unlock(tech_pvt->h323_io_mutex);
PTRACE(4, "mod_h323\t------------->h323_io_mutex_unlock");
if ((m_capability->GetMainType() == H323Capability::e_Data) && m_conn->m_rxChennel && m_conn->m_txChennel ) {
const char *uuid = switch_channel_get_variable(m_fsChannel, SWITCH_SIGNAL_BOND_VARIABLE);
if (uuid != NULL){
PTRACE(4, "mod_h323\t------------------------->switch_rtp_udptl_mode");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------------------->switch_rtp_udptl_mode\n");
switch_rtp_udptl_mode(tech_pvt->rtp_session);
switch_core_session_message_t msg = { 0 };
msg.from = switch_channel_get_name(m_fsChannel);
......@@ -1821,6 +1906,7 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
switch_core_session_message_send(uuid,&msg);
}
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
return true;
}
......@@ -1829,36 +1915,36 @@ PBoolean FSH323_ExternalRTPChannel::Start(){
PBoolean FSH323_ExternalRTPChannel::OnReceivedPDU(
const H245_H2250LogicalChannelParameters& param,
unsigned& errorCode){
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::OnReceivedPDU ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedPDU [%p]\n",this);
if (!H323_ExternalRTPChannel::OnReceivedPDU(param,errorCode))
return true;
PIPSocket::Address remoteIpAddress;
WORD remotePort;
GetRemoteAddress(remoteIpAddress,remotePort);
PTRACE(4, "mod_h323\tRemote RTP address "<<(const char *)remoteIpAddress.AsString()<<":"<<remotePort);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Remote RTP address %s:%u\n",(const char *)remoteIpAddress.AsString(),remotePort);
m_conn->setRemoteAddress((const char *)remoteIpAddress.AsString(), remotePort);
return true;
}
PBoolean FSH323_ExternalRTPChannel::OnSendingPDU(H245_H2250LogicalChannelParameters& param){
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::OnSendingPDU ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"FSH323_ExternalRTPChannel::OnSendingPDU [%p]\n",this);
return H323_ExternalRTPChannel::OnSendingPDU(param);
}
PBoolean FSH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters& param){
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::OnReceivedAckPDU ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnReceivedAckPDU [%p]\n",this);
return H323_ExternalRTPChannel::OnReceivedAckPDU(param);
}
void FSH323_ExternalRTPChannel::OnSendOpenAck(H245_H2250LogicalChannelAckParameters& param){
PTRACE(4, "mod_h323\t======>FSH323_ExternalRTPChannel::OnSendOpenAck ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323_ExternalRTPChannel::OnSendOpenAck [%p]\n",this);
H323_ExternalRTPChannel::OnSendOpenAck(param);
}
FSH323Connection * FSH323EndPoint::FSMakeCall(const PString & dest, void *userData){
PTRACE(4, "mod_h323\t======>FSH323EndPoint::FSMakeCall DST NUMBER = "<<dest<<" ["<<*this<<"]");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>FSH323EndPoint::FSMakeCall DST NUMBER = %s [%p]\n",(const char*)dest,this);
FSH323Connection * connection;
PString token;
......@@ -1870,13 +1956,12 @@ FSH323Connection * FSH323EndPoint::FSMakeCall(const PString & dest, void *userDa
WORD port;
if (taddr.GetIpAndPort(addr, port)) {
if (addr) {
PTRACE(4, "mod_h323\t----> Using "<<addr<<" for outbound call");
transport = new H323TransportTCP(*this, addr,false);
if (!transport)
PTRACE(4, "mod_h323\t----> Unable to create transport for outgoing call");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to create transport for outgoing call\n");
}
} else
PTRACE(4, "mod_h323\t----> Unable to get address and port");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----> Unable to get address and port\n");
}
if (!(connection = (FSH323Connection *)H323EndPoint::MakeCall(dest, token, userData))) {
......@@ -1890,7 +1975,7 @@ static switch_call_cause_t create_outgoing_channel(switch_core_session_t *sessio
switch_event_t *var_event,
switch_caller_profile_t *outbound_profile,
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause){
PTRACE(4, "mod_h323\t======>create_outgoing_channel DST NUMBER = "<<outbound_profile->destination_number);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>create_outgoing_channel DST NUMBER = %s\n",outbound_profile->destination_number);
FSH323Connection * connection;
if (h323_process == NULL) {
......@@ -1902,13 +1987,13 @@ static switch_call_cause_t create_outgoing_channel(switch_core_session_t *sessio
}
*new_session = connection->GetSession();
PTRACE(4, "mod_h323\t--------->GetSession() return = "<<connection->GetSession());
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"--------->GetSession() return = [%p]\n",connection->GetSession());
return SWITCH_CAUSE_SUCCESS;
}
static switch_status_t on_destroy(switch_core_session_t *session){
PTRACE(4, "mod_h323\t======>on_destroy ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>on_destroy\n");
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
......@@ -1938,18 +2023,53 @@ static switch_status_t on_destroy(switch_core_session_t *session){
static switch_status_t on_hangup(switch_core_session_t *session){
PTRACE(4, "mod_h323\t======>switch_status_t on_hangup ");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"======>switch_status_t on_hangup [%p]\n",session);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
switch_channel_t *channel = switch_core_session_get_channel(session);
h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(session);
if (tech_pvt->me) {
PTRACE(4, "mod_h323\t----->"<<(const char *)(tech_pvt->me->GetCallToken()));
if (tech_pvt->me) {
if (tech_pvt->me->m_rtp_resetting == 1) {
switch_core_session_unlock_codec_read(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_read [%p]\n",session);
switch_core_session_unlock_codec_write(session);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->switch_core_session_unlock_codec_write [%p]\n",session);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
tech_pvt->me->m_channel_hangup = true;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
if (tech_pvt->me->TryLock() == 1){
tech_pvt->me->CloseAllLogicalChannels(true);
tech_pvt->me->CloseAllLogicalChannels(false);
tech_pvt->me->Unlock();
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"----->%s\n",(const char *)(tech_pvt->me->GetCallToken()));
Q931::CauseValues cause = (Q931::CauseValues)switch_channel_get_cause_q850(channel);
int trylock = tech_pvt->me->TryLock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> () = %d\n",trylock);
if (trylock == 1){
const PString currentToken(tech_pvt->me->GetCallToken());
FSH323Connection *connection = (FSH323Connection *)tech_pvt->me->GetEndPoint()->FindConnectionWithLock(currentToken);
connection->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
tech_pvt->me->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
}else if (trylock == -1){
tech_pvt->me->Unlock();
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"-----> UnLock()\n");
}
tech_pvt->me->SetQ931Cause(cause);
tech_pvt->me->ClearCallSynchronous(NULL, H323TranslateToCallEndReason(cause, UINT_MAX));
tech_pvt->me = NULL;
}
// switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
// switch_mutex_lock(tech_pvt->h323_mutex);
}
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_lock\n");
switch_mutex_lock(tech_pvt->h323_mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"------------->h323_mutex_unlock\n");
switch_mutex_unlock(tech_pvt->h323_mutex);
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -31,6 +31,69 @@
#define OpalT38_IFP_COR GetOpalT38_IFP_COR()
#define OpalT38_IFP_PRE GetOpalT38_IFP_PRE()
const char* const GetDirections[H323Channel::NumDirections+1] = {
"IsBidirectional",
"IsTransmitter",
"IsReceiver",
"NumDirections"
};
const char * const PayloadTypesNames[RTP_DataFrame::LastKnownPayloadType] = {
"PCMU",
"FS1016",
"G721",
"GSM",
"G7231",
"DVI4_8k",
"DVI4_16k",
"LPC",
"PCMA",
"G722",
"L16_Stereo",
"L16_Mono",
"G723",
"CN",
"MPA",
"G728",
"DVI4_11k",
"DVI4_22k",
"G729",
"CiscoCN",
NULL, NULL, NULL, NULL, NULL,
"CelB",
"JPEG",
NULL, NULL, NULL, NULL,
"H261",
"MPV",
"MP2T",
"H263"
};
const char* const GetAnswerCallResponse[H323Connection::NumAnswerCallResponses+1]={
"AnswerCallNow",
"AnswerCallDenied",
"AnswerCallPending",
"AnswerCallDeferred",
"AnswerCallAlertWithMedia",
"AnswerCallDeferredWithMedia",
"AnswerCallDeniedByInvalidCID",
"AnswerCallNowWithAlert",
"NumAnswerCallResponses"
};
const char* const GetMainTypes[H323Capability::e_NumMainTypes+1] = {
"Audio",
"Video",
"Data",
"UserInput",
"ExtendVideo",
"GenericControl",
"ConferenceControl",
"NumMainTypes"
};
extern void SetT38_IFP_PRE();
class OpalMediaFormat;
......@@ -179,6 +242,7 @@ class FSH323EndPoint:public H323EndPoint {
int m_gkretry;
FSGkRegThread *m_thread;
bool m_stop_gk;
bool m_fax_old_asn;
};
......@@ -231,14 +295,18 @@ class FSH323Connection:public H323Connection {
H245_RequestModeAck & ack,
H245_RequestModeReject & reject,
PINDEX & selectedMode);
virtual bool OnSendSignalSetup(H323SignalPDU & setupPDU);
bool SetLocalCapabilities();
static bool decodeCapability(const H323Capability & capability, const char **dataFormat, int *payload = 0, PString * capabName = 0);
bool decodeCapability(const H323Capability & capability, const char **dataFormat, int *payload = 0, PString * capabName = 0);
virtual H323Connection::AnswerCallResponse OnAnswerCall(const PString & caller, const H323SignalPDU & signalPDU, H323SignalPDU & connectPDU);
virtual bool OnReceivedCapabilitySet(const H323Capabilities & remoteCaps,
const H245_MultiplexCapability * muxCap, H245_TerminalCapabilitySetReject & reject);
switch_core_session_t *GetSession() const {
return m_fsSession;
}
FSH323EndPoint* GetEndPoint() const{
return m_endpoint;
}
virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
virtual void OnUserInputString(const PString & value);
......@@ -273,6 +341,7 @@ class FSH323Connection:public H323Connection {
bool m_active_chennel_fax;
int m_rtp_resetting;
bool m_isRequst_fax;
bool m_channel_hangup;
protected:
FSH323EndPoint * m_endpoint;
PString m_remoteAddr;
......@@ -316,6 +385,7 @@ class FSH323_ExternalRTPChannel:public H323_ExternalRTPChannel {
WORD m_RTPlocalPort;
BYTE payloadCode;
unsigned m_sessionID;
int m_rtp_resetting;
};
class BaseG7231Capab:public H323AudioCapability {
......@@ -408,7 +478,7 @@ class BaseGSM0610Cap:public H323AudioCapability {
gsm.m_scrambled = m_scrambled;
return true;
} virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
PTRACE(2, "mod_h323\t==============>BaseGSM0610Cap::OnReceivedPDU");
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"==============>BaseGSM0610Cap::OnReceivedPDU [%p]\n",this);
if (pdu.GetTag() != H245_AudioCapability::e_gsmFullRate)
return false;
const H245_GSMAudioCapability & gsm = pdu;
......@@ -459,9 +529,6 @@ class FSH323_T38CapabilityPre : public FSH323_T38Capability {
FSH323_T38CapabilityPre() : FSH323_T38Capability(OpalT38_IFP_PRE) {}
};
//H323_REGISTER_CAPABILITY(FSH323_T38CapabilityCor, OpalT38_IFP_COR)
//H323_REGISTER_CAPABILITY(FSH323_T38CapabilityPre, OpalT38_IFP_PRE)
H323Channel * FSH323_T38Capability::CreateChannel(
H323Connection & connection,
......@@ -469,10 +536,10 @@ H323Channel * FSH323_T38Capability::CreateChannel(
unsigned int sessionID,
const H245_H2250LogicalChannelParameters * params) const
{
PTRACE(1, "FSH323_T38Capability::CreateChannel "
<< connection
<< " sessionID=" << sessionID
<< " direction=" << direction);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"FSH323_T38Capability::CreateChannel %p sessionID= %u direction=%s [%p]\n"
,&connection
,sessionID
,GetDirections[direction]);
return connection.CreateRealTimeLogicalChannel(*this, direction, sessionID, params);
}
......@@ -494,9 +561,6 @@ class cls : public base { \
H323_REGISTER_CAPABILITY(cls,name) \
//DEFINE_H323_CAPAB_m(FS_T38_COR,FSH323_T38Capability,OpalT38_IFP_COR)
//DEFINE_H323_CAPAB_m(FS_T38_RPE,FSH323_T38Capability,OpalT38_IFP_PRE)
DEFINE_H323_CAPAB(FS_G7231_5, BaseG7231Capab, false, OPAL_G7231_5k3 "{sw}")
DEFINE_H323_CAPAB(FS_G7231_6, BaseG7231Capab, false, OPAL_G7231_6k3 "{sw}")
DEFINE_H323_CAPAB(FS_G7231A_5, BaseG7231Capab, true, OPAL_G7231A_5k3 "{sw}")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论