-
- All Implemented Interfaces:
-
java.io.Serializable
public class LinkedPriorityQueue implements Serializable
Highly efficient priority queue. Implemented using linked list. We expect that latest frame will be inserted near to the last index. For this case normal linked priority queue will have insertion complexity of O(n). But our implementation should insert it nearly O(1).
-
-
Field Summary
Fields Modifier and Type Field Description private booleanwaiting
-
Constructor Summary
Constructors Constructor Description LinkedPriorityQueue(int maxSize, int jitterLength)Constructor
-
Method Summary
Modifier and Type Method Description voidsetWaiting(boolean waiting)Set the value of waiting intgetSize()intgetJitter()voidupdateJitter(int jitterLength)booleanisUniqueSequence(int sequenceNumber)Determines if the given sequence number is unique in this queue. RtpFramegetFirstElement()RtpFramegetLastElement()voidenqueue(RtpFrame packet)Enqueue the packet in the in sorted manner.Queue will be sorted whenever a packet is enqueued.If queue size if full, it will remove all the ancient elements and add the new one. RtpFramedequeue()voidreset()If we want to reuse the queue again. intgetMissingRange(int lastNACKSequence, ArrayList<LossPacketRange> missingList, int allowedMissCount)Check and return the range of missing sequence number. booleanisEmpty()booleanisFull()StringtoString()Prints all the elements of this queue. booleanisWaiting()RtpFramegetFrame(int sequenceNumber)Get the instance of RtpFrame for the given sequence number. -
-
Method Detail
-
setWaiting
void setWaiting(boolean waiting)
Set the value of waiting
-
getSize
int getSize()
-
getJitter
int getJitter()
-
updateJitter
void updateJitter(int jitterLength)
-
isUniqueSequence
boolean isUniqueSequence(int sequenceNumber)
Determines if the given sequence number is unique in this queue.
- Parameters:
sequenceNumber- Sequence number that need to be checked for uniqueness.
-
getFirstElement
RtpFrame getFirstElement()
-
getLastElement
RtpFrame getLastElement()
-
enqueue
void enqueue(RtpFrame packet)
Enqueue the packet in the in sorted manner.Queue will be sorted whenever a packet is enqueued.If queue size if full, it will remove all the ancient elements and add the new one.
- Parameters:
packet- instance that need to be inserted into the queue.
-
reset
void reset()
If we want to reuse the queue again. we must reset all volatile information.
-
getMissingRange
int getMissingRange(int lastNACKSequence, ArrayList<LossPacketRange> missingList, int allowedMissCount)
Check and return the range of missing sequence number.
- Parameters:
lastNACKSequence- is the latest sequence number for which NACK packet sending check has been donemissingList- If any miss is found, an instance of LossPacketRange will be added into this listdescribing the range of missing sequence numberallowedMissCount- allowed distance of next RtpFrame to be considered as missing.
-
isEmpty
boolean isEmpty()
-
isFull
boolean isFull()
-
isWaiting
boolean isWaiting()
-
-
-
-