📄 ast_h323.cxx
字号:
} break; case H323Connection::EndedByRemoteUser: if (h323debug) { cout << "-- " << remoteName << " has cleared the call" << endl; } break; case H323Connection::EndedByCallerAbort: if (h323debug) { cout << "-- " << remoteName << " has stopped calling" << endl; } break; case H323Connection::EndedByRefusal: if (h323debug) { cout << "-- " << remoteName << " did not accept your call" << endl; } break; case H323Connection::EndedByRemoteBusy: if (h323debug) { cout << "-- " << remoteName << " was busy" << endl; } break; case H323Connection::EndedByRemoteCongestion: if (h323debug) { cout << "-- Congested link to " << remoteName << endl; } break; case H323Connection::EndedByNoAnswer: if (h323debug) { cout << "-- " << remoteName << " did not answer your call" << endl; } break; case H323Connection::EndedByTransportFail: if (h323debug) { cout << "-- Call with " << remoteName << " ended abnormally" << endl; } break; case H323Connection::EndedByCapabilityExchange: if (h323debug) { cout << "-- Could not find common codec with " << remoteName << endl; } break; case H323Connection::EndedByNoAccept: if (h323debug) { cout << "-- Did not accept incoming call from " << remoteName << endl; } break; case H323Connection::EndedByAnswerDenied: if (h323debug) { cout << "-- Refused incoming call from " << remoteName << endl; } break; case H323Connection::EndedByNoUser: if (h323debug) { cout << "-- Remote endpoint could not find user: " << remoteName << endl; } break; case H323Connection::EndedByNoBandwidth: if (h323debug) { cout << "-- Call to " << remoteName << " aborted, insufficient bandwidth." << endl; } break; case H323Connection::EndedByUnreachable: if (h323debug) { cout << "-- " << remoteName << " could not be reached." << endl; } break; case H323Connection::EndedByHostOffline: if (h323debug) { cout << "-- " << remoteName << " is not online." << endl; } break; case H323Connection::EndedByNoEndPoint: if (h323debug) { cout << "-- No phone running for " << remoteName << endl; } break; case H323Connection::EndedByConnectFail: if (h323debug) { cout << "-- Transport error calling " << remoteName << endl; } break; default: if (h323debug) {#ifdef PTRACING cout << " -- Call with " << remoteName << " completed (" << connection.GetCallEndReason() << ")" << endl;#else cout << " -- Call with " << remoteName << " completed ([" << (int)connection.GetCallEndReason() << "])" << endl;#endif } } if (connection.IsEstablished()) { if (h323debug) { cout << "\t-- Call duration " << setprecision(0) << setw(5) << (PTime() - connection.GetConnectionStartTime()) << endl; } } /* Invoke the PBX application registered callback */ on_connection_cleared(connection.GetCallReference(), clearedCallToken); return;}H323Connection * MyH323EndPoint::CreateConnection(unsigned callReference, void *userData, H323Transport *transport, H323SignalPDU *setupPDU){ unsigned options = 0; call_options_t *opts = (call_options_t *)userData; MyH323Connection *conn; if (opts && opts->fastStart) { options |= H323Connection::FastStartOptionEnable; } else { options |= H323Connection::FastStartOptionDisable; } if (opts && opts->h245Tunneling) { options |= H323Connection::H245TunnelingOptionEnable; } else { options |= H323Connection::H245TunnelingOptionDisable; }/* Disable until I can figure out the proper way to deal with this */#if 0 if (opts->silenceSuppression) { options |= H323Connection::SilenceSuppresionOptionEnable; } else { options |= H323Connection::SilenceSUppressionOptionDisable; }#endif conn = new MyH323Connection(*this, callReference, options); if (conn) { if (opts) conn->SetCallOptions(opts, (setupPDU ? TRUE : FALSE)); } return conn;}/* MyH323Connection Implementation */MyH323Connection::MyH323Connection(MyH323EndPoint & ep, unsigned callReference, unsigned options) : H323Connection(ep, callReference, options){#ifdef H323_H450 /* Dispatcher will free out all registered handlers */ if (h450dispatcher) delete h450dispatcher; h450dispatcher = new H450xDispatcher(*this); h4502handler = new H4502Handler(*this, *h450dispatcher); h4504handler = new MyH4504Handler(*this, *h450dispatcher); h4506handler = new H4506Handler(*this, *h450dispatcher); h45011handler = new H45011Handler(*this, *h450dispatcher);#endif cause = -1; sessionId = 0; bridging = FALSE; holdHandling = progressSetup = progressAlert = 0; dtmfMode = 0; dtmfCodec[0] = dtmfCodec[1] = (RTP_DataFrame::PayloadTypes)0; redirect_reason = -1; transfer_capability = -1;#ifdef TUNNELLING tunnelOptions = remoteTunnelOptions = 0;#endif if (h323debug) { cout << " == New H.323 Connection created." << endl; } return;}MyH323Connection::~MyH323Connection(){ if (h323debug) { cout << " == H.323 Connection deleted." << endl; } return;}BOOL MyH323Connection::OnReceivedProgress(const H323SignalPDU &pdu){ BOOL isInband; unsigned pi; if (!H323Connection::OnReceivedProgress(pdu)) { return FALSE; } if (!pdu.GetQ931().GetProgressIndicator(pi)) pi = 0; if (h323debug) { cout << "\t- Progress Indicator: " << pi << endl; } switch(pi) { case Q931::ProgressNotEndToEndISDN: case Q931::ProgressInbandInformationAvailable: isInband = TRUE; break; default: isInband = FALSE; } on_progress(GetCallReference(), (const char *)GetCallToken(), isInband); return connectionState != ShuttingDownConnection;}BOOL MyH323Connection::MySendProgress(){ /* The code taken from H323Connection::AnsweringCall() but ALWAYS send PROGRESS message, including slow start operations */ H323SignalPDU progressPDU; H225_Progress_UUIE &prog = progressPDU.BuildProgress(*this); if (!mediaWaitForConnect) { if (SendFastStartAcknowledge(prog.m_fastStart)) prog.IncludeOptionalField(H225_Progress_UUIE::e_fastStart); else { if (connectionState == ShuttingDownConnection) return FALSE; /* Do early H.245 start */ earlyStart = TRUE; if (!h245Tunneling) { if (!H323Connection::StartControlChannel()) return FALSE; prog.IncludeOptionalField(H225_Progress_UUIE::e_h245Address); controlChannel->SetUpTransportPDU(prog.m_h245Address, TRUE); } } } progressPDU.GetQ931().SetProgressIndicator(Q931::ProgressInbandInformationAvailable);#ifdef TUNNELLING EmbedTunneledInfo(progressPDU);#endif HandleTunnelPDU(&progressPDU); WriteSignalPDU(progressPDU); return TRUE;}H323Connection::AnswerCallResponse MyH323Connection::OnAnswerCall(const PString & caller, const H323SignalPDU & setupPDU, H323SignalPDU & connectPDU){ unsigned pi; if (h323debug) { cout << "\t=-= In OnAnswerCall for call " << GetCallReference() << endl; } if (connectionState == ShuttingDownConnection) return H323Connection::AnswerCallDenied; if (!setupPDU.GetQ931().GetProgressIndicator(pi)) { pi = 0; } if (h323debug) { cout << "\t\t- Progress Indicator: " << pi << endl; } if (progressAlert) { pi = progressAlert; } else if (pi == Q931::ProgressOriginNotISDN) { pi = Q931::ProgressInbandInformationAvailable; } if (pi && alertingPDU) { alertingPDU->GetQ931().SetProgressIndicator(pi); } if (h323debug) { cout << "\t\t- Inserting PI of " << pi << " into ALERTING message" << endl; }#ifdef TUNNELLING if (alertingPDU) EmbedTunneledInfo(*alertingPDU); EmbedTunneledInfo(connectPDU);#endif if (!on_answer_call(GetCallReference(), (const char *)GetCallToken())) { return H323Connection::AnswerCallDenied; } /* The call will be answered later with "AnsweringCall()" function. */ return ((pi || (fastStartState != FastStartDisabled)) ? AnswerCallDeferredWithMedia : AnswerCallDeferred);}BOOL MyH323Connection::OnAlerting(const H323SignalPDU & alertingPDU, const PString & username){ if (h323debug) { cout << "\t=-= In OnAlerting for call " << GetCallReference() << ": sessionId=" << sessionId << endl; cout << "\t-- Ringing phone for \"" << username << "\"" << endl; } if (on_progress) { BOOL isInband; unsigned alertingPI; if (!alertingPDU.GetQ931().GetProgressIndicator(alertingPI)) { alertingPI = 0; } if (h323debug) { cout << "\t\t- Progress Indicator: " << alertingPI << endl; } switch(alertingPI) { case Q931::ProgressNotEndToEndISDN: case Q931::ProgressInbandInformationAvailable: isInband = TRUE; break; default: isInband = FALSE; } on_progress(GetCallReference(), (const char *)GetCallToken(), isInband); } on_chan_ringing(GetCallReference(), (const char *)GetCallToken() ); return connectionState != ShuttingDownConnection;}void MyH323Connection::SetCallOptions(void *o, BOOL isIncoming){ call_options_t *opts = (call_options_t *)o; progressSetup = opts->progress_setup; progressAlert = opts->progress_alert; holdHandling = opts->holdHandling; dtmfCodec[0] = (RTP_DataFrame::PayloadTypes)opts->dtmfcodec[0]; dtmfCodec[1] = (RTP_DataFrame::PayloadTypes)opts->dtmfcodec[1]; dtmfMode = opts->dtmfmode; if (isIncoming) { fastStartState = (opts->fastStart ? FastStartInitiate : FastStartDisabled); h245Tunneling = (opts->h245Tunneling ? TRUE : FALSE); } else { sourceE164 = PString(opts->cid_num); SetLocalPartyName(PString(opts->cid_name)); SetDisplayName(PString(opts->cid_name)); if (opts->redirect_reason >= 0) { rdnis = PString(opts->cid_rdnis); redirect_reason = opts->redirect_reason; } cid_presentation = opts->presentation; cid_ton = opts->type_of_number; if (opts->transfer_capability >= 0) { transfer_capability = opts->transfer_capability; } } tunnelOptions = opts->tunnelOptions;}void MyH323Connection::SetCallDetails(void *callDetails, const H323SignalPDU &setupPDU, BOOL isIncoming){ PString sourceE164; PString destE164; PString sourceAliases; PString destAliases; char *s, *s1; call_details_t *cd = (call_details_t *)callDetails; memset(cd, 0, sizeof(*cd)); cd->call_reference = GetCallReference(); cd->call_token = strdup((const char *)GetCallToken()); sourceE164 = ""; setupPDU.GetSourceE164(sourceE164); cd->call_source_e164 = strdup((const char *)sourceE164); destE164 = ""; setupPDU.GetDestinationE164(destE164); cd->call_dest_e164 = strdup((const char *)destE164); /* XXX Is it possible to have this information for outgoing calls too? XXX */ if (isIncoming) { PString sourceName; PIPSocket::Address Ip; WORD sourcePort; PString redirect_number; unsigned redirect_reason; unsigned plan, type, screening, presentation; Q931::InformationTransferCapability capability; unsigned transferRate, codingStandard, userInfoLayer1; /* Fetch presentation and type information about calling party's number */ if (setupPDU.GetQ931().GetCallingPartyNumber(sourceName, &plan, &type, &presentation, &screening, 0, 0)) { /* Construct fields back */ cd->type_of_number = (type << 4) | plan; cd->presentation = (presentation << 5) | screening; } else if (cd->call_source_e164[0]) { cd->type_of_number = 0; /* UNKNOWN */ cd->presentation = 0x03; /* ALLOWED NETWORK NUMBER - Default */ if (setupPDU.GetQ931().HasIE(Q931::UserUserIE)) { const H225_Setup_UUIE &setup_uuie = setupPDU.m_h323_uu_pdu.m_h323_message_body; if (setup_uuie.HasOptionalField(H225_Setup_UUIE::e_presentationIndicator)) cd->presentation = (cd->presentation & 0x9f) | (((unsigned int)setup_uuie.m_presentationIndicator.GetTag()) << 5); if (setup_uuie.HasOptionalField(H225_Setup_UUIE::e_screeningIndicator)) cd->presentation = (cd->presentation & 0xe0) | (((unsigned int)setup_uuie.m_screeningIndicator.GetValue()) & 0x1f); } } else { cd->type_of_number = 0; /* UNKNOWN */ cd->presentation = 0x43; /* NUMBER NOT AVAILABLE */ } sourceName = setupPDU.GetQ931().GetDisplayName(); cd->call_source_name = strdup((const char *)sourceName); GetSignallingChannel()->GetRemoteAddress().GetIpAndPort(Ip, sourcePort); cd->sourceIp = strdup((const char *)Ip.AsString()); if (setupPDU.GetQ931().GetRedirectingNumber(redirect_number, NULL, NULL, NULL, NULL, &redirect_reason, 0, 0, 0)) { cd->redirect_number = strdup((const char *)redirect_number); cd->redirect_reason = redirect_reason; } else cd->redirect_reason = -1; /* Fetch Q.931's transfer capability */ if (((Q931 &)setupPDU.GetQ931()).GetBearerCapabilities(capability, transferRate, &codingStandard, &userInfoLayer1))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -