Package com.castlabs.sdk.debug
Class RateLimitTracer
java.lang.Object
com.castlabs.sdk.debug.RateLimitTracer
Rate limit tracer that can update a race limiter according to a list of traces.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
A single download trace with a start and end time. -
Constructor Summary
ConstructorDescriptionRateLimitTracer
(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data) Create a new tracerRateLimitTracer
(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data, com.google.android.exoplayer2.util.Clock clock) Create a new tracer -
Method Summary
Modifier and TypeMethodDescriptionstatic RateLimitTracer
create
(RateLimiter rateLimiter, InputStream traceData) Create a new rate limit tracer that, once started, will update the give rate limiterlong
long
long
long
getRate()
Get the current ratelong
long
Get the total duration of the traceslong
Get the adjusted end time for a traceGet a view on the traceslong
The adjusted start time for a tracevoid
start()
Start the tracervoid
stop()
Stop the tracer
-
Constructor Details
-
RateLimitTracer
Create a new tracer- Parameters:
rateLimiter
- The rate limiter that will be updateddata
- The trace data
-
RateLimitTracer
public RateLimitTracer(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data, com.google.android.exoplayer2.util.Clock clock) Create a new tracer- Parameters:
rateLimiter
- The rate limiter that will be updateddata
- The trace dataclock
- The clock
-
-
Method Details
-
start
public void start()Start the tracer -
stop
public void stop()Stop the tracer -
getTraceEndTime
Get the adjusted end time for a trace- Parameters:
trace
- The trace- Returns:
- The adjusted end time
-
getTraceStartTime
The adjusted start time for a trace- Parameters:
trace
- The trace- Returns:
- The adjusted start time for a trace
-
getTimeInTrace
public long getTimeInTrace()- Returns:
- The current time within the trace range, i.e 0 to trace-duration
-
getRate
public long getRate()Get the current rate- Returns:
- The current rate
-
create
public static RateLimitTracer create(RateLimiter rateLimiter, InputStream traceData) throws IOException Create a new rate limit tracer that, once started, will update the give rate limiter- Parameters:
rateLimiter
- The rate limitertraceData
- The trace data- Returns:
- The rate tracer
- Throws:
IOException
- in case an error occurs while the input stream is loaded
-
getTraces
Get a view on the traces- Returns:
- The traces
-
getTraceDurationMs
public long getTraceDurationMs()Get the total duration of the traces- Returns:
- the duration of the traces
-
getMinBitrate
public long getMinBitrate()- Returns:
- The min bitrate of the traces
-
getMaxBitrate
public long getMaxBitrate()- Returns:
- The max bitrate of the traces
-
getAvgBitrate
public long getAvgBitrate()- Returns:
- The average bitrate of the traces
-