Split out jitter timer to be one per metadata, clear out jitter data when clearing as well
This commit is contained in:
parent
7d55a3f1c4
commit
0ec2800894
2 changed files with 71 additions and 66 deletions
17
lib/dtsc.cpp
17
lib/dtsc.cpp
|
@ -2278,16 +2278,7 @@ namespace DTSC{
|
|||
pack.getFlag("keyframe"), pack.getDataLen());
|
||||
}
|
||||
|
||||
/// Helper class that calculates inter-packet jitter
|
||||
class jitterTimer{
|
||||
public:
|
||||
uint64_t trueTime[8]; // Array of bootMS-based measurement points
|
||||
uint64_t packTime[8]; // Array of corresponding packet times
|
||||
uint64_t curJitter; // Maximum jitter measurement in past 10 seconds
|
||||
unsigned int x; // Current indice within above two arrays
|
||||
uint64_t maxJitter; // Highest jitter ever observed by this jitterTimer
|
||||
uint64_t lastTime; // Last packet used for a measurement point
|
||||
jitterTimer(){
|
||||
jitterTimer::jitterTimer(){
|
||||
for (int i = 0; i < 8; ++i){
|
||||
trueTime[i] = 0;
|
||||
packTime[i] = 0;
|
||||
|
@ -2296,7 +2287,8 @@ namespace DTSC{
|
|||
lastTime = 0;
|
||||
x = 0;
|
||||
}
|
||||
uint64_t addPack(uint64_t t){
|
||||
|
||||
uint64_t jitterTimer::addPack(uint64_t t){
|
||||
if (veryUglyJitterOverride){return veryUglyJitterOverride;}
|
||||
uint64_t curMs = Util::bootMS();
|
||||
if (!x){
|
||||
|
@ -2348,14 +2340,12 @@ namespace DTSC{
|
|||
}
|
||||
return maxJitter;
|
||||
}
|
||||
};
|
||||
|
||||
/// Updates the metadata given the packet's properties.
|
||||
void Meta::update(uint64_t packTime, int64_t packOffset, uint32_t packTrack, uint64_t packDataSize,
|
||||
uint64_t packBytePos, bool isKeyframe, uint64_t packSendSize){
|
||||
///\todo warning Re-Implement Ivec
|
||||
if (getLive()){
|
||||
static std::map<size_t, jitterTimer> theJitters;
|
||||
setMinKeepAway(packTrack, theJitters[packTrack].addPack(packTime));
|
||||
}
|
||||
|
||||
|
@ -2548,6 +2538,7 @@ namespace DTSC{
|
|||
/// Wipes internal structures, also marking as outdated and deleting memory structures if in
|
||||
/// master mode.
|
||||
void Meta::clear(){
|
||||
theJitters.clear();
|
||||
if (isMemBuf){
|
||||
isMemBuf = false;
|
||||
free(streamMemBuf);
|
||||
|
|
14
lib/dtsc.h
14
lib/dtsc.h
|
@ -268,6 +268,19 @@ namespace DTSC{
|
|||
Util::RelAccXFieldData fragmentSizeField;
|
||||
};
|
||||
|
||||
|
||||
class jitterTimer{
|
||||
public:
|
||||
uint64_t trueTime[8]; // Array of bootMS-based measurement points
|
||||
uint64_t packTime[8]; // Array of corresponding packet times
|
||||
uint64_t curJitter; // Maximum jitter measurement in past 10 seconds
|
||||
unsigned int x; // Current indice within above two arrays
|
||||
uint64_t maxJitter; // Highest jitter ever observed by this jitterTimer
|
||||
uint64_t lastTime; // Last packet used for a measurement point
|
||||
jitterTimer();
|
||||
uint64_t addPack(uint64_t t);
|
||||
};
|
||||
|
||||
class Meta{
|
||||
public:
|
||||
Meta(const std::string &_streamName, const DTSC::Scan &src);
|
||||
|
@ -499,6 +512,7 @@ namespace DTSC{
|
|||
std::map<size_t, size_t> sizeMemBuf;
|
||||
|
||||
private:
|
||||
std::map<size_t, jitterTimer> theJitters;
|
||||
// Internal buffers so we don't always need to search for everything
|
||||
Util::RelAccXFieldData streamVodField;
|
||||
Util::RelAccXFieldData streamLiveField;
|
||||
|
|
Loading…
Add table
Reference in a new issue