Beispiel #1
0
    int doTest()
    {
        // should be valid?
        //RTPSession tx();
        RTPSession tx(InetHostAddress("localhost"));
        tx.setSchedulingTimeout(10000);
        tx.setExpireTimeout(1000000);

        tx.startRunning();

        tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
        if ( !tx.addDestination(pattern.getDestinationAddress(),
                    pattern.getDestinationPort()) ) {
            return 1;
        }

        // 50 packets per second (packet duration of 20ms)
        uint32 period = 20;
        uint16 inc = tx.getCurrentRTPClockRate()/50;
        TimerPort::setTimer(period);
        for ( uint32 i = 0; i < pattern.getPacketsNumber(); i++ ) {
            tx.putData(i*inc, pattern.getPacketData(i), pattern.getPacketSize(i));
            Thread::sleep(TimerPort::getTimer());
            TimerPort::incTimer(period);
        }
        return 0;
    }
Beispiel #2
0
    int doTest() {
        // should be valid?
        //RTPSession tx();
        // Initialize with local address and Local port is detination port +2 - keep RTP/RTCP port pairs
        ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort());
        tx.initialize("test_t.zid");

        tx.setSchedulingTimeout(10000);
        tx.setExpireTimeout(1000000);

        tx.startRunning();

        tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));
        if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
            return 1;
        }
        tx.startZrtp();
        // 2 packets per second (packet duration of 500ms)
        uint32 period = 500;
        uint16 inc = tx.getCurrentRTPClockRate()/2;
        TimerPort::setTimer(period);
        uint32 i;
        for (i = 0; i < pattern.getPacketsNumber(); i++ ) {
            tx.putData(i*inc,
                       pattern.getPacketData(i),
                       pattern.getPacketSize(i));
            cout << "Sent some data: " << i << endl;
            Thread::sleep(TimerPort::getTimer());
            TimerPort::incTimer(period);
        }
        tx.putData(i*inc, (unsigned char*)"exit", 5);
        Thread::sleep(200);
        return 0;
    }
Beispiel #3
0
    int doTest()
    {
        // should be valid?
        //RTPSession tx();
        ExtZrtpSession tx(/*pattern.getSsrc(),*/ pattern.getSenderAddress(), pattern.getSenderPort());
//        config.clear();
//        config.setStandardConfig();
        config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("DH2k"));
        config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC38"));
        config.addAlgo(PubKeyAlgorithm, zrtpPubKeys.getByName("EC25"));

         config.addAlgo(HashAlgorithm, zrtpHashes.getByName("S384"));

//          config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("2FS3"));
//          config.addAlgo(CipherAlgorithm, zrtpSymCiphers.getByName("AES3"));

        config.addAlgo(SasType, zrtpSasTypes.getByName("B256"));

        tx.initialize("test_t.zid", true, &config);
        // At this point the Hello hash is available. See ZRTP specification
        // chapter 9.1 for further information when an how to use the Hello
        // hash.
        int numSupportedVersion = tx.getNumberSupportedVersions();
        cout << "TX Hello hash 0: " << tx.getHelloHash(0) << endl;
        cout << "TX Hello hash 0 length: " << tx.getHelloHash(0).length() << endl;
        if (numSupportedVersion > 1) {
            cout << "TX Hello hash 1: " << tx.getHelloHash(1) << endl;
            cout << "TX Hello hash 1 length: " << tx.getHelloHash(1).length() << endl;
        }
        tx.setUserCallback(new MyUserCallback(&tx));

        tx.setSchedulingTimeout(10000);
        tx.setExpireTimeout(1000000);

        tx.startRunning();

        tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));

        if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
            return 1;
        }
        tx.startZrtp();

        // 2 packets per second (packet duration of 500ms)
        uint32 period = 500;
        uint16 inc = tx.getCurrentRTPClockRate()/2;
        TimerPort::setTimer(period);
        uint32 i;
        for (i = 0; i < pattern.getPacketsNumber(); i++ ) {
            tx.putData(i*inc,
                       pattern.getPacketData(i),
                       pattern.getPacketSize(i));
            cout << "Sent some data: " << i << endl;
            Thread::sleep(TimerPort::getTimer());
            TimerPort::incTimer(period);
        }
        tx.putData(i*inc, (unsigned char*)"exit", 5);
        Thread::sleep(TimerPort::getTimer());
        return 0;
    }
Beispiel #4
0
    int doTest() {
        // should be valid?
        //RTPSession tx();
        ExtZrtpSession tx(pattern.getSsrc(), pattern.getSenderAddress(), pattern.getSenderPort());
//        SymmetricZRTPSession tx(pattern.getSsrc(), InetHostAddress("localhost"));
        tx.setSchedulingTimeout(10000);
        tx.setExpireTimeout(1000000);

        tx.startRunning();

        tx.setPayloadFormat(StaticPayloadFormat(sptPCMU));

        // We are sender:
        if (!tx.addDestination(pattern.getReceiverAddress(), pattern.getReceiverPort()) ) {
            return 1;
        }

        // 2 packets per second (packet duration of 500ms)
        uint32 period = 500;
        uint16 inc = tx.getCurrentRTPClockRate()/2;
        TimerPort::setTimer(period);
        uint32 i;
        for (i = 0; i < pattern.getPacketsNumber(); i++ ) {
            tx.putData(i*inc,
                       pattern.getPacketData(i),
                       pattern.getPacketSize(i));
            cout << "Sent some data: " << i << endl;
            Thread::sleep(TimerPort::getTimer());
            TimerPort::incTimer(period);
        }
        tx.putData(i*inc, (unsigned char*)"exit", 5);
        Thread::sleep(TimerPort::getTimer());
        return 0;
    }
Beispiel #5
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;
    }