Package com.castlabs.sdk.debug

# Class RateLimitTracer

java.lang.Object
com.castlabs.sdk.debug.RateLimitTracer

public class RateLimitTracer extends Object
Rate limit tracer that can update a race limiter according to a list of traces.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `RateLimitTracer.Trace`
  A single download trace with a start and end time.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `RateLimitTracer(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data)`
  Create a new tracer
  `RateLimitTracer(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data, com.google.android.exoplayer2.util.Clock clock)`
  Create a new tracer

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static RateLimitTracer`
  `create(RateLimiter rateLimiter, InputStream traceData)`
  Create a new rate limit tracer that, once started, will update the give rate limiter
  `long`
  `getAvgBitrate()`
  Get the average bitrate of the traces.
  `long`
  `getMaxBitrate()`
  Get the maximum bitrate of the traces.
  `long`
  `getMinBitrate()`
  Get the minimum bitrate of the traces.
  `long`
  `getRate()`
  Get the current rate
  `long`
  `getTimeInTrace()`
  Get the current time within the trace range.
  `long`
  `getTraceDurationMs()`
  Get the total duration of the traces
  `long`
  `getTraceEndTime(RateLimitTracer.Trace trace)`
  Get the adjusted end time for a trace
  `List<RateLimitTracer.Trace>`
  `getTraces()`
  Get a view on the traces
  `long`
  `getTraceStartTime(RateLimitTracer.Trace trace)`
  The adjusted start time for a trace
  `void`
  `start()`
  Start the tracer
  `void`
  `stop()`
  Stop the tracer

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### RateLimitTracer

    public RateLimitTracer(RateLimiter rateLimiter, List<RateLimitTracer.Trace> data)
    Create a new tracer
    Parameters:
      `rateLimiter` - The rate limiter that will be updated
      `data` - 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 updated
      `data` - The trace data
      `clock` - The clock

- ## Method Details

  - ### start

    public void start()
    Start the tracer

  - ### stop

    public void stop()
    Stop the tracer

  - ### getTraceEndTime

    public long getTraceEndTime(RateLimitTracer.Trace trace)
    Get the adjusted end time for a trace
    Parameters:
      `trace` - The trace
    Returns:
      The adjusted end time

  - ### getTraceStartTime

    public long getTraceStartTime(RateLimitTracer.Trace trace)
    The adjusted start time for a trace
    Parameters:
      `trace` - The trace
    Returns:
      The adjusted start time for a trace

  - ### getTimeInTrace

    public long getTimeInTrace()
    Get the current time within the trace range.
    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 limiter
      `traceData` - The trace data
    Returns:
      The rate tracer
    Throws:
      `IOException` - in case an error occurs while the input stream is loaded

  - ### getTraces

    public List<RateLimitTracer.Trace> 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()
    Get the minimum bitrate of the traces.
    Returns:
      The min bitrate of the traces

  - ### getMaxBitrate

    public long getMaxBitrate()
    Get the maximum bitrate of the traces.
    Returns:
      The max bitrate of the traces

  - ### getAvgBitrate

    public long getAvgBitrate()
    Get the average bitrate of the traces.
    Returns:
      The average bitrate of the traces