Ejemplo n.º 1
0
Archivo: rtp.cpp Proyecto: dyfet/ccrtp
void RTPAudio::onGotHello(const SyncSource &src)
{
	RTPEvent *event = RTPEvent::first;

	slog(Slog::levelDebug) << "hello(" << src.getID() << ") ";
        Participant* p = src.getParticipant();
	slog() << p->getSDESItem(SDESItemTypeCNAME) << std::endl;

	while(event)
	{
		event->gotHello(src);
		event = event->next;
	}
}
Ejemplo n.º 2
0
Archivo: rtp.cpp Proyecto: dyfet/ccrtp
void RTPAudio::onGotGoodbye(const SyncSource &src, const string& reason)
{
	RTPEvent *event = RTPEvent::first;

	slog(Slog::levelDebug) << "bye(" << src.getID() << ") ";
	Participant* p = src.getParticipant();
	slog() << p->getSDESItem(SDESItemTypeCNAME) << "; " << reason;
	slog() << std::endl;

	while(event)
	{
		event->gotGoodbye(src, reason);
		event = event->next;
	}
}
Ejemplo n.º 3
0
    int doTest()
    {
        const uint32 NSESSIONS = 10;
        RTPSession rx(pattern.getDestinationAddress(),pattern.getDestinationPort());
        RTPSession **tx = new RTPSession* [NSESSIONS];
        for ( uint32 i = 0; i < NSESSIONS; i++ ) {
            tx[i] = new RTPSession(InetHostAddress("localhost"));
        }
        for ( uint32 i = 0; i  < NSESSIONS; i++) {
            tx[i]->setSchedulingTimeout(10000);
            tx[i]->setExpireTimeout(1000000);
            tx[i]->setPayloadFormat(StaticPayloadFormat(sptPCMU));
            if ( !tx[i]->addDestination(pattern.getDestinationAddress(), pattern.getDestinationPort()) ) {
                return 1;
            }
        }

        rx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
        rx.setSchedulingTimeout(5000);
        rx.setExpireTimeout(10000000); // 10 seconds!
        rx.startRunning();

        for ( uint32 i = 0; i  < NSESSIONS; i++) {
            tx[i]->startRunning();
        }
        uint32 period = 20;
        TimerPort::setTimer(period);
        for ( uint32 i = 0; i < pattern.getPacketsNumber(); i++ ) {
            if ( i == 70 ) {
                RTPApplication &app = defaultApplication();
                app.setSDESItem(SDESItemTypeCNAME,"foo@bar");
            }
            for ( uint32 s = 0; s  < NSESSIONS; s++) {
            // 50 packets per second (packet duration of 20ms)
                uint16 inc =
                    tx[s]->getCurrentRTPClockRate()/50;
                tx[s]->putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i));
            }
            Thread::sleep(TimerPort::getTimer());
            TimerPort::incTimer(period);
        }

        Thread::sleep(5000);
        for ( uint32 i = 0; i < NSESSIONS; i++ ) {
            delete tx[i];
        }
        RTPSession::SyncSourcesIterator it;
        cout << "Sources of synchronization:" << endl;
        for (it = rx.begin() ; it != rx.end(); it++) {
            const SyncSource &s = *it;
            cout << s.getID();
            if ( s.isSender() )
                cout << " (sender) ";
            cout << s.getNetworkAddress() << ":" <<
                s.getControlTransportPort() << "/" <<
                s.getDataTransportPort();
            Participant *p = s.getParticipant();
            cout << " (" <<
                p->getSDESItem(SDESItemTypeCNAME)
                 << ") " << endl;
        }
        RTPApplication &app = defaultApplication();
        RTPApplication::ParticipantsIterator ai;
        cout << "Participants:" << endl;
        for ( ai = app.begin(); ai != app.end(); ai++ ) {
            const Participant &p = *ai;
            cout << p.getSDESItem(SDESItemTypeCNAME) << endl;
            //cout << p.getPRIVPrefix();
        }
        delete[] tx;
        return 0;
    }