Move TrackGroup and TrackGroupArray in common

This is a dependency of TrackSelection and Player.

#player-to-common

PiperOrigin-RevId: 353004379
This commit is contained in:
krocard 2021-01-21 14:17:27 +00:00 committed by kim-vde
parent 437c6d5dd8
commit efcaee563a
3 changed files with 15 additions and 31 deletions

View File

@ -23,20 +23,10 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.Assertions;
import java.util.Arrays;
// TODO: Add an allowMultipleStreams boolean to indicate where the one stream per group restriction
// does not apply.
/**
* Defines a group of tracks exposed by a {@link MediaPeriod}.
*
* <p>A {@link MediaPeriod} is only able to provide one {@link SampleStream} corresponding to a
* group at any given time, however this {@link SampleStream} may adapt between multiple tracks
* within the group.
*/
/** Defines an immutable group of tracks identified by their format identity. */
public final class TrackGroup implements Parcelable {
/**
* The number of tracks in the group.
*/
/** The number of tracks in the group. */
public final int length;
private final Format[] formats;
@ -45,7 +35,7 @@ public final class TrackGroup implements Parcelable {
private int hashCode;
/**
* @param formats The track formats. Must not be null, contain null elements or be of length 0.
* @param formats The track formats. At least one {@link Format} must be provided.
*/
public TrackGroup(Format... formats) {
Assertions.checkState(formats.length > 0);

View File

@ -21,17 +21,13 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import java.util.Arrays;
/** An array of {@link TrackGroup}s exposed by a {@link MediaPeriod}. */
/** An immutable array of {@link TrackGroup}s. */
public final class TrackGroupArray implements Parcelable {
/**
* The empty array.
*/
/** The empty array. */
public static final TrackGroupArray EMPTY = new TrackGroupArray();
/**
* The number of groups in the array. Greater than or equal to zero.
*/
/** The number of groups in the array. Greater than or equal to zero. */
public final int length;
private final TrackGroup[] trackGroups;
@ -39,9 +35,7 @@ public final class TrackGroupArray implements Parcelable {
// Lazily initialized hashcode.
private int hashCode;
/**
* @param trackGroups The groups. Must not be null or contain null elements, but may be empty.
*/
/** @param trackGroups The groups. May be empty. */
public TrackGroupArray(TrackGroup... trackGroups) {
this.trackGroups = trackGroups;
this.length = trackGroups.length;
@ -83,9 +77,7 @@ public final class TrackGroupArray implements Parcelable {
return C.INDEX_UNSET;
}
/**
* Returns whether this track group array is empty.
*/
/** Returns whether this track group array is empty. */
public boolean isEmpty() {
return length == 0;
}

View File

@ -29,14 +29,16 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
/**
* Loads media corresponding to a {@link Timeline.Period}, and allows that media to be read. All
* methods are called on the player's internal playback thread, as described in the
* {@link ExoPlayer} Javadoc.
* methods are called on the player's internal playback thread, as described in the {@link
* ExoPlayer} Javadoc.
*
* <p>A {@link MediaPeriod} may only able to provide one {@link SampleStream} corresponding to a
* group at any given time, however this {@link SampleStream} may adapt between multiple tracks
* within the group.
*/
public interface MediaPeriod extends SequenceableLoader {
/**
* A callback to be notified of {@link MediaPeriod} events.
*/
/** A callback to be notified of {@link MediaPeriod} events. */
interface Callback extends SequenceableLoader.Callback<MediaPeriod> {
/**