- ongoing work to ease jitter & RTT calculation
This commit is contained in:
parent
d90940c907
commit
0607bd1c47
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright(C) 2007-2016 VoIP objects (voipobjects.com)
|
||||
/* Copyright(C) 2007-2023 VoIP objects (voipobjects.com)
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
|
|
|||
|
|
@ -22,9 +22,9 @@
|
|||
|
||||
using namespace MT;
|
||||
AudioStream::AudioStream(const CodecList::Settings& settings)
|
||||
:mPacketTime(0), mEncodedTime(0), mCodecSettings(settings),
|
||||
mRemoteTelephoneCodec(0), mRtpSession(), mTransmittingPayloadType(-1),
|
||||
mRtpSender(mStat)
|
||||
:mPacketTime(0), mEncodedTime(0), mCodecSettings(settings),
|
||||
mRemoteTelephoneCodec(0), mRtpSession(), mTransmittingPayloadType(-1),
|
||||
mRtpSender(mStat)
|
||||
{
|
||||
mOutputBuffer.setCapacity(16384);
|
||||
mCapturedAudio.setCapacity(16384);
|
||||
|
|
@ -296,9 +296,9 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
|
|||
assert(info);
|
||||
|
||||
// Drop RTP packets if stream is not receiving now; let RTCP go
|
||||
if (!(state() & (int)StreamState::Receiving) && RtpHelper::isRtp(buffer, length))
|
||||
if (!(state() & (int)StreamState::Receiving) && RtpHelper::isRtpOrRtcp(buffer, length))
|
||||
{
|
||||
ICELogMedia(<< "Stream is not allowed to receive RTP stream. Ignore the packet");
|
||||
ICELogMedia(<< "Stream is not allowed to receive RTP stream. Ignore the RT(C)P packet");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -320,8 +320,6 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
|
|||
}
|
||||
}
|
||||
|
||||
//ICELogDebug(<< "Packet no: " << RtpHelper::findPacketNo(mReceiveBuffer, receiveLength));
|
||||
|
||||
switch (source.family())
|
||||
{
|
||||
case AF_INET:
|
||||
|
|
@ -360,6 +358,7 @@ void AudioStream::dataArrived(PDatagramSocket s, const void* buffer, int length,
|
|||
if (packet)
|
||||
{
|
||||
ICELogMedia(<< "jrtplib returned packet");
|
||||
|
||||
// Find right handler for rtp stream
|
||||
SingleAudioStream* rtpStream = nullptr;
|
||||
AudioStreamMap::iterator streamIter = mStreamMap.find(packet->GetSSRC());
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@
|
|||
namespace MT
|
||||
{
|
||||
|
||||
class AudioStream: public Stream
|
||||
{
|
||||
public:
|
||||
class AudioStream: public Stream
|
||||
{
|
||||
public:
|
||||
AudioStream(const CodecList::Settings& codecSettings);
|
||||
~AudioStream();
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ namespace MT
|
|||
|
||||
void setFinalStatisticsOutput(Statistics* stats);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
Audio::DataWindow mCapturedAudio; // Data from microphone
|
||||
Audio::DataWindow mStereoCapturedAudio;
|
||||
char mIncomingPcmBuffer[AUDIO_MIC_BUFFER_SIZE]; // Temporary buffer to allow reading from file
|
||||
|
|
@ -106,7 +106,7 @@ namespace MT
|
|||
Statistics* mFinalStatistics = nullptr;
|
||||
|
||||
bool decryptSrtp(void* data, int* len);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ PStream Terminal::createStream(int type, VariantMap& /*config*/)
|
|||
switch (type)
|
||||
{
|
||||
case Stream::Audio:
|
||||
result = PStream(new AudioStream(MT::CodecList::Settings::DefaultSettings));
|
||||
result = std::make_shared<AudioStream>(MT::CodecList::Settings::DefaultSettings);
|
||||
mAudioList.add(result);
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ RTCPScheduler::~RTCPScheduler()
|
|||
|
||||
void RTCPScheduler::Reset()
|
||||
{
|
||||
pmembers = 0;
|
||||
headeroverhead = 0; // user has to set this to an appropriate value
|
||||
hassentrtcp = false;
|
||||
firstcall = true;
|
||||
|
|
|
|||
|
|
@ -900,9 +900,26 @@ void RTPExternalTransmitter::InjectRTPorRTCP(const void *data, size_t len, const
|
|||
AbortWaitInternal();
|
||||
|
||||
MAINMUTEX_UNLOCK
|
||||
|
||||
}
|
||||
|
||||
void RTPExternalTransmitter::InjectRaw(RTPRawPacket* packet)
|
||||
{
|
||||
if (!init)
|
||||
return;
|
||||
|
||||
MAINMUTEX_LOCK
|
||||
if (!created)
|
||||
{
|
||||
MAINMUTEX_UNLOCK
|
||||
return;
|
||||
}
|
||||
rawpacketlist.push_back(packet);
|
||||
AbortWaitInternal();
|
||||
|
||||
MAINMUTEX_UNLOCK
|
||||
}
|
||||
|
||||
|
||||
#ifdef RTPDEBUG
|
||||
void RTPExternalTransmitter::Dump()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -96,6 +96,8 @@ public:
|
|||
|
||||
/** Use this function to inject an RTP or RTCP packet and the transmitter will try to figure out which type of packet it is. */
|
||||
void InjectRTPorRTCP(const void *data, size_t len, const RTPAddress &a);
|
||||
|
||||
void InjectRaw(RTPRawPacket* packet);
|
||||
private:
|
||||
RTPExternalTransmitter *transmitter;
|
||||
};
|
||||
|
|
@ -186,6 +188,8 @@ public:
|
|||
void InjectRTP(const void *data, size_t len, const RTPAddress &a);
|
||||
void InjectRTCP(const void *data, size_t len, const RTPAddress &a);
|
||||
void InjectRTPorRTCP(const void *data, size_t len, const RTPAddress &a);
|
||||
void InjectRaw(RTPRawPacket* packet);
|
||||
|
||||
private:
|
||||
void FlushPackets();
|
||||
|
||||
|
|
@ -233,6 +237,11 @@ inline void RTPExternalPacketInjecter::InjectRTPorRTCP(const void *data, size_t
|
|||
transmitter->InjectRTPorRTCP(data, len, a);
|
||||
}
|
||||
|
||||
inline void RTPExternalPacketInjecter::InjectRaw(RTPRawPacket* packet)
|
||||
{
|
||||
transmitter->InjectRaw(packet);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // RTPTCPSOCKETTRANSMITTER_H
|
||||
|
|
|
|||
|
|
@ -1444,8 +1444,8 @@ int RTPSession::ProcessPolledData()
|
|||
RTPTime colltimeout = RTPTime(Td*collisionmultiplier);
|
||||
RTPTime notetimeout = RTPTime(Td*notemultiplier);
|
||||
|
||||
sources.MultipleTimeouts(t,sendertimeout,byetimeout,generaltimeout,notetimeout);
|
||||
collisionlist.Timeout(t,colltimeout);
|
||||
// sources.MultipleTimeouts(t,sendertimeout,byetimeout,generaltimeout,notetimeout);
|
||||
// collisionlist.Timeout(t,colltimeout);
|
||||
|
||||
// We'll check if it's time for RTCP stuff
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@
|
|||
#include <jthread/jmutex.h>
|
||||
#endif // RTP_SUPPORT_THREAD
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace jrtplib
|
||||
{
|
||||
|
||||
|
|
@ -474,7 +476,11 @@ protected:
|
|||
const uint8_t *cname,size_t cnamelength) { }
|
||||
|
||||
/** Is called when a new entry \c srcdat is added to the source table. */
|
||||
virtual void OnNewSource(RTPSourceData *srcdat) { }
|
||||
virtual void OnNewSource(RTPSourceData *srcdat)
|
||||
{
|
||||
// Sync timestamp unit
|
||||
srcdat->SetTimestampUnit(timestampunit);
|
||||
}
|
||||
|
||||
/** Is called when the entry \c srcdat is about to be deleted from the source table. */
|
||||
virtual void OnRemoveSource(RTPSourceData *srcdat) { }
|
||||
|
|
|
|||
|
|
@ -35,12 +35,12 @@
|
|||
#include "rtpaddress.h"
|
||||
#include "rtpmemorymanager.h"
|
||||
#if ! (defined(WIN32) || defined(_WIN32_WCE))
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in.h>
|
||||
#endif // WIN32
|
||||
|
||||
#ifdef RTPDEBUG
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#endif // RTPDEBUG
|
||||
|
||||
#include "rtpdebug.h"
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
numnewpackets++; \
|
||||
\
|
||||
if (pack->GetExtendedSequenceNumber() == 0) \
|
||||
{ \
|
||||
{ \
|
||||
baseseqnr = 0x0000FFFF; \
|
||||
numcycles = 0x00010000; \
|
||||
} \
|
||||
|
|
@ -76,7 +76,7 @@ namespace jrtplib
|
|||
{
|
||||
|
||||
void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,double tsunit,
|
||||
bool ownpacket,bool *accept,bool applyprobation,bool *onprobation)
|
||||
bool ownpacket, bool *accept, bool applyprobation, bool *onprobation)
|
||||
{
|
||||
// Note that the sequence number in the RTP packet is still just the
|
||||
// 16 bit number contained in the RTP header
|
||||
|
|
@ -139,7 +139,7 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
|
|||
|
||||
ACCEPTPACKETCODE
|
||||
|
||||
#endif // RTP_SUPPORT_PROBATION
|
||||
#endif // RTP_SUPPORT_PROBATION
|
||||
}
|
||||
else // already got packets
|
||||
{
|
||||
|
|
@ -197,15 +197,15 @@ void RTPSourceStats::ProcessPacket(RTPPacket *pack,const RTPTime &receivetime,do
|
|||
djitter += diff;
|
||||
jitter = (uint32_t)djitter;
|
||||
#else
|
||||
RTPTime curtime = receivetime;
|
||||
double diffts1,diffts2,diff;
|
||||
uint32_t curts = pack->GetTimestamp();
|
||||
RTPTime curtime = receivetime;
|
||||
double diffts1,diffts2,diff;
|
||||
uint32_t curts = pack->GetTimestamp();
|
||||
|
||||
curtime -= prevpacktime;
|
||||
diffts1 = curtime.GetDouble()/tsunit;
|
||||
curtime -= prevpacktime;
|
||||
diffts1 = curtime.GetDouble() / tsunit;
|
||||
|
||||
if (curts > prevtimestamp)
|
||||
{
|
||||
if (curts > prevtimestamp)
|
||||
{
|
||||
uint32_t unsigneddiff = curts - prevtimestamp;
|
||||
|
||||
if (unsigneddiff < 0x10000000) // okay, curts realy is larger than prevtimestamp
|
||||
|
|
@ -217,9 +217,9 @@ if (curts > prevtimestamp)
|
|||
unsigneddiff = -unsigneddiff; // to get the actual difference (in absolute value)
|
||||
diffts2 = -((double)unsigneddiff);
|
||||
}
|
||||
}
|
||||
else if (curts < prevtimestamp)
|
||||
{
|
||||
}
|
||||
else if (curts < prevtimestamp)
|
||||
{
|
||||
uint32_t unsigneddiff = prevtimestamp - curts;
|
||||
|
||||
if (unsigneddiff < 0x10000000) // okay, curts really is smaller than prevtimestamp
|
||||
|
|
@ -231,17 +231,17 @@ else if (curts < prevtimestamp)
|
|||
unsigneddiff = -unsigneddiff; // to get the actual difference (in absolute value)
|
||||
diffts2 = (double)unsigneddiff;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
diffts2 = 0;
|
||||
|
||||
diff = diffts1 - diffts2;
|
||||
if (diff < 0)
|
||||
diff = diffts1 - diffts2;
|
||||
if (diff < 0)
|
||||
diff = -diff;
|
||||
diff -= djitter;
|
||||
diff /= 16.0;
|
||||
djitter += diff;
|
||||
jitter = (uint32_t)djitter;
|
||||
diff -= djitter;
|
||||
diff /= 16.0;
|
||||
djitter += diff;
|
||||
jitter = (uint32_t)djitter;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -809,6 +809,8 @@ int RTPSources::ObtainSourceDataInstance(uint32_t ssrc,RTPInternalSourceData **s
|
|||
#endif // RTP_SUPPORT_PROBATION
|
||||
if (srcdat2 == 0)
|
||||
return ERR_RTP_OUTOFMEM;
|
||||
|
||||
// Add new source item
|
||||
if ((status = sourcelist.AddElement(ssrc,srcdat2)) < 0)
|
||||
{
|
||||
RTPDelete(srcdat2,GetMemoryManager());
|
||||
|
|
|
|||
Loading…
Reference in New Issue