rtpaudiostream.h

来自「rtp在linux下的实现」· C头文件 代码 · 共 78 行

H
78
字号
// 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"

#ifndef WIN32
#include "linTypes.h"
#else
#include "../../Tracer/Tracer.h"
#endif


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:
	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();
	int SetTracer(Tracer *tracer);
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;
	unsigned long ssrc;
	int jitterBufferDepth;
	int restartThreshold;
	unsigned long lastOutputTimestamp;
	unsigned long lastOutputDuration;
	AudioSample *lastPacketTransmitted;
	int lastPacketRepeatCount;
	int numSIDPackets;
	bool silenceIntervalInProgress;
	bool dynamicJitterBuffer;
	Tracer *tracer;
	CRITICAL_SECTION packetQueueMutex;
	CRITICAL_SECTION audioStreamMutex;
};

#endif // !defined(AFX_RTPAUDIOSTREAM_H__1CB0DE48_EADE_4C23_9C56_C8ECDE1A90AD__INCLUDED_)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?