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.
  • 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()
      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()
      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