- ongoing work to ease jitter & RTT calculation

This commit is contained in:
Dmytro Bogovych 2023-04-11 13:43:38 +03:00
parent d90940c907
commit 0607bd1c47
14 changed files with 1071 additions and 1037 deletions

View File

@ -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/. */

View File

@ -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());

View File

@ -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;

View File

@ -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;

View File

@ -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()
{

View File

@ -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

View File

@ -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

View File

@ -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) { }

View File

@ -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());