Esempio n. 1
0
void Mixer::remoteStartTransmission(const ::Ice::Current& curr) {
	stringstream a;
	stringstream b;
	LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission()"));

	IPV4Address *tmpAddr = new IPV4Address(getRemoteAddressFromConnection(curr.con));
	a << string("Mixer::remoteStartTransmission() rem hostAddr: ") << tmpAddr->getHostname();
	LOG4CXX_DEBUG(logger, a.str());

	TerminalInfo *info = remoteHostsM[tmpAddr->getHostname()];
	if (remoteHostsM.find(tmpAddr->getHostname()) == remoteHostsM.end()  ) {
		cout << "ERROR info not found\n";
	}

	if (this->currentState != States::PASSIVE_CONNECTED) {
		LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission() bad state"));
	} else {
		changeState(States::PASSIVE_OPERATIONAL);

		cout << "TRANSCEIVER STARTED\n";

		// TODO start RTP.RTCP transmission
		CodecFactory codecfactory;
		Codec* codecInc = codecfactory.getCodec(AudioCodec::PCMU); // HACK
		// 		Codec* codecInc = codecfactory.getCodec(info->incomingCodec);
		Codec* codecOut = codecfactory.getCodec(AudioCodec::PCMU);
		//		Codec* codecOut = codecfactory.getCodec(info->outgoingCodec); // HACK

		info->transport = new TransportCCRTP();
		info->transport->setParams(codecInc->getFrameCount(), codecInc->getFrameSize());
		info->transport->setLocalEndpoint("0.0.0.0", localRTPPort);
		info->transport->setRemoteEndpoint(info->address, info->rtpPort);
		info->buf = new RingBuffer(1024*1024, 1);
		// 		b << "Mixer::remoteStartTransmission() creating transport,
		localRTPPort += 2;

		stringstream a;
		a << "rem address: " << info->address << " port: " << info->rtpPort;
		LOG4CXX_DEBUG(logger, a.str());

		info->transport->start();

		LOG4CXX_DEBUG(logger, string("Mixer::remoteStartTransmission() transmission started"));
	}
}
Esempio n. 2
0
void Mixer::remoteTryConnect(const ::agh::CallParameters& params, const ::Ice::Identity& ident, const ::Ice::Current& curr) {
	stringstream a;
	LOG4CXX_DEBUG(logger, string("Mixer::remoteTryConnect()"));
	masterCallbackPrx = IMasterCallbackPrx::uncheckedCast(curr.con->createProxy(ident));

	if (localAddr) {
		delete localAddr;
	}
	if (remoteAddr) {
		delete remoteAddr;
	}

	IPV4Address *tmpAddr = new IPV4Address(getRemoteAddressFromConnection(curr.con));
	TerminalInfo *info = new TerminalInfo;
	info->address = *tmpAddr;
	info->rtpPort = params.masterRtpPort;
	info->outgoingCodec = params.outgoingCodec.id;
	info->incomingCodec = params.incomingCodec.id;
	info->transport = NULL;
	info->readedSize = 0;
	info->buf = NULL;
	remoteHostsM[tmpAddr->getHostname()] = info;
	a << "Mixer::remoteTryConnect() conf received, remote addr: " << tmpAddr << " port: " << params.masterRtpPort;
	LOG4CXX_DEBUG(logger, a.str());

	changeState(States::PASSIVE_CONNECTED);

	// inform remote site
	LOG4CXX_DEBUG(logger, string("Mixer::remoteTryConnect() sending ACK..."));
	CallParametersResponse response;
	response.slaveRtpPort = localRTPPort;

	// Response in new thread
	WorkerThread* tmpThread = new WorkerThread(this, response);
	tmpThread->start();
	LOG4CXX_DEBUG(logger, string("Mixer::remoteTryConnect() ACK has been sent"));
}