mirror of
https://github.com/androidx/media.git
synced 2025-05-12 10:09:55 +08:00
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:
parent
437c6d5dd8
commit
efcaee563a
@ -23,20 +23,10 @@ import com.google.android.exoplayer2.Format;
|
|||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
// TODO: Add an allowMultipleStreams boolean to indicate where the one stream per group restriction
|
/** Defines an immutable group of tracks identified by their format identity. */
|
||||||
// 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.
|
|
||||||
*/
|
|
||||||
public final class TrackGroup implements Parcelable {
|
public final class TrackGroup implements Parcelable {
|
||||||
|
|
||||||
/**
|
/** The number of tracks in the group. */
|
||||||
* The number of tracks in the group.
|
|
||||||
*/
|
|
||||||
public final int length;
|
public final int length;
|
||||||
|
|
||||||
private final Format[] formats;
|
private final Format[] formats;
|
||||||
@ -45,7 +35,7 @@ public final class TrackGroup implements Parcelable {
|
|||||||
private int hashCode;
|
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) {
|
public TrackGroup(Format... formats) {
|
||||||
Assertions.checkState(formats.length > 0);
|
Assertions.checkState(formats.length > 0);
|
@ -21,17 +21,13 @@ import androidx.annotation.Nullable;
|
|||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import java.util.Arrays;
|
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 {
|
public final class TrackGroupArray implements Parcelable {
|
||||||
|
|
||||||
/**
|
/** The empty array. */
|
||||||
* The empty array.
|
|
||||||
*/
|
|
||||||
public static final TrackGroupArray EMPTY = new TrackGroupArray();
|
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;
|
public final int length;
|
||||||
|
|
||||||
private final TrackGroup[] trackGroups;
|
private final TrackGroup[] trackGroups;
|
||||||
@ -39,9 +35,7 @@ public final class TrackGroupArray implements Parcelable {
|
|||||||
// Lazily initialized hashcode.
|
// Lazily initialized hashcode.
|
||||||
private int hashCode;
|
private int hashCode;
|
||||||
|
|
||||||
/**
|
/** @param trackGroups The groups. May be empty. */
|
||||||
* @param trackGroups The groups. Must not be null or contain null elements, but may be empty.
|
|
||||||
*/
|
|
||||||
public TrackGroupArray(TrackGroup... trackGroups) {
|
public TrackGroupArray(TrackGroup... trackGroups) {
|
||||||
this.trackGroups = trackGroups;
|
this.trackGroups = trackGroups;
|
||||||
this.length = trackGroups.length;
|
this.length = trackGroups.length;
|
||||||
@ -83,9 +77,7 @@ public final class TrackGroupArray implements Parcelable {
|
|||||||
return C.INDEX_UNSET;
|
return C.INDEX_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns whether this track group array is empty. */
|
||||||
* Returns whether this track group array is empty.
|
|
||||||
*/
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return length == 0;
|
return length == 0;
|
||||||
}
|
}
|
@ -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
|
* 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
|
* methods are called on the player's internal playback thread, as described in the {@link
|
||||||
* {@link ExoPlayer} Javadoc.
|
* 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 {
|
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> {
|
interface Callback extends SequenceableLoader.Callback<MediaPeriod> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user