Home
AV module

RealtimePacketQueue

Queue that emits media packets in presentation-timestamp order relative to a realtime clock.

RealtimePacketQueue

#include <icy/av/realtimepacketqueue.h>
template<class PacketT>
class RealtimePacketQueue

Defined in src/av/include/icy/av/realtimepacketqueue.h:30

Inherits: AsyncPacketQueue< PacketT >

Queue that emits media packets in presentation-timestamp order relative to a realtime clock.

Packets are sorted by their time field on insertion. On each pop attempt the queue checks whether the wall-clock time since stream activation has reached the next packet's timestamp; if not, the packet is held back. This provides a soft realtime playback scheduler.

List of all members

NameKindOwner
RealtimePacketQueuefunctionDeclared here
~RealtimePacketQueuefunctionDeclared here
pushfunctionDeclared here
realTimefunctionDeclared here
_startTimevariableDeclared here
popNextfunctionDeclared here
onStreamStateChangefunctionDeclared here
BaseQueuetypedefDeclared here
emittervariableInherited from AsyncPacketQueue
AsyncPacketQueuefunctionInherited from AsyncPacketQueue
~AsyncPacketQueuefunctionInherited from AsyncPacketQueue
closefunctionInherited from AsyncPacketQueue
processfunctionInherited from AsyncPacketQueue
acceptsfunctionInherited from AsyncPacketQueue
retentionfunctionInherited from AsyncPacketQueue
dispatchfunctionInherited from AsyncPacketQueue
onStreamStateChangefunctionInherited from AsyncPacketQueue
QueuetypedefInherited from AsyncPacketQueue
ProcessortypedefInherited from AsyncPacketQueue
AsyncQueuefunctionInherited from AsyncQueue
cancelfunctionInherited from AsyncQueue
_threadvariableInherited from AsyncQueue
~AsyncQueuefunctionInherited from AsyncQueue
QueuetypedefInherited from AsyncQueue
ondispatchvariableInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
~RunnableQueuefunctionInherited from RunnableQueue
pushfunctionInherited from RunnableQueue
flushfunctionInherited from RunnableQueue
clearfunctionInherited from RunnableQueue
runfunctionInherited from RunnableQueue
runTimeoutfunctionInherited from RunnableQueue
dispatchfunctionInherited from RunnableQueue
timeoutfunctionInherited from RunnableQueue
setTimeoutfunctionInherited from RunnableQueue
droppedfunctionInherited from RunnableQueue
_limitvariableInherited from RunnableQueue
_timeoutvariableInherited from RunnableQueue
_droppedvariableInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
operator=functionInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
operator=functionInherited from RunnableQueue
popNextfunctionInherited from RunnableQueue
dispatchNextfunctionInherited from RunnableQueue
pushfunctionInherited from Queue
pushfunctionInherited from Queue
emptyfunctionInherited from Queue
frontfunctionInherited from Queue
backfunctionInherited from Queue
popfunctionInherited from Queue
sortfunctionInherited from Queue
sizefunctionInherited from Queue
queuefunctionInherited from Queue
_queuevariableInherited from Queue
_mutexvariableInherited from Queue
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from AsyncPacketQueue

