mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Rename Window->MediaWindow, Timline->MediaTimeline
Window is potentially confusing with Android's Window class. Once Window is renamed, it makes sense to rename Timeline too. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=130938392
This commit is contained in:
parent
fb55254f90
commit
94c908e89c
@ -22,8 +22,8 @@ import com.google.android.exoplayer2.C;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
import com.google.android.exoplayer2.RendererCapabilities;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
|
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
|
||||||
@ -89,7 +89,7 @@ import java.util.Locale;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
int periodCount = timeline.getPeriodCount();
|
int periodCount = timeline.getPeriodCount();
|
||||||
int windowCount = timeline.getWindowCount();
|
int windowCount = timeline.getWindowCount();
|
||||||
Log.d(TAG, "sourceInfo[startTime=" + timeline.getAbsoluteStartTime() + ", periodCount="
|
Log.d(TAG, "sourceInfo[startTime=" + timeline.getAbsoluteStartTime() + ", periodCount="
|
||||||
|
@ -40,9 +40,9 @@ import com.google.android.exoplayer2.DefaultLoadControl;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
|
import com.google.android.exoplayer2.MediaWindow;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.Window;
|
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
|
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
|
||||||
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
|
import com.google.android.exoplayer2.drm.StreamingDrmSessionManager;
|
||||||
@ -376,9 +376,9 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi
|
|||||||
debugViewHelper.stop();
|
debugViewHelper.stop();
|
||||||
debugViewHelper = null;
|
debugViewHelper = null;
|
||||||
shouldRestorePosition = false;
|
shouldRestorePosition = false;
|
||||||
Timeline playerTimeline = player.getCurrentTimeline();
|
MediaTimeline playerTimeline = player.getCurrentTimeline();
|
||||||
if (playerTimeline != null) {
|
if (playerTimeline != null) {
|
||||||
Window window = playerTimeline.getWindow(player.getCurrentWindowIndex());
|
MediaWindow window = playerTimeline.getWindow(player.getCurrentWindowIndex());
|
||||||
if (!window.isDynamic) {
|
if (!window.isDynamic) {
|
||||||
shouldRestorePosition = true;
|
shouldRestorePosition = true;
|
||||||
playerPeriod = player.getCurrentPeriodIndex();
|
playerPeriod = player.getCurrentPeriodIndex();
|
||||||
@ -417,7 +417,7 @@ public class PlayerActivity extends Activity implements OnKeyListener, OnTouchLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import android.test.InstrumentationTestCase;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
||||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
@ -96,7 +96,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import android.test.InstrumentationTestCase;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
||||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
@ -96,7 +96,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ import android.test.InstrumentationTestCase;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.Renderer;
|
import com.google.android.exoplayer2.Renderer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
|
||||||
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
import com.google.android.exoplayer2.source.ExtractorMediaSource;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
@ -115,7 +115,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public interface ExoPlayer {
|
|||||||
* @param timeline The source's timeline.
|
* @param timeline The source's timeline.
|
||||||
* @param manifest The loaded manifest.
|
* @param manifest The loaded manifest.
|
||||||
*/
|
*/
|
||||||
void onSourceInfoRefreshed(Timeline timeline, Object manifest);
|
void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an error occurs. The playback state will transition to {@link #STATE_IDLE}
|
* Called when an error occurs. The playback state will transition to {@link #STATE_IDLE}
|
||||||
@ -376,9 +376,9 @@ public interface ExoPlayer {
|
|||||||
void blockingSendMessages(ExoPlayerMessage... messages);
|
void blockingSendMessages(ExoPlayerMessage... messages);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current {@link Timeline}, or {@code null} if there is no timeline.
|
* Returns the current {@link MediaTimeline}, or {@code null} if there is no timeline.
|
||||||
*/
|
*/
|
||||||
Timeline getCurrentTimeline();
|
MediaTimeline getCurrentTimeline();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current manifest. The type depends on the {@link MediaSource} passed to
|
* Returns the current manifest. The type depends on the {@link MediaSource} passed to
|
||||||
@ -421,7 +421,7 @@ public interface ExoPlayer {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
int getBufferedPercentageInPeriod();
|
int getBufferedPercentageInPeriod();
|
||||||
|
|
||||||
// Window based.
|
// MediaWindow based.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the seek window associated with the current period, or
|
* Returns the index of the seek window associated with the current period, or
|
||||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
private int playbackState;
|
private int playbackState;
|
||||||
private int pendingSeekAcks;
|
private int pendingSeekAcks;
|
||||||
private boolean isLoading;
|
private boolean isLoading;
|
||||||
private Timeline timeline;
|
private MediaTimeline timeline;
|
||||||
private Object manifest;
|
private Object manifest;
|
||||||
|
|
||||||
// Playback information when there is no pending seek/set source operation.
|
// Playback information when there is no pending seek/set source operation.
|
||||||
@ -166,7 +166,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void seekTo(long positionMs) {
|
public void seekTo(long positionMs) {
|
||||||
Timeline timeline = getCurrentTimeline();
|
MediaTimeline timeline = getCurrentTimeline();
|
||||||
if (timeline == null) {
|
if (timeline == null) {
|
||||||
throw new IllegalArgumentException("Windows are not yet known");
|
throw new IllegalArgumentException("Windows are not yet known");
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
}
|
}
|
||||||
int periodIndex = getCurrentPeriodIndex();
|
int periodIndex = getCurrentPeriodIndex();
|
||||||
int windowIndex = timeline.getPeriodWindowIndex(periodIndex);
|
int windowIndex = timeline.getPeriodWindowIndex(periodIndex);
|
||||||
Window window = timeline.getWindow(windowIndex);
|
MediaWindow window = timeline.getWindow(windowIndex);
|
||||||
int firstPeriodIndex = timeline.getWindowFirstPeriodIndex(windowIndex);
|
int firstPeriodIndex = timeline.getWindowFirstPeriodIndex(windowIndex);
|
||||||
int lastPeriodIndex = timeline.getWindowLastPeriodIndex(windowIndex);
|
int lastPeriodIndex = timeline.getWindowLastPeriodIndex(windowIndex);
|
||||||
if (firstPeriodIndex == periodIndex && lastPeriodIndex == periodIndex
|
if (firstPeriodIndex == periodIndex && lastPeriodIndex == periodIndex
|
||||||
@ -320,7 +320,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public MediaTimeline getCurrentTimeline() {
|
||||||
return timeline;
|
return timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
|||||||
}
|
}
|
||||||
case ExoPlayerImplInternal.MSG_SOURCE_INFO_REFRESHED: {
|
case ExoPlayerImplInternal.MSG_SOURCE_INFO_REFRESHED: {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Pair<Timeline, Object> timelineAndManifest = (Pair<Timeline, Object>) msg.obj;
|
Pair<MediaTimeline, Object> timelineAndManifest = (Pair<MediaTimeline, Object>) msg.obj;
|
||||||
timeline = timelineAndManifest.first;
|
timeline = timelineAndManifest.first;
|
||||||
manifest = timelineAndManifest.second;
|
manifest = timelineAndManifest.second;
|
||||||
for (EventListener listener : listeners) {
|
for (EventListener listener : listeners) {
|
||||||
|
@ -131,7 +131,7 @@ import java.io.IOException;
|
|||||||
private Period loadingPeriod;
|
private Period loadingPeriod;
|
||||||
private long playingPeriodEndPositionUs;
|
private long playingPeriodEndPositionUs;
|
||||||
|
|
||||||
private Timeline timeline;
|
private MediaTimeline timeline;
|
||||||
|
|
||||||
public ExoPlayerImplInternal(Renderer[] renderers, TrackSelector trackSelector,
|
public ExoPlayerImplInternal(Renderer[] renderers, TrackSelector trackSelector,
|
||||||
LoadControl loadControl, boolean playWhenReady, Handler eventHandler,
|
LoadControl loadControl, boolean playWhenReady, Handler eventHandler,
|
||||||
@ -224,7 +224,7 @@ import java.io.IOException;
|
|||||||
// MediaSource.Listener implementation.
|
// MediaSource.Listener implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
handler.obtainMessage(MSG_REFRESH_SOURCE_INFO, Pair.create(timeline, manifest)).sendToTarget();
|
handler.obtainMessage(MSG_REFRESH_SOURCE_INFO, Pair.create(timeline, manifest)).sendToTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,7 +282,7 @@ import java.io.IOException;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MSG_REFRESH_SOURCE_INFO: {
|
case MSG_REFRESH_SOURCE_INFO: {
|
||||||
handleSourceInfoRefreshed((Pair<Timeline, Object>) msg.obj);
|
handleSourceInfoRefreshed((Pair<MediaTimeline, Object>) msg.obj);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case MSG_SOURCE_CONTINUE_LOADING_REQUESTED: {
|
case MSG_SOURCE_CONTINUE_LOADING_REQUESTED: {
|
||||||
@ -785,10 +785,10 @@ import java.io.IOException;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSourceInfoRefreshed(Pair<Timeline, Object> timelineAndManifest)
|
private void handleSourceInfoRefreshed(Pair<MediaTimeline, Object> timelineAndManifest)
|
||||||
throws ExoPlaybackException, IOException {
|
throws ExoPlaybackException, IOException {
|
||||||
eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, timelineAndManifest).sendToTarget();
|
eventHandler.obtainMessage(MSG_SOURCE_INFO_REFRESHED, timelineAndManifest).sendToTarget();
|
||||||
Timeline oldTimeline = this.timeline;
|
MediaTimeline oldTimeline = this.timeline;
|
||||||
this.timeline = timelineAndManifest.first;
|
this.timeline = timelineAndManifest.first;
|
||||||
|
|
||||||
// Update the loaded periods to take into account the new timeline.
|
// Update the loaded periods to take into account the new timeline.
|
||||||
@ -866,8 +866,8 @@ import java.io.IOException;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void attemptRestart(Timeline newTimeline, Timeline oldTimeline, int oldPeriodIndex)
|
private void attemptRestart(MediaTimeline newTimeline, MediaTimeline oldTimeline,
|
||||||
throws ExoPlaybackException {
|
int oldPeriodIndex) throws ExoPlaybackException {
|
||||||
int newPeriodIndex = C.INDEX_UNSET;
|
int newPeriodIndex = C.INDEX_UNSET;
|
||||||
while (newPeriodIndex == C.INDEX_UNSET
|
while (newPeriodIndex == C.INDEX_UNSET
|
||||||
&& oldPeriodIndex < oldTimeline.getPeriodCount() - 1) {
|
&& oldPeriodIndex < oldTimeline.getPeriodCount() - 1) {
|
||||||
@ -1196,7 +1196,7 @@ import java.io.IOException;
|
|||||||
this.nextPeriod = nextPeriod;
|
this.nextPeriod = nextPeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(Timeline timeline, int index) {
|
public void setIndex(MediaTimeline timeline, int index) {
|
||||||
this.index = index;
|
this.index = index;
|
||||||
isLast = index == timeline.getPeriodCount() - 1 && !timeline.getPeriodWindow(index).isDynamic;
|
isLast = index == timeline.getPeriodCount() - 1 && !timeline.getPeriodWindow(index).isDynamic;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ package com.google.android.exoplayer2;
|
|||||||
/**
|
/**
|
||||||
* The player's timeline consisting of one or more periods. Instances are immutable.
|
* The player's timeline consisting of one or more periods. Instances are immutable.
|
||||||
*/
|
*/
|
||||||
public interface Timeline {
|
public interface MediaTimeline {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of periods in the timeline.
|
* Returns the number of periods in the timeline.
|
||||||
@ -50,8 +50,7 @@ public interface Timeline {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a unique identifier for the period at {@code periodIndex}, or {@code null} if the
|
* Returns a unique identifier for the period at {@code periodIndex}, or {@code null} if the
|
||||||
* period at {@code periodIndex} is not known. The identifier is stable across {@link Timeline}
|
* period at {@code periodIndex} is not known. The identifier is stable across timeline changes.
|
||||||
* changes.
|
|
||||||
*
|
*
|
||||||
* @param periodIndex A period index.
|
* @param periodIndex A period index.
|
||||||
* @return An identifier for the period, or {@code null} if the period is not known.
|
* @return An identifier for the period, or {@code null} if the period is not known.
|
||||||
@ -59,12 +58,12 @@ public interface Timeline {
|
|||||||
Object getPeriodId(int periodIndex);
|
Object getPeriodId(int periodIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Window} to which the period with the specified index belongs.
|
* Returns the {@link MediaWindow} to which the period with the specified index belongs.
|
||||||
*
|
*
|
||||||
* @param periodIndex The period index.
|
* @param periodIndex The period index.
|
||||||
* @return The corresponding window.
|
* @return The corresponding window.
|
||||||
*/
|
*/
|
||||||
Window getPeriodWindow(int periodIndex);
|
MediaWindow getPeriodWindow(int periodIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the window to which the period with the specified index belongs.
|
* Returns the index of the window to which the period with the specified index belongs.
|
||||||
@ -89,14 +88,14 @@ public interface Timeline {
|
|||||||
int getWindowCount();
|
int getWindowCount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Window} at the specified index.
|
* Returns the {@link MediaWindow} at the specified index.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index.
|
* @param windowIndex The window index.
|
||||||
*/
|
*/
|
||||||
Window getWindow(int windowIndex);
|
MediaWindow getWindow(int windowIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the first period belonging to the {@link Window} at the specified index.
|
* Returns the index of the first period belonging to the window at the specified index.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index.
|
* @param windowIndex The window index.
|
||||||
* @return The index of the first period in the window.
|
* @return The index of the first period in the window.
|
||||||
@ -104,7 +103,7 @@ public interface Timeline {
|
|||||||
int getWindowFirstPeriodIndex(int windowIndex);
|
int getWindowFirstPeriodIndex(int windowIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the last period belonging to the {@link Window} at the specified index.
|
* Returns the index of the last period belonging to the window at the specified index.
|
||||||
*
|
*
|
||||||
* @param windowIndex The window index.
|
* @param windowIndex The window index.
|
||||||
* @return The index of the last period in the window.
|
* @return The index of the last period in the window.
|
@ -18,19 +18,19 @@ package com.google.android.exoplayer2;
|
|||||||
/**
|
/**
|
||||||
* A window of available media. Instances are immutable.
|
* A window of available media. Instances are immutable.
|
||||||
*/
|
*/
|
||||||
public final class Window {
|
public final class MediaWindow {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link Window} consisting of a single period with the specified duration. The
|
* Creates a new window consisting of a single period with the specified duration. The default
|
||||||
* default start position is zero.
|
* start position is zero.
|
||||||
*
|
*
|
||||||
* @param durationUs The duration of the window, in microseconds.
|
* @param durationUs The duration of the window, in microseconds.
|
||||||
* @param isSeekable Whether seeking is supported within the window.
|
* @param isSeekable Whether seeking is supported within the window.
|
||||||
* @param isDynamic Whether this seek window may change when the timeline is updated.
|
* @param isDynamic Whether this seek window may change when the timeline is updated.
|
||||||
*/
|
*/
|
||||||
public static Window createWindowFromZero(long durationUs, boolean isSeekable,
|
public static MediaWindow createWindowFromZero(long durationUs, boolean isSeekable,
|
||||||
boolean isDynamic) {
|
boolean isDynamic) {
|
||||||
return new Window(durationUs, isSeekable, isDynamic, 0);
|
return new MediaWindow(durationUs, isSeekable, isDynamic, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,7 +59,7 @@ public final class Window {
|
|||||||
* @param defaultStartPositionUs The default position relative to the start of the window at which
|
* @param defaultStartPositionUs The default position relative to the start of the window at which
|
||||||
* to start playback, in microseconds.
|
* to start playback, in microseconds.
|
||||||
*/
|
*/
|
||||||
public Window(long durationUs, boolean isSeekable, boolean isDynamic,
|
public MediaWindow(long durationUs, boolean isSeekable, boolean isDynamic,
|
||||||
long defaultStartPositionUs) {
|
long defaultStartPositionUs) {
|
||||||
this.durationUs = durationUs;
|
this.durationUs = durationUs;
|
||||||
this.isSeekable = isSeekable;
|
this.isSeekable = isSeekable;
|
||||||
@ -85,7 +85,7 @@ public final class Window {
|
|||||||
if (obj == null || getClass() != obj.getClass()) {
|
if (obj == null || getClass() != obj.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Window other = (Window) obj;
|
MediaWindow other = (MediaWindow) obj;
|
||||||
return other.durationUs == durationUs
|
return other.durationUs == durationUs
|
||||||
&& other.isSeekable == isSeekable
|
&& other.isSeekable == isSeekable
|
||||||
&& other.isDynamic == isDynamic
|
&& other.isDynamic == isDynamic
|
||||||
@ -94,7 +94,7 @@ public final class Window {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Window[" + durationUs + ", " + defaultStartPositionUs + ", " + isSeekable + ", "
|
return "MediaWindow[" + durationUs + ", " + defaultStartPositionUs + ", " + isSeekable + ", "
|
||||||
+ isDynamic + "]";
|
+ isDynamic + "]";
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +505,7 @@ public final class SimpleExoPlayer implements ExoPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timeline getCurrentTimeline() {
|
public MediaTimeline getCurrentTimeline() {
|
||||||
return player.getCurrentTimeline();
|
return player.getCurrentTimeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ package com.google.android.exoplayer2.source;
|
|||||||
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.Window;
|
import com.google.android.exoplayer2.MediaWindow;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
@ -32,18 +32,18 @@ import java.util.Map;
|
|||||||
public final class ConcatenatingMediaSource implements MediaSource {
|
public final class ConcatenatingMediaSource implements MediaSource {
|
||||||
|
|
||||||
private final MediaSource[] mediaSources;
|
private final MediaSource[] mediaSources;
|
||||||
private final Timeline[] timelines;
|
private final MediaTimeline[] timelines;
|
||||||
private final Object[] manifests;
|
private final Object[] manifests;
|
||||||
private final Map<MediaPeriod, Integer> sourceIndexByMediaPeriod;
|
private final Map<MediaPeriod, Integer> sourceIndexByMediaPeriod;
|
||||||
|
|
||||||
private ConcatenatedTimeline timeline;
|
private ConcatenatedMediaTimeline timeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mediaSources The {@link MediaSource}s to concatenate.
|
* @param mediaSources The {@link MediaSource}s to concatenate.
|
||||||
*/
|
*/
|
||||||
public ConcatenatingMediaSource(MediaSource... mediaSources) {
|
public ConcatenatingMediaSource(MediaSource... mediaSources) {
|
||||||
this.mediaSources = mediaSources;
|
this.mediaSources = mediaSources;
|
||||||
timelines = new Timeline[mediaSources.length];
|
timelines = new MediaTimeline[mediaSources.length];
|
||||||
manifests = new Object[mediaSources.length];
|
manifests = new Object[mediaSources.length];
|
||||||
sourceIndexByMediaPeriod = new HashMap<>();
|
sourceIndexByMediaPeriod = new HashMap<>();
|
||||||
}
|
}
|
||||||
@ -55,16 +55,16 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
|||||||
mediaSources[i].prepareSource(new Listener() {
|
mediaSources[i].prepareSource(new Listener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline sourceTimeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline sourceTimeline, Object manifest) {
|
||||||
timelines[index] = sourceTimeline;
|
timelines[index] = sourceTimeline;
|
||||||
manifests[index] = manifest;
|
manifests[index] = manifest;
|
||||||
for (Timeline timeline : timelines) {
|
for (MediaTimeline timeline : timelines) {
|
||||||
if (timeline == null) {
|
if (timeline == null) {
|
||||||
// Don't invoke the listener until all sources have timelines.
|
// Don't invoke the listener until all sources have timelines.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeline = new ConcatenatedTimeline(timelines.clone());
|
timeline = new ConcatenatedMediaTimeline(timelines.clone());
|
||||||
listener.onSourceInfoRefreshed(timeline, manifests.clone());
|
listener.onSourceInfoRefreshed(timeline, manifests.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,21 +105,21 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Timeline} that is the concatenation of one or more {@link Timeline}s.
|
* A {@link MediaTimeline} that is the concatenation of one or more {@link MediaTimeline}s.
|
||||||
*/
|
*/
|
||||||
private static final class ConcatenatedTimeline implements Timeline {
|
private static final class ConcatenatedMediaTimeline implements MediaTimeline {
|
||||||
|
|
||||||
private final Timeline[] timelines;
|
private final MediaTimeline[] timelines;
|
||||||
private final int[] sourcePeriodOffsets;
|
private final int[] sourcePeriodOffsets;
|
||||||
private final int[] sourceWindowOffsets;
|
private final int[] sourceWindowOffsets;
|
||||||
|
|
||||||
public ConcatenatedTimeline(Timeline[] timelines) {
|
public ConcatenatedMediaTimeline(MediaTimeline[] timelines) {
|
||||||
int[] sourcePeriodOffsets = new int[timelines.length];
|
int[] sourcePeriodOffsets = new int[timelines.length];
|
||||||
int[] sourceWindowOffsets = new int[timelines.length];
|
int[] sourceWindowOffsets = new int[timelines.length];
|
||||||
int periodCount = 0;
|
int periodCount = 0;
|
||||||
int windowCount = 0;
|
int windowCount = 0;
|
||||||
for (int i = 0; i < timelines.length; i++) {
|
for (int i = 0; i < timelines.length; i++) {
|
||||||
Timeline timeline = timelines[i];
|
MediaTimeline timeline = timelines[i];
|
||||||
periodCount += timeline.getPeriodCount();
|
periodCount += timeline.getPeriodCount();
|
||||||
sourcePeriodOffsets[i] = periodCount;
|
sourcePeriodOffsets[i] = periodCount;
|
||||||
windowCount += timeline.getWindowCount();
|
windowCount += timeline.getWindowCount();
|
||||||
@ -163,7 +163,7 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getPeriodWindow(int periodIndex) {
|
public MediaWindow getPeriodWindow(int periodIndex) {
|
||||||
return getWindow(getPeriodWindowIndex(periodIndex));
|
return getWindow(getPeriodWindowIndex(periodIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ public final class ConcatenatingMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getWindow(int windowIndex) {
|
public MediaWindow getWindow(int windowIndex) {
|
||||||
int sourceIndex = getSourceIndexForWindow(windowIndex);
|
int sourceIndex = getSourceIndexForWindow(windowIndex);
|
||||||
int firstWindowIndexInSource = getFirstWindowIndexInSource(sourceIndex);
|
int firstWindowIndexInSource = getFirstWindowIndexInSource(sourceIndex);
|
||||||
return timelines[sourceIndex].getWindow(windowIndex - firstWindowIndexInSource);
|
return timelines[sourceIndex].getWindow(windowIndex - firstWindowIndexInSource);
|
||||||
|
@ -299,7 +299,7 @@ import java.util.Arrays;
|
|||||||
durationUs = largestQueuedTimestampUs == Long.MIN_VALUE ? 0
|
durationUs = largestQueuedTimestampUs == Long.MIN_VALUE ? 0
|
||||||
: largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US;
|
: largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US;
|
||||||
sourceListener.onSourceInfoRefreshed(
|
sourceListener.onSourceInfoRefreshed(
|
||||||
new SinglePeriodTimeline(durationUs, seekMap.isSeekable()), null);
|
new SinglePeriodMediaTimeline(durationUs, seekMap.isSeekable()), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,7 +382,7 @@ import java.util.Arrays;
|
|||||||
tracks = new TrackGroupArray(trackArray);
|
tracks = new TrackGroupArray(trackArray);
|
||||||
prepared = true;
|
prepared = true;
|
||||||
sourceListener.onSourceInfoRefreshed(
|
sourceListener.onSourceInfoRefreshed(
|
||||||
new SinglePeriodTimeline(durationUs, seekMap.isSeekable()), null);
|
new SinglePeriodMediaTimeline(durationUs, seekMap.isSeekable()), null);
|
||||||
callback.onPrepared(this);
|
callback.onPrepared(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,8 +18,8 @@ package com.google.android.exoplayer2.source;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.ParserException;
|
import com.google.android.exoplayer2.ParserException;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
@ -94,7 +94,7 @@ public final class ExtractorMediaSource implements MediaSource, MediaSource.List
|
|||||||
private final EventListener eventListener;
|
private final EventListener eventListener;
|
||||||
|
|
||||||
private MediaSource.Listener sourceListener;
|
private MediaSource.Listener sourceListener;
|
||||||
private Timeline timeline;
|
private MediaTimeline timeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uri The {@link Uri} of the media stream.
|
* @param uri The {@link Uri} of the media stream.
|
||||||
@ -135,7 +135,7 @@ public final class ExtractorMediaSource implements MediaSource, MediaSource.List
|
|||||||
@Override
|
@Override
|
||||||
public void prepareSource(MediaSource.Listener listener) {
|
public void prepareSource(MediaSource.Listener listener) {
|
||||||
sourceListener = listener;
|
sourceListener = listener;
|
||||||
timeline = new SinglePeriodTimeline(C.TIME_UNSET, false);
|
timeline = new SinglePeriodMediaTimeline(C.TIME_UNSET, false);
|
||||||
listener.onSourceInfoRefreshed(timeline, null);
|
listener.onSourceInfoRefreshed(timeline, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ public final class ExtractorMediaSource implements MediaSource, MediaSource.List
|
|||||||
// MediaSource.Listener implementation.
|
// MediaSource.Listener implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
if (this.timeline.getPeriodDurationUs(0) != C.TIME_UNSET
|
if (this.timeline.getPeriodDurationUs(0) != C.TIME_UNSET
|
||||||
&& timeline.getPeriodDurationUs(0) == C.TIME_UNSET) {
|
&& timeline.getPeriodDurationUs(0) == C.TIME_UNSET) {
|
||||||
// Suppress source info changes that would make the duration unknown when it is already known.
|
// Suppress source info changes that would make the duration unknown when it is already known.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.source;
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -36,7 +36,7 @@ public interface MediaSource {
|
|||||||
* @param timeline The source's timeline.
|
* @param timeline The source's timeline.
|
||||||
* @param manifest The loaded manifest.
|
* @param manifest The loaded manifest.
|
||||||
*/
|
*/
|
||||||
void onSourceInfoRefreshed(Timeline timeline, Object manifest);
|
void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import java.util.IdentityHashMap;
|
|||||||
/* package */ final class MergingMediaPeriod implements MediaPeriod, MediaPeriod.Callback {
|
/* package */ final class MergingMediaPeriod implements MediaPeriod, MediaPeriod.Callback {
|
||||||
|
|
||||||
public final MediaPeriod[] periods;
|
public final MediaPeriod[] periods;
|
||||||
|
|
||||||
private final Callback callback;
|
private final Callback callback;
|
||||||
private final IdentityHashMap<SampleStream, Integer> streamPeriodIndices;
|
private final IdentityHashMap<SampleStream, Integer> streamPeriodIndices;
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.source;
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
@ -47,7 +47,7 @@ public final class MergingMediaSource implements MediaSource {
|
|||||||
mediaSources[0].prepareSource(new Listener() {
|
mediaSources[0].prepareSource(new Listener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
checkConsistentTimeline(timeline);
|
checkConsistentTimeline(timeline);
|
||||||
|
|
||||||
// All source timelines must match.
|
// All source timelines must match.
|
||||||
@ -59,7 +59,7 @@ public final class MergingMediaSource implements MediaSource {
|
|||||||
mediaSources[i].prepareSource(new Listener() {
|
mediaSources[i].prepareSource(new Listener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
checkConsistentTimeline(timeline);
|
checkConsistentTimeline(timeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public final class MergingMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkConsistentTimeline(Timeline timeline) {
|
private void checkConsistentTimeline(MediaTimeline timeline) {
|
||||||
int windowCount = timeline.getWindowCount();
|
int windowCount = timeline.getWindowCount();
|
||||||
for (int i = 0; i < windowCount; i++) {
|
for (int i = 0; i < windowCount; i++) {
|
||||||
Assertions.checkArgument(!timeline.getWindow(i).isDynamic);
|
Assertions.checkArgument(!timeline.getWindow(i).isDynamic);
|
||||||
|
@ -16,19 +16,19 @@
|
|||||||
package com.google.android.exoplayer2.source;
|
package com.google.android.exoplayer2.source;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.Window;
|
import com.google.android.exoplayer2.MediaWindow;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Timeline} consisting of a single period and static window.
|
* A {@link MediaTimeline} consisting of a single period and static window.
|
||||||
*/
|
*/
|
||||||
public final class SinglePeriodTimeline implements Timeline {
|
public final class SinglePeriodMediaTimeline implements MediaTimeline {
|
||||||
|
|
||||||
private static final Object ID = new Object();
|
private static final Object ID = new Object();
|
||||||
|
|
||||||
private final long offsetInFirstPeriodUs;
|
private final long offsetInFirstPeriodUs;
|
||||||
private final Window window;
|
private final MediaWindow window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a timeline with one period of known duration and a window extending from zero to its
|
* Creates a timeline with one period of known duration and a window extending from zero to its
|
||||||
@ -37,8 +37,8 @@ public final class SinglePeriodTimeline implements Timeline {
|
|||||||
* @param durationUs The duration of the period, in microseconds.
|
* @param durationUs The duration of the period, in microseconds.
|
||||||
* @param isSeekable Whether seeking is supported within the period.
|
* @param isSeekable Whether seeking is supported within the period.
|
||||||
*/
|
*/
|
||||||
public SinglePeriodTimeline(long durationUs, boolean isSeekable) {
|
public SinglePeriodMediaTimeline(long durationUs, boolean isSeekable) {
|
||||||
this(0, Window.createWindowFromZero(durationUs, isSeekable, false /* isDynamic */));
|
this(0, MediaWindow.createWindowFromZero(durationUs, isSeekable, false /* isDynamic */));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,7 +48,7 @@ public final class SinglePeriodTimeline implements Timeline {
|
|||||||
* @param offsetInFirstPeriodUs The offset of the start of the window in the period.
|
* @param offsetInFirstPeriodUs The offset of the start of the window in the period.
|
||||||
* @param window The available window within the period.
|
* @param window The available window within the period.
|
||||||
*/
|
*/
|
||||||
public SinglePeriodTimeline(long offsetInFirstPeriodUs, Window window) {
|
public SinglePeriodMediaTimeline(long offsetInFirstPeriodUs, MediaWindow window) {
|
||||||
this.offsetInFirstPeriodUs = offsetInFirstPeriodUs;
|
this.offsetInFirstPeriodUs = offsetInFirstPeriodUs;
|
||||||
this.window = window;
|
this.window = window;
|
||||||
}
|
}
|
||||||
@ -82,7 +82,7 @@ public final class SinglePeriodTimeline implements Timeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getPeriodWindow(int periodIndex) {
|
public MediaWindow getPeriodWindow(int periodIndex) {
|
||||||
Assertions.checkIndex(periodIndex, 0, 1);
|
Assertions.checkIndex(periodIndex, 0, 1);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ public final class SinglePeriodTimeline implements Timeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getWindow(int windowIndex) {
|
public MediaWindow getWindow(int windowIndex) {
|
||||||
Assertions.checkIndex(windowIndex, 0, 1);
|
Assertions.checkIndex(windowIndex, 0, 1);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
@ -18,7 +18,7 @@ package com.google.android.exoplayer2.source;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
@ -57,7 +57,7 @@ public final class SingleSampleMediaSource implements MediaSource {
|
|||||||
private final Handler eventHandler;
|
private final Handler eventHandler;
|
||||||
private final EventListener eventListener;
|
private final EventListener eventListener;
|
||||||
private final int eventSourceId;
|
private final int eventSourceId;
|
||||||
private final Timeline timeline;
|
private final MediaTimeline timeline;
|
||||||
|
|
||||||
public SingleSampleMediaSource(Uri uri, DataSource.Factory dataSourceFactory, Format format,
|
public SingleSampleMediaSource(Uri uri, DataSource.Factory dataSourceFactory, Format format,
|
||||||
long durationUs) {
|
long durationUs) {
|
||||||
@ -79,7 +79,7 @@ public final class SingleSampleMediaSource implements MediaSource {
|
|||||||
this.eventHandler = eventHandler;
|
this.eventHandler = eventHandler;
|
||||||
this.eventListener = eventListener;
|
this.eventListener = eventListener;
|
||||||
this.eventSourceId = eventSourceId;
|
this.eventSourceId = eventSourceId;
|
||||||
timeline = new SinglePeriodTimeline(durationUs, true);
|
timeline = new SinglePeriodMediaTimeline(durationUs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MediaSource implementation.
|
// MediaSource implementation.
|
||||||
|
@ -21,9 +21,9 @@ import android.os.SystemClock;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
|
import com.google.android.exoplayer2.MediaWindow;
|
||||||
import com.google.android.exoplayer2.ParserException;
|
import com.google.android.exoplayer2.ParserException;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.Window;
|
|
||||||
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener;
|
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
@ -71,8 +71,8 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
public static final long DEFAULT_LIVE_EDGE_OFFSET_FIXED_MS = 30000;
|
public static final long DEFAULT_LIVE_EDGE_OFFSET_FIXED_MS = 30000;
|
||||||
/**
|
/**
|
||||||
* The interval in milliseconds between invocations of
|
* The interval in milliseconds between invocations of
|
||||||
* {@link MediaSource.Listener#onSourceInfoRefreshed(Timeline, Object)} when the source's
|
* {@link MediaSource.Listener#onSourceInfoRefreshed(MediaTimeline, Object)} when the source's
|
||||||
* {@link Window} is changing dynamically (for example, for incomplete live streams).
|
* {@link MediaWindow} is changing dynamically (for example, for incomplete live streams).
|
||||||
*/
|
*/
|
||||||
private static final int NOTIFY_MANIFEST_INTERVAL_MS = 5000;
|
private static final int NOTIFY_MANIFEST_INTERVAL_MS = 5000;
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
private long manifestLoadEndTimestamp;
|
private long manifestLoadEndTimestamp;
|
||||||
private DashManifest manifest;
|
private DashManifest manifest;
|
||||||
private Handler handler;
|
private Handler handler;
|
||||||
private Window window;
|
private MediaWindow window;
|
||||||
private long elapsedRealtimeOffsetMs;
|
private long elapsedRealtimeOffsetMs;
|
||||||
|
|
||||||
private int firstPeriodId;
|
private int firstPeriodId;
|
||||||
@ -384,9 +384,9 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
defaultInitialTimeUs = Math.max(0, windowDurationUs - (liveEdgeOffsetForManifestMs * 1000));
|
defaultInitialTimeUs = Math.max(0, windowDurationUs - (liveEdgeOffsetForManifestMs * 1000));
|
||||||
}
|
}
|
||||||
window = new Window(windowDurationUs, true /* isSeekable */, manifest.dynamic,
|
window = new MediaWindow(windowDurationUs, true /* isSeekable */, manifest.dynamic,
|
||||||
defaultInitialTimeUs);
|
defaultInitialTimeUs);
|
||||||
sourceListener.onSourceInfoRefreshed(new DashTimeline(firstPeriodId, currentStartTimeUs,
|
sourceListener.onSourceInfoRefreshed(new DashMediaTimeline(firstPeriodId, currentStartTimeUs,
|
||||||
manifest, window), manifest);
|
manifest, window), manifest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -466,15 +466,15 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class DashTimeline implements Timeline {
|
private static final class DashMediaTimeline implements MediaTimeline {
|
||||||
|
|
||||||
private final int firstPeriodId;
|
private final int firstPeriodId;
|
||||||
private final long offsetInFirstPeriodUs;
|
private final long offsetInFirstPeriodUs;
|
||||||
private final DashManifest manifest;
|
private final DashManifest manifest;
|
||||||
private final Window window;
|
private final MediaWindow window;
|
||||||
|
|
||||||
public DashTimeline(int firstPeriodId, long offsetInFirstPeriodUs, DashManifest manifest,
|
public DashMediaTimeline(int firstPeriodId, long offsetInFirstPeriodUs, DashManifest manifest,
|
||||||
Window window) {
|
MediaWindow window) {
|
||||||
this.firstPeriodId = firstPeriodId;
|
this.firstPeriodId = firstPeriodId;
|
||||||
this.offsetInFirstPeriodUs = offsetInFirstPeriodUs;
|
this.offsetInFirstPeriodUs = offsetInFirstPeriodUs;
|
||||||
this.manifest = manifest;
|
this.manifest = manifest;
|
||||||
@ -509,7 +509,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getPeriodWindow(int periodIndex) {
|
public MediaWindow getPeriodWindow(int periodIndex) {
|
||||||
Assertions.checkIndex(periodIndex, 0, manifest.getPeriodCount());
|
Assertions.checkIndex(periodIndex, 0, manifest.getPeriodCount());
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
@ -536,7 +536,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Window getWindow(int windowIndex) {
|
public MediaWindow getWindow(int windowIndex) {
|
||||||
Assertions.checkIndex(windowIndex, 0, 1);
|
Assertions.checkIndex(windowIndex, 0, 1);
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,14 @@ import android.net.Uri;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.ParserException;
|
import com.google.android.exoplayer2.ParserException;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
||||||
import com.google.android.exoplayer2.source.CompositeSequenceableLoader;
|
import com.google.android.exoplayer2.source.CompositeSequenceableLoader;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.SampleStream;
|
import com.google.android.exoplayer2.source.SampleStream;
|
||||||
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
import com.google.android.exoplayer2.source.SinglePeriodMediaTimeline;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.source.hls.playlist.HlsMasterPlaylist;
|
import com.google.android.exoplayer2.source.hls.playlist.HlsMasterPlaylist;
|
||||||
@ -282,7 +282,7 @@ import java.util.List;
|
|||||||
callback.onPrepared(this);
|
callback.onPrepared(this);
|
||||||
|
|
||||||
// TODO[playlists]: Calculate the window.
|
// TODO[playlists]: Calculate the window.
|
||||||
Timeline timeline = new SinglePeriodTimeline(durationUs, !isLive);
|
MediaTimeline timeline = new SinglePeriodMediaTimeline(durationUs, !isLive);
|
||||||
sourceListener.onSourceInfoRefreshed(timeline, playlist);
|
sourceListener.onSourceInfoRefreshed(timeline, playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.Eve
|
|||||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
import com.google.android.exoplayer2.source.SinglePeriodMediaTimeline;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
@ -64,7 +64,7 @@ public final class HlsMediaSource implements MediaSource {
|
|||||||
public void prepareSource(MediaSource.Listener listener) {
|
public void prepareSource(MediaSource.Listener listener) {
|
||||||
sourceListener = listener;
|
sourceListener = listener;
|
||||||
// TODO: Defer until the playlist has been loaded.
|
// TODO: Defer until the playlist has been loaded.
|
||||||
listener.onSourceInfoRefreshed(new SinglePeriodTimeline(C.TIME_UNSET, false), null);
|
listener.onSourceInfoRefreshed(new SinglePeriodMediaTimeline(C.TIME_UNSET, false), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,15 +19,15 @@ import android.net.Uri;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
|
import com.google.android.exoplayer2.MediaWindow;
|
||||||
import com.google.android.exoplayer2.ParserException;
|
import com.google.android.exoplayer2.ParserException;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.Window;
|
|
||||||
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener;
|
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener;
|
||||||
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod;
|
import com.google.android.exoplayer2.source.MediaPeriod;
|
||||||
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
import com.google.android.exoplayer2.source.MediaPeriod.Callback;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.SinglePeriodTimeline;
|
import com.google.android.exoplayer2.source.SinglePeriodMediaTimeline;
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest;
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement;
|
||||||
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
|
import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser;
|
||||||
@ -157,7 +157,7 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
for (int i = 0; i < mediaPeriods.size(); i++) {
|
for (int i = 0; i < mediaPeriods.size(); i++) {
|
||||||
mediaPeriods.get(i).updateManifest(manifest);
|
mediaPeriods.get(i).updateManifest(manifest);
|
||||||
}
|
}
|
||||||
Timeline timeline;
|
MediaTimeline timeline;
|
||||||
if (manifest.isLive) {
|
if (manifest.isLive) {
|
||||||
long startTimeUs = Long.MAX_VALUE;
|
long startTimeUs = Long.MAX_VALUE;
|
||||||
long endTimeUs = Long.MIN_VALUE;
|
long endTimeUs = Long.MIN_VALUE;
|
||||||
@ -170,7 +170,7 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (startTimeUs == Long.MAX_VALUE) {
|
if (startTimeUs == Long.MAX_VALUE) {
|
||||||
timeline = new SinglePeriodTimeline(C.TIME_UNSET, false);
|
timeline = new SinglePeriodMediaTimeline(C.TIME_UNSET, false);
|
||||||
} else {
|
} else {
|
||||||
if (manifest.dvrWindowLengthUs != C.TIME_UNSET
|
if (manifest.dvrWindowLengthUs != C.TIME_UNSET
|
||||||
&& manifest.dvrWindowLengthUs > 0) {
|
&& manifest.dvrWindowLengthUs > 0) {
|
||||||
@ -178,13 +178,13 @@ public final class SsMediaSource implements MediaSource,
|
|||||||
}
|
}
|
||||||
long durationUs = endTimeUs - startTimeUs;
|
long durationUs = endTimeUs - startTimeUs;
|
||||||
long defaultInitialStartPositionUs = Math.max(0, durationUs - (liveEdgeOffsetMs * 1000));
|
long defaultInitialStartPositionUs = Math.max(0, durationUs - (liveEdgeOffsetMs * 1000));
|
||||||
Window window = new Window(durationUs, true /* isSeekable */, true /* isDynamic */,
|
MediaWindow window = new MediaWindow(durationUs, true /* isSeekable */,
|
||||||
defaultInitialStartPositionUs);
|
true /* isDynamic */, defaultInitialStartPositionUs);
|
||||||
timeline = new SinglePeriodTimeline(startTimeUs, window);
|
timeline = new SinglePeriodMediaTimeline(startTimeUs, window);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean isSeekable = manifest.durationUs != C.TIME_UNSET;
|
boolean isSeekable = manifest.durationUs != C.TIME_UNSET;
|
||||||
timeline = new SinglePeriodTimeline(manifest.durationUs, isSeekable);
|
timeline = new SinglePeriodMediaTimeline(manifest.durationUs, isSeekable);
|
||||||
}
|
}
|
||||||
sourceListener.onSourceInfoRefreshed(timeline, manifest);
|
sourceListener.onSourceInfoRefreshed(timeline, manifest);
|
||||||
scheduleManifestRefresh();
|
scheduleManifestRefresh();
|
||||||
|
@ -19,8 +19,8 @@ import android.widget.TextView;
|
|||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +89,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,13 +19,13 @@ import android.view.View;
|
|||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link OnClickListener} that can be passed to
|
* An {@link OnClickListener} that can be passed to
|
||||||
* {@link android.widget.MediaController#setPrevNextListeners(OnClickListener, OnClickListener)} to
|
* {@link android.widget.MediaController#setPrevNextListeners(OnClickListener, OnClickListener)} to
|
||||||
* make the controller's previous and next buttons seek to the previous and next windows in the
|
* make the controller's previous and next buttons seek to the previous and next windows in the
|
||||||
* {@link Timeline}.
|
* {@link MediaTimeline}.
|
||||||
*/
|
*/
|
||||||
public class MediaControllerPrevNextClickListener implements OnClickListener {
|
public class MediaControllerPrevNextClickListener implements OnClickListener {
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public class MediaControllerPrevNextClickListener implements OnClickListener {
|
|||||||
if (currentWindowIndex == C.INDEX_UNSET) {
|
if (currentWindowIndex == C.INDEX_UNSET) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Timeline timeline = player.getCurrentTimeline();
|
MediaTimeline timeline = player.getCurrentTimeline();
|
||||||
if (isNext) {
|
if (isNext) {
|
||||||
if (currentWindowIndex < timeline.getWindowCount() - 1) {
|
if (currentWindowIndex < timeline.getWindowCount() - 1) {
|
||||||
player.seekToDefaultPosition(currentWindowIndex + 1);
|
player.seekToDefaultPosition(currentWindowIndex + 1);
|
||||||
|
@ -24,8 +24,8 @@ import com.google.android.exoplayer2.ExoPlaybackException;
|
|||||||
import com.google.android.exoplayer2.ExoPlayer;
|
import com.google.android.exoplayer2.ExoPlayer;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
import com.google.android.exoplayer2.ExoPlayerFactory;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.MediaTimeline;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
|
||||||
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
|
||||||
import com.google.android.exoplayer2.audio.AudioTrack;
|
import com.google.android.exoplayer2.audio.AudioTrack;
|
||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
@ -215,7 +215,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void onSourceInfoRefreshed(Timeline timeline, Object manifest) {
|
public final void onSourceInfoRefreshed(MediaTimeline timeline, Object manifest) {
|
||||||
// Do nothing.
|
// Do nothing.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user