-
class AudioTimestampComputes timestamps for audio frames. Video frames do not need this since the timestamp comes from the surface texture. This is independent from the channels count, as long as the read bytes include all channels and the byte rate accounts for this as well. If channels is 2, both values will be doubled and we behave the same. This class keeps track of gaps between frames. This can be used, for example, to write zeros instead of nothing.
-
-
Constructor Summary
Constructors Constructor Description AudioTimestamp(int byteRate)
-
Method Summary
Modifier and Type Method Description static longbytesToUs(long bytes, int byteRate)static longbytesToMillis(long bytes, int byteRate)longincreaseUs(int readBytes)This method accounts for the current time and proved to be the most reliable amongthe ones tested.This creates regular timestamps unless we accumulate a lot of delay (greater thantwice the buffer duration), in which case it creates a gap and starts again tryingto be regular from the new point. intgetGapCount(int frameBytes)Returns the number of gaps (meaning, missing frames) assuming that eachframe has frameBytes size. longgetGapStartUs(long lastTimeUs)Returns the timestamp of the first missing frame. -
-
Method Detail
-
bytesToUs
static long bytesToUs(long bytes, int byteRate)
-
bytesToMillis
static long bytesToMillis(long bytes, int byteRate)
-
increaseUs
long increaseUs(int readBytes)
This method accounts for the current time and proved to be the most reliable amongthe ones tested.This creates regular timestamps unless we accumulate a lot of delay (greater thantwice the buffer duration), in which case it creates a gap and starts again tryingto be regular from the new point.Returns timestamps in the nanoTime reference.
-
getGapCount
int getGapCount(int frameBytes)
Returns the number of gaps (meaning, missing frames) assuming that eachframe has frameBytes size. Possibly 0.
- Parameters:
frameBytes- size of standard frame
-
getGapStartUs
long getGapStartUs(long lastTimeUs)
Returns the timestamp of the first missing frame.Should be called only after getGapCount returns somethinggreater than zero.
- Parameters:
lastTimeUs- the last real frame timestamp
-
-
-
-