#include <cstdio>
#include <ctime>
#ifdef CCXX_NAMESPACES
using namespace ost;
using namespace std;
#endif
const int RECEIVER_BASE = 33634;
const int TRANSMITTER_BASE = 32522;
class ccRTP_Hello_Rx: public Thread
{
private:
InetHostAddress local_ip;
uint32 ssrc;
public:
ccRTP_Hello_Rx(){
local_ip = "127.0.0.1";
if( ! local_ip ){
cerr << "Rx: IP address is not correct!" << endl;
exit();
}
}
~ccRTP_Hello_Rx(){
cout << endl << "Destroying receiver -ID: " << hex
<< (int)ssrc;
terminate();
delete socket;
cout << "... " << "destroyed.";
}
void run(void){
<< " ..." << endl;
cerr << "Rx (" << hex << (int)ssrc
<< "): could not connect to port."
<< TRANSMITTER_BASE;
cout << "Rx (" << hex << (int)ssrc
<< "): " << local_ip.getHostname()
<< " is waiting for salutes in port "
<< RECEIVER_BASE << "..." << endl;
cout << "Rx (" << hex << (int)ssrc
<< "): The queue is "
<< "active." << endl;
for( int i = 0 ; true ; i++ ){
while ( NULL == adu ) {
Thread::sleep(10);
}
time_t receiving_time = time(NULL);
char tmstring[30];
strftime(tmstring,30,"%X",localtime(&receiving_time));
cout << "Rx (" << hex << (int)ssrc
<< "): [receiving at " << tmstring << "]: "
delete adu;
}
}
};
class ccRTP_Hello_Tx: public Thread, public TimerPort
{
private:
InetHostAddress local_ip;
uint32 ssrc;
public:
ccRTP_Hello_Tx(){
local_ip = "127.0.0.1";
if( ! local_ip ){
cerr << "Tx: IP address is not correct!" << endl;
exit();
}
socket =
new RTPSession(local_ip,TRANSMITTER_BASE);
}
~ccRTP_Hello_Tx(){
cout << endl << "Destroying transmitter -ID: " << hex
<< (int)ssrc;
terminate();
delete socket;
cout << "... " << "destroyed.";
}
void run(void){
cout << "Tx (" << hex << (int)ssrc << "): " <<
local_ip.getHostname()
<< " is going to salute perself through "
<< local_ip << "..." << endl;
cerr << "Tx (" << hex << (int)ssrc
<< "): could not connect to port."
<< RECEIVER_BASE;
cout << "Tx (" << hex << (int)ssrc <<
"): Transmitting salutes to port "
<< RECEIVER_BASE << "..." << endl;
uint32 timestamp = 0;
TimerPort::setTimer(1000);
cout << "Tx (" << hex << (int)ssrc << "): The queue is "
<< "active." << endl;
for( int i = 0 ; true ;i++ ){
unsigned char salute[50];
snprintf((char *)salute,50,
"Hello, brave gnu world (#%u)!",i);
time_t sending_time = time(NULL);
if ( 0 == i ){
} else {
}
strlen((char *)salute)+1);
char tmstring[30];
strftime(tmstring,30,"%X",
localtime(&sending_time));
cout << "Tx (" << hex << (int)ssrc
<< "): sending salute " << "no " << dec << i
<< ", at " << tmstring
<< "..." << endl;
Thread::sleep(TimerPort::getTimer());
TimerPort::incTimer(1000);
}
}
};
int main(int argc, char *argv[])
{
ccRTP_Hello_Rx *receiver = new ccRTP_Hello_Rx;
ccRTP_Hello_Tx *transmitter = new ccRTP_Hello_Tx;
cout << "This is rtphello, a very simple test program for ccRTP." <<
endl << "Strike [Enter] when you are fed up with it." << endl;
receiver->start();
transmitter->start();
cin.get();
delete transmitter;
delete receiver;
cout << endl << "That's all." << endl;
return 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
bool addDestination(const InetHostAddress &ia, tpport_t dataPort=DefaultRTPDataPort, tpport_t controlPort=0)
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
uint32 getCurrentTimestamp() const
Get the timestamp that should be given for a packet whose payload sampling instant corresponds to the...
bool isActive() const
Get active connection state flag.
Definition: ioqueue.h:138
uint32 getLocalSSRC() const
Definition: queuebase.h:184
bool setPayloadFormat(const PayloadFormat &pf)
Set the payload format in use, for timing and payload type identification purposes.
Definition: queuebase.h:177
uint32 getCurrentRTPClockRate() const
Get the clock rate in RTP clock units (for instance, 8000 units per second for PCMU,...
Definition: queuebase.h:195
This template class adds the threading aspect to the RTPSessionBase template in one of the many possi...
Definition: rtp.h:421
void startRunning()
Activate stack and start service thread.
Definition: rtp.h:508
@ sptMP2T
MPEG 2 Transport stream (RFCs 1890, 2250)
Definition: formats.h:108
@ SDESItemTypeCNAME
Canonical end-point identifier.
Definition: rtcppkt.h:67
SingleThreadRTPSession RTPSession
Uses two pairs of sockets for RTP data and RTCP transmission/reception.
Definition: rtp.h:601
__EXPORT RTPApplication & defaultApplication()
Get the RTPApplication object for the "default" application (the only one used by common applications...
Generic and audio/video profile specific RTP interface of ccRTP.