KindNameDescription
variableemitter
functionAsyncPacketQueue inline
function~AsyncPacketQueue virtual inline
functionclose virtual inlineFlushes remaining packets, cancels the queue, and joins the dispatch thread.
functionprocess virtual inline overrideClones the incoming packet and pushes it onto the async queue. This queue is therefore an explicit PacketStream ownership boundary. Drops the packet with a warning if the queue has been cancelled.
functionaccepts virtual inline overrideReturns true if the packet can be cast to type T.
functionretention virtual const inline overrideReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiondispatch virtual inline overrideEmits the packet to downstream processors from the async thread.
functiononStreamStateChange virtual inline overrideCloses the queue on [Error](icy-Error.html#error) or Closed stream state transitions.
typedefQueue
typedefProcessor

Inherited from AsyncQueue

KindNameDescription
functionAsyncQueue inline
functioncancel virtual inline overrideCancels the queue and joins the dispatch thread.
variable_thread
function~AsyncQueue virtual inline
typedefQueue

Inherited from RunnableQueue

KindNameDescription
variableondispatchThe default dispatch function. Must be set before the queue is running.
functionRunnableQueue inline
function~RunnableQueue virtual inline
functionpush virtual inlinePush an item onto the queue. The queue takes ownership of the item pointer.
functionflush virtual inlineFlush all outgoing items.
functionclear inline
functionrun virtual inline overrideCalled asynchronously to dispatch queued items. If not timeout is set this method blocks until cancel() is called, otherwise runTimeout() will be called.
functionrunTimeout virtual inlineCalled asynchronously to dispatch queued items until the queue is empty or the timeout expires. Pseudo protected for std::bind compatability.
functiondispatch virtual inlineDispatch a single item to listeners.
functiontimeout inline
functionsetTimeout inlineSets the dispatch timeout. Must only be called when the queue is empty.
functiondropped const inline
variable_limit
variable_timeout
variable_dropped
functionRunnableQueueDeleted constructor.
functionoperator=Deleted assignment operator.
functionRunnableQueueDeleted constructor.
functionoperator=Deleted assignment operator.
functionpopNext virtual inlinePops the next waiting item.
functiondispatchNext virtual inlinePops and dispatches the next waiting item.

Inherited from Queue

KindNameDescription
functionpush inlineAppends an item to the back of the queue (thread-safe).
functionpush inlineAppends an item to the back of the queue by move (thread-safe).
functionempty const inline
functionfront const inline
functionback const inline
functionpop inlineRemoves the front item from the queue (thread-safe).
functionsort inlineSorts all queued items using the given comparator (thread-safe).
functionsize const inline
functionqueue const inline
variable_queue
variable_mutex

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Inherited from PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Public Methods

ReturnNameDescription
RealtimePacketQueue inlineConstruct the queue with a maximum capacity.
voidpush virtual inline overrideInsert a packet into the queue and re-sort by presentation timestamp.
int64_trealTime inlineReturn the elapsed time since stream activation in microseconds.

RealtimePacketQueue

inline

inline RealtimePacketQueue(int maxSize = 1024)

Defined in src/av/include/icy/av/realtimepacketqueue.h:37

Construct the queue with a maximum capacity.

Parameters

  • maxSize The maximum number of packets the queue will hold.

push

virtual inline override

virtual inline void push(PacketT * item) override

Defined in src/av/include/icy/av/realtimepacketqueue.h:48

Insert a packet into the queue and re-sort by presentation timestamp.

Parameters

  • item The packet to enqueue; ownership is transferred.

realTime

inline

inline int64_t realTime()

Defined in src/av/include/icy/av/realtimepacketqueue.h:55

Return the elapsed time since stream activation in microseconds.

Protected Attributes

ReturnNameDescription
int64_t_startTime

_startTime

int64_t _startTime

Defined in src/av/include/icy/av/realtimepacketqueue.h:98

Protected Methods

ReturnNameDescription
PacketT *popNext virtual inline overrideReturn the next packet whose timestamp is <= realTime(), or nullptr if none is ready.
voidonStreamStateChange virtual inline overrideRecord the stream start time when the stream becomes active.

popNext

virtual inline override

virtual inline PacketT * popNext() override

Defined in src/av/include/icy/av/realtimepacketqueue.h:62

Return the next packet whose timestamp is <= realTime(), or nullptr if none is ready.

Reimplements

onStreamStateChange

virtual inline override

virtual inline void onStreamStateChange(const PacketStreamState & state) override

Defined in src/av/include/icy/av/realtimepacketqueue.h:78

Record the stream start time when the stream becomes active.

Reimplements

Public Types

NameDescription
BaseQueue

BaseQueue

using BaseQueue = AsyncPacketQueue< PacketT >

Defined in src/av/include/icy/av/realtimepacketqueue.h:33