/* MyH323_ExternalRTPChannel */ MyH323_ExternalRTPChannel::MyH323_ExternalRTPChannel(MyH323Connection & connection, const H323Capability & capability, Directions direction, unsigned id) : H323_ExternalRTPChannel::H323_ExternalRTPChannel(connection, capability, direction, id) { struct rtp_info *info; /* Determine the Local (A side) IP Address and port */ info = on_external_rtp_create(connection.GetCallReference(), (const char *)connection.GetCallToken()); if (!info) { cout << "\tERROR: on_external_rtp_create failure" << endl; return; } else { /* Request our peer to send RTP packets to the same address we * use for signalling. We rely on OpenH323 to determine this * address. */ connection.GetSignallingChannel()->GetLocalAddress().GetIpAddress(localIpAddr); localPort = info->port; /* tell the H.323 stack */ SetExternalAddress(H323TransportAddress(localIpAddr, localPort), H323TransportAddress(localIpAddr, localPort + 1)); /* clean up allocated memory */ free(info); } /* Get the payload code */ OpalMediaFormat format(capability.GetFormatName(), FALSE); payloadCode = format.GetPayloadType(); }
BOOL MyH323_ExternalRTPChannel::OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param) { PIPSocket::Address remoteIpAddress; WORD remotePort; MyH323Connection* conn = (MyH323Connection*) &connection; if (h323debug) cout << "\t=-= In OnReceivedAckPDU for call " << connection.GetCallReference() << endl; if (H323_ExternalRTPChannel::OnReceivedAckPDU(param)) { if (!connection.Lock()) { ast_log(LOG_ERROR,"chan_h323: OnReceivedAckPDU: Could not obtain connection lock"); return FALSE; } /* if RTP hasn't been connected yet */ if (!conn->AST_RTP_Connected) { H323_ExternalRTPChannel::GetRemoteAddress(remoteIpAddress, remotePort); if (h323debug) { cout << "\t\tRTP channel id " << sessionID << " parameters:" << endl; cout << "\t\t-- remoteIpAddress: " << remoteIpAddress << endl; cout << "\t\t-- remotePort: " << remotePort << endl; cout << "\t\t-- ExternalIpAddress: " << conn->externalIpAddress << endl; cout << "\t\t-- ExternalPort: " << conn->externalPort << endl; } /* Notify Asterisk of remote RTP information */ on_start_logical_channel(connection.GetCallReference(), (const char *)remoteIpAddress.AsString(), remotePort, (const char *)conn->GetCallToken()); conn->AST_RTP_Connected = TRUE; } connection.Unlock(); return TRUE; } return FALSE; }