📄 h323ep.cxx
字号:
connectionsMutex.Signal(); // Now, outside the connectionsMutex, we can clean up connections for (PINDEX i = 0; i < connections.GetSize(); i++) { H323Connection & connection = connections[i]; connection.CleanUpOnCallEnd(); OnConnectionCleared(connection, connection.GetCallToken()); } // Clean up the memory used connections.RemoveAll(); // Signal thread that may be waiting on ClearAllCalls() connectionsAreCleaned.Signal();}BOOL H323EndPoint::HasConnection(const PString & token){ PWaitAndSignal wait(connectionsMutex); return FindConnectionWithoutLocks(token) != NULL;}H323Connection * H323EndPoint::FindConnectionWithLock(const PString & token){ PWaitAndSignal wait(connectionsMutex); H323Connection * connection = FindConnectionWithoutLocks(token); if (connection == NULL) return NULL; connection->Lock(); return connection;}H323Connection * H323EndPoint::FindConnectionWithoutLocks(const PString & token){ if (token.IsEmpty()) return NULL; H323Connection * conn_ptr = connectionsActive.GetAt(token); if (conn_ptr != NULL) return conn_ptr; PINDEX i; for (i = 0; i < connectionsActive.GetSize(); i++) { H323Connection & conn = connectionsActive.GetDataAt(i); if (conn.GetCallIdentifier().AsString() == token) return &conn; } for (i = 0; i < connectionsActive.GetSize(); i++) { H323Connection & conn = connectionsActive.GetDataAt(i); if (conn.GetConferenceIdentifier().AsString() == token) return &conn; } return NULL;}BOOL H323EndPoint::OnIncomingCall(H323Connection & /*connection*/, const H323SignalPDU & /*setupPDU*/, H323SignalPDU & /*alertingPDU*/){ return TRUE;}H323Connection::AnswerCallResponse H323EndPoint::OnAnswerCall(H323Connection & /*connection*/, const PString & PTRACE_caller, const H323SignalPDU & /*setupPDU*/, H323SignalPDU & /*connectPDU*/){ PTRACE(2, "H225\tOnAnswerCall from \"" << PTRACE_caller << '"'); return H323Connection::AnswerCallNow;}BOOL H323EndPoint::OnAlerting(H323Connection & /*connection*/, const H323SignalPDU & /*alertingPDU*/, const PString & /*username*/){ PTRACE(1, "H225\tReceived alerting PDU."); return TRUE;}BOOL H323EndPoint::OnConnectionForwarded(H323Connection & /*connection*/, const PString & /*forwardParty*/, const H323SignalPDU & /*pdu*/){ return FALSE;}void H323EndPoint::OnConnectionEstablished(H323Connection & /*connection*/, const PString & /*token*/){}BOOL H323EndPoint::IsConnectionEstablished(const PString & token){ H323Connection * connection = FindConnectionWithLock(token); if (connection == NULL) return FALSE; BOOL established = connection->IsEstablished(); connection->Unlock(); return established;}void H323EndPoint::OnConnectionCleared(H323Connection & /*connection*/, const PString & /*token*/){}PString H323EndPoint::BuildConnectionToken(const H323Transport & transport, unsigned callReference, BOOL fromRemote){ PString token; if (fromRemote) token = transport.GetRemoteAddress(); else token = "ip$localhost"; token.sprintf("/%u", callReference); return token;}H323Connection & H323EndPoint::GetConnection(const H323Transport & transport, unsigned callReference, BOOL fromRemote){ PString token = BuildConnectionToken(transport, callReference, fromRemote); PWaitAndSignal wait(connectionsMutex); if (connectionsActive.Contains(token)) return connectionsActive[token]; H323Connection * connection = CreateConnection(callReference); connectionsActive.SetAt(token, connection); PTRACE(3, "H323\tCreated new connection: " << token); return *connection;}BOOL H323EndPoint::OnStartLogicalChannel(H323Connection & /*connection*/, H323Channel & /*channel*/){ return TRUE;}void H323EndPoint::OnClosedLogicalChannel(H323Connection & /*connection*/, const H323Channel & /*channel*/){}BOOL H323EndPoint::OpenAudioChannel(H323Connection & /*connection*/, BOOL isEncoding, unsigned bufferSize, H323AudioCodec & codec){ PString deviceName; if (isEncoding) deviceName = GetSoundChannelRecordDevice(); else deviceName = GetSoundChannelPlayDevice(); PSoundChannel * soundChannel = new PSoundChannel; if (soundChannel->Open(deviceName, isEncoding ? PSoundChannel::Recorder : PSoundChannel::Player, 1, 8000, 16)) { PTRACE(3, "Codec\tOpened sound channel \"" << deviceName << "\" for " << (isEncoding ? "record" : "play") << "ing using " << soundChannelBuffers << 'x' << bufferSize << " byte buffers."); soundChannel->SetBuffers(bufferSize, soundChannelBuffers); return codec.AttachChannel(soundChannel); } PTRACE(1, "Codec\tCould not open sound channel \"" << deviceName << "\" for " << (isEncoding ? "record" : "play") << "ing: " << soundChannel->GetErrorText()); delete soundChannel; return FALSE;}BOOL H323EndPoint::OpenVideoDevice(H323Connection & /*connection*/, BOOL PTRACE_isEncoding, H323VideoCodec & /*codec*/){ PTRACE(1, "Codec\tCould not open video channel for " << (PTRACE_isEncoding ? "captur" : "display") << "ing: not yet implemented"); return FALSE;}void H323EndPoint::OnRTPStatistics(const H323Connection & /*connection*/, const RTP_Session & /*session*/) const{}void H323EndPoint::OnUserInputString(H323Connection & /*connection*/, const PString & /*value*/){}void H323EndPoint::OnUserInputTone(H323Connection & connection, char tone, unsigned /*duration*/, unsigned /*logicalChannel*/, unsigned /*rtpTimestamp*/){ connection.OnUserInputString(PString(tone));}void H323EndPoint::SetLocalUserName(const PString & name){ localAliasNames.RemoveAll(); localAliasNames.AppendString(name);}BOOL H323EndPoint::AddAliasName(const PString & name){ if (localAliasNames.GetValuesIndex(name) != P_MAX_INDEX) return FALSE; localAliasNames.AppendString(name); return TRUE;}BOOL H323EndPoint::RemoveAliasName(const PString & name){ PINDEX pos = localAliasNames.GetValuesIndex(name); if (pos == P_MAX_INDEX) return FALSE; localAliasNames.RemoveAt(pos); return TRUE;}BOOL H323EndPoint::SetSoundChannelPlayDevice(const PString & name){ if (PSoundChannel::GetDeviceNames(PSoundChannel::Player).GetValuesIndex(name) == P_MAX_INDEX) return FALSE; soundChannelPlayDevice = name; return TRUE;}BOOL H323EndPoint::SetSoundChannelRecordDevice(const PString & name){ if (PSoundChannel::GetDeviceNames(PSoundChannel::Recorder).GetValuesIndex(name) == P_MAX_INDEX) return FALSE; soundChannelRecordDevice = name; return TRUE;}void H323EndPoint::SetSoundChannelBufferDepth(unsigned depth){ PAssert(depth > 1, PInvalidParameter); soundChannelBuffers = depth;}BOOL H323EndPoint::IsTerminal() const{ switch (terminalType) { case e_TerminalOnly : case e_TerminalAndMC : return TRUE; default : return FALSE; }}BOOL H323EndPoint::IsGateway() const{ switch (terminalType) { case e_GatewayOnly : case e_GatewayAndMC : case e_GatewayAndMCWithDataMP : case e_GatewayAndMCWithAudioMP : case e_GatewayAndMCWithAVMP : return TRUE; default : return FALSE; }}BOOL H323EndPoint::IsGatekeeper() const{ switch (terminalType) { case e_GatekeeperOnly : case e_GatekeeperWithDataMP : case e_GatekeeperWithAudioMP : case e_GatekeeperWithAVMP : return TRUE; default : return FALSE; }}BOOL H323EndPoint::IsMCU() const{ switch (terminalType) { case e_MCUOnly : case e_MCUWithDataMP : case e_MCUWithAudioMP : case e_MCUWithAVMP : return TRUE; default : return FALSE; }}/////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -