Commit 48bc98f1 by olly Committed by Oliver Woodman

Naming cleanup.

- RollingSampleBuffer -> DefaultTrackOutput
- TsChunk -> HlsMediaChunk
- Established hls.playlist package for HLS playlist things
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120325049
parent 69b431b8
Showing with 102 additions and 95 deletions
......@@ -30,10 +30,10 @@ import com.google.android.exoplayer.dash.mpd.MediaPresentationDescriptionParser;
import com.google.android.exoplayer.drm.MediaDrmCallback;
import com.google.android.exoplayer.extractor.ExtractorSampleSource;
import com.google.android.exoplayer.hls.HlsChunkSource;
import com.google.android.exoplayer.hls.HlsPlaylist;
import com.google.android.exoplayer.hls.HlsPlaylistParser;
import com.google.android.exoplayer.hls.HlsSampleSource;
import com.google.android.exoplayer.hls.PtsTimestampAdjusterProvider;
import com.google.android.exoplayer.hls.playlist.HlsPlaylist;
import com.google.android.exoplayer.hls.playlist.HlsPlaylistParser;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingChunkSource;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifestParser;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.C;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.C;
......
......@@ -17,18 +17,18 @@ package com.google.android.exoplayer.chunk;
import com.google.android.exoplayer.Format;
import com.google.android.exoplayer.drm.DrmInitData;
import com.google.android.exoplayer.extractor.RollingSampleBuffer;
import com.google.android.exoplayer.extractor.DefaultTrackOutput;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec;
/**
* A base implementation of {@link MediaChunk}, for chunks that contain a single track.
* <p>
* Loaded samples are output to a {@link RollingSampleBuffer}.
* Loaded samples are output to a {@link DefaultTrackOutput}.
*/
public abstract class BaseMediaChunk extends MediaChunk {
private RollingSampleBuffer trackOutput;
private DefaultTrackOutput trackOutput;
private int firstSampleIndex;
/**
......@@ -46,19 +46,19 @@ public abstract class BaseMediaChunk extends MediaChunk {
}
/**
* Initializes the chunk for loading, setting the {@link RollingSampleBuffer} that will receive
* Initializes the chunk for loading, setting the {@link DefaultTrackOutput} that will receive
* samples as they are loaded.
*
* @param trackOutput The output that will receive the loaded samples.
*/
public void init(RollingSampleBuffer trackOutput) {
public void init(DefaultTrackOutput trackOutput) {
this.trackOutput = trackOutput;
this.firstSampleIndex = trackOutput.getWriteIndex();
}
/**
* Returns the index of the first sample in the output that was passed to
* {@link #init(RollingSampleBuffer)} that will originate from this chunk.
* {@link #init(DefaultTrackOutput)} that will originate from this chunk.
*/
public final int getFirstSampleIndex() {
return firstSampleIndex;
......@@ -72,9 +72,9 @@ public abstract class BaseMediaChunk extends MediaChunk {
public abstract DrmInitData getDrmInitData();
/**
* Returns the track output most recently passed to {@link #init(RollingSampleBuffer)}.
* Returns the track output most recently passed to {@link #init(DefaultTrackOutput)}.
*/
protected final RollingSampleBuffer getTrackOutput() {
protected final DefaultTrackOutput getTrackOutput() {
return trackOutput;
}
......
......@@ -26,7 +26,7 @@ import com.google.android.exoplayer.TrackGroupArray;
import com.google.android.exoplayer.TrackSelection;
import com.google.android.exoplayer.TrackStream;
import com.google.android.exoplayer.chunk.ChunkSampleSourceEventListener.EventDispatcher;
import com.google.android.exoplayer.extractor.RollingSampleBuffer;
import com.google.android.exoplayer.extractor.DefaultTrackOutput;
import com.google.android.exoplayer.upstream.Loader;
import com.google.android.exoplayer.upstream.Loader.Loadable;
import com.google.android.exoplayer.util.Assertions;
......@@ -56,7 +56,7 @@ public class ChunkSampleSource implements SampleSource, TrackStream, Loader.Call
private final ChunkHolder nextChunkHolder;
private final LinkedList<BaseMediaChunk> mediaChunks;
private final List<BaseMediaChunk> readOnlyMediaChunks;
private final RollingSampleBuffer sampleQueue;
private final DefaultTrackOutput sampleQueue;
private final int bufferSizeContribution;
private final EventDispatcher eventDispatcher;
......@@ -125,7 +125,7 @@ public class ChunkSampleSource implements SampleSource, TrackStream, Loader.Call
nextChunkHolder = new ChunkHolder();
mediaChunks = new LinkedList<>();
readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
sampleQueue = new RollingSampleBuffer(loadControl.getAllocator());
sampleQueue = new DefaultTrackOutput(loadControl.getAllocator());
pendingResetPositionUs = C.UNSET_TIME_US;
}
......
......@@ -19,9 +19,9 @@ import com.google.android.exoplayer.Format;
import com.google.android.exoplayer.chunk.ChunkExtractorWrapper.SingleTrackMetadataOutput;
import com.google.android.exoplayer.drm.DrmInitData;
import com.google.android.exoplayer.extractor.DefaultExtractorInput;
import com.google.android.exoplayer.extractor.DefaultTrackOutput;
import com.google.android.exoplayer.extractor.Extractor;
import com.google.android.exoplayer.extractor.ExtractorInput;
import com.google.android.exoplayer.extractor.RollingSampleBuffer;
import com.google.android.exoplayer.extractor.SeekMap;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec;
......@@ -111,7 +111,7 @@ public class ContainerMediaChunk extends BaseMediaChunk implements SingleTrackMe
loadDataSpec.absoluteStreamPosition, dataSource.open(loadDataSpec));
if (bytesLoaded == 0) {
// Set the target to ourselves.
RollingSampleBuffer trackOutput = getTrackOutput();
DefaultTrackOutput trackOutput = getTrackOutput();
trackOutput.formatWithOffset(sampleFormat, sampleOffsetUs);
extractorWrapper.init(this, trackOutput);
}
......
......@@ -19,8 +19,8 @@ import com.google.android.exoplayer.C;
import com.google.android.exoplayer.Format;
import com.google.android.exoplayer.drm.DrmInitData;
import com.google.android.exoplayer.extractor.DefaultExtractorInput;
import com.google.android.exoplayer.extractor.DefaultTrackOutput;
import com.google.android.exoplayer.extractor.ExtractorInput;
import com.google.android.exoplayer.extractor.RollingSampleBuffer;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec;
import com.google.android.exoplayer.util.Util;
......@@ -91,7 +91,7 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk {
length += bytesLoaded;
}
ExtractorInput extractorInput = new DefaultExtractorInput(dataSource, bytesLoaded, length);
RollingSampleBuffer trackOutput = getTrackOutput();
DefaultTrackOutput trackOutput = getTrackOutput();
trackOutput.formatWithOffset(sampleFormat, 0);
// Load the sample data.
int result = 0;
......
......@@ -29,9 +29,10 @@ import java.nio.ByteBuffer;
import java.util.concurrent.LinkedBlockingDeque;
/**
* A rolling buffer of sample data and corresponding sample information.
* A {@link TrackOutput} that buffers extracted samples in a queue and allows for consumption from
* that queue.
*/
public final class RollingSampleBuffer implements TrackOutput {
public final class DefaultTrackOutput implements TrackOutput {
private static final int INITIAL_SCRATCH_SIZE = 32;
......@@ -60,7 +61,7 @@ public final class RollingSampleBuffer implements TrackOutput {
/**
* @param allocator An {@link Allocator} from which allocations for sample data can be obtained.
*/
public RollingSampleBuffer(Allocator allocator) {
public DefaultTrackOutput(Allocator allocator) {
this.allocator = allocator;
allocationLength = allocator.getIndividualAllocationLength();
infoQueue = new InfoQueue();
......
......@@ -208,7 +208,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
private boolean prepared;
private boolean seenFirstTrackSelection;
private int enabledTrackCount;
private RollingSampleBuffer[] sampleQueues;
private DefaultTrackOutput[] sampleQueues;
private TrackGroupArray tracks;
private long durationUs;
private boolean[] pendingMediaFormat;
......@@ -324,7 +324,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
}
extractorHolder = new ExtractorHolder(extractors, this);
pendingResetPositionUs = C.UNSET_TIME_US;
sampleQueues = new RollingSampleBuffer[0];
sampleQueues = new DefaultTrackOutput[0];
}
// SampleSource implementation.
......@@ -425,7 +425,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
return pendingResetPositionUs;
} else {
long largestQueuedTimestampUs = Long.MIN_VALUE;
for (RollingSampleBuffer sampleQueue : sampleQueues) {
for (DefaultTrackOutput sampleQueue : sampleQueues) {
largestQueuedTimestampUs = Math.max(largestQueuedTimestampUs,
sampleQueue.getLargestQueuedTimestampUs());
}
......@@ -473,7 +473,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
return TrackStream.NOTHING_READ;
}
RollingSampleBuffer sampleQueue = sampleQueues[track];
DefaultTrackOutput sampleQueue = sampleQueues[track];
if (pendingMediaFormat[track]) {
formatHolder.format = sampleQueue.getUpstreamFormat();
formatHolder.drmInitData = drmInitData;
......@@ -538,7 +538,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
@Override
public TrackOutput track(int id) {
sampleQueues = Arrays.copyOf(sampleQueues, sampleQueues.length + 1);
RollingSampleBuffer sampleQueue = new RollingSampleBuffer(allocator);
DefaultTrackOutput sampleQueue = new DefaultTrackOutput(allocator);
sampleQueues[sampleQueues.length - 1] = sampleQueue;
return sampleQueue;
}
......@@ -634,14 +634,14 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
private int getExtractedSamplesCount() {
int extractedSamplesCount = 0;
for (RollingSampleBuffer sampleQueue : sampleQueues) {
for (DefaultTrackOutput sampleQueue : sampleQueues) {
extractedSamplesCount += sampleQueue.getWriteIndex();
}
return extractedSamplesCount;
}
private boolean haveFormatsForAllTracks() {
for (RollingSampleBuffer sampleQueue : sampleQueues) {
for (DefaultTrackOutput sampleQueue : sampleQueues) {
if (sampleQueue.getUpstreamFormat() == null) {
return false;
}
......@@ -664,7 +664,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
}
private void clearSampleQueues() {
for (RollingSampleBuffer sampleQueue : sampleQueues) {
for (DefaultTrackOutput sampleQueue : sampleQueues) {
sampleQueue.clear();
}
}
......
......@@ -28,6 +28,11 @@ import com.google.android.exoplayer.extractor.mp3.Mp3Extractor;
import com.google.android.exoplayer.extractor.ts.AdtsExtractor;
import com.google.android.exoplayer.extractor.ts.PtsTimestampAdjuster;
import com.google.android.exoplayer.extractor.ts.TsExtractor;
import com.google.android.exoplayer.hls.playlist.HlsMasterPlaylist;
import com.google.android.exoplayer.hls.playlist.HlsMediaPlaylist;
import com.google.android.exoplayer.hls.playlist.HlsPlaylist;
import com.google.android.exoplayer.hls.playlist.HlsPlaylistParser;
import com.google.android.exoplayer.hls.playlist.Variant;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec;
import com.google.android.exoplayer.upstream.HttpDataSource.InvalidResponseCodeException;
......@@ -325,7 +330,7 @@ public class HlsChunkSource {
* should be interpreted as a seek position.
* @param out A holder to populate.
*/
public void getNextChunk(TsChunk previous, long playbackPositionUs, ChunkHolder out) {
public void getNextChunk(HlsMediaChunk previous, long playbackPositionUs, ChunkHolder out) {
int variantIndex = getNextVariantIndex(previous, playbackPositionUs);
boolean switchingVariant = previous != null
&& variants[variantIndex].format != previous.format;
......@@ -450,7 +455,7 @@ public class HlsChunkSource {
extractorNeedsInit = false;
}
out.chunk = new TsChunk(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs,
out.chunk = new HlsMediaChunk(dataSource, dataSpec, trigger, format, startTimeUs, endTimeUs,
chunkMediaSequence, segment.discontinuitySequenceNumber, extractor, extractorNeedsInit,
switchingVariant, encryptionKey, encryptionIv);
}
......@@ -576,7 +581,7 @@ public class HlsChunkSource {
return false;
}
private int getNextVariantIndex(TsChunk previous, long playbackPositionUs) {
private int getNextVariantIndex(HlsMediaChunk previous, long playbackPositionUs) {
clearStaleBlacklistedVariants();
if (enabledVariants.length > 1) {
long bufferedDurationUs;
......
......@@ -27,9 +27,9 @@ import com.google.android.exoplayer.util.Util;
import java.io.IOException;
/**
* An MPEG2TS chunk.
* An HLS {@link MediaChunk}.
*/
public final class TsChunk extends MediaChunk {
/* package */ final class HlsMediaChunk extends MediaChunk {
/**
* The discontinuity sequence number of the chunk.
......@@ -65,7 +65,7 @@ public final class TsChunk extends MediaChunk {
* @param encryptionKey For AES encryption chunks, the encryption key.
* @param encryptionIv For AES encryption chunks, the encryption initialization vector.
*/
public TsChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format,
public HlsMediaChunk(DataSource dataSource, DataSpec dataSpec, int trigger, Format format,
long startTimeUs, long endTimeUs, int chunkIndex, int discontinuitySequenceNumber,
Extractor extractor, boolean extractorNeedsInit, boolean shouldSpliceIn,
byte[] encryptionKey, byte[] encryptionIv) {
......
......@@ -16,8 +16,8 @@
package com.google.android.exoplayer.hls;
import com.google.android.exoplayer.drm.DrmInitData;
import com.google.android.exoplayer.extractor.DefaultTrackOutput;
import com.google.android.exoplayer.extractor.ExtractorOutput;
import com.google.android.exoplayer.extractor.RollingSampleBuffer;
import com.google.android.exoplayer.extractor.SeekMap;
import com.google.android.exoplayer.upstream.Allocator;
......@@ -29,10 +29,10 @@ import android.util.SparseArray;
/* package */ final class HlsOutput implements ExtractorOutput {
private final Allocator allocator;
private final SparseArray<RollingSampleBuffer> sampleQueues = new SparseArray<>();
private final SparseArray<DefaultTrackOutput> sampleQueues = new SparseArray<>();
private boolean prepared;
private RollingSampleBuffer[] trackOutputArray;
private DefaultTrackOutput[] trackOutputArray;
private volatile boolean tracksBuilt;
public HlsOutput(Allocator allocator) {
......@@ -53,12 +53,12 @@ import android.util.SparseArray;
return false;
} else {
if (trackOutputArray == null) {
trackOutputArray = new RollingSampleBuffer[sampleQueues.size()];
trackOutputArray = new DefaultTrackOutput[sampleQueues.size()];
for (int i = 0; i < trackOutputArray.length; i++) {
trackOutputArray[i] = sampleQueues.valueAt(i);
}
}
for (RollingSampleBuffer sampleQueue : trackOutputArray) {
for (DefaultTrackOutput sampleQueue : trackOutputArray) {
if (sampleQueue.getUpstreamFormat() == null) {
return false;
}
......@@ -71,7 +71,7 @@ import android.util.SparseArray;
/**
* Returns the array of track outputs, or null if the output is not yet prepared.
*/
public RollingSampleBuffer[] getTrackOutputs() {
public DefaultTrackOutput[] getTrackOutputs() {
return trackOutputArray;
}
......@@ -98,11 +98,11 @@ import android.util.SparseArray;
// ExtractorOutput implementation. Called by the loading thread.
@Override
public RollingSampleBuffer track(int id) {
public DefaultTrackOutput track(int id) {
if (sampleQueues.indexOfKey(id) >= 0) {
return sampleQueues.get(id);
}
RollingSampleBuffer trackOutput = new RollingSampleBuffer(allocator);
DefaultTrackOutput trackOutput = new DefaultTrackOutput(allocator);
sampleQueues.put(id, trackOutput);
return trackOutput;
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.Format;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.C;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.ParserException;
......
......@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
/**
* Represents an HLS playlist.
*/
public abstract class HlsPlaylist {
public final static int TYPE_MASTER = 0;
public final static int TYPE_MEDIA = 1;
public static final int TYPE_MASTER = 0;
public static final int TYPE_MEDIA = 1;
public final String baseUri;
public final int type;
......
......@@ -13,12 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.Format;
import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.hls.HlsMediaPlaylist.Segment;
import com.google.android.exoplayer.hls.playlist.HlsMediaPlaylist.Segment;
import com.google.android.exoplayer.upstream.UriLoadable;
import com.google.android.exoplayer.util.MimeTypes;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.android.exoplayer.hls;
package com.google.android.exoplayer.hls.playlist;
import com.google.android.exoplayer.Format;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment