Make MediaLoadData a top level class

In order to reuse it in LoadErrorHandlingPolicy.

PiperOrigin-RevId: 281333287
This commit is contained in:
aquilescanta 2019-11-19 19:05:18 +00:00 committed by Oliver Woodman
parent c8e5144494
commit f6afbe6cb0
13 changed files with 102 additions and 80 deletions

View File

@ -25,7 +25,8 @@
* Fix byte order of HDR10+ static metadata to match CTA-861.3.
* Reconfigure audio sink when PCM encoding changes
([#6601](https://github.com/google/ExoPlayer/issues/6601)).
* Make `MediaSourceEventListener.LoadEventInfo` a top-level class.
* Make `MediaSourceEventListener.LoadEventInfo` and
`MediaSourceEventListener.MediaLoadData` top-level classes.
### 2.11.0 (not yet released) ###

View File

@ -21,6 +21,7 @@ import com.google.android.exoplayer2.analytics.AnalyticsCollector;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MaskingMediaPeriod;
import com.google.android.exoplayer2.source.MaskingMediaSource;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener;

View File

@ -35,6 +35,7 @@ import com.google.android.exoplayer2.drm.DefaultDrmSessionEventListener;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.MetadataOutput;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.TrackGroupArray;

View File

@ -31,8 +31,8 @@ import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
import java.io.IOException;

View File

@ -27,8 +27,8 @@ import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.analytics.PlaybackStats.PlaybackState;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;

View File

@ -0,0 +1,91 @@
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer2.source;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
/** Descriptor for data being loaded or selected by a media source. */
public final class MediaLoadData {
/** One of the {@link C} {@code DATA_TYPE_*} constants defining the type of data. */
public final int dataType;
/**
* One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds to media of a
* specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
*/
public final int trackType;
/**
* The format of the track to which the data belongs. Null if the data does not belong to a
* specific track.
*/
@Nullable public final Format trackFormat;
/**
* One of the {@link C} {@code SELECTION_REASON_*} constants if the data belongs to a track.
* {@link C#SELECTION_REASON_UNKNOWN} otherwise.
*/
public final int trackSelectionReason;
/**
* Optional data associated with the selection of the track to which the data belongs. Null if the
* data does not belong to a track.
*/
@Nullable public final Object trackSelectionData;
/**
* The start time of the media, or {@link C#TIME_UNSET} if the data does not belong to a specific
* media period.
*/
public final long mediaStartTimeMs;
/**
* The end time of the media, or {@link C#TIME_UNSET} if the data does not belong to a specific
* media period or the end time is unknown.
*/
public final long mediaEndTimeMs;
/**
* Creates media load data.
*
* @param dataType One of the {@link C} {@code DATA_TYPE_*} constants defining the type of data.
* @param trackType One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds to
* media of a specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
* @param trackFormat The format of the track to which the data belongs. Null if the data does not
* belong to a track.
* @param trackSelectionReason One of the {@link C} {@code SELECTION_REASON_*} constants if the
* data belongs to a track. {@link C#SELECTION_REASON_UNKNOWN} otherwise.
* @param trackSelectionData Optional data associated with the selection of the track to which the
* data belongs. Null if the data does not belong to a track.
* @param mediaStartTimeMs The start time of the media, or {@link C#TIME_UNSET} if the data does
* not belong to a specific media period.
* @param mediaEndTimeMs The end time of the media, or {@link C#TIME_UNSET} if the data does not
* belong to a specific media period or the end time is unknown.
*/
public MediaLoadData(
int dataType,
int trackType,
@Nullable Format trackFormat,
int trackSelectionReason,
@Nullable Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs) {
this.dataType = dataType;
this.trackType = trackType;
this.trackFormat = trackFormat;
this.trackSelectionReason = trackSelectionReason;
this.trackSelectionData = trackSelectionData;
this.mediaStartTimeMs = mediaStartTimeMs;
this.mediaEndTimeMs = mediaEndTimeMs;
}
}

View File

@ -35,77 +35,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
/** Interface for callbacks to be notified of {@link MediaSource} events. */
public interface MediaSourceEventListener {
/** Descriptor for data being loaded or selected by a media source. */
final class MediaLoadData {
/** One of the {@link C} {@code DATA_TYPE_*} constants defining the type of data. */
public final int dataType;
/**
* One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds to media of a
* specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
*/
public final int trackType;
/**
* The format of the track to which the data belongs. Null if the data does not belong to a
* specific track.
*/
@Nullable public final Format trackFormat;
/**
* One of the {@link C} {@code SELECTION_REASON_*} constants if the data belongs to a track.
* {@link C#SELECTION_REASON_UNKNOWN} otherwise.
*/
public final int trackSelectionReason;
/**
* Optional data associated with the selection of the track to which the data belongs. Null if
* the data does not belong to a track.
*/
@Nullable public final Object trackSelectionData;
/**
* The start time of the media, or {@link C#TIME_UNSET} if the data does not belong to a
* specific media period.
*/
public final long mediaStartTimeMs;
/**
* The end time of the media, or {@link C#TIME_UNSET} if the data does not belong to a specific
* media period or the end time is unknown.
*/
public final long mediaEndTimeMs;
/**
* Creates media load data.
*
* @param dataType One of the {@link C} {@code DATA_TYPE_*} constants defining the type of data.
* @param trackType One of the {@link C} {@code TRACK_TYPE_*} constants if the data corresponds
* to media of a specific type. {@link C#TRACK_TYPE_UNKNOWN} otherwise.
* @param trackFormat The format of the track to which the data belongs. Null if the data does
* not belong to a track.
* @param trackSelectionReason One of the {@link C} {@code SELECTION_REASON_*} constants if the
* data belongs to a track. {@link C#SELECTION_REASON_UNKNOWN} otherwise.
* @param trackSelectionData Optional data associated with the selection of the track to which
* the data belongs. Null if the data does not belong to a track.
* @param mediaStartTimeMs The start time of the media, or {@link C#TIME_UNSET} if the data does
* not belong to a specific media period.
* @param mediaEndTimeMs The end time of the media, or {@link C#TIME_UNSET} if the data does not
* belong to a specific media period or the end time is unknown.
*/
public MediaLoadData(
int dataType,
int trackType,
@Nullable Format trackFormat,
int trackSelectionReason,
@Nullable Object trackSelectionData,
long mediaStartTimeMs,
long mediaEndTimeMs) {
this.dataType = dataType;
this.trackType = trackType;
this.trackFormat = trackFormat;
this.trackSelectionReason = trackSelectionReason;
this.trackSelectionData = trackSelectionData;
this.mediaStartTimeMs = mediaStartTimeMs;
this.mediaEndTimeMs = mediaEndTimeMs;
}
}
/**
* Called when a media period is created by the media source.
*

View File

@ -25,11 +25,11 @@ import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.CompositeMediaSource;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MaskingMediaPeriod;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSourceFactory;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.upstream.Allocator;

View File

@ -31,7 +31,7 @@ import com.google.android.exoplayer2.audio.AudioAttributes;
import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.MappingTrackSelector;

View File

@ -37,9 +37,9 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.testutil.ActionSchedule;
import com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable;

View File

@ -29,7 +29,6 @@ import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.source.ClippingMediaSource.IllegalClippingException;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.testutil.FakeMediaPeriod;
import com.google.android.exoplayer2.testutil.FakeMediaSource;
import com.google.android.exoplayer2.testutil.FakeTimeline;

View File

@ -27,10 +27,10 @@ import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener.EventDispatcher;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.source.TrackGroup;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.upstream.Allocator;

View File

@ -26,12 +26,12 @@ import android.util.Pair;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.LoadEventInfo;
import com.google.android.exoplayer2.source.MediaLoadData;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
import com.google.android.exoplayer2.source.MediaSource.MediaSourceCaller;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadData;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;