getSourceAndGroup(int group) {
int totalTrackGroupCount = 0;
- for (int i = 0; i < sources.length; i++) {
- int sourceTrackGroupCount = sources[i].getTrackGroups().length;
+ for (SampleSource source : sources) {
+ int sourceTrackGroupCount = source.getTrackGroups().length;
if (group < totalTrackGroupCount + sourceTrackGroupCount) {
- return Pair.create(sources[i], group - totalTrackGroupCount);
+ return Pair.create(source, group - totalTrackGroupCount);
}
totalTrackGroupCount += sourceTrackGroupCount;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java
index 1d457c96f1..f1db1798eb 100644
--- a/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java
+++ b/library/src/main/java/com/google/android/exoplayer/TrackRenderer.java
@@ -227,7 +227,6 @@ public abstract class TrackRenderer implements ExoPlayerComponent {
long resetPositionUs = stream.readReset();
if (resetPositionUs != C.UNSET_TIME_US) {
reset(resetPositionUs);
- return;
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/ContainerMediaChunk.java b/library/src/main/java/com/google/android/exoplayer/chunk/ContainerMediaChunk.java
index 67d8da8d5f..281632ea1e 100644
--- a/library/src/main/java/com/google/android/exoplayer/chunk/ContainerMediaChunk.java
+++ b/library/src/main/java/com/google/android/exoplayer/chunk/ContainerMediaChunk.java
@@ -36,9 +36,9 @@ public class ContainerMediaChunk extends BaseMediaChunk implements SingleTrackMe
private final ChunkExtractorWrapper extractorWrapper;
private final long sampleOffsetUs;
+ private final Format sampleFormat;
private volatile DrmInitData drmInitData;
- private volatile Format sampleFormat;
private volatile int bytesLoaded;
private volatile boolean loadCanceled;
diff --git a/library/src/main/java/com/google/android/exoplayer/chunk/FormatEvaluator.java b/library/src/main/java/com/google/android/exoplayer/chunk/FormatEvaluator.java
index 50ea402f5a..9650022a8e 100644
--- a/library/src/main/java/com/google/android/exoplayer/chunk/FormatEvaluator.java
+++ b/library/src/main/java/com/google/android/exoplayer/chunk/FormatEvaluator.java
@@ -70,7 +70,7 @@ public interface FormatEvaluator {
/**
* A format evaluation.
*/
- public static final class Evaluation {
+ final class Evaluation {
/**
* The selected format.
@@ -99,7 +99,7 @@ public interface FormatEvaluator {
/**
* Selects randomly between the available formats, excluding those that are blacklisted.
*/
- public static final class RandomEvaluator implements FormatEvaluator {
+ final class RandomEvaluator implements FormatEvaluator {
private final Random random;
@@ -131,8 +131,8 @@ public interface FormatEvaluator {
Evaluation evaluation) {
// Count the number of non-blacklisted formats.
int nonBlacklistedFormatCount = 0;
- for (int i = 0; i < blacklistFlags.length; i++) {
- if (!blacklistFlags[i]) {
+ for (boolean blacklistFlag : blacklistFlags) {
+ if (!blacklistFlag) {
nonBlacklistedFormatCount++;
}
}
@@ -171,7 +171,7 @@ public interface FormatEvaluator {
* reference implementation only. It is recommended that application developers implement their
* own adaptive evaluator to more precisely suit their use case.
*/
- public static final class AdaptiveEvaluator implements FormatEvaluator {
+ final class AdaptiveEvaluator implements FormatEvaluator {
public static final int DEFAULT_MAX_INITIAL_BITRATE = 800000;
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
index 99c44ca554..7d19c85cff 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
@@ -371,7 +371,6 @@ public class DashChunkSource implements ChunkSource {
}
} catch (BehindLiveWindowException e) {
fatalError = e;
- return;
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java
index be995edd1b..e7f37dc0d5 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java
@@ -90,8 +90,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
// MPD parsing.
@Override
- public MediaPresentationDescription parse(Uri uri, InputStream inputStream)
- throws IOException, ParserException {
+ public MediaPresentationDescription parse(Uri uri, InputStream inputStream) throws IOException {
try {
XmlPullParser xpp = xmlParserFactory.newPullParser();
xpp.setInput(inputStream, null);
@@ -101,9 +100,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
"inputStream does not contain a valid media presentation description");
}
return parseMediaPresentationDescription(xpp, uri.toString());
- } catch (XmlPullParserException e) {
- throw new ParserException(e);
- } catch (ParseException e) {
+ } catch (XmlPullParserException | ParseException e) {
throw new ParserException(e);
}
}
@@ -114,7 +111,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
long durationMs = parseDuration(xpp, "mediaPresentationDuration", -1);
long minBufferTimeMs = parseDuration(xpp, "minBufferTime", -1);
String typeString = xpp.getAttributeValue(null, "type");
- boolean dynamic = (typeString != null) ? typeString.equals("dynamic") : false;
+ boolean dynamic = typeString != null && typeString.equals("dynamic");
long minUpdateTimeMs = (dynamic) ? parseDuration(xpp, "minimumUpdatePeriod", -1) : -1;
long timeShiftBufferDepthMs = (dynamic) ? parseDuration(xpp, "timeShiftBufferDepth", -1) : -1;
UtcTimingElement utcTiming = null;
@@ -372,7 +369,6 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
float frameRate = parseFrameRate(xpp, adaptationSetFrameRate);
int audioChannels = adaptationSetAudioChannels;
int audioSamplingRate = parseInt(xpp, "audioSamplingRate", adaptationSetAudioSamplingRate);
- String language = adaptationSetLanguage;
boolean seenFirstBaseUrl = false;
do {
@@ -399,7 +395,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
} while (!ParserUtil.isEndTag(xpp, "Representation"));
Format format = buildFormat(id, mimeType, width, height, frameRate, audioChannels,
- audioSamplingRate, bandwidth, language, codecs);
+ audioSamplingRate, bandwidth, adaptationSetLanguage, codecs);
return buildRepresentation(contentId, -1, format,
segmentBase != null ? segmentBase : new SingleSegmentBase(baseUrl));
}
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java
index 60ead5db9f..37a926b2c6 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/Representation.java
@@ -30,8 +30,8 @@ public abstract class Representation {
/**
* Identifies the piece of content to which this {@link Representation} belongs.
*
- * For example, all {@link Representation}s belonging to a video should have the same
- * {@link #contentId}, which should uniquely identify that video.
+ * For example, all {@link Representation}s belonging to a video should have the same content
+ * identifier that uniquely identifies that video.
*/
public final String contentId;
/**
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
index c0c4cf0517..359162edbf 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/SegmentBase.java
@@ -327,7 +327,7 @@ public abstract class SegmentBase {
@Override
public RangedUri getSegmentUrl(Representation representation, int sequenceNumber) {
- long time = 0;
+ long time;
if (segmentTimeline != null) {
time = segmentTimeline.get(sequenceNumber - startNumber).startTime;
} else {
@@ -357,8 +357,8 @@ public abstract class SegmentBase {
*/
public static class SegmentTimelineElement {
- /* package */ long startTime;
- /* package */ long duration;
+ /* package */ final long startTime;
+ /* package */ final long duration;
/**
* @param startTime The start time of the element. The value in seconds is the division of this
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/UrlTemplate.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/UrlTemplate.java
index 1439ee6ec6..97e4b72915 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/UrlTemplate.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/UrlTemplate.java
@@ -144,14 +144,18 @@ public final class UrlTemplate {
}
identifier = identifier.substring(0, formatTagIndex);
}
- if (identifier.equals(NUMBER)) {
- identifiers[identifierCount] = NUMBER_ID;
- } else if (identifier.equals(BANDWIDTH)) {
- identifiers[identifierCount] = BANDWIDTH_ID;
- } else if (identifier.equals(TIME)) {
- identifiers[identifierCount] = TIME_ID;
- } else {
- throw new IllegalArgumentException("Invalid template: " + template);
+ switch (identifier) {
+ case NUMBER:
+ identifiers[identifierCount] = NUMBER_ID;
+ break;
+ case BANDWIDTH:
+ identifiers[identifierCount] = BANDWIDTH_ID;
+ break;
+ case TIME:
+ identifiers[identifierCount] = TIME_ID;
+ break;
+ default:
+ throw new IllegalArgumentException("Invalid template: " + template);
}
identifierFormatTags[identifierCount] = formatTag;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/UtcTimingElementResolver.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/UtcTimingElementResolver.java
index dba0a91ae2..7fd48f3fcf 100644
--- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/UtcTimingElementResolver.java
+++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/UtcTimingElementResolver.java
@@ -154,7 +154,7 @@ public final class UtcTimingElementResolver implements Loader.Callback {
private static class XsDateTimeParser implements UriLoadable.Parser {
@Override
- public Long parse(Uri uri, InputStream inputStream) throws ParserException, IOException {
+ public Long parse(Uri uri, InputStream inputStream) throws IOException {
String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
try {
return Util.parseXsDateTime(firstLine);
@@ -168,7 +168,7 @@ public final class UtcTimingElementResolver implements Loader.Callback {
private static class Iso8601Parser implements UriLoadable.Parser {
@Override
- public Long parse(Uri uri, InputStream inputStream) throws ParserException, IOException {
+ public Long parse(Uri uri, InputStream inputStream) throws IOException {
String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine();
try {
// TODO: It may be necessary to handle timestamp offsets from UTC.
diff --git a/library/src/main/java/com/google/android/exoplayer/drm/DrmInitData.java b/library/src/main/java/com/google/android/exoplayer/drm/DrmInitData.java
index c01fc59ca7..75c7152adf 100644
--- a/library/src/main/java/com/google/android/exoplayer/drm/DrmInitData.java
+++ b/library/src/main/java/com/google/android/exoplayer/drm/DrmInitData.java
@@ -35,12 +35,12 @@ public interface DrmInitData {
* @param schemeUuid The DRM scheme's UUID.
* @return The initialization data for the scheme, or null if the scheme is not supported.
*/
- public abstract SchemeInitData get(UUID schemeUuid);
+ SchemeInitData get(UUID schemeUuid);
/**
* A {@link DrmInitData} implementation that maps UUID onto scheme specific data.
*/
- public static final class Mapped implements DrmInitData {
+ final class Mapped implements DrmInitData {
private final Map schemeData;
@@ -68,9 +68,9 @@ public interface DrmInitData {
/**
* A {@link DrmInitData} implementation that returns the same initialization data for all schemes.
*/
- public static final class Universal implements DrmInitData {
+ final class Universal implements DrmInitData {
- private SchemeInitData data;
+ private final SchemeInitData data;
public Universal(SchemeInitData data) {
this.data = data;
@@ -86,7 +86,7 @@ public interface DrmInitData {
/**
* Scheme initialization data.
*/
- public static final class SchemeInitData {
+ final class SchemeInitData {
/**
* The mimeType of {@link #data}.
diff --git a/library/src/main/java/com/google/android/exoplayer/drm/DrmSessionManager.java b/library/src/main/java/com/google/android/exoplayer/drm/DrmSessionManager.java
index a5e78ab008..481a6ed766 100644
--- a/library/src/main/java/com/google/android/exoplayer/drm/DrmSessionManager.java
+++ b/library/src/main/java/com/google/android/exoplayer/drm/DrmSessionManager.java
@@ -27,24 +27,24 @@ public interface DrmSessionManager {
/**
* The error state. {@link #getError()} can be used to retrieve the cause.
*/
- public static final int STATE_ERROR = 0;
+ int STATE_ERROR = 0;
/**
* The session is closed.
*/
- public static final int STATE_CLOSED = 1;
+ int STATE_CLOSED = 1;
/**
* The session is being opened (i.e. {@link #open(DrmInitData)} has been called, but the session
* is not yet open).
*/
- public static final int STATE_OPENING = 2;
+ int STATE_OPENING = 2;
/**
* The session is open, but does not yet have the keys required for decryption.
*/
- public static final int STATE_OPENED = 3;
+ int STATE_OPENED = 3;
/**
* The session is open and has the keys required for decryption.
*/
- public static final int STATE_OPENED_WITH_KEYS = 4;
+ int STATE_OPENED_WITH_KEYS = 4;
/**
* Opens the session, possibly asynchronously.
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/Extractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/Extractor.java
index e068389be8..6f68099df4 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/Extractor.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/Extractor.java
@@ -29,18 +29,18 @@ public interface Extractor {
* to the next {@link #read(ExtractorInput, PositionHolder)} is required to provide data
* continuing from the position in the stream reached by the returning call.
*/
- public static final int RESULT_CONTINUE = 0;
+ int RESULT_CONTINUE = 0;
/**
* Returned by {@link #read(ExtractorInput, PositionHolder)} if the {@link ExtractorInput} passed
* to the next {@link #read(ExtractorInput, PositionHolder)} is required to provide data starting
* from a specified position in the stream.
*/
- public static final int RESULT_SEEK = 1;
+ int RESULT_SEEK = 1;
/**
* Returned by {@link #read(ExtractorInput, PositionHolder)} if the end of the
* {@link ExtractorInput} was reached. Equal to {@link C#RESULT_END_OF_INPUT}.
*/
- public static final int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT;
+ int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT;
/**
* Initializes the extractor with an {@link ExtractorOutput}.
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java b/library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java
index 47c6281754..580d10960f 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ExtractorSampleSource.java
@@ -315,9 +315,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
for (int i = 0; i < extractors.length; i++) {
try {
extractors[i] = DEFAULT_EXTRACTOR_CLASSES.get(i).newInstance();
- } catch (InstantiationException e) {
- throw new IllegalStateException("Unexpected error creating default extractor", e);
- } catch (IllegalAccessException e) {
+ } catch (Exception e) {
throw new IllegalStateException("Unexpected error creating default extractor", e);
}
}
@@ -569,7 +567,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
// If we're not pending a reset, see if we can seek within the sample queues.
boolean seekInsideBuffer = !isPendingReset();
for (int i = 0; seekInsideBuffer && i < sampleQueues.length; i++) {
- seekInsideBuffer &= sampleQueues[i].skipToKeyframeBefore(positionUs);
+ seekInsideBuffer = sampleQueues[i].skipToKeyframeBefore(positionUs);
}
// If we failed to seek within the sample queues, we need to restart.
if (!seekInsideBuffer) {
@@ -827,7 +825,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
* @throws InterruptedException Thrown if the thread was interrupted.
*/
public Extractor selectExtractor(ExtractorInput input)
- throws UnrecognizedInputFormatException, IOException, InterruptedException {
+ throws IOException, InterruptedException {
if (extractor != null) {
return extractor;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java
index 363d8c1457..bd6aa90f17 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/flv/VideoTagPayloadReader.java
@@ -137,10 +137,8 @@ import java.util.List;
* Builds initialization data for a {@link Format} from H.264 (AVC) codec private data.
*
* @return The AvcSequenceHeader data needed to initialize the video codec.
- * @throws ParserException If the initialization data could not be built.
*/
- private AvcSequenceHeaderData parseAvcCodecPrivate(ParsableByteArray buffer)
- throws ParserException {
+ private AvcSequenceHeaderData parseAvcCodecPrivate(ParsableByteArray buffer) {
// TODO: Deduplicate with AtomParsers.parseAvcCFromParent.
buffer.setPosition(4);
int nalUnitLengthFieldLength = (buffer.readUnsignedByte() & 0x03) + 1;
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/DefaultEbmlReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/DefaultEbmlReader.java
index 8a173ad07b..cf7b7827ec 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/DefaultEbmlReader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/DefaultEbmlReader.java
@@ -145,8 +145,8 @@ import java.util.Stack;
* @throws IOException If an error occurs reading from the input.
* @throws InterruptedException If the thread is interrupted.
*/
- private long maybeResyncToNextLevel1Element(ExtractorInput input) throws EOFException,
- IOException, InterruptedException {
+ private long maybeResyncToNextLevel1Element(ExtractorInput input) throws IOException,
+ InterruptedException {
input.resetPeekPosition();
while (true) {
input.peekFully(scratch, 0, MAX_ID_BYTES);
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReader.java
index 383c726190..04d7784298 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReader.java
@@ -32,34 +32,34 @@ import java.io.IOException;
/**
* Type for unknown elements.
*/
- public static final int TYPE_UNKNOWN = 0;
+ int TYPE_UNKNOWN = 0;
/**
* Type for elements that contain child elements.
*/
- public static final int TYPE_MASTER = 1;
+ int TYPE_MASTER = 1;
/**
* Type for integer value elements of up to 8 bytes.
*/
- public static final int TYPE_UNSIGNED_INT = 2;
+ int TYPE_UNSIGNED_INT = 2;
/**
* Type for string elements.
*/
- public static final int TYPE_STRING = 3;
+ int TYPE_STRING = 3;
/**
* Type for binary elements.
*/
- public static final int TYPE_BINARY = 4;
+ int TYPE_BINARY = 4;
/**
* Type for IEEE floating point value elements of either 4 or 8 bytes.
*/
- public static final int TYPE_FLOAT = 5;
+ int TYPE_FLOAT = 5;
/**
* Initializes the extractor with an {@link EbmlReaderOutput}.
*
* @param output An {@link EbmlReaderOutput} to receive events.
*/
- public void init(EbmlReaderOutput output);
+ void init(EbmlReaderOutput output);
/**
* Resets the state of the reader.
@@ -67,7 +67,7 @@ import java.io.IOException;
* Subsequent calls to {@link #read(ExtractorInput)} will start reading a new EBML structure
* from scratch.
*/
- public void reset();
+ void reset();
/**
* Reads from an {@link ExtractorInput}, invoking an event callback if possible.
@@ -78,7 +78,6 @@ import java.io.IOException;
* @throws IOException If an error occurs reading from the input.
* @throws InterruptedException If the thread is interrupted.
*/
- public boolean read(ExtractorInput input) throws ParserException, IOException,
- InterruptedException;
+ boolean read(ExtractorInput input) throws IOException, InterruptedException;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReaderOutput.java b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReaderOutput.java
index 4d1c06276b..b002a9c888 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReaderOutput.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mkv/EbmlReaderOutput.java
@@ -112,6 +112,6 @@ import java.io.IOException;
* @throws InterruptedException If the thread is interrupted.
*/
void binaryElement(int id, int contentsSize, ExtractorInput input)
- throws ParserException, IOException, InterruptedException;
+ throws IOException, InterruptedException;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Id3Util.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Id3Util.java
index 7b158f71cd..c2c843e595 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Id3Util.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp3/Id3Util.java
@@ -100,7 +100,7 @@ import java.nio.charset.Charset;
if (extendedHeaderSize > frame.bytesLeft()) {
return null;
}
- int paddingSize = 0;
+ int paddingSize;
if (extendedHeaderSize >= 6) {
frame.skipBytes(2); // extended flags
paddingSize = frame.readUnsignedIntToInt();
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java
index 48a30236e3..21632723e3 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Atom.java
@@ -260,8 +260,8 @@ import java.util.List;
@Override
public String toString() {
return getAtomTypeString(type)
- + " leaves: " + Arrays.toString(leafChildren.toArray(new LeafAtom[0]))
- + " containers: " + Arrays.toString(containerChildren.toArray(new ContainerAtom[0]));
+ + " leaves: " + Arrays.toString(leafChildren.toArray())
+ + " containers: " + Arrays.toString(containerChildren.toArray());
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java
index 8a8374b5ed..dd0f98b541 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/mp4/Mp4Extractor.java
@@ -69,7 +69,6 @@ public final class Mp4Extractor implements Extractor, SeekMap {
private int atomHeaderBytesRead;
private ParsableByteArray atomData;
- private int sampleSize;
private int sampleBytesWritten;
private int sampleCurrentNalBytesRemaining;
@@ -341,7 +340,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
}
}
this.durationUs = durationUs;
- this.tracks = tracks.toArray(new Mp4Track[0]);
+ this.tracks = tracks.toArray(new Mp4Track[tracks.size()]);
extractorOutput.endTracks();
extractorOutput.seekMap(this);
}
@@ -378,7 +377,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
return RESULT_SEEK;
}
input.skipFully((int) skipAmount);
- sampleSize = track.sampleTable.sizes[sampleIndex];
+ int sampleSize = track.sampleTable.sizes[sampleIndex];
if (track.track.nalUnitLengthFieldLength != -1) {
// Zero the top three bytes of the array that we'll use to parse nal unit lengths, in case
// they're only 1 or 2 bytes long.
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisBitArray.java b/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisBitArray.java
index 95ae0eb789..462c3790b3 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisBitArray.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisBitArray.java
@@ -26,7 +26,9 @@ import com.google.android.exoplayer.util.Assertions;
/* package */ final class VorbisBitArray {
public final byte[] data;
- private int limit;
+
+ private final int limit;
+
private int byteOffset;
private int bitOffset;
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisUtil.java b/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisUtil.java
index a325e4e03e..cc419f7055 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisUtil.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ogg/VorbisUtil.java
@@ -174,7 +174,7 @@ import java.util.Arrays;
bitArray.skipBits(headerData.getPosition() * 8);
for (int i = 0; i < numberOfBooks; i++) {
- readBook(bitArray);
+ skipBook(bitArray);
}
int timeCount = bitArray.readBits(6) + 1;
@@ -336,7 +336,7 @@ import java.util.Arrays;
}
}
- private static CodeBook readBook(VorbisBitArray bitArray) throws ParserException {
+ private static void skipBook(VorbisBitArray bitArray) throws ParserException {
if (bitArray.readBits(24) != 0x564342) {
throw new ParserException("expected code book to start with [0x56, 0x43, 0x42] at "
+ bitArray.getPosition());
@@ -393,7 +393,6 @@ import java.util.Arrays;
// discard (no decoding required yet)
bitArray.skipBits((int) (lookupValuesCount * valueBits));
}
- return new CodeBook(dimensions, entries, lengthMap, lookupType, isOrdered);
}
/**
@@ -403,25 +402,6 @@ import java.util.Arrays;
return (long) Math.floor(Math.pow(entries, 1.d / dimension));
}
- public static final class CodeBook {
-
- public final int dimensions;
- public final int entries;
- public final long[] lengthMap;
- public final int lookupType;
- public final boolean isOrdered;
-
- public CodeBook(int dimensions, int entries, long[] lengthMap, int lookupType,
- boolean isOrdered) {
- this.dimensions = dimensions;
- this.entries = entries;
- this.lengthMap = lengthMap;
- this.lookupType = lookupType;
- this.isOrdered = isOrdered;
- }
-
- }
-
public static final class CommentHeader {
public final String vendor;
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H262Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H262Reader.java
index 234699d72f..b9de7f9df2 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H262Reader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H262Reader.java
@@ -85,71 +85,69 @@ import java.util.Collections;
@Override
public void consume(ParsableByteArray data) {
- while (data.bytesLeft() > 0) {
- int offset = data.getPosition();
- int limit = data.limit();
- byte[] dataArray = data.data;
+ int offset = data.getPosition();
+ int limit = data.limit();
+ byte[] dataArray = data.data;
- // Append the data to the buffer.
- totalBytesWritten += data.bytesLeft();
- output.sampleData(data, data.bytesLeft());
+ // Append the data to the buffer.
+ totalBytesWritten += data.bytesLeft();
+ output.sampleData(data, data.bytesLeft());
- int searchOffset = offset;
- while (true) {
- int startCodeOffset = NalUnitUtil.findNalUnit(dataArray, searchOffset, limit, prefixFlags);
-
- if (startCodeOffset == limit) {
- // We've scanned to the end of the data without finding another start code.
- if (!hasOutputFormat) {
- csdBuffer.onData(dataArray, offset, limit);
- }
- return;
- }
-
- // We've found a start code with the following value.
- int startCodeValue = data.data[startCodeOffset + 3] & 0xFF;
+ int searchOffset = offset;
+ while (true) {
+ int startCodeOffset = NalUnitUtil.findNalUnit(dataArray, searchOffset, limit, prefixFlags);
+ if (startCodeOffset == limit) {
+ // We've scanned to the end of the data without finding another start code.
if (!hasOutputFormat) {
- // This is the number of bytes from the current offset to the start of the next start
- // code. It may be negative if the start code started in the previously consumed data.
- int lengthToStartCode = startCodeOffset - offset;
- if (lengthToStartCode > 0) {
- csdBuffer.onData(dataArray, offset, startCodeOffset);
- }
- // This is the number of bytes belonging to the next start code that have already been
- // passed to csdDataTargetBuffer.
- int bytesAlreadyPassed = lengthToStartCode < 0 ? -lengthToStartCode : 0;
- if (csdBuffer.onStartCode(startCodeValue, bytesAlreadyPassed)) {
- // The csd data is complete, so we can parse and output the media format.
- Pair result = parseCsdBuffer(csdBuffer);
- output.format(result.first);
- frameDurationUs = result.second;
- hasOutputFormat = true;
- }
+ csdBuffer.onData(dataArray, offset, limit);
}
-
- if (hasOutputFormat && (startCodeValue == START_GROUP || startCodeValue == START_PICTURE)) {
- int bytesWrittenPastStartCode = limit - startCodeOffset;
- if (foundFirstFrameInGroup) {
- int flags = isKeyframe ? C.BUFFER_FLAG_KEY_FRAME : 0;
- int size = (int) (totalBytesWritten - framePosition) - bytesWrittenPastStartCode;
- output.sampleMetadata(frameTimeUs, flags, size, bytesWrittenPastStartCode, null);
- isKeyframe = false;
- }
- if (startCodeValue == START_GROUP) {
- foundFirstFrameInGroup = false;
- isKeyframe = true;
- } else /* startCode == START_PICTURE */ {
- frameTimeUs = pesPtsUsAvailable ? pesTimeUs : (frameTimeUs + frameDurationUs);
- framePosition = totalBytesWritten - bytesWrittenPastStartCode;
- pesPtsUsAvailable = false;
- foundFirstFrameInGroup = true;
- }
- }
-
- offset = startCodeOffset;
- searchOffset = offset + 3;
+ return;
}
+
+ // We've found a start code with the following value.
+ int startCodeValue = data.data[startCodeOffset + 3] & 0xFF;
+
+ if (!hasOutputFormat) {
+ // This is the number of bytes from the current offset to the start of the next start
+ // code. It may be negative if the start code started in the previously consumed data.
+ int lengthToStartCode = startCodeOffset - offset;
+ if (lengthToStartCode > 0) {
+ csdBuffer.onData(dataArray, offset, startCodeOffset);
+ }
+ // This is the number of bytes belonging to the next start code that have already been
+ // passed to csdDataTargetBuffer.
+ int bytesAlreadyPassed = lengthToStartCode < 0 ? -lengthToStartCode : 0;
+ if (csdBuffer.onStartCode(startCodeValue, bytesAlreadyPassed)) {
+ // The csd data is complete, so we can parse and output the media format.
+ Pair result = parseCsdBuffer(csdBuffer);
+ output.format(result.first);
+ frameDurationUs = result.second;
+ hasOutputFormat = true;
+ }
+ }
+
+ if (hasOutputFormat && (startCodeValue == START_GROUP || startCodeValue == START_PICTURE)) {
+ int bytesWrittenPastStartCode = limit - startCodeOffset;
+ if (foundFirstFrameInGroup) {
+ int flags = isKeyframe ? C.BUFFER_FLAG_KEY_FRAME : 0;
+ int size = (int) (totalBytesWritten - framePosition) - bytesWrittenPastStartCode;
+ output.sampleMetadata(frameTimeUs, flags, size, bytesWrittenPastStartCode, null);
+ isKeyframe = false;
+ }
+ if (startCodeValue == START_GROUP) {
+ foundFirstFrameInGroup = false;
+ isKeyframe = true;
+ } else /* startCode == START_PICTURE */ {
+ frameTimeUs = pesPtsUsAvailable ? pesTimeUs : (frameTimeUs + frameDurationUs);
+ framePosition = totalBytesWritten - bytesWrittenPastStartCode;
+ pesPtsUsAvailable = false;
+ foundFirstFrameInGroup = true;
+ }
+ }
+
+ offset = startCodeOffset;
+ searchOffset = offset + 3;
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
index 09a176f068..7a15421ab6 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
@@ -94,46 +94,44 @@ import java.util.List;
@Override
public void consume(ParsableByteArray data) {
- while (data.bytesLeft() > 0) {
- int offset = data.getPosition();
- int limit = data.limit();
- byte[] dataArray = data.data;
+ int offset = data.getPosition();
+ int limit = data.limit();
+ byte[] dataArray = data.data;
- // Append the data to the buffer.
- totalBytesWritten += data.bytesLeft();
- output.sampleData(data, data.bytesLeft());
+ // Append the data to the buffer.
+ totalBytesWritten += data.bytesLeft();
+ output.sampleData(data, data.bytesLeft());
- // Scan the appended data, processing NAL units as they are encountered
- while (true) {
- int nalUnitOffset = NalUnitUtil.findNalUnit(dataArray, offset, limit, prefixFlags);
+ // Scan the appended data, processing NAL units as they are encountered
+ while (true) {
+ int nalUnitOffset = NalUnitUtil.findNalUnit(dataArray, offset, limit, prefixFlags);
- if (nalUnitOffset == limit) {
- // We've scanned to the end of the data without finding the start of another NAL unit.
- nalUnitData(dataArray, offset, limit);
- return;
- }
-
- // We've seen the start of a NAL unit of the following type.
- int nalUnitType = NalUnitUtil.getNalUnitType(dataArray, nalUnitOffset);
-
- // This is the number of bytes from the current offset to the start of the next NAL unit.
- // It may be negative if the NAL unit started in the previously consumed data.
- int lengthToNalUnit = nalUnitOffset - offset;
- if (lengthToNalUnit > 0) {
- nalUnitData(dataArray, offset, nalUnitOffset);
- }
- int bytesWrittenPastPosition = limit - nalUnitOffset;
- long absolutePosition = totalBytesWritten - bytesWrittenPastPosition;
- // Indicate the end of the previous NAL unit. If the length to the start of the next unit
- // is negative then we wrote too many bytes to the NAL buffers. Discard the excess bytes
- // when notifying that the unit has ended.
- endNalUnit(absolutePosition, bytesWrittenPastPosition,
- lengthToNalUnit < 0 ? -lengthToNalUnit : 0, pesTimeUs);
- // Indicate the start of the next NAL unit.
- startNalUnit(absolutePosition, nalUnitType, pesTimeUs);
- // Continue scanning the data.
- offset = nalUnitOffset + 3;
+ if (nalUnitOffset == limit) {
+ // We've scanned to the end of the data without finding the start of another NAL unit.
+ nalUnitData(dataArray, offset, limit);
+ return;
}
+
+ // We've seen the start of a NAL unit of the following type.
+ int nalUnitType = NalUnitUtil.getNalUnitType(dataArray, nalUnitOffset);
+
+ // This is the number of bytes from the current offset to the start of the next NAL unit.
+ // It may be negative if the NAL unit started in the previously consumed data.
+ int lengthToNalUnit = nalUnitOffset - offset;
+ if (lengthToNalUnit > 0) {
+ nalUnitData(dataArray, offset, nalUnitOffset);
+ }
+ int bytesWrittenPastPosition = limit - nalUnitOffset;
+ long absolutePosition = totalBytesWritten - bytesWrittenPastPosition;
+ // Indicate the end of the previous NAL unit. If the length to the start of the next unit
+ // is negative then we wrote too many bytes to the NAL buffers. Discard the excess bytes
+ // when notifying that the unit has ended.
+ endNalUnit(absolutePosition, bytesWrittenPastPosition,
+ lengthToNalUnit < 0 ? -lengthToNalUnit : 0, pesTimeUs);
+ // Indicate the start of the next NAL unit.
+ startNalUnit(absolutePosition, nalUnitType, pesTimeUs);
+ // Continue scanning the data.
+ offset = nalUnitOffset + 3;
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
index b838325548..df4441d876 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
@@ -342,8 +342,8 @@ import java.util.Collections;
private static void skipShortTermRefPicSets(ParsableNalUnitBitArray bitArray) {
int numShortTermRefPicSets = bitArray.readUnsignedExpGolombCodedInt();
boolean interRefPicSetPredictionFlag = false;
- int numNegativePics = 0;
- int numPositivePics = 0;
+ int numNegativePics;
+ int numPositivePics;
// As this method applies in a SPS, the only element of NumDeltaPocs accessed is the previous
// one, so we just keep track of that rather than storing the whole array.
// RefRpsIdx = stRpsIdx - (delta_idx_minus1 + 1) and delta_idx_minus1 is always zero in SPS.
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/ts/PsExtractor.java b/library/src/main/java/com/google/android/exoplayer/extractor/ts/PsExtractor.java
index 2276bd9cd8..95a328a78a 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/ts/PsExtractor.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/ts/PsExtractor.java
@@ -216,7 +216,7 @@ public final class PsExtractor implements Extractor {
input.readFully(psPacketBuffer.data, 0, pesLength);
psPacketBuffer.setPosition(6);
psPacketBuffer.setLimit(pesLength);
- payloadReader.consume(psPacketBuffer, output);
+ payloadReader.consume(psPacketBuffer);
psPacketBuffer.setLimit(psPacketBuffer.capacity());
}
@@ -253,8 +253,8 @@ public final class PsExtractor implements Extractor {
* Notifies the reader that a seek has occurred.
*
* Following a call to this method, the data passed to the next invocation of
- * {@link #consume(ParsableByteArray, ExtractorOutput)} will not be a continuation of
- * the data that was previously passed. Hence the reader should reset any internal state.
+ * {@link #consume(ParsableByteArray)} will not be a continuation of the data that was
+ * previously passed. Hence the reader should reset any internal state.
*/
public void seek() {
seenFirstDts = false;
@@ -265,9 +265,8 @@ public final class PsExtractor implements Extractor {
* Consumes the payload of a PS packet.
*
* @param data The PES packet. The position will be set to the start of the payload.
- * @param output The output to which parsed data should be written.
*/
- public void consume(ParsableByteArray data, ExtractorOutput output) {
+ public void consume(ParsableByteArray data) {
data.readBytes(pesScratch.data, 0, 3);
pesScratch.setPosition(0);
parseHeader();
diff --git a/library/src/main/java/com/google/android/exoplayer/extractor/wav/WavHeaderReader.java b/library/src/main/java/com/google/android/exoplayer/extractor/wav/WavHeaderReader.java
index 3a0ab83265..08cf4463b2 100644
--- a/library/src/main/java/com/google/android/exoplayer/extractor/wav/WavHeaderReader.java
+++ b/library/src/main/java/com/google/android/exoplayer/extractor/wav/WavHeaderReader.java
@@ -39,14 +39,13 @@ import java.io.IOException;
* Peeks and returns a {@code WavHeader}.
*
* @param input Input stream to peek the WAV header from.
+ * @throws ParserException If the input file is an incorrect RIFF WAV.
* @throws IOException If peeking from the input fails.
* @throws InterruptedException If interrupted while peeking from input.
- * @throws ParserException If the input file is an incorrect RIFF WAV.
* @return A new {@code WavHeader} peeked from {@code input}, or null if the input is not a
* supported WAV format.
*/
- public static WavHeader peek(ExtractorInput input)
- throws IOException, InterruptedException, ParserException {
+ public static WavHeader peek(ExtractorInput input) throws IOException, InterruptedException {
Assertions.checkNotNull(input);
// Allocate a scratch buffer large enough to store the format chunk.
@@ -117,12 +116,12 @@ import java.io.IOException;
* @param input Input stream to skip to the data chunk in. Its peek position must be pointing to
* a valid chunk header.
* @param wavHeader WAV header to populate with data bounds.
+ * @throws ParserException If an error occurs parsing chunks.
* @throws IOException If reading from the input fails.
* @throws InterruptedException If interrupted while reading from input.
- * @throws ParserException If an error occurs parsing chunks.
*/
public static void skipToData(ExtractorInput input, WavHeader wavHeader)
- throws IOException, InterruptedException, ParserException {
+ throws IOException, InterruptedException {
Assertions.checkNotNull(input);
Assertions.checkNotNull(wavHeader);
diff --git a/library/src/main/java/com/google/android/exoplayer/hls/Aes128DataSource.java b/library/src/main/java/com/google/android/exoplayer/hls/Aes128DataSource.java
index 1d45793e8d..2128eb4b60 100644
--- a/library/src/main/java/com/google/android/exoplayer/hls/Aes128DataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/hls/Aes128DataSource.java
@@ -68,9 +68,7 @@ import javax.crypto.spec.SecretKeySpec;
Cipher cipher;
try {
cipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- } catch (NoSuchPaddingException e) {
+ } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
throw new RuntimeException(e);
}
@@ -79,9 +77,7 @@ import javax.crypto.spec.SecretKeySpec;
try {
cipher.init(Cipher.DECRYPT_MODE, cipherKey, cipherIV);
- } catch (InvalidKeyException e) {
- throw new RuntimeException(e);
- } catch (InvalidAlgorithmParameterException e) {
+ } catch (InvalidKeyException | InvalidAlgorithmParameterException e) {
throw new RuntimeException(e);
}
diff --git a/library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java b/library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
index 344b2ea1c1..42c408d4e5 100644
--- a/library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/hls/HlsChunkSource.java
@@ -663,8 +663,8 @@ public class HlsChunkSource {
}
private boolean allEnabledVariantsBlacklisted() {
- for (int i = 0; i < enabledVariantBlacklistFlags.length; i++) {
- if (!enabledVariantBlacklistFlags[i]) {
+ for (boolean enabledVariantBlacklistFlag : enabledVariantBlacklistFlags) {
+ if (!enabledVariantBlacklistFlag) {
return false;
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java b/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
index bac90a7406..d6d8f3361b 100644
--- a/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
@@ -60,7 +60,7 @@ public final class HlsSampleSource implements SampleSource, Loader.Callback {
private final Loader loader;
private final HlsChunkSource chunkSource;
- private final LinkedList mediaChunks = new LinkedList();
+ private final LinkedList mediaChunks = new LinkedList<>();
private final HlsOutput output;
private final int bufferSizeContribution;
private final ChunkHolder nextChunkHolder;
@@ -262,13 +262,7 @@ public final class HlsSampleSource implements SampleSource, Loader.Callback {
/* package */ boolean isReady(int group) {
Assertions.checkState(groupEnabledStates[group]);
- if (loadingFinished) {
- return true;
- }
- if (isPendingReset()) {
- return false;
- }
- return !sampleQueues[group].isEmpty();
+ return loadingFinished || (!isPendingReset() && !sampleQueues[group].isEmpty());
}
/* package */ void maybeThrowError() throws IOException {
diff --git a/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsParserUtil.java b/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsParserUtil.java
index 3a25a7d67d..5e23c55f19 100644
--- a/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsParserUtil.java
+++ b/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsParserUtil.java
@@ -25,9 +25,6 @@ import java.util.regex.Pattern;
*/
/* package */ final class HlsParserUtil {
- private static final String BOOLEAN_YES = "YES";
- private static final String BOOLEAN_NO = "NO";
-
private HlsParserUtil() {}
public static String parseStringAttr(String line, Pattern pattern, String tag)
@@ -57,16 +54,4 @@ import java.util.regex.Pattern;
return null;
}
- public static boolean parseOptionalBooleanAttr(String line, Pattern pattern) {
- Matcher matcher = pattern.matcher(line);
- if (matcher.find()) {
- return BOOLEAN_YES.equals(matcher.group(1));
- }
- return false;
- }
-
- public static Pattern compileBooleanAttrPattern(String attrName) {
- return Pattern.compile(attrName + "=(" + BOOLEAN_YES + "|" + BOOLEAN_NO + ")");
- }
-
}
diff --git a/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsPlaylistParser.java b/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsPlaylistParser.java
index 464fcf7e8d..919a30a694 100644
--- a/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsPlaylistParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/hls/playlist/HlsPlaylistParser.java
@@ -109,7 +109,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser
// HlsParserUtil.compileBooleanAttrPattern(DEFAULT_ATTR);
@Override
- public HlsPlaylist parse(Uri uri, InputStream inputStream) throws IOException, ParserException {
+ public HlsPlaylist parse(Uri uri, InputStream inputStream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
Queue extraLines = new LinkedList<>();
String line;
diff --git a/library/src/main/java/com/google/android/exoplayer/metadata/MetadataParser.java b/library/src/main/java/com/google/android/exoplayer/metadata/MetadataParser.java
index 654f549b18..8b316a9a9c 100644
--- a/library/src/main/java/com/google/android/exoplayer/metadata/MetadataParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/metadata/MetadataParser.java
@@ -30,7 +30,7 @@ public interface MetadataParser {
* @param mimeType A metadata mime type.
* @return Whether the mime type is supported.
*/
- public boolean canParse(String mimeType);
+ boolean canParse(String mimeType);
/**
* Parses metadata objects of type from the provided binary data.
@@ -40,6 +40,6 @@ public interface MetadataParser {
* @return @return A parsed metadata object of type .
* @throws IOException If a problem occurred parsing the data.
*/
- public T parse(byte[] data, int size) throws IOException;
+ T parse(byte[] data, int size) throws IOException;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
index b3d9a82234..08f94ee6c8 100644
--- a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
@@ -266,10 +266,9 @@ public class SmoothStreamingChunkSource implements ChunkSource {
int manifestTrackIndex = getManifestTrackIndex(streamElement, selectedFormat);
Uri uri = streamElement.buildRequestUri(manifestTrackIndex, chunkIndex);
- Chunk mediaChunk = newMediaChunk(selectedFormat, dataSource, uri, null,
- currentAbsoluteChunkIndex, chunkStartTimeUs, chunkEndTimeUs, evaluation.trigger,
- extractorWrapper, drmInitData, selectedFormat);
- out.chunk = mediaChunk;
+ out.chunk = newMediaChunk(selectedFormat, dataSource, uri, null, currentAbsoluteChunkIndex,
+ chunkStartTimeUs, chunkEndTimeUs, evaluation.trigger, extractorWrapper, drmInitData,
+ selectedFormat);
}
@Override
diff --git a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java
index a985cf572e..dad1f06bbc 100644
--- a/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingManifestParser.java
@@ -63,8 +63,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser();
}
- public final Object parse(XmlPullParser xmlParser) throws XmlPullParserException, IOException,
- ParserException {
+ public final Object parse(XmlPullParser xmlParser) throws XmlPullParserException, IOException {
String tagName;
boolean foundStartTag = false;
int skippingElementDepth = 0;
@@ -224,17 +222,15 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser streamElements;
+
private int majorVersion;
private int minorVersion;
private long timescale;
@@ -343,7 +341,6 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser streamElements;
public SmoothStreamMediaParser(ElementParser parent, String baseUri) {
super(parent, baseUri, TAG);
diff --git a/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java b/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java
index a86edd376a..28ff5bc0b4 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/CuePainter.java
@@ -233,7 +233,6 @@ import android.util.Log;
}
int textTop;
- int textBottom;
if (cueLine != Cue.DIMEN_UNSET) {
int anchorPosition;
if (cueLineType == Cue.LINE_TYPE_FRACTION) {
@@ -250,17 +249,13 @@ import android.util.Log;
textTop = cueLineAnchor == Cue.ANCHOR_TYPE_END ? anchorPosition - textHeight
: cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorPosition * 2 - textHeight) / 2
: anchorPosition;
- textBottom = textTop + textHeight;
- if (textBottom > parentBottom) {
+ if (textTop + textHeight > parentBottom) {
textTop = parentBottom - textHeight;
- textBottom = parentBottom;
} else if (textTop < parentTop) {
textTop = parentTop;
- textBottom = parentTop + textHeight;
}
} else {
textTop = parentBottom - textHeight - (int) (parentHeight * bottomPaddingFraction);
- textBottom = textTop + textHeight;
}
textWidth = textRight - textLeft;
diff --git a/library/src/main/java/com/google/android/exoplayer/text/Subtitle.java b/library/src/main/java/com/google/android/exoplayer/text/Subtitle.java
index 55a99cdf43..245571192b 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/Subtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/Subtitle.java
@@ -28,7 +28,7 @@ public interface Subtitle {
* @param timeUs The time in microseconds.
* @return The index of the next event, or -1 if there are no events after the specified time.
*/
- public int getNextEventTimeIndex(long timeUs);
+ int getNextEventTimeIndex(long timeUs);
/**
* Gets the number of event times, where events are defined as points in time at which the cues
@@ -36,7 +36,7 @@ public interface Subtitle {
*
* @return The number of event times.
*/
- public int getEventTimeCount();
+ int getEventTimeCount();
/**
* Gets the event time at a specified index.
@@ -44,14 +44,7 @@ public interface Subtitle {
* @param index The index of the event time to obtain.
* @return The event time in microseconds.
*/
- public long getEventTime(int index);
-
- /**
- * Convenience method for obtaining the last event time.
- *
- * @return The time of the last event in microseconds, or -1 if {@code getEventTimeCount() == 0}.
- */
- public long getLastEventTime();
+ long getEventTime(int index);
/**
* Retrieve the subtitle cues that should be displayed at a given time.
@@ -59,6 +52,6 @@ public interface Subtitle {
* @param timeUs The time in microseconds.
* @return A list of cues that should be displayed, possibly empty.
*/
- public List getCues(long timeUs);
+ List getCues(long timeUs);
}
diff --git a/library/src/main/java/com/google/android/exoplayer/text/SubtitleOutputBuffer.java b/library/src/main/java/com/google/android/exoplayer/text/SubtitleOutputBuffer.java
index 5792a120d0..f083dcb7c8 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/SubtitleOutputBuffer.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/SubtitleOutputBuffer.java
@@ -51,11 +51,6 @@ import java.util.List;
return subtitle.getEventTime(index) + offsetUs;
}
- @Override
- public long getLastEventTime() {
- return subtitle.getLastEventTime() + offsetUs;
- }
-
@Override
public int getNextEventTimeIndex(long timeUs) {
return subtitle.getNextEventTimeIndex(timeUs - offsetUs);
diff --git a/library/src/main/java/com/google/android/exoplayer/text/SubtitleParserFactory.java b/library/src/main/java/com/google/android/exoplayer/text/SubtitleParserFactory.java
index 81b107cba2..d0c46222e6 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/SubtitleParserFactory.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/SubtitleParserFactory.java
@@ -53,7 +53,7 @@ public interface SubtitleParserFactory {
* TX3G ({@link com.google.android.exoplayer.text.tx3g.Tx3gParser})
*
*/
- final SubtitleParserFactory DEFAULT = new SubtitleParserFactory() {
+ SubtitleParserFactory DEFAULT = new SubtitleParserFactory() {
@Override
public boolean supportsFormat(Format format) {
@@ -68,7 +68,7 @@ public interface SubtitleParserFactory {
throw new IllegalArgumentException("Attempted to create parser for unsupported format");
}
return clazz.asSubclass(SubtitleParser.class).newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
+ } catch (Exception e) {
throw new IllegalStateException("Unexpected error instantiating parser", e);
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java b/library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java
index 4ab5d3e8b8..fc8f197de6 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/TextTrackRenderer.java
@@ -140,11 +140,10 @@ public final class TextTrackRenderer extends TrackRenderer implements Callback {
}
boolean textRendererNeedsUpdate = false;
- long subtitleNextEventTimeUs = Long.MAX_VALUE;
if (subtitle != null) {
// We're iterating through the events in a subtitle. Set textRendererNeedsUpdate if we
// advance to the next event.
- subtitleNextEventTimeUs = getNextEventTime();
+ long subtitleNextEventTimeUs = getNextEventTime();
while (subtitleNextEventTimeUs <= positionUs) {
nextSubtitleEventIndex++;
subtitleNextEventTimeUs = getNextEventTime();
diff --git a/library/src/main/java/com/google/android/exoplayer/text/eia608/ClosedCaptionCtrl.java b/library/src/main/java/com/google/android/exoplayer/text/eia608/ClosedCaptionCtrl.java
index e1f2bab41e..d057b7e653 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/eia608/ClosedCaptionCtrl.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/eia608/ClosedCaptionCtrl.java
@@ -18,38 +18,36 @@ package com.google.android.exoplayer.text.eia608;
/* package */ final class ClosedCaptionCtrl extends ClosedCaption {
/**
- * The receipt of the {@link #RESUME_CAPTION_LOADING} command initiates pop-on style captioning.
- * Subsequent data should be loaded into a non-displayed memory and held there until the
- * {@link #END_OF_CAPTION} command is received, at which point the non-displayed memory becomes
- * the displayed memory (and vice versa).
+ * Command initiating pop-on style captioning. Subsequent data should be loaded into a
+ * non-displayed memory and held there until the {@link #END_OF_CAPTION} command is received, at
+ * which point the non-displayed memory becomes the displayed memory (and vice versa).
*/
public static final byte RESUME_CAPTION_LOADING = 0x20;
/**
- * The receipt of the {@link #ROLL_UP_CAPTIONS_2_ROWS} command initiates roll-up style
- * captioning, with the maximum of 2 rows displayed simultaneously.
+ * Command initiating roll-up style captioning, with the maximum of 2 rows displayed
+ * simultaneously.
*/
public static final byte ROLL_UP_CAPTIONS_2_ROWS = 0x25;
/**
- * The receipt of the {@link #ROLL_UP_CAPTIONS_3_ROWS} command initiates roll-up style
- * captioning, with the maximum of 3 rows displayed simultaneously.
+ * Command initiating roll-up style captioning, with the maximum of 3 rows displayed
+ * simultaneously.
*/
public static final byte ROLL_UP_CAPTIONS_3_ROWS = 0x26;
/**
- * The receipt of the {@link #ROLL_UP_CAPTIONS_4_ROWS} command initiates roll-up style
- * captioning, with the maximum of 4 rows displayed simultaneously.
+ * Command initiating roll-up style captioning, with the maximum of 4 rows displayed
+ * simultaneously.
*/
public static final byte ROLL_UP_CAPTIONS_4_ROWS = 0x27;
/**
- * The receipt of the {@link #RESUME_DIRECT_CAPTIONING} command initiates paint-on style
- * captioning. Subsequent data should be addressed immediately to displayed memory without need
- * for the {@link #RESUME_CAPTION_LOADING} command.
+ * Command initiating paint-on style captioning. Subsequent data should be addressed immediately
+ * to displayed memory without need for the {@link #RESUME_CAPTION_LOADING} command.
*/
public static final byte RESUME_DIRECT_CAPTIONING = 0x29;
/**
- * The receipt of the {@link #END_OF_CAPTION} command indicates the end of pop-on style caption,
- * at this point already loaded in non-displayed memory caption should become the displayed
- * memory (and vice versa). If no {@link #RESUME_CAPTION_LOADING} command has been received,
- * {@link #END_OF_CAPTION} command forces the receiver into pop-on style.
+ * Command indicating the end of a pop-on style caption. At this point the caption loaded in
+ * non-displayed memory should be swapped with the one in displayed memory. If no
+ * {@link #RESUME_CAPTION_LOADING} command has been received, this command forces the receiver
+ * into pop-on style.
*/
public static final byte END_OF_CAPTION = 0x2F;
diff --git a/library/src/main/java/com/google/android/exoplayer/text/subrip/SubripSubtitle.java b/library/src/main/java/com/google/android/exoplayer/text/subrip/SubripSubtitle.java
index b10804311b..cfc61ad435 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/subrip/SubripSubtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/subrip/SubripSubtitle.java
@@ -58,20 +58,12 @@ import java.util.List;
return cueTimesUs[index];
}
- @Override
- public long getLastEventTime() {
- if (getEventTimeCount() == 0) {
- return -1;
- }
- return cueTimesUs[cueTimesUs.length - 1];
- }
-
@Override
public List getCues(long timeUs) {
int index = Util.binarySearchFloor(cueTimesUs, timeUs, true, false);
if (index == -1 || cues[index] == null) {
// timeUs is earlier than the start of the first cue, or we have an empty cue.
- return Collections.emptyList();
+ return Collections.emptyList();
} else {
return Collections.singletonList(cues[index]);
}
diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java
index d393875c57..184ac336a6 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlNode.java
@@ -74,7 +74,7 @@ import java.util.TreeSet;
public final long startTimeUs;
public final long endTimeUs;
public final TtmlStyle style;
- private String[] styleIds;
+ private final String[] styleIds;
private List children;
private int start;
diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
index 9c144625c1..abe3fceb19 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
@@ -280,23 +280,29 @@ public final class TtmlParser extends SubtitleParser {
for (int i = 0; i < attributeCount; i++) {
String attr = ParserUtil.removeNamespacePrefix(parser.getAttributeName(i));
String value = parser.getAttributeValue(i);
- if (attr.equals(ATTR_BEGIN)) {
- startTime = parseTimeExpression(value,
- DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
- } else if (attr.equals(ATTR_END)) {
- endTime = parseTimeExpression(value,
- DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
- } else if (attr.equals(ATTR_DURATION)) {
- duration = parseTimeExpression(value,
- DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
- } else if (attr.equals(ATTR_STYLE)) {
- // IDREFS: potentially multiple space delimited ids
- String[] ids = parseStyleIds(value);
- if (ids.length > 0) {
- styleIds = ids;
- }
- } else {
- // Do nothing.
+ switch (attr) {
+ case ATTR_BEGIN:
+ startTime = parseTimeExpression(value,
+ DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
+ break;
+ case ATTR_END:
+ endTime = parseTimeExpression(value,
+ DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
+ break;
+ case ATTR_DURATION:
+ duration = parseTimeExpression(value,
+ DEFAULT_FRAMERATE, DEFAULT_SUBFRAMERATE, DEFAULT_TICKRATE);
+ break;
+ case ATTR_STYLE:
+ // IDREFS: potentially multiple space delimited ids
+ String[] ids = parseStyleIds(value);
+ if (ids.length > 0) {
+ styleIds = ids;
+ }
+ break;
+ default:
+ // Do nothing.
+ break;
}
}
if (parent != null && parent.startTimeUs != TtmlNode.UNDEFINED_TIME) {
@@ -320,7 +326,7 @@ public final class TtmlParser extends SubtitleParser {
}
private static boolean isSupportedTag(String tag) {
- if (tag.equals(TtmlNode.TAG_TT)
+ return tag.equals(TtmlNode.TAG_TT)
|| tag.equals(TtmlNode.TAG_HEAD)
|| tag.equals(TtmlNode.TAG_BODY)
|| tag.equals(TtmlNode.TAG_DIV)
@@ -334,10 +340,7 @@ public final class TtmlParser extends SubtitleParser {
|| tag.equals(TtmlNode.TAG_METADATA)
|| tag.equals(TtmlNode.TAG_SMPTE_IMAGE)
|| tag.equals(TtmlNode.TAG_SMPTE_DATA)
- || tag.equals(TtmlNode.TAG_SMPTE_INFORMATION)) {
- return true;
- }
- return false;
+ || tag.equals(TtmlNode.TAG_SMPTE_INFORMATION);
}
private static void parseFontSize(String expression, TtmlStyle out) throws ParserException {
@@ -411,18 +414,25 @@ public final class TtmlParser extends SubtitleParser {
String timeValue = matcher.group(1);
double offsetSeconds = Double.parseDouble(timeValue);
String unit = matcher.group(2);
- if (unit.equals("h")) {
- offsetSeconds *= 3600;
- } else if (unit.equals("m")) {
- offsetSeconds *= 60;
- } else if (unit.equals("s")) {
- // Do nothing.
- } else if (unit.equals("ms")) {
- offsetSeconds /= 1000;
- } else if (unit.equals("f")) {
- offsetSeconds /= frameRate;
- } else if (unit.equals("t")) {
- offsetSeconds /= tickRate;
+ switch (unit) {
+ case "h":
+ offsetSeconds *= 3600;
+ break;
+ case "m":
+ offsetSeconds *= 60;
+ break;
+ case "s":
+ // Do nothing.
+ break;
+ case "ms":
+ offsetSeconds /= 1000;
+ break;
+ case "f":
+ offsetSeconds /= frameRate;
+ break;
+ case "t":
+ offsetSeconds /= tickRate;
+ break;
}
return (long) (offsetSeconds * C.MICROS_PER_SECOND);
}
diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlSubtitle.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlSubtitle.java
index a989bf86f8..d03a509fed 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlSubtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlSubtitle.java
@@ -55,11 +55,6 @@ public final class TtmlSubtitle implements Subtitle {
return eventTimesUs[index];
}
- @Override
- public long getLastEventTime() {
- return (eventTimesUs.length == 0 ? -1 : eventTimesUs[eventTimesUs.length - 1]);
- }
-
/* @VisibleForTesting */
/* package */ TtmlNode getRoot() {
return root;
@@ -69,7 +64,7 @@ public final class TtmlSubtitle implements Subtitle {
public List getCues(long timeUs) {
CharSequence cueText = root.getText(timeUs, globalStyles);
if (cueText == null) {
- return Collections.emptyList();
+ return Collections.emptyList();
} else {
Cue cue = new Cue(cueText);
return Collections.singletonList(cue);
diff --git a/library/src/main/java/com/google/android/exoplayer/text/tx3g/Tx3gSubtitle.java b/library/src/main/java/com/google/android/exoplayer/text/tx3g/Tx3gSubtitle.java
index d3ff90fcda..3401edba1b 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/tx3g/Tx3gSubtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/tx3g/Tx3gSubtitle.java
@@ -49,11 +49,6 @@ import java.util.List;
return 0;
}
- @Override
- public long getLastEventTime() {
- return 0;
- }
-
@Override
public List getCues(long timeUs) {
return timeUs >= 0 ? cues : Collections.emptyList();
diff --git a/library/src/main/java/com/google/android/exoplayer/text/webvtt/CssParser.java b/library/src/main/java/com/google/android/exoplayer/text/webvtt/CssParser.java
index 818c720afe..ff72e2f52b 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/webvtt/CssParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/webvtt/CssParser.java
@@ -286,10 +286,6 @@ import java.util.Map;
return false;
}
- boolean commentEndsInPosition(byte[] data, int pos) {
- return data[pos] == '/' && data[pos - 1] == '*';
- }
-
private static String parseIdentifier(ParsableByteArray input, StringBuilder stringBuilder) {
stringBuilder.setLength(0);
int position = input.getPosition();
diff --git a/library/src/main/java/com/google/android/exoplayer/text/webvtt/Mp4WebvttSubtitle.java b/library/src/main/java/com/google/android/exoplayer/text/webvtt/Mp4WebvttSubtitle.java
index 474abafbc1..09bddabfe7 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/webvtt/Mp4WebvttSubtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/webvtt/Mp4WebvttSubtitle.java
@@ -49,11 +49,6 @@ import java.util.List;
return 0;
}
- @Override
- public long getLastEventTime() {
- return 0;
- }
-
@Override
public List getCues(long timeUs) {
return timeUs >= 0 ? cues : Collections.emptyList();
diff --git a/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java b/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java
index 309ca1d535..9099295b31 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/webvtt/WebvttSubtitle.java
@@ -72,14 +72,6 @@ public final class WebvttSubtitle implements Subtitle {
return sortedCueTimesUs[index];
}
- @Override
- public long getLastEventTime() {
- if (getEventTimeCount() == 0) {
- return -1;
- }
- return sortedCueTimesUs[sortedCueTimesUs.length - 1];
- }
-
@Override
public List getCues(long timeUs) {
ArrayList list = null;
@@ -120,7 +112,7 @@ public final class WebvttSubtitle implements Subtitle {
if (list != null) {
return list;
} else {
- return Collections.emptyList();
+ return Collections.emptyList();
}
}
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/AssetDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/AssetDataSource.java
index 6b284710bd..2b7a1f2782 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/AssetDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/AssetDataSource.java
@@ -110,7 +110,7 @@ public final class AssetDataSource implements DataSource {
if (bytesRemaining == 0) {
return C.RESULT_END_OF_INPUT;
} else {
- int bytesRead = 0;
+ int bytesRead;
try {
int bytesToRead = bytesRemaining == C.LENGTH_UNBOUNDED ? readLength
: (int) Math.min(bytesRemaining, readLength);
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/BandwidthMeter.java b/library/src/main/java/com/google/android/exoplayer/upstream/BandwidthMeter.java
index f8f7eb24af..bc99bf27ff 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/BandwidthMeter.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/BandwidthMeter.java
@@ -23,7 +23,7 @@ public interface BandwidthMeter extends TransferListener {
/**
* Interface definition for a callback to be notified of {@link BandwidthMeter} events.
*/
- public interface EventListener {
+ interface EventListener {
/**
* Invoked periodically to indicate that bytes have been transferred.
@@ -40,7 +40,7 @@ public interface BandwidthMeter extends TransferListener {
/**
* Indicates no bandwidth estimate is available.
*/
- final long NO_ESTIMATE = -1;
+ long NO_ESTIMATE = -1;
/**
* Gets the estimated bandwidth, in bits/sec.
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/ContentDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/ContentDataSource.java
index c1a2f6ea19..658fd1f96a 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/ContentDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/ContentDataSource.java
@@ -108,7 +108,7 @@ public final class ContentDataSource implements DataSource {
if (bytesRemaining == 0) {
return C.RESULT_END_OF_INPUT;
} else {
- int bytesRead = 0;
+ int bytesRead;
try {
int bytesToRead = bytesRemaining == C.LENGTH_UNBOUNDED ? readLength
: (int) Math.min(bytesRemaining, readLength);
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/DataSink.java b/library/src/main/java/com/google/android/exoplayer/upstream/DataSink.java
index 7fb160fe1e..900d064ebe 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/DataSink.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/DataSink.java
@@ -23,21 +23,20 @@ import java.io.IOException;
public interface DataSink {
/**
- * Opens the {@link DataSink} to consume the specified data. Calls to {@link #open(DataSpec)} and
- * {@link #close()} must be balanced.
+ * Opens the {@link DataSink} to consume the specified data.
*
* @param dataSpec Defines the data to be consumed.
* @return This {@link DataSink}, for convenience.
* @throws IOException
*/
- public DataSink open(DataSpec dataSpec) throws IOException;
+ DataSink open(DataSpec dataSpec) throws IOException;
/**
* Closes the {@link DataSink}.
*
* @throws IOException
*/
- public void close() throws IOException;
+ void close() throws IOException;
/**
* Consumes the provided data.
@@ -47,6 +46,6 @@ public interface DataSink {
* @param length The length of the data to consume, in bytes.
* @throws IOException
*/
- public void write(byte[] buffer, int offset, int length) throws IOException;
+ void write(byte[] buffer, int offset, int length) throws IOException;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/DataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/DataSource.java
index 5fae84fe65..2878517a8e 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/DataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/DataSource.java
@@ -27,13 +27,11 @@ import java.io.IOException;
public interface DataSource {
/**
- * Opens the {@link DataSource} to read the specified data. Calls to {@link #open(DataSpec)} and
- * {@link #close()} must be balanced.
+ * Opens the {@link DataSource} to read the specified data.
*
- * Note: If {@link #open(DataSpec)} throws an {@link IOException}, callers must still call
- * {@link #close()} to ensure that any partial effects of the {@link #open(DataSpec)} invocation
- * are cleaned up. Implementations of this class can assume that callers will call
- * {@link #close()} in this case.
+ * Note: If an {@link IOException} is thrown, callers must still call {@link #close()} to ensure
+ * that any partial effects of the invocation are cleaned up. Implementations of this class can
+ * assume that callers will call {@link #close()} in this case.
*
* @param dataSpec Defines the data to be read.
* @throws IOException If an error occurs opening the source.
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java
index 38d0c498b3..18546480a0 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/DefaultHttpDataSource.java
@@ -339,9 +339,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
if (!allowCrossProtocolRedirects) {
// HttpURLConnection disallows cross-protocol redirects, but otherwise performs redirection
// automatically. This is the behavior we want, so use it.
- HttpURLConnection connection = makeConnection(
- url, postBody, position, length, allowGzip, true /* followRedirects */);
- return connection;
+ return makeConnection(url, postBody, position, length, allowGzip, true /* followRedirects */);
}
// We need to handle redirects ourselves to allow cross-protocol redirects.
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/FileDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/FileDataSource.java
index 7b5c94c307..0225e5f1a8 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/FileDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/FileDataSource.java
@@ -90,7 +90,7 @@ public final class FileDataSource implements DataSource {
if (bytesRemaining == 0) {
return C.RESULT_END_OF_INPUT;
} else {
- int bytesRead = 0;
+ int bytesRead;
try {
bytesRead = file.read(buffer, offset, (int) Math.min(bytesRemaining, readLength));
} catch (IOException e) {
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java
index 76dc9c6aa4..4d8e4af1be 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/HttpDataSource.java
@@ -32,7 +32,7 @@ public interface HttpDataSource extends DataSource {
/**
* A {@link Predicate} that rejects content types often used for pay-walls.
*/
- public static final Predicate REJECT_PAYWALL_TYPES = new Predicate() {
+ Predicate REJECT_PAYWALL_TYPES = new Predicate() {
@Override
public boolean evaluate(String contentType) {
@@ -47,7 +47,7 @@ public interface HttpDataSource extends DataSource {
/**
* Thrown when an error is encountered when trying to read from a {@link HttpDataSource}.
*/
- public static class HttpDataSourceException extends IOException {
+ class HttpDataSourceException extends IOException {
/*
* The {@link DataSpec} associated with the current connection.
@@ -79,7 +79,7 @@ public interface HttpDataSource extends DataSource {
/**
* Thrown when the content type is invalid.
*/
- public static final class InvalidContentTypeException extends HttpDataSourceException {
+ final class InvalidContentTypeException extends HttpDataSourceException {
public final String contentType;
@@ -93,7 +93,7 @@ public interface HttpDataSource extends DataSource {
/**
* Thrown when an attempt to open a connection results in a response code not in the 2xx range.
*/
- public static final class InvalidResponseCodeException extends HttpDataSourceException {
+ final class InvalidResponseCodeException extends HttpDataSourceException {
/**
* The response code that was outside of the 2xx range.
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/UdpDataSource.java b/library/src/main/java/com/google/android/exoplayer/upstream/UdpDataSource.java
index ee333b56a4..ecf34d0bfa 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/UdpDataSource.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/UdpDataSource.java
@@ -37,10 +37,6 @@ public final class UdpDataSource implements DataSource {
*/
public static final class UdpDataSourceException extends IOException {
- public UdpDataSourceException(String message) {
- super(message);
- }
-
public UdpDataSourceException(IOException cause) {
super(cause);
}
@@ -58,8 +54,9 @@ public final class UdpDataSource implements DataSource {
public static final int DEAFULT_SOCKET_TIMEOUT_MILLIS = 8 * 1000;
private final TransferListener listener;
- private final DatagramPacket packet;
private final int socketTimeoutMillis;
+ private final byte[] packetBuffer;
+ private final DatagramPacket packet;
private Uri uri;
private DatagramSocket socket;
@@ -68,7 +65,6 @@ public final class UdpDataSource implements DataSource {
private InetSocketAddress socketAddress;
private boolean opened;
- private byte[] packetBuffer;
private int packetRemaining;
/**
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/UriLoadable.java b/library/src/main/java/com/google/android/exoplayer/upstream/UriLoadable.java
index 1bfef347b2..ac7317fea0 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/UriLoadable.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/UriLoadable.java
@@ -44,7 +44,7 @@ public final class UriLoadable implements Loadable {
* @throws ParserException If an error occurs parsing the data.
* @throws IOException If an error occurs reading data from the stream.
*/
- T parse(Uri uri, InputStream inputStream) throws ParserException, IOException;
+ T parse(Uri uri, InputStream inputStream) throws IOException;
}
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/cache/Cache.java b/library/src/main/java/com/google/android/exoplayer/upstream/cache/Cache.java
index a818520282..232edb38c9 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/cache/Cache.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/cache/Cache.java
@@ -27,7 +27,7 @@ public interface Cache {
/**
* Interface definition for a callback to be notified of {@link Cache} events.
*/
- public interface Listener {
+ interface Listener {
/**
* Invoked when a {@link CacheSpan} is added to the cache.
diff --git a/library/src/main/java/com/google/android/exoplayer/upstream/cache/SimpleCache.java b/library/src/main/java/com/google/android/exoplayer/upstream/cache/SimpleCache.java
index 5ff3118d3c..a7e2ebdb6f 100644
--- a/library/src/main/java/com/google/android/exoplayer/upstream/cache/SimpleCache.java
+++ b/library/src/main/java/com/google/android/exoplayer/upstream/cache/SimpleCache.java
@@ -359,9 +359,7 @@ public final class SimpleCache implements Cache {
// floorSpan covers the queried region.
return true;
}
- Iterator iterator = entries.tailSet(floorSpan, false).iterator();
- while (iterator.hasNext()) {
- CacheSpan next = iterator.next();
+ for (CacheSpan next : entries.tailSet(floorSpan, false)) {
if (next.position > currentEndPosition) {
// There's a hole in the cache within the queried region.
return false;
diff --git a/library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java b/library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java
index 6ba16f0ee1..1bb886b68c 100644
--- a/library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java
+++ b/library/src/main/java/com/google/android/exoplayer/util/CodecSpecificDataUtil.java
@@ -67,8 +67,6 @@ public final class CodecSpecificDataUtil {
AUDIO_SPECIFIC_CONFIG_CHANNEL_CONFIGURATION_INVALID
};
- // Advanced Audio Coding Low-Complexity profile.
- private static final int AUDIO_OBJECT_TYPE_AAC_LC = 2;
// Spectral Band Replication.
private static final int AUDIO_OBJECT_TYPE_SBR = 5;
// Error Resilient Bit-Sliced Arithmetic Coding.
@@ -136,33 +134,6 @@ public final class CodecSpecificDataUtil {
return audioSpecificConfig;
}
- /**
- * Builds a simple HE-AAC LC AudioSpecificConfig, as defined in ISO 14496-3 1.6.2.1
- *
- * @param sampleRate The sample rate in Hz.
- * @param numChannels The number of channels.
- * @return The AudioSpecificConfig.
- */
- public static byte[] buildAacAudioSpecificConfig(int sampleRate, int numChannels) {
- int sampleRateIndex = -1;
- for (int i = 0; i < AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE.length; ++i) {
- if (sampleRate == AUDIO_SPECIFIC_CONFIG_SAMPLING_RATE_TABLE[i]) {
- sampleRateIndex = i;
- }
- }
- int channelConfig = -1;
- for (int i = 0; i < AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE.length; ++i) {
- if (numChannels == AUDIO_SPECIFIC_CONFIG_CHANNEL_COUNT_TABLE[i]) {
- channelConfig = i;
- }
- }
- // The full specification for AudioSpecificConfig is stated in ISO 14496-3 Section 1.6.2.1
- byte[] csd = new byte[2];
- csd[0] = (byte) ((AUDIO_OBJECT_TYPE_AAC_LC << 3) | (sampleRateIndex >> 1));
- csd[1] = (byte) (((sampleRateIndex & 0x1) << 7) | (channelConfig << 3));
- return csd;
- }
-
/**
* Constructs a NAL unit consisting of the NAL start code followed by the specified data.
*
diff --git a/library/src/main/java/com/google/android/exoplayer/util/ManifestFetcher.java b/library/src/main/java/com/google/android/exoplayer/util/ManifestFetcher.java
index ed09da2439..7fb81aeeaf 100644
--- a/library/src/main/java/com/google/android/exoplayer/util/ManifestFetcher.java
+++ b/library/src/main/java/com/google/android/exoplayer/util/ManifestFetcher.java
@@ -47,11 +47,11 @@ public class ManifestFetcher implements Loader.Callback {
*/
public interface EventListener {
- public void onManifestRefreshStarted();
+ void onManifestRefreshStarted();
- public void onManifestRefreshed();
+ void onManifestRefreshed();
- public void onManifestError(IOException e);
+ void onManifestError(IOException e);
}
@@ -65,7 +65,7 @@ public class ManifestFetcher implements Loader.Callback {
* Returns the {@link Uri} from which subsequent manifests should be requested, or null to
* continue using the current {@link Uri}.
*/
- public Uri getNextManifestUri();
+ Uri getNextManifestUri();
}
diff --git a/library/src/main/java/com/google/android/exoplayer/util/UriUtil.java b/library/src/main/java/com/google/android/exoplayer/util/UriUtil.java
index 61eb8fa0a4..f98d6e13ee 100644
--- a/library/src/main/java/com/google/android/exoplayer/util/UriUtil.java
+++ b/library/src/main/java/com/google/android/exoplayer/util/UriUtil.java
@@ -163,7 +163,7 @@ public final class UriUtil {
int segmentStart = offset;
int i = offset;
while (i <= limit) {
- int nextSegmentStart = -1;
+ int nextSegmentStart;
if (i == limit) {
nextSegmentStart = i;
} else if (uri.charAt(i) == '/') {
diff --git a/library/src/main/java/com/google/android/exoplayer/util/Util.java b/library/src/main/java/com/google/android/exoplayer/util/Util.java
index 117e31c086..870c44345b 100644
--- a/library/src/main/java/com/google/android/exoplayer/util/Util.java
+++ b/library/src/main/java/com/google/android/exoplayer/util/Util.java
@@ -384,20 +384,6 @@ public final class Util {
return stayInBounds ? Math.min(list.size() - 1, index) : index;
}
- /**
- * Creates an integer array containing the integers from 0 to {@code length - 1}.
- *
- * @param length The length of the array.
- * @return The array.
- */
- public static int[] firstIntegersArray(int length) {
- int[] firstIntegers = new int[length];
- for (int i = 0; i < length; i++) {
- firstIntegers[i] = i;
- }
- return firstIntegers;
- }
-
/**
* Parses an xs:duration attribute value, returning the parsed duration in milliseconds.
*
@@ -876,8 +862,8 @@ public final class Util {
* See {@link #escapeFileName(String)} for more information.
*
* @param fileName File name to be unescaped.
- * @return The original value of the file name before it was escaped,
- * or null if the escaped fileName seems invalid.
+ * @return The original value of the file name before it was escaped, or null if the escaped
+ * fileName seems invalid.
*/
public static String unescapeFileName(String fileName) {
int length = fileName.length();