#include <cstdio>
#include <cstdlib>
#ifdef CCXX_NAMESPACES
using namespace ost;
using namespace std;
#endif
class ccRTP_dupHello: public Thread
{
private:
public:
~ccRTP_dupHello()
{
terminate();
delete duplexA;
delete duplexB;
}
ccRTP_dupHello() : duplexA(NULL), duplexB(NULL)
{}
void run(void)
{
InetHostAddress local_ip;
local_ip = "127.0.0.1";
if( ! local_ip ) {
cerr << ": IP address is not correct!" << endl;
exit();
}
cout << local_ip.getHostname() <<
" is going to talk to perself through " <<
local_ip << "..." << endl;
const int A_BASE = 22222;
const int B_BASE = 33334;
duplexA =
new RTPDuplex(local_ip,A_BASE,B_BASE);
duplexB =
new RTPDuplex(local_ip,B_BASE,A_BASE);
if( duplexA->
connect(local_ip,B_BASE) < 0 )
cerr << "Duplex A could not connect.";
if( duplexB->
connect(local_ip,A_BASE) < 0 )
cerr << "Duplex B could not connect.";
if( duplexA->RTPDataQueue::isActive() )
cout << "The queue A is active." << endl;
else
cerr << "The queue A is not active." << endl;
if( duplexB->RTPDataQueue::isActive() )
cout << "The queue B is active." << endl;
else
cerr << "The queue B is not active." << endl;
cout << "Transmitting..." << endl;
unsigned char helloA[] = "Hello, brave gnu world from A!";
unsigned char helloB[] = "Hello, brave gnu world from B!";
time_t sending_time;
time_t receiving_time;
char tmstring[30];
for( int i = 0 ; true ; i++ ) {
sending_time = time(NULL);
duplexA->
putData(2*(i)*90000,helloA,
strlen((char *)helloA));
strftime(tmstring,30,"%X",localtime(&sending_time));
cout << "A: sending message at " << tmstring << "..."
<< endl;
receiving_time = time(NULL);
if ( aduA ) {
strftime(tmstring,30,"%X",localtime(&receiving_time));
cout << "A:[receiving at " << tmstring << "]: " <<
}
Thread::sleep(100);
sending_time = time(NULL);
duplexB->
putData(2*(i)*90000,helloB,
strlen((char *)helloB));
strftime(tmstring,30,"%X",localtime(&sending_time));
cout << "B: sending message at " << tmstring << "..."
<< endl;
receiving_time = time(NULL);
if ( aduB ) {
strftime(tmstring,30,"%X",localtime(&receiving_time));
cout << "B:[receiving at " << tmstring << "]: " <<
}
Thread::sleep(1900);
}
}
};
int main(int argc, char *argv[])
{
ccRTP_dupHello *hello = new ccRTP_dupHello;
cout << "This is rtpduphello, a very simple test program for ccRTP."
<< endl << "Strike [Enter] when you are fed up." << endl;
hello->start();
cin.get();
cout << endl << "That's all" << endl;
delete hello;
exit(0);
}
Interface (envelope) to data received over RTP packets.
Definition: queuebase.h:69
const uint8 *const getData() const
Get data as it is received in RTP packets (i.e.
Definition: queuebase.h:105
uint32 getFirstTimestamp(const SyncSource *src=NULL) const
Get timestamp of first packet waiting in the queue.
const AppDataUnit * getData(uint32 stamp, const SyncSource *src=NULL)
Retreive data from a specific timestamped packet if such a packet is currently available in the recei...
void setSchedulingTimeout(microtimeout_t to)
Set the default scheduling timeout to use when no data packets are waiting to be sent.
Definition: oqueue.h:364
void putData(uint32 stamp, const unsigned char *data=NULL, size_t len=0)
This is used to create a data packet in the send queue.
void setExpireTimeout(microtimeout_t to)
Set the "expired" timer for expiring packets pending in the send queue which have gone unsent and are...
Definition: oqueue.h:379
A peer associated RTP socket pair for physically connected peer hosts.
Definition: ext.h:74
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition: queuebase.h:177
@ sptMP2T
MPEG 2 Transport stream (RFCs 1890, 2250)
Definition: formats.h:108
UDPTransmit::Error connect(const InetHostAddress &host, tpport_t port=0)