/usr/include/libtgvoip/JitterBuffer.h is in libtgvoip-dev 1.0.3-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | //
// libtgvoip is free and unencumbered public domain software.
// For more information, see http://unlicense.org or the UNLICENSE file
// you should have received with this source code distribution.
//
#ifndef LIBTGVOIP_JITTERBUFFER_H
#define LIBTGVOIP_JITTERBUFFER_H
#include <stdlib.h>
#include <vector>
#include <stdio.h>
#include "MediaStreamItf.h"
#include "BlockingQueue.h"
#include "BufferPool.h"
#include "threading.h"
#define JITTER_SLOT_COUNT 64
#define JITTER_SLOT_SIZE 1024
#define JR_OK 1
#define JR_MISSING 2
#define JR_BUFFERING 3
struct jitter_packet_t{
unsigned char* buffer;
size_t size;
uint32_t timestamp;
double recvTimeDiff;
};
typedef struct jitter_packet_t jitter_packet_t;
namespace tgvoip{
class JitterBuffer{
public:
JitterBuffer(MediaStreamItf* out, uint32_t step);
~JitterBuffer();
void SetMinPacketCount(uint32_t count);
int GetMinPacketCount();
int GetCurrentDelay();
double GetAverageDelay();
void Reset();
void HandleInput(unsigned char* data, size_t len, uint32_t timestamp);
size_t HandleOutput(unsigned char* buffer, size_t len, int offsetInSteps, int* playbackScaledDuration);
void Tick();
void GetAverageLateCount(double* out);
int GetAndResetLostPacketCount();
double GetLastMeasuredJitter();
double GetLastMeasuredDelay();
private:
static size_t CallbackIn(unsigned char* data, size_t len, void* param);
static size_t CallbackOut(unsigned char* data, size_t len, void* param);
void PutInternal(jitter_packet_t* pkt);
int GetInternal(jitter_packet_t* pkt, int offset);
void Advance();
BufferPool bufferPool;
tgvoip_mutex_t mutex;
jitter_packet_t slots[JITTER_SLOT_COUNT];
int64_t nextTimestamp;
uint32_t step;
uint32_t minDelay;
uint32_t minMinDelay;
uint32_t maxMinDelay;
uint32_t maxUsedSlots;
uint32_t lastPutTimestamp;
uint32_t lossesToReset;
double resyncThreshold;
int lostCount;
int lostSinceReset;
int gotSinceReset;
bool wasReset;
bool needBuffering;
int delayHistory[64];
int lateHistory[64];
bool adjustingDelay;
unsigned int tickCount;
unsigned int latePacketCount;
unsigned int dontIncMinDelay;
unsigned int dontDecMinDelay;
int lostPackets;
double prevRecvTime;
double expectNextAtTime;
double deviationHistory[64];
int deviationPtr;
double lastMeasuredJitter;
double lastMeasuredDelay;
int outstandingDelayChange;
unsigned int dontChangeDelay;
double avgDelay;
//FILE* dump;
};
}
#endif //LIBTGVOIP_JITTERBUFFER_H
|