Commit ed0b02d0 by Oliver Woodman

Package restructuring to accommodate incoming features (sorry).

This may be painful in terms of applications having to change their
imports. Sorry about that.
parent 27c0e7d7
Showing with 67 additions and 54 deletions
...@@ -58,7 +58,7 @@ accompanying demo application. To get started: ...@@ -58,7 +58,7 @@ accompanying demo application. To get started:
ExoPlayer can also be built using Gradle. You can include it as a dependent project and build from source. e.g. ExoPlayer can also be built using Gradle. You can include it as a dependent project and build from source. e.g.
``` ```
// setting.gradle // settings.gradle
include ':app', ':..:ExoPlayer:library' include ':app', ':..:ExoPlayer:library'
// app/build.gradle // app/build.gradle
......
...@@ -117,9 +117,11 @@ public class FullPlayerActivity extends Activity implements SurfaceHolder.Callba ...@@ -117,9 +117,11 @@ public class FullPlayerActivity extends Activity implements SurfaceHolder.Callba
View root = findViewById(R.id.root); View root = findViewById(R.id.root);
root.setOnTouchListener(new OnTouchListener() { root.setOnTouchListener(new OnTouchListener() {
@Override @Override
public boolean onTouch(View arg0, MotionEvent arg1) { public boolean onTouch(View view, MotionEvent motionEvent) {
if (arg1.getAction() == MotionEvent.ACTION_DOWN) { if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
toggleControlsVisibility(); toggleControlsVisibility();
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
view.performClick();
} }
return true; return true;
} }
......
...@@ -18,7 +18,7 @@ package com.google.android.exoplayer.chunk; ...@@ -18,7 +18,7 @@ package com.google.android.exoplayer.chunk;
import com.google.android.exoplayer.MediaFormat; import com.google.android.exoplayer.MediaFormat;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.SampleHolder; import com.google.android.exoplayer.SampleHolder;
import com.google.android.exoplayer.parser.Extractor; import com.google.android.exoplayer.chunk.parser.Extractor;
import com.google.android.exoplayer.upstream.DataSource; import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec; import com.google.android.exoplayer.upstream.DataSpec;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
...@@ -28,9 +28,9 @@ import java.util.Map; ...@@ -28,9 +28,9 @@ import java.util.Map;
import java.util.UUID; import java.util.UUID;
/** /**
* An Mp4 {@link MediaChunk}. * A {@link MediaChunk} extracted from a container.
*/ */
public final class Mp4MediaChunk extends MediaChunk { public final class ContainerMediaChunk extends MediaChunk {
private final Extractor extractor; private final Extractor extractor;
private final boolean maybeSelfContained; private final boolean maybeSelfContained;
...@@ -44,7 +44,7 @@ public final class Mp4MediaChunk extends MediaChunk { ...@@ -44,7 +44,7 @@ public final class Mp4MediaChunk extends MediaChunk {
* @deprecated Use the other constructor, passing null as {@code psshInfo}. * @deprecated Use the other constructor, passing null as {@code psshInfo}.
*/ */
@Deprecated @Deprecated
public Mp4MediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format,
int trigger, long startTimeUs, long endTimeUs, int nextChunkIndex, int trigger, long startTimeUs, long endTimeUs, int nextChunkIndex,
Extractor extractor, boolean maybeSelfContained, long sampleOffsetUs) { Extractor extractor, boolean maybeSelfContained, long sampleOffsetUs) {
this(dataSource, dataSpec, format, trigger, startTimeUs, endTimeUs, nextChunkIndex, this(dataSource, dataSpec, format, trigger, startTimeUs, endTimeUs, nextChunkIndex,
...@@ -68,7 +68,7 @@ public final class Mp4MediaChunk extends MediaChunk { ...@@ -68,7 +68,7 @@ public final class Mp4MediaChunk extends MediaChunk {
* improve startup latency. * improve startup latency.
* @param sampleOffsetUs An offset to subtract from the sample timestamps parsed by the extractor. * @param sampleOffsetUs An offset to subtract from the sample timestamps parsed by the extractor.
*/ */
public Mp4MediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, public ContainerMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format,
int trigger, long startTimeUs, long endTimeUs, int nextChunkIndex, Extractor extractor, int trigger, long startTimeUs, long endTimeUs, int nextChunkIndex, Extractor extractor,
Map<UUID, byte[]> psshInfo, boolean maybeSelfContained, long sampleOffsetUs) { Map<UUID, byte[]> psshInfo, boolean maybeSelfContained, long sampleOffsetUs) {
super(dataSource, dataSpec, format, trigger, startTimeUs, endTimeUs, nextChunkIndex); super(dataSource, dataSpec, format, trigger, startTimeUs, endTimeUs, nextChunkIndex);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser; package com.google.android.exoplayer.chunk.parser;
import com.google.android.exoplayer.MediaFormat; import com.google.android.exoplayer.MediaFormat;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser; package com.google.android.exoplayer.chunk.parser;
/** /**
* Defines segments within a media stream. * Defines segments within a media stream.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.chunk.parser.mp4;
/* package */ final class DefaultSampleValues { /* package */ final class DefaultSampleValues {
......
...@@ -13,20 +13,23 @@ ...@@ -13,20 +13,23 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.chunk.parser.mp4;
import com.google.android.exoplayer.C; import com.google.android.exoplayer.C;
import com.google.android.exoplayer.MediaFormat; import com.google.android.exoplayer.MediaFormat;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.SampleHolder; import com.google.android.exoplayer.SampleHolder;
import com.google.android.exoplayer.parser.Extractor; import com.google.android.exoplayer.chunk.parser.Extractor;
import com.google.android.exoplayer.parser.SegmentIndex; import com.google.android.exoplayer.chunk.parser.SegmentIndex;
import com.google.android.exoplayer.parser.mp4.Atom.ContainerAtom; import com.google.android.exoplayer.mp4.Atom;
import com.google.android.exoplayer.parser.mp4.Atom.LeafAtom; import com.google.android.exoplayer.mp4.Atom.ContainerAtom;
import com.google.android.exoplayer.mp4.Atom.LeafAtom;
import com.google.android.exoplayer.mp4.Track;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
import com.google.android.exoplayer.util.Assertions; import com.google.android.exoplayer.util.Assertions;
import com.google.android.exoplayer.util.CodecSpecificDataUtil; import com.google.android.exoplayer.util.CodecSpecificDataUtil;
import com.google.android.exoplayer.util.MimeTypes; import com.google.android.exoplayer.util.MimeTypes;
import com.google.android.exoplayer.util.ParsableByteArray;
import com.google.android.exoplayer.util.Util; import com.google.android.exoplayer.util.Util;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.chunk.parser.mp4;
/** /**
* Encapsulates information parsed from a track encryption (tenc) box in an MP4 stream. * Encapsulates information parsed from a track encryption (tenc) box in an MP4 stream.
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.chunk.parser.mp4;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
import com.google.android.exoplayer.util.ParsableByteArray;
/** /**
* A holder for information corresponding to a single fragment of an mp4 file. * A holder for information corresponding to a single fragment of an mp4 file.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.webm; package com.google.android.exoplayer.chunk.parser.webm;
import com.google.android.exoplayer.C; import com.google.android.exoplayer.C;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.webm; package com.google.android.exoplayer.chunk.parser.webm;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.webm; package com.google.android.exoplayer.chunk.parser.webm;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
......
...@@ -13,13 +13,13 @@ ...@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.webm; package com.google.android.exoplayer.chunk.parser.webm;
import com.google.android.exoplayer.MediaFormat; import com.google.android.exoplayer.MediaFormat;
import com.google.android.exoplayer.ParserException; import com.google.android.exoplayer.ParserException;
import com.google.android.exoplayer.SampleHolder; import com.google.android.exoplayer.SampleHolder;
import com.google.android.exoplayer.parser.Extractor; import com.google.android.exoplayer.chunk.parser.Extractor;
import com.google.android.exoplayer.parser.SegmentIndex; import com.google.android.exoplayer.chunk.parser.SegmentIndex;
import com.google.android.exoplayer.upstream.NonBlockingInputStream; import com.google.android.exoplayer.upstream.NonBlockingInputStream;
import com.google.android.exoplayer.util.LongArray; import com.google.android.exoplayer.util.LongArray;
import com.google.android.exoplayer.util.MimeTypes; import com.google.android.exoplayer.util.MimeTypes;
......
...@@ -23,22 +23,22 @@ import com.google.android.exoplayer.TrackRenderer; ...@@ -23,22 +23,22 @@ import com.google.android.exoplayer.TrackRenderer;
import com.google.android.exoplayer.chunk.Chunk; import com.google.android.exoplayer.chunk.Chunk;
import com.google.android.exoplayer.chunk.ChunkOperationHolder; import com.google.android.exoplayer.chunk.ChunkOperationHolder;
import com.google.android.exoplayer.chunk.ChunkSource; import com.google.android.exoplayer.chunk.ChunkSource;
import com.google.android.exoplayer.chunk.ContainerMediaChunk;
import com.google.android.exoplayer.chunk.Format; import com.google.android.exoplayer.chunk.Format;
import com.google.android.exoplayer.chunk.Format.DecreasingBandwidthComparator; import com.google.android.exoplayer.chunk.Format.DecreasingBandwidthComparator;
import com.google.android.exoplayer.chunk.FormatEvaluator; import com.google.android.exoplayer.chunk.FormatEvaluator;
import com.google.android.exoplayer.chunk.FormatEvaluator.Evaluation; import com.google.android.exoplayer.chunk.FormatEvaluator.Evaluation;
import com.google.android.exoplayer.chunk.MediaChunk; import com.google.android.exoplayer.chunk.MediaChunk;
import com.google.android.exoplayer.chunk.Mp4MediaChunk;
import com.google.android.exoplayer.chunk.SingleSampleMediaChunk; import com.google.android.exoplayer.chunk.SingleSampleMediaChunk;
import com.google.android.exoplayer.chunk.parser.Extractor;
import com.google.android.exoplayer.chunk.parser.mp4.FragmentedMp4Extractor;
import com.google.android.exoplayer.chunk.parser.webm.WebmExtractor;
import com.google.android.exoplayer.dash.mpd.AdaptationSet; import com.google.android.exoplayer.dash.mpd.AdaptationSet;
import com.google.android.exoplayer.dash.mpd.ContentProtection; import com.google.android.exoplayer.dash.mpd.ContentProtection;
import com.google.android.exoplayer.dash.mpd.MediaPresentationDescription; import com.google.android.exoplayer.dash.mpd.MediaPresentationDescription;
import com.google.android.exoplayer.dash.mpd.Period; import com.google.android.exoplayer.dash.mpd.Period;
import com.google.android.exoplayer.dash.mpd.RangedUri; import com.google.android.exoplayer.dash.mpd.RangedUri;
import com.google.android.exoplayer.dash.mpd.Representation; import com.google.android.exoplayer.dash.mpd.Representation;
import com.google.android.exoplayer.parser.Extractor;
import com.google.android.exoplayer.parser.mp4.FragmentedMp4Extractor;
import com.google.android.exoplayer.parser.webm.WebmExtractor;
import com.google.android.exoplayer.text.webvtt.WebvttParser; import com.google.android.exoplayer.text.webvtt.WebvttParser;
import com.google.android.exoplayer.upstream.DataSource; import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec; import com.google.android.exoplayer.upstream.DataSpec;
...@@ -464,9 +464,9 @@ public class DashChunkSource implements ChunkSource { ...@@ -464,9 +464,9 @@ public class DashChunkSource implements ChunkSource {
return new SingleSampleMediaChunk(dataSource, dataSpec, representation.format, 0, return new SingleSampleMediaChunk(dataSource, dataSpec, representation.format, 0,
startTimeUs, endTimeUs, nextAbsoluteSegmentNum, null, representationHolder.vttHeader); startTimeUs, endTimeUs, nextAbsoluteSegmentNum, null, representationHolder.vttHeader);
} else { } else {
return new Mp4MediaChunk(dataSource, dataSpec, representation.format, trigger, startTimeUs, return new ContainerMediaChunk(dataSource, dataSpec, representation.format, trigger,
endTimeUs, nextAbsoluteSegmentNum, representationHolder.extractor, psshInfo, false, startTimeUs, endTimeUs, nextAbsoluteSegmentNum, representationHolder.extractor, psshInfo,
presentationTimeOffsetUs); false, presentationTimeOffsetUs);
} }
} }
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
*/ */
package com.google.android.exoplayer.dash; package com.google.android.exoplayer.dash;
import com.google.android.exoplayer.chunk.parser.SegmentIndex;
import com.google.android.exoplayer.dash.mpd.RangedUri; import com.google.android.exoplayer.dash.mpd.RangedUri;
import com.google.android.exoplayer.parser.SegmentIndex;
import com.google.android.exoplayer.util.Util; import com.google.android.exoplayer.util.Util;
import android.net.Uri; import android.net.Uri;
......
...@@ -13,11 +13,13 @@ ...@@ -13,11 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.mp4;
import com.google.android.exoplayer.util.ParsableByteArray;
import java.util.ArrayList; import java.util.ArrayList;
/* package */ abstract class Atom { public abstract class Atom {
public static final int TYPE_avc1 = 0x61766331; public static final int TYPE_avc1 = 0x61766331;
public static final int TYPE_avc3 = 0x61766333; public static final int TYPE_avc3 = 0x61766333;
...@@ -66,7 +68,7 @@ import java.util.ArrayList; ...@@ -66,7 +68,7 @@ import java.util.ArrayList;
this.type = type; this.type = type;
} }
public final static class LeafAtom extends Atom { public static final class LeafAtom extends Atom {
public final ParsableByteArray data; public final ParsableByteArray data;
...@@ -77,7 +79,7 @@ import java.util.ArrayList; ...@@ -77,7 +79,7 @@ import java.util.ArrayList;
} }
public final static class ContainerAtom extends Atom { public static final class ContainerAtom extends Atom {
public final ArrayList<Atom> children; public final ArrayList<Atom> children;
public final int endByteOffset; public final int endByteOffset;
......
...@@ -13,9 +13,10 @@ ...@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.mp4;
import com.google.android.exoplayer.MediaFormat; import com.google.android.exoplayer.MediaFormat;
import com.google.android.exoplayer.chunk.parser.mp4.TrackEncryptionBox;
/** /**
* Encapsulates information describing an MP4 track. * Encapsulates information describing an MP4 track.
......
...@@ -21,16 +21,16 @@ import com.google.android.exoplayer.TrackInfo; ...@@ -21,16 +21,16 @@ import com.google.android.exoplayer.TrackInfo;
import com.google.android.exoplayer.chunk.Chunk; import com.google.android.exoplayer.chunk.Chunk;
import com.google.android.exoplayer.chunk.ChunkOperationHolder; import com.google.android.exoplayer.chunk.ChunkOperationHolder;
import com.google.android.exoplayer.chunk.ChunkSource; import com.google.android.exoplayer.chunk.ChunkSource;
import com.google.android.exoplayer.chunk.ContainerMediaChunk;
import com.google.android.exoplayer.chunk.Format; import com.google.android.exoplayer.chunk.Format;
import com.google.android.exoplayer.chunk.Format.DecreasingBandwidthComparator; import com.google.android.exoplayer.chunk.Format.DecreasingBandwidthComparator;
import com.google.android.exoplayer.chunk.FormatEvaluator; import com.google.android.exoplayer.chunk.FormatEvaluator;
import com.google.android.exoplayer.chunk.FormatEvaluator.Evaluation; import com.google.android.exoplayer.chunk.FormatEvaluator.Evaluation;
import com.google.android.exoplayer.chunk.MediaChunk; import com.google.android.exoplayer.chunk.MediaChunk;
import com.google.android.exoplayer.chunk.Mp4MediaChunk; import com.google.android.exoplayer.chunk.parser.Extractor;
import com.google.android.exoplayer.parser.Extractor; import com.google.android.exoplayer.chunk.parser.mp4.FragmentedMp4Extractor;
import com.google.android.exoplayer.parser.mp4.FragmentedMp4Extractor; import com.google.android.exoplayer.chunk.parser.mp4.TrackEncryptionBox;
import com.google.android.exoplayer.parser.mp4.Track; import com.google.android.exoplayer.mp4.Track;
import com.google.android.exoplayer.parser.mp4.TrackEncryptionBox;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.ProtectionElement; import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.ProtectionElement;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement; import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.StreamElement;
import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.TrackElement; import com.google.android.exoplayer.smoothstreaming.SmoothStreamingManifest.TrackElement;
...@@ -373,7 +373,7 @@ public class SmoothStreamingChunkSource implements ChunkSource { ...@@ -373,7 +373,7 @@ public class SmoothStreamingChunkSource implements ChunkSource {
DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey); DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
// In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk. // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
// To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs. // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
return new Mp4MediaChunk(dataSource, dataSpec, formatInfo, trigger, chunkStartTimeUs, return new ContainerMediaChunk(dataSource, dataSpec, formatInfo, trigger, chunkStartTimeUs,
nextStartTimeUs, nextChunkIndex, extractor, psshInfo, false, -chunkStartTimeUs); nextStartTimeUs, nextChunkIndex, extractor, psshInfo, false, -chunkStartTimeUs);
} }
......
...@@ -18,7 +18,6 @@ package com.google.android.exoplayer.text.eia608; ...@@ -18,7 +18,6 @@ package com.google.android.exoplayer.text.eia608;
import com.google.android.exoplayer.util.BitArray; import com.google.android.exoplayer.util.BitArray;
import com.google.android.exoplayer.util.MimeTypes; import com.google.android.exoplayer.util.MimeTypes;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
...@@ -87,7 +86,7 @@ public class Eia608Parser { ...@@ -87,7 +86,7 @@ public class Eia608Parser {
return mimeType.equals(MimeTypes.APPLICATION_EIA608); return mimeType.equals(MimeTypes.APPLICATION_EIA608);
} }
public List<ClosedCaption> parse(byte[] data, int size, long timeUs) throws IOException { public List<ClosedCaption> parse(byte[] data, int size, long timeUs) {
if (size <= 0) { if (size <= 0) {
return null; return null;
} }
......
...@@ -25,6 +25,7 @@ import com.google.android.exoplayer.upstream.cache.CacheDataSink.CacheDataSinkEx ...@@ -25,6 +25,7 @@ import com.google.android.exoplayer.upstream.cache.CacheDataSink.CacheDataSinkEx
import com.google.android.exoplayer.util.Assertions; import com.google.android.exoplayer.util.Assertions;
import android.net.Uri; import android.net.Uri;
import android.util.Log;
import java.io.IOException; import java.io.IOException;
...@@ -50,6 +51,8 @@ public final class CacheDataSource implements DataSource { ...@@ -50,6 +51,8 @@ public final class CacheDataSource implements DataSource {
} }
private static final String TAG = "CacheDataSource";
private final Cache cache; private final Cache cache;
private final DataSource cacheReadDataSource; private final DataSource cacheReadDataSource;
private final DataSource cacheWriteDataSource; private final DataSource cacheWriteDataSource;
...@@ -123,9 +126,6 @@ public final class CacheDataSource implements DataSource { ...@@ -123,9 +126,6 @@ public final class CacheDataSource implements DataSource {
@Override @Override
public long open(DataSpec dataSpec) throws IOException { public long open(DataSpec dataSpec) throws IOException {
Assertions.checkState(dataSpec.uriIsFullStream); Assertions.checkState(dataSpec.uriIsFullStream);
// TODO: Support caching for unbounded requests. This requires storing the source length
// into the cache (the simplest approach is to incorporate it into each cache file's name).
Assertions.checkState(dataSpec.length != C.LENGTH_UNBOUNDED);
try { try {
uri = dataSpec.uri; uri = dataSpec.uri;
key = dataSpec.key; key = dataSpec.key;
...@@ -148,10 +148,12 @@ public final class CacheDataSource implements DataSource { ...@@ -148,10 +148,12 @@ public final class CacheDataSource implements DataSource {
totalCachedBytesRead += bytesRead; totalCachedBytesRead += bytesRead;
} }
readPosition += bytesRead; readPosition += bytesRead;
bytesRemaining -= bytesRead; if (bytesRemaining != C.LENGTH_UNBOUNDED) {
bytesRemaining -= bytesRead;
}
} else { } else {
closeCurrentSource(); closeCurrentSource();
if (bytesRemaining > 0) { if (bytesRemaining > 0 && bytesRemaining != C.LENGTH_UNBOUNDED) {
openNextSource(); openNextSource();
return read(buffer, offset, max); return read(buffer, offset, max);
} }
...@@ -185,6 +187,11 @@ public final class CacheDataSource implements DataSource { ...@@ -185,6 +187,11 @@ public final class CacheDataSource implements DataSource {
CacheSpan span; CacheSpan span;
if (ignoreCache) { if (ignoreCache) {
span = null; span = null;
} else if (bytesRemaining == C.LENGTH_UNBOUNDED) {
// TODO: Support caching for unbounded requests. This requires storing the source length
// into the cache (the simplest approach is to incorporate it into each cache file's name).
Log.w(TAG, "Cache bypassed due to unbounded length.");
span = null;
} else if (blockOnCache) { } else if (blockOnCache) {
span = cache.startReadWrite(key, readPosition); span = cache.startReadWrite(key, readPosition);
} else { } else {
......
...@@ -13,9 +13,7 @@ ...@@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package com.google.android.exoplayer.parser.mp4; package com.google.android.exoplayer.util;
import com.google.android.exoplayer.util.Assertions;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
...@@ -23,7 +21,7 @@ import java.nio.ByteBuffer; ...@@ -23,7 +21,7 @@ import java.nio.ByteBuffer;
* Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are * Wraps a byte array, providing a set of methods for parsing data from it. Numerical values are
* parsed with the assumption that their constituent bytes are in big endian order. * parsed with the assumption that their constituent bytes are in big endian order.
*/ */
/* package */ final class ParsableByteArray { public final class ParsableByteArray {
public final byte[] data; public final byte[] data;
......
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