Reorganize BandwidthMeter interface

This commit is contained in:
Oliver Woodman 2015-05-11 21:11:53 +01:00
parent 64cc380fe1
commit 79c7798d84
2 changed files with 19 additions and 20 deletions

View file

@ -18,7 +18,24 @@ package com.google.android.exoplayer.upstream;
/**
* Provides estimates of the currently available bandwidth.
*/
public interface BandwidthMeter {
public interface BandwidthMeter extends TransferListener {
/**
* Interface definition for a callback to be notified of {@link BandwidthMeter} events.
*/
public interface EventListener {
/**
* Invoked periodically to indicate that bytes have been transferred.
*
* @param elapsedMs The time taken to transfer the bytes, in milliseconds.
* @param bytes The number of bytes transferred.
* @param bitrate The estimated bitrate in bits/sec, or {@link #NO_ESTIMATE} if no estimate
* is available. Note that this estimate is typically derived from more information than
* {@code bytes} and {@code elapsedMs}.
*/
void onBandwidthSample(int elapsedMs, long bytes, long bitrate);
}
/**
* Indicates no bandwidth estimate is available.

View file

@ -26,25 +26,7 @@ import android.os.Handler;
* Counts transferred bytes while transfers are open and creates a bandwidth sample and updated
* bandwidth estimate each time a transfer ends.
*/
public class DefaultBandwidthMeter implements BandwidthMeter, TransferListener {
/**
* Interface definition for a callback to be notified of {@link DefaultBandwidthMeter} events.
*/
public interface EventListener {
/**
* Invoked periodically to indicate that bytes have been transferred.
*
* @param elapsedMs The time taken to transfer the bytes, in milliseconds.
* @param bytes The number of bytes transferred.
* @param bitrate The estimated bitrate in bits/sec, or {@link #NO_ESTIMATE} if no estimate
* is available. Note that this estimate is typically derived from more information than
* {@code bytes} and {@code elapsedMs}.
*/
void onBandwidthSample(int elapsedMs, long bytes, long bitrate);
}
public class DefaultBandwidthMeter implements BandwidthMeter {
private static final int DEFAULT_MAX_WEIGHT = 2000;