/* 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();
}