Add receive time to decode unit

This commit is contained in:
Cameron Gutman 2017-06-10 16:08:52 -07:00
parent 4113108f23
commit 99cfae7acc
5 changed files with 17 additions and 11 deletions

View File

@ -45,7 +45,7 @@ int performRtspHandshake(void);
void initializeVideoDepacketizer(int pktSize);
void destroyVideoDepacketizer(void);
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length);
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long long receiveTimeMs);
void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry);
void stopVideoDepacketizer(void);
void requestDecoderRefresh(void);

View File

@ -63,6 +63,11 @@ typedef struct _DECODE_UNIT {
// Frame number
int frameNumber;
// Receive time of first buffer
// NOTE: This will be populated from gettimeofday() if !HAVE_CLOCK_GETTIME and
// populated from clock_gettime(CLOCK_MONOTONIC) if HAVE_CLOCK_GETTIME
unsigned long long receiveTimeMs;
// Length of the entire buffer chain in bytes
int fullLength;

View File

@ -42,10 +42,11 @@ static int queuePacket(PRTP_FEC_QUEUE queue, PRTPFEC_QUEUE_ENTRY newEntry, int h
entry = entry->next;
}
newEntry->packet = packet;
newEntry->length = length;
newEntry->isParity = isParity;
newEntry->receiveTimeMs = PltGetMillis();
newEntry->prev = NULL;
newEntry->next = NULL;

View File

@ -6,6 +6,7 @@ typedef struct _RTPFEC_QUEUE_ENTRY {
PRTP_PACKET packet;
int length;
int isParity;
unsigned long long receiveTimeMs;
struct _RTPFEC_QUEUE_ENTRY* next;
struct _RTPFEC_QUEUE_ENTRY* prev;
@ -25,7 +26,7 @@ typedef struct _RTP_FEC_QUEUE {
int bufferDataPackets;
int receivedBufferDataPackets;
int fecPercentage;
int currentFrameNumber;
unsigned int nextRtpSequenceNumber;
} RTP_FEC_QUEUE, *PRTP_FEC_QUEUE;

View File

@ -7,20 +7,18 @@ static PLENTRY nalChainHead;
static int nalChainDataLength;
static int nextFrameNumber;
static int nextPacketNumber;
static int startFrameNumber;
static int waitingForNextSuccessfulFrame;
static int waitingForIdrFrame;
static int gotNextFrameStart;
static int lastPacketInStream;
static int decodingFrame;
static int strictIdrFrameWait;
static unsigned long long firstPacketReceiveTime;
#define CONSECUTIVE_DROP_LIMIT 120
static int consecutiveFrameDrops;
static LINKED_BLOCKING_QUEUE decodeUnitQueue;
static unsigned int nominalPacketDataLength;
typedef struct _BUFFER_DESC {
char* data;
@ -33,16 +31,14 @@ void initializeVideoDepacketizer(int pktSize) {
if ((VideoCallbacks.capabilities & CAPABILITY_DIRECT_SUBMIT) == 0) {
LbqInitializeLinkedBlockingQueue(&decodeUnitQueue, 15);
}
nominalPacketDataLength = pktSize - sizeof(NV_VIDEO_PACKET);
nextFrameNumber = 1;
nextPacketNumber = 0;
startFrameNumber = 0;
waitingForNextSuccessfulFrame = 0;
waitingForIdrFrame = 1;
gotNextFrameStart = 0;
lastPacketInStream = -1;
decodingFrame = 0;
firstPacketReceiveTime = 0;
LC_ASSERT(NegotiatedVideoFormat != 0);
strictIdrFrameWait =
@ -231,6 +227,7 @@ static void reassembleFrame(int frameNumber) {
qdu->decodeUnit.bufferList = nalChainHead;
qdu->decodeUnit.fullLength = nalChainDataLength;
qdu->decodeUnit.frameNumber = frameNumber;
qdu->decodeUnit.receiveTimeMs = firstPacketReceiveTime;
nalChainHead = NULL;
nalChainDataLength = 0;
@ -401,7 +398,7 @@ static void processRtpPayloadFast(BUFFER_DESC location) {
}
// Process an RTP Payload
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) {
void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length, unsigned long long receiveTimeMs) {
BUFFER_DESC currentPos;
int frameIndex;
char flags;
@ -450,6 +447,7 @@ void processRtpPayload(PNV_VIDEO_PACKET videoPacket, int length) {
// We're now decoding a frame
decodingFrame = 1;
firstPacketReceiveTime = receiveTimeMs;
}
// This must be the first packet in a frame or be contiguous with the last
@ -536,5 +534,6 @@ void queueRtpPacket(PRTPFEC_QUEUE_ENTRY queueEntry) {
}
processRtpPayload((PNV_VIDEO_PACKET)(((char*)queueEntry->packet) + dataOffset),
queueEntry->length - dataOffset);
queueEntry->length - dataOffset,
queueEntry->receiveTimeMs);
}