YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.SeekPositionCalculator Class Reference

The estimate behind the server-side time range management for renderers that cannot seek themselves: from a playback time to a byte position of the file. More...

Collaboration diagram for de.yaacc.share.SeekPositionCalculator:
Collaboration graph

Static Public Member Functions

static long bytePositionForTime (long totalSize, long timeMs, long totalDurationMs)
 
static long estimateDurationMs (long totalSize)
 Guesses the duration of a file from its size at 128 kbit/s: size * 8 * 1000 / (128 * 1024), computed without overflow.
 

Detailed Description

The estimate behind the server-side time range management for renderers that cannot seek themselves: from a playback time to a byte position of the file.

Plain Java, long/double arithmetic that cannot overflow; every result is inside the file.

The formula is the one of the original implementation: the first 10 percent of the file are treated as header/metadata, the playback time is spread over the remaining 90 percent, and the result never goes beyond 85 percent of the file. The duration is guessed from the file size assuming 128 kbit/s.

Member Function Documentation

◆ bytePositionForTime()

static long de.yaacc.share.SeekPositionCalculator.bytePositionForTime ( long totalSize,
long timeMs,
long totalDurationMs )
static
Parameters
totalSizesize of the file in bytes; <= 0 means unknown
timeMsplayback time in milliseconds
totalDurationMsduration in milliseconds; <= 0 means unknown
Returns
the byte position, 0 if the size or the duration is unknown, never negative and never beyond 85 percent of the file

Referenced by de.yaacc.share.ServerSideSeeking.plan().

Here is the caller graph for this function:

◆ estimateDurationMs()

static long de.yaacc.share.SeekPositionCalculator.estimateDurationMs ( long totalSize)
static

Guesses the duration of a file from its size at 128 kbit/s: size * 8 * 1000 / (128 * 1024), computed without overflow.

Returns
the duration in milliseconds, 0 for an unknown (<= 0) size

Referenced by de.yaacc.share.ServerSideSeeking.plan().

Here is the caller graph for this function:

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