YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.multiroom.engine.ChunkScheduler Class Reference

Decides when a chunk is to be played. More...

Collaboration diagram for de.yaacc.multiroom.engine.ChunkScheduler:
Collaboration graph

Classes

enum  Action
 What to do with a chunk. More...
 
class  Config
 
class  Decision
 The decision and, for PLAY_AT and WAIT with a synchronised clock, the client time to play at.
 
class  ScheduledChunk
 A chunk that is due, with the client time to play it at.
 

Public Member Functions

 ChunkScheduler (OffsetSource offsets, MicroClock clock, Config config)
 
synchronized void setBufferMs (int bufferMs)
 The buffer of the server settings, clamped to 0 .
 
synchronized void setLatencyMs (int latencyMs)
 The client latency of the server settings (plus the device's own), clamped to -10 000 .
 
synchronized void codecHeaderAccepted ()
 The codec header was accepted: chunks may be released from now on.
 
synchronized void reset ()
 A new connection or a new stream: the queue is emptied and chunks wait for the next accepted header.
 
synchronized Decision offer (StreamChunk chunk)
 Decides what to do with a chunk; a chunk that has to wait is queued.
 
synchronized List< ScheduledChunk > releaseDue ()
 The chunks whose time is near, in the order of their timestamps; chunks that became late or too far ahead while they waited are dropped.
 
synchronized int queuedChunks ()
 
synchronized long queuedBytes ()
 
synchronized long droppedLate ()
 
synchronized long droppedTooFarAhead ()
 
synchronized long droppedQueueFull ()
 
synchronized long flushed ()
 Chunks thrown away because the clock was found anew.
 

Detailed Description

Decides when a chunk is to be played.

A chunk is recorded at the server time timestamp, the server delays everything by bufferMs, and this client's own latency setting moves its playback earlier (a slow output) or later: the chunk is played at the server time timestamp + bufferMs - latency, which is the client time timestamp + bufferMs - latency - offset on the clock of the OffsetSource. All times are microseconds. The timestamps are the server's and are not trusted.

Decisions.

  • DROP_TOO_FAR_AHEAD: the timestamp is more than 5 s after the corrected clock, that is the play time is more than bufferMs + 5 s away (the client's latency setting is left out of that test, so that a latency of -10 s does not turn every fresh chunk into one that is "too far ahead").
  • DROP_LATE: the play time is in the past by more than the tolerance (default 0).
  • PLAY_AT: the play time is at most releaseLead away (default 250 ms): the caller gets the time and plays the chunk then.
  • WAIT: the play time is further away; the chunk waits in the queue and releaseDue() hands it over later. Also WAIT: the codec header was not accepted yet, or the clock is not synchronised.
  • DROP_QUEUE_FULL: the queue holds the maximum number of chunks or bytes (the new chunk is dropped).

No chunk is released before codecHeaderAccepted(). When the offset source starts a new epoch (the server clock jumped) the queue is emptied, because its chunks carry the old clock. The queue is ordered by timestamp.

Thread safe.

Member Function Documentation

◆ releaseDue()

synchronized List< ScheduledChunk > de.yaacc.multiroom.engine.ChunkScheduler.releaseDue ( )

The chunks whose time is near, in the order of their timestamps; chunks that became late or too far ahead while they waited are dropped.

Empty before the codec header was accepted and while the clock is not synchronised.

◆ setBufferMs()

synchronized void de.yaacc.multiroom.engine.ChunkScheduler.setBufferMs ( int bufferMs)

The buffer of the server settings, clamped to 0 .

. 10 000 ms.

◆ setLatencyMs()

synchronized void de.yaacc.multiroom.engine.ChunkScheduler.setLatencyMs ( int latencyMs)

The client latency of the server settings (plus the device's own), clamped to -10 000 .

. 10 000 ms.


The documentation for this class was generated from the following file: