// RTPAudioStream.h: interface for the RTPAudioStream class.
|
//
|
//////////////////////////////////////////////////////////////////////
|
|
#ifndef AFX_RTPAUDIOSTREAM_H__1CB0DE48_EADE_4C23_9C56_C8ECDE1A90AD__INCLUDED_
|
#define AFX_RTPAUDIOSTREAM_H__1CB0DE48_EADE_4C23_9C56_C8ECDE1A90AD__INCLUDED_
|
|
#include <queue>
|
#include <functional>
|
#include "AudioSample.h"
|
#include "../../Tracer/Tracer.h"
|
|
|
class RTPCompareLess
|
{
|
public:
|
bool operator() (AudioSample *sample1, AudioSample *sample2)
|
{
|
return *sample1 < *sample2;
|
}
|
};
|
|
class RTPCompareGreater
|
{
|
public:
|
bool operator() (AudioSample *sample1, AudioSample *sample2)
|
{
|
return *sample1 >= *sample2;
|
}
|
};
|
|
class RTPAudioStream : public TraceUser
|
{
|
public:
|
RTPAudioStream(unsigned long ssrc);
|
virtual ~RTPAudioStream();
|
int SetRestartThreshold(int depthInMillisec);
|
int InsertRTPPacket(AudioSample *audioSample);
|
int GiveNextRTPPacket(AudioSample **pOutSample);
|
int NumQueuedPackets();
|
int JitterBufferDepth(); // Current depth of the jitter buffer in milliseconds
|
unsigned long SSRC();
|
protected:
|
int SetTraceLevel();
|
private:
|
int SetLastTransmittedPacket(AudioSample *);
|
int TimeDifference(unsigned long timestamp1, unsigned long timestamp2);
|
int TimeDifference(AudioSample *, AudioSample *);
|
int TimeDifferenceMillisec(AudioSample *, AudioSample *);
|
int Clear();
|
int AddPacket(AudioSample *);
|
int PopNextPacket(AudioSample **pAudioSample);
|
int PopNextPacketForTransmit(AudioSample **pOutSample);
|
private:
|
// typedef std::priority_queue<AudioSample *, std::vector<AudioSample * >, std::greater_equal<AudioSample *> > PACKET_QUEUE;
|
typedef std::priority_queue<AudioSample *, std::vector<AudioSample * >, RTPCompareGreater > PACKET_QUEUE;
|
PACKET_QUEUE packetQueue; // protected by packetQueueMutex
|
unsigned long ssrc;
|
int jitterBufferDepth; // protected by packetQueueMutex
|
int restartThreshold;
|
unsigned long lastOutputTimestamp;
|
unsigned long lastOutputDuration;
|
AudioSample *lastPacketTransmitted;
|
int lastPacketRepeatCount;
|
int numSIDPackets;
|
bool silenceIntervalInProgress;
|
bool dynamicJitterBuffer;
|
CRITICAL_SECTION packetQueueMutex;
|
CRITICAL_SECTION audioStreamMutex;
|
};
|
|
#endif // !defined(AFX_RTPAUDIOSTREAM_H__1CB0DE48_EADE_4C23_9C56_C8ECDE1A90AD__INCLUDED_)
|