Add NonNull at package level for extractor

PiperOrigin-RevId: 286381499
This commit is contained in:
olly 2019-12-19 14:26:44 +00:00 committed by Oliver Woodman
parent fc4b258c10
commit 0f94ebfb7d
7 changed files with 30 additions and 8 deletions

View file

@ -91,7 +91,7 @@ public abstract class BinarySearchSeeker {
protected final BinarySearchSeekMap seekMap; protected final BinarySearchSeekMap seekMap;
protected final TimestampSeeker timestampSeeker; protected final TimestampSeeker timestampSeeker;
protected @Nullable SeekOperationParams seekOperationParams; @Nullable protected SeekOperationParams seekOperationParams;
private final int minimumSearchRange; private final int minimumSearchRange;
@ -173,7 +173,6 @@ public abstract class BinarySearchSeeker {
*/ */
public int handlePendingSeek(ExtractorInput input, PositionHolder seekPositionHolder) public int handlePendingSeek(ExtractorInput input, PositionHolder seekPositionHolder)
throws InterruptedException, IOException { throws InterruptedException, IOException {
TimestampSeeker timestampSeeker = Assertions.checkNotNull(this.timestampSeeker);
while (true) { while (true) {
SeekOperationParams seekOperationParams = Assertions.checkNotNull(this.seekOperationParams); SeekOperationParams seekOperationParams = Assertions.checkNotNull(this.seekOperationParams);
long floorPosition = seekOperationParams.getFloorBytePosition(); long floorPosition = seekOperationParams.getFloorBytePosition();

View file

@ -76,7 +76,7 @@ public final class ChunkIndex implements SeekMap {
* @return The index of the corresponding chunk. * @return The index of the corresponding chunk.
*/ */
public int getChunkIndex(long timeUs) { public int getChunkIndex(long timeUs) {
return Util.binarySearchFloor(timesUs, timeUs, true, true); return Util.binarySearchFloor(timesUs, timeUs, /* inclusive= */ true, /* stayInBounds= */ true);
} }
// SeekMap implementation. // SeekMap implementation.

View file

@ -15,6 +15,7 @@
*/ */
package com.google.android.exoplayer2.extractor; package com.google.android.exoplayer2.extractor;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.extractor.amr.AmrExtractor; import com.google.android.exoplayer2.extractor.amr.AmrExtractor;
import com.google.android.exoplayer2.extractor.flac.FlacExtractor; import com.google.android.exoplayer2.extractor.flac.FlacExtractor;
import com.google.android.exoplayer2.extractor.flv.FlvExtractor; import com.google.android.exoplayer2.extractor.flv.FlvExtractor;
@ -56,10 +57,11 @@ import java.lang.reflect.Constructor;
*/ */
public final class DefaultExtractorsFactory implements ExtractorsFactory { public final class DefaultExtractorsFactory implements ExtractorsFactory {
@Nullable
private static final Constructor<? extends Extractor> FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR; private static final Constructor<? extends Extractor> FLAC_EXTENSION_EXTRACTOR_CONSTRUCTOR;
static { static {
Constructor<? extends Extractor> flacExtensionExtractorConstructor = null; @Nullable Constructor<? extends Extractor> flacExtensionExtractorConstructor = null;
try { try {
// LINT.IfChange // LINT.IfChange
flacExtensionExtractorConstructor = flacExtensionExtractorConstructor =

View file

@ -171,7 +171,7 @@ public final class FlacMetadataReader {
if (type == FlacConstants.METADATA_TYPE_STREAM_INFO) { if (type == FlacConstants.METADATA_TYPE_STREAM_INFO) {
metadataHolder.flacStreamMetadata = readStreamInfoBlock(input); metadataHolder.flacStreamMetadata = readStreamInfoBlock(input);
} else { } else {
FlacStreamMetadata flacStreamMetadata = metadataHolder.flacStreamMetadata; @Nullable FlacStreamMetadata flacStreamMetadata = metadataHolder.flacStreamMetadata;
if (flacStreamMetadata == null) { if (flacStreamMetadata == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View file

@ -15,6 +15,8 @@
*/ */
package com.google.android.exoplayer2.extractor; package com.google.android.exoplayer2.extractor;
import static com.google.android.exoplayer2.util.Util.castNonNull;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.metadata.Metadata; import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.metadata.id3.CommentFrame; import com.google.android.exoplayer2.metadata.id3.CommentFrame;
@ -107,8 +109,8 @@ public final class GaplessInfoHolder {
Matcher matcher = GAPLESS_COMMENT_PATTERN.matcher(data); Matcher matcher = GAPLESS_COMMENT_PATTERN.matcher(data);
if (matcher.find()) { if (matcher.find()) {
try { try {
int encoderDelay = Integer.parseInt(matcher.group(1), 16); int encoderDelay = Integer.parseInt(castNonNull(matcher.group(1)), 16);
int encoderPadding = Integer.parseInt(matcher.group(2), 16); int encoderPadding = Integer.parseInt(castNonNull(matcher.group(2)), 16);
if (encoderDelay > 0 || encoderPadding > 0) { if (encoderDelay > 0 || encoderPadding > 0) {
this.encoderDelay = encoderDelay; this.encoderDelay = encoderDelay;
this.encoderPadding = encoderPadding; this.encoderPadding = encoderPadding;

View file

@ -50,7 +50,7 @@ public final class Id3Peeker {
ExtractorInput input, @Nullable Id3Decoder.FramePredicate id3FramePredicate) ExtractorInput input, @Nullable Id3Decoder.FramePredicate id3FramePredicate)
throws IOException, InterruptedException { throws IOException, InterruptedException {
int peekedId3Bytes = 0; int peekedId3Bytes = 0;
Metadata metadata = null; @Nullable Metadata metadata = null;
while (true) { while (true) {
try { try {
input.peekFully(scratch.data, /* offset= */ 0, Id3Decoder.ID3_HEADER_LENGTH); input.peekFully(scratch.data, /* offset= */ 0, Id3Decoder.ID3_HEADER_LENGTH);

View file

@ -0,0 +1,19 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@NonNullApi
package com.google.android.exoplayer2.extractor;
import com.google.android.exoplayer2.util.NonNullApi;