ccrtp-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ccrtp-devel] problems with multicast


From: Amos Tibaldi
Subject: [Ccrtp-devel] problems with multicast
Date: Sat, 27 Mar 2010 21:36:39 +0100

Hello,

I am trying to send and receive multicast packet over rtp;
I have configured 2 PCs connected with ethernet and have issued the command "ip r add 224.0.0.0/4 dev eth0" on both the PCs.
The sender program sends correctly the packets (I can see them with wireshark on the receiver machine), but the receiver program cannot receive them.
What could be the problem? I attach the code....
Thanks in advance...
------------------------rtpsender.cpp
#include <cstdio>
#include <ctime>
#include <ccrtp/rtp.h>

using namespace ost;
using namespace std;

class ccRTPImageSender: public Thread
{
private:
    static const int RECEIVER_PORT = 1235;
    static const int TRANSMITTER_PORT = 46016;
    RTPSession *socket;
    InetMcastAddress local_ip;
    uint32 ssrc;
public:
    ccRTPImageSender(){
        local_ip = "224.0.0.1";
        socket = new RTPSession(local_ip, TRANSMITTER_PORT);
        ssrc = socket->getLocalSSRC();
    }
    ~ccRTPImageSender(){
        terminate();
        delete socket;
    }
    void run(void){   
        socket->setSchedulingTimeout(20000);
        socket->setExpireTimeout(3000000);
        socket->addDestination(local_ip, RECEIVER_PORT);
        uint32 timestamp = 0;
        socket->setPayloadFormat(StaticPayloadFormat(sptMP2T));
        socket->startRunning();
        for( int i = 0 ; true ;i++ ){
cout << "sending" <<endl;
            unsigned char salute[50];
            snprintf((char *)salute,50, "Hello, brave gnu world (#%u)!",i);
            time_t sending_time = time(NULL);
            if ( 0 == i ){
                timestamp = socket->getCurrentTimestamp();
            } else {
                timestamp += socket->getCurrentRTPClockRate();
            }   

            socket->putData(timestamp,salute,
                    strlen((char *)salute)+1);
            Thread::sleep(1000);
        }
    }
};

int main(int argc, char *argv[])
{
    ccRTPImageSender *transmitter = new ccRTPImageSender;
    transmitter->start();
    cin.get();
    delete transmitter;
    return 0;
}

-----------------------rtpreceiver.cpp
#include <cstdio>
#include <ctime>
#include <stdlib.h>
#include <ccrtp/rtp.h>

using namespace ost;
using namespace std;


class ccRTPImageReceiver
{
private:
    static const int RECEIVER_PORT = 1235;
    static const int TRANSMITTER_PORT = 46016;
    RTPSession *socket;
    InetMcastAddress local_ip;
    uint32 ssrc;
public:
    ccRTPImageReceiver(){
        local_ip = "224.0.0.1";
        socket = new RTPSession(local_ip, RECEIVER_PORT);
        ssrc = socket->getLocalSSRC();
        socket->setSchedulingTimeout(20000);
        socket->setExpireTimeout(3000000);

InetHostAddress vaio = "10.10.10.11";
        socket->addDestination(vaio, TRANSMITTER_PORT);
        socket->setPayloadFormat(StaticPayloadFormat(sptMP2T));
        socket->startRunning();
    }
    ~ccRTPImageReceiver(){
        terminate();
        delete socket;
    }
    void * getData(){   
        const AppDataUnit *adu = NULL;
        while ( NULL == adu ) {
            Thread::sleep(10);
            adu = socket->getData(socket->getFirstTimestamp());
        }
        char * buffer = (char *) malloc(3000);
        strcpy((char*)buffer, (const char*)adu->getData());
        delete adu;
        return (void*) buffer;
    }
    void deleteData(void * data)
    {
        free(data);
    }
};

int main(int argc, char *argv[])
{
    ccRTPImageReceiver receiver;
    for(; true; )
    {
        void * theData = receiver.getData();
        printf("Rec: %s\n", (char*) theData);
        receiver.deleteData(theData);
    }
    cin.get();
    return 0;
}



Oltre 20 giochi per Messenger. Provali subito!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]