Sender initializes timestamps with a random value. RTCP socket can be disabled.

git-svn-id: http://yate.null.ro/svn/yate/trunk@1028 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2006-09-13 18:50:04 +00:00
parent e1527c0177
commit 2b90733b21
3 changed files with 24 additions and 9 deletions

View File

@ -256,6 +256,13 @@ void RTPReceiver::timerTick(const Time& when)
{
}
RTPSender::RTPSender(RTPSession* session, bool randomTs)
: RTPBaseIO(session), m_evTime(0), m_tsLast(0)
{
if (randomTs)
m_ts = ::random() & ~1;
}
bool RTPSender::rtpSend(bool marker, int payload, unsigned int timestamp, const void* data, int len)
{

View File

@ -241,17 +241,23 @@ void RTPTransport::setMonitor(RTPProcessor* monitor)
m_monitor = monitor;
}
bool RTPTransport::localAddr(SocketAddr& addr)
bool RTPTransport::localAddr(SocketAddr& addr, bool rtcp)
{
// check if sockets are already created and bound
if (m_rtpSock.valid())
return false;
int p = addr.port();
// make sure we don't have a port or it's an even one
if ((p & 1))
// for RTCP make sure we don't have a port or it's an even one
if (rtcp && (p & 1))
return false;
if (m_rtpSock.create(addr.family(),SOCK_DGRAM) && m_rtpSock.bind(addr)) {
m_rtpSock.setBlocking(false);
if (!rtcp) {
// RTCP not requested - we are done
m_rtpSock.getSockName(addr);
m_localAddr = addr;
return true;
}
if (!p) {
m_rtpSock.getSockName(addr);
p = addr.port();

View File

@ -218,9 +218,10 @@ public:
/**
* Set the local network address of the RTP transport
* @param addr New local RTP transport address
* @param rtcp Enable RTCP transport
* @return True if address set, false if a failure occured
*/
bool localAddr(SocketAddr& addr);
bool localAddr(SocketAddr& addr, bool rtcp = true);
/**
* Set the remote network address of the RTP transport
@ -541,10 +542,10 @@ class YRTP_API RTPSender : public RTPBaseIO
public:
/**
* Constructor
* @param session RTP session the sender belongs
* @param randomTs Initialize a random timestamp offset
*/
inline RTPSender(RTPSession* session = 0)
: RTPBaseIO(session), m_evTime(0), m_tsLast(0)
{ }
RTPSender(RTPSession* session = 0, bool randomTs = true);
/**
* Do-nothing destructor
@ -873,10 +874,11 @@ public:
/**
* Set the local network address of the RTP transport of this session
* @param addr New local RTP transport address
* @param rtpc Enable RTCP in this session
* @return True if address set, false if a failure occured
*/
inline bool localAddr(SocketAddr& addr)
{ return m_transport && m_transport->localAddr(addr); }
inline bool localAddr(SocketAddr& addr, bool rtcp = true)
{ return m_transport && m_transport->localAddr(addr,rtcp); }
/**
* Set the remote network address of the RTP transport of this session