From db8356a17c3c2b20f4fd1b107f2a34b8f067dca7 Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 18 Nov 2020 20:11:59 +0000 Subject: [PATCH] Suppress warnings in preparation for Checker Framework 3.7.1 upgrade. LSC: go/checker-lsc Tested: tap_presubmit: http://test/OCL:342788975:BASE:342885903:1605667635149:7731b723 Some tests failed; test failures are believed to be unrelated to this CL PiperOrigin-RevId: 343129490 --- .../source/ClippingMediaPeriod.java | 6 +- .../source/DefaultMediaSourceFactory.java | 4 + .../source/ExtractorMediaSource.java | 2 + .../source/MediaSourceDrmHelper.java | 10 ++- .../exoplayer2/source/MediaSourceFactory.java | 2 + .../source/ProgressiveMediaSource.java | 2 + .../source/SingleSampleMediaPeriod.java | 5 +- .../upstream/cache/CacheDataSource.java | 21 ++++- .../cache/CacheDataSourceFactory.java | 15 +++- .../upstream/cache/CacheWriter.java | 2 + .../upstream/cache/CachedContentIndex.java | 4 + .../upstream/cache/ContentMetadata.java | 2 + .../cache/DefaultContentMetadata.java | 22 ++++- .../exoplayer2/extractor/mp4/AtomParsers.java | 84 +++++++++++++++---- .../extractor/mp4/FragmentedMp4Extractor.java | 10 ++- .../extractor/mp4/MetadataUtil.java | 2 + .../extractor/mp4/Mp4Extractor.java | 10 ++- .../extractor/mp4/PsshAtomUtil.java | 6 ++ .../exoplayer2/extractor/mp4/Track.java | 36 +++++--- .../extractor/mp4/TrackEncryptionBox.java | 7 +- 20 files changed, 207 insertions(+), 45 deletions(-) diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java index 7bb6a83add..a47ac0c573 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaPeriod.java @@ -39,7 +39,11 @@ public final class ClippingMediaPeriod implements MediaPeriod, MediaPeriod.Callb */ public final MediaPeriod mediaPeriod; - @Nullable private MediaPeriod.Callback callback; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private MediaPeriod.Callback callback; + private @NullableType ClippingSampleStream[] sampleStreams; private long pendingInitialDiscontinuityPositionUs; /* package */ long startUs; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java index a04dbd215f..285aa3a67c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/DefaultMediaSourceFactory.java @@ -253,6 +253,8 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { return this; } + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Override public DefaultMediaSourceFactory setDrmHttpDataSourceFactory( @Nullable HttpDataSource.Factory drmHttpDataSourceFactory) { @@ -389,6 +391,8 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { private MediaSource maybeWrapWithAdsMediaSource(MediaItem mediaItem, MediaSource mediaSource) { Assertions.checkNotNull(mediaItem.playbackProperties); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Nullable MediaItem.AdsConfiguration adsConfiguration = mediaItem.playbackProperties.adsConfiguration; if (adsConfiguration == null) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java index 38146c92b2..d82b9b037c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ExtractorMediaSource.java @@ -172,6 +172,8 @@ public final class ExtractorMediaSource extends CompositeMediaSource { /** * @deprecated Use {@link ProgressiveMediaSource.Factory#setDrmHttpDataSourceFactory} instead. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Deprecated @Override public MediaSourceFactory setDrmHttpDataSourceFactory( diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceDrmHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceDrmHelper.java index f4a7b89fc7..414a72d34e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceDrmHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceDrmHelper.java @@ -34,7 +34,11 @@ import java.util.Map; /** A helper to create a {@link DrmSessionManager} from a {@link MediaItem}. */ public final class MediaSourceDrmHelper { - @Nullable private HttpDataSource.Factory drmHttpDataSourceFactory; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private HttpDataSource.Factory drmHttpDataSourceFactory; + @Nullable private String userAgent; /** @@ -45,6 +49,8 @@ public final class MediaSourceDrmHelper { * @param drmHttpDataSourceFactory The HTTP data source factory or {@code null} to use {@link * DefaultHttpDataSourceFactory}. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") public void setDrmHttpDataSourceFactory( @Nullable HttpDataSource.Factory drmHttpDataSourceFactory) { this.drmHttpDataSourceFactory = drmHttpDataSourceFactory; @@ -65,6 +71,8 @@ public final class MediaSourceDrmHelper { /** Creates a {@link DrmSessionManager} for the given media item. */ public DrmSessionManager create(MediaItem mediaItem) { Assertions.checkNotNull(mediaItem.playbackProperties); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Nullable MediaItem.DrmConfiguration drmConfiguration = mediaItem.playbackProperties.drmConfiguration; if (drmConfiguration == null || Util.SDK_INT < 18) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java index 204220e334..d3dcf1ea3a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MediaSourceFactory.java @@ -77,6 +77,8 @@ public interface MediaSourceFactory { * DefaultHttpDataSourceFactory}. * @return This factory, for convenience. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") MediaSourceFactory setDrmHttpDataSourceFactory( @Nullable HttpDataSource.Factory drmHttpDataSourceFactory); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java index 19f09fde22..f4fa33ed27 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaSource.java @@ -153,6 +153,8 @@ public final class ProgressiveMediaSource extends BaseMediaSource return this; } + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Override public Factory setDrmHttpDataSourceFactory( @Nullable HttpDataSource.Factory drmHttpDataSourceFactory) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java index 352785d37d..7241af85c7 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SingleSampleMediaPeriod.java @@ -406,7 +406,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; private final StatsDataSource dataSource; - @Nullable private byte[] sampleData; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + private byte[] sampleData; public SourceLoadable(DataSpec dataSpec, DataSource dataSource) { this.loadTaskId = LoadEventInfo.getNewId(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java index c2bbdbb893..5c4a9dddbe 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java @@ -57,14 +57,25 @@ public final class CacheDataSource implements DataSource { private @MonotonicNonNull Cache cache; private DataSource.Factory cacheReadDataSourceFactory; - @Nullable private DataSink.Factory cacheWriteDataSinkFactory; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private DataSink.Factory cacheWriteDataSinkFactory; + private CacheKeyFactory cacheKeyFactory; private boolean cacheIsReadOnly; - @Nullable private DataSource.Factory upstreamDataSourceFactory; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private DataSource.Factory upstreamDataSourceFactory; + @Nullable private PriorityTaskManager upstreamPriorityTaskManager; private int upstreamPriority; @CacheDataSource.Flags private int flags; - @Nullable private CacheDataSource.EventListener eventListener; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private CacheDataSource.EventListener eventListener; public Factory() { cacheReadDataSourceFactory = new FileDataSource.Factory(); @@ -117,6 +128,8 @@ public final class CacheDataSource implements DataSource { * DataSinks} for writing data to the cache, or {@code null} to disable writing. * @return This factory. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") public Factory setCacheWriteDataSinkFactory( @Nullable DataSink.Factory cacheWriteDataSinkFactory) { this.cacheWriteDataSinkFactory = cacheWriteDataSinkFactory; @@ -153,6 +166,8 @@ public final class CacheDataSource implements DataSource { * cache, or {@code null} to cause failure in the case of a cache miss. * @return This factory. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") public Factory setUpstreamDataSourceFactory( @Nullable DataSource.Factory upstreamDataSourceFactory) { this.upstreamDataSourceFactory = upstreamDataSourceFactory; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java index 2c51da8a8d..afc617b64b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java @@ -28,8 +28,15 @@ public final class CacheDataSourceFactory implements DataSource.Factory { private final DataSource.Factory upstreamFactory; private final DataSource.Factory cacheReadDataSourceFactory; @CacheDataSource.Flags private final int flags; - @Nullable private final DataSink.Factory cacheWriteDataSinkFactory; - @Nullable private final CacheDataSource.EventListener eventListener; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private final DataSink.Factory cacheWriteDataSinkFactory; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + private final CacheDataSource.EventListener eventListener; + @Nullable private final CacheKeyFactory cacheKeyFactory; /** @@ -60,6 +67,8 @@ public final class CacheDataSourceFactory implements DataSource.Factory { * @see CacheDataSource#CacheDataSource(Cache, DataSource, DataSource, DataSink, int, * CacheDataSource.EventListener) */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") public CacheDataSourceFactory( Cache cache, DataSource.Factory upstreamFactory, @@ -81,6 +90,8 @@ public final class CacheDataSourceFactory implements DataSource.Factory { * @see CacheDataSource#CacheDataSource(Cache, DataSource, DataSource, DataSink, int, * CacheDataSource.EventListener, CacheKeyFactory) */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") public CacheDataSourceFactory( Cache cache, DataSource.Factory upstreamFactory, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java index 8ea2b4e280..ec18bd4e40 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheWriter.java @@ -73,6 +73,8 @@ public final class CacheWriter { * writer should instantiate its own internal temporary buffer. * @param progressListener An optional progress listener. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public CacheWriter( CacheDataSource dataSource, DataSpec dataSpec, diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java index 850ac59f04..8bf3320f00 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndex.java @@ -153,6 +153,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; * enabled. This option is only useful for downgrading from database storage back to legacy * storage. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public CachedContentIndex( @Nullable DatabaseProvider databaseProvider, @Nullable File legacyStorageDir, @@ -517,6 +519,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; private boolean changed; @Nullable private ReusableBufferedOutputStream bufferedOutputStream; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public LegacyStorage(File file, @Nullable byte[] secretKey, boolean encrypt) { checkState(secretKey != null || !encrypt); @Nullable Cipher cipher = null; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadata.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadata.java index 26b6d83a43..8081420b02 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadata.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadata.java @@ -42,6 +42,8 @@ public interface ContentMetadata { * @param defaultValue Value to return if the metadata doesn't exist. * @return The metadata value. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") @Nullable byte[] get(String key, @Nullable byte[] defaultValue); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java index 706fa0d2c3..741fed9f11 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java @@ -63,10 +63,15 @@ public final class DefaultContentMetadata implements ContentMetadata { return metadata.entrySet(); } + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") @Override @Nullable public final byte[] get(String name, @Nullable byte[] defaultValue) { - @Nullable byte[] bytes = metadata.get(name); + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] bytes = metadata.get(name); if (bytes != null) { return Arrays.copyOf(bytes, bytes.length); } else { @@ -77,7 +82,10 @@ public final class DefaultContentMetadata implements ContentMetadata { @Override @Nullable public final String get(String name, @Nullable String defaultValue) { - @Nullable byte[] bytes = metadata.get(name); + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] bytes = metadata.get(name); if (bytes != null) { return new String(bytes, Charsets.UTF_8); } else { @@ -87,7 +95,10 @@ public final class DefaultContentMetadata implements ContentMetadata { @Override public final long get(String name, long defaultValue) { - @Nullable byte[] bytes = metadata.get(name); + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] bytes = metadata.get(name); if (bytes != null) { return ByteBuffer.wrap(bytes).getLong(); } else { @@ -129,7 +140,10 @@ public final class DefaultContentMetadata implements ContentMetadata { } for (Entry entry : first.entrySet()) { byte[] value = entry.getValue(); - @Nullable byte[] otherValue = second.get(entry.getKey()); + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] otherValue = second.get(entry.getKey()); if (!Arrays.equals(value, otherValue)) { return false; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java index 58cb57f261..76bafb9c9a 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java @@ -177,9 +177,18 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; */ @Nullable public static Metadata parseMdtaFromMeta(Atom.ContainerAtom meta) { - @Nullable Atom.LeafAtom hdlrAtom = meta.getLeafAtomOfType(Atom.TYPE_hdlr); - @Nullable Atom.LeafAtom keysAtom = meta.getLeafAtomOfType(Atom.TYPE_keys); - @Nullable Atom.LeafAtom ilstAtom = meta.getLeafAtomOfType(Atom.TYPE_ilst); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom hdlrAtom = meta.getLeafAtomOfType(Atom.TYPE_hdlr); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom keysAtom = meta.getLeafAtomOfType(Atom.TYPE_keys); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom ilstAtom = meta.getLeafAtomOfType(Atom.TYPE_ilst); if (hdlrAtom == null || keysAtom == null || ilstAtom == null @@ -210,6 +219,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; int keyIndex = ilst.readInt() - 1; if (keyIndex >= 0 && keyIndex < keyNames.length) { String key = keyNames[keyIndex]; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Nullable Metadata.Entry entry = MetadataUtil.parseMdtaMetadataEntryFromIlst(ilst, atomPosition + atomSize, key); @@ -279,10 +290,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; mdhdData.second, drmInitData, isQuickTime); - @Nullable long[] editListDurations = null; - @Nullable long[] editListMediaTimes = null; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + long[] editListDurations = null; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + long[] editListMediaTimes = null; if (!ignoreEditLists) { - @Nullable Atom.ContainerAtom edtsAtom = trak.getContainerAtomOfType(Atom.TYPE_edts); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.ContainerAtom edtsAtom = trak.getContainerAtomOfType(Atom.TYPE_edts); if (edtsAtom != null) { @Nullable Pair edtsData = parseEdts(edtsAtom); if (edtsData != null) { @@ -310,11 +330,17 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; Track track, Atom.ContainerAtom stblAtom, GaplessInfoHolder gaplessInfoHolder) throws ParserException { SampleSizeBox sampleSizeBox; - @Nullable Atom.LeafAtom stszAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stsz); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom stszAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stsz); if (stszAtom != null) { sampleSizeBox = new StszSampleSizeBox(stszAtom); } else { - @Nullable Atom.LeafAtom stz2Atom = stblAtom.getLeafAtomOfType(Atom.TYPE_stz2); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom stz2Atom = stblAtom.getLeafAtomOfType(Atom.TYPE_stz2); if (stz2Atom == null) { throw new ParserException("Track has no sample table size information"); } @@ -335,7 +361,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; // Entries are byte offsets of chunks. boolean chunkOffsetsAreLongs = false; - @Nullable Atom.LeafAtom chunkOffsetsAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stco); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom chunkOffsetsAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stco); if (chunkOffsetsAtom == null) { chunkOffsetsAreLongs = true; chunkOffsetsAtom = checkNotNull(stblAtom.getLeafAtomOfType(Atom.TYPE_co64)); @@ -346,10 +375,16 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; // Entries are (number of samples, timestamp delta between those samples). ParsableByteArray stts = checkNotNull(stblAtom.getLeafAtomOfType(Atom.TYPE_stts)).data; // Entries are the indices of samples that are synchronization samples. - @Nullable Atom.LeafAtom stssAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stss); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom stssAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_stss); @Nullable ParsableByteArray stss = stssAtom != null ? stssAtom.data : null; // Entries are (number of samples, timestamp offset). - @Nullable Atom.LeafAtom cttsAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_ctts); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom cttsAtom = stblAtom.getLeafAtomOfType(Atom.TYPE_ctts); @Nullable ParsableByteArray ctts = cttsAtom != null ? cttsAtom.data : null; // Prepare to read chunk information. @@ -693,7 +728,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; ilst.skipBytes(Atom.HEADER_SIZE); ArrayList entries = new ArrayList<>(); while (ilst.getPosition() < limit) { - @Nullable Metadata.Entry entry = MetadataUtil.parseIlstElement(ilst); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Metadata.Entry entry = MetadataUtil.parseIlstElement(ilst); if (entry != null) { entries.add(entry); } @@ -996,7 +1034,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; @Nullable List initializationData = null; @Nullable String mimeType = null; @Nullable String codecs = null; - @Nullable byte[] projectionData = null; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] projectionData = null; @C.StereoMode int stereoMode = Format.NO_VALUE; while (childPosition - position < size) { @@ -1046,7 +1087,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationDataBytes = parseEsdsFromParent(parent, childStartPosition); mimeType = mimeTypeAndInitializationDataBytes.first; - @Nullable byte[] initializationDataBytes = mimeTypeAndInitializationDataBytes.second; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] initializationDataBytes = mimeTypeAndInitializationDataBytes.second; if (initializationDataBytes != null) { initializationData = ImmutableList.of(initializationDataBytes); } @@ -1123,7 +1167,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; */ @Nullable private static Pair parseEdts(Atom.ContainerAtom edtsAtom) { - @Nullable Atom.LeafAtom elstAtom = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom elstAtom = edtsAtom.getLeafAtomOfType(Atom.TYPE_elst); if (elstAtom == null) { return null; } @@ -1273,7 +1320,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationData = parseEsdsFromParent(parent, esdsAtomPosition); mimeType = mimeTypeAndInitializationData.first; - @Nullable byte[] initializationDataBytes = mimeTypeAndInitializationData.second; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] initializationDataBytes = mimeTypeAndInitializationData.second; if (initializationDataBytes != null) { if (MimeTypes.AUDIO_AAC.equals(mimeType)) { // Update sampleRate and channelCount from the AudioSpecificConfig initialization @@ -1528,6 +1578,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } /** Parses the proj box from sv3d box, as specified by https://github.com/google/spatial-media. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") @Nullable private static byte[] parseProjFromParent(ParsableByteArray parent, int position, int size) { int childPosition = position + Atom.HEADER_SIZE; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java index 32d3bc0677..e052a672f6 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java @@ -1166,7 +1166,10 @@ public class FragmentedMp4Extractor implements Extractor { int perSampleIvSize = sgpd.readUnsignedByte(); byte[] keyId = new byte[16]; sgpd.readBytes(keyId, 0, keyId.length); - @Nullable byte[] constantIv = null; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + byte[] constantIv = null; if (perSampleIvSize == 0) { int constantIvSize = sgpd.readUnsignedByte(); constantIv = new byte[constantIvSize]; @@ -1414,7 +1417,10 @@ public class FragmentedMp4Extractor implements Extractor { @C.BufferFlags int sampleFlags = trackBundle.getCurrentSampleFlags(); // Encryption data. - @Nullable TrackOutput.CryptoData cryptoData = null; + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + TrackOutput.CryptoData cryptoData = null; @Nullable TrackEncryptionBox encryptionBox = trackBundle.getEncryptionBoxIfEncrypted(); if (encryptionBox != null) { cryptoData = encryptionBox.cryptoData; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java index 4a048f8b64..4305394a68 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java @@ -341,6 +341,8 @@ import java.util.List; * @param ilst Holds the data to be parsed. * @return The parsed element, or null if the element's type was not recognized. */ + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") @Nullable public static Metadata.Entry parseIlstElement(ParsableByteArray ilst) { int position = ilst.getPosition(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java index 2a6346fb87..cc50347bea 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java @@ -464,7 +464,10 @@ public final class Mp4Extractor implements Extractor, SeekMap { @Nullable Metadata udtaMetadata = null; boolean isQuickTime = fileType == FILE_TYPE_QUICKTIME; GaplessInfoHolder gaplessInfoHolder = new GaplessInfoHolder(); - @Nullable Atom.LeafAtom udta = moov.getLeafAtomOfType(Atom.TYPE_udta); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.LeafAtom udta = moov.getLeafAtomOfType(Atom.TYPE_udta); if (udta != null) { udtaMetadata = AtomParsers.parseUdta(udta, isQuickTime); if (udtaMetadata != null) { @@ -472,7 +475,10 @@ public final class Mp4Extractor implements Extractor, SeekMap { } } @Nullable Metadata mdtaMetadata = null; - @Nullable Atom.ContainerAtom meta = moov.getContainerAtomOfType(Atom.TYPE_meta); + // nullness annotations are not applicable to outer types + @SuppressWarnings("nullness:nullness.on.outer") + @Nullable + Atom.ContainerAtom meta = moov.getContainerAtomOfType(Atom.TYPE_meta); if (meta != null) { mdtaMetadata = AtomParsers.parseMdtaFromMeta(meta); } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java index b4f537f0ce..93df56daa6 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java @@ -37,6 +37,8 @@ public final class PsshAtomUtil { * @param data The scheme specific data. * @return The PSSH atom. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public static byte[] buildPsshAtom(UUID systemId, @Nullable byte[] data) { return buildPsshAtom(systemId, null, data); } @@ -49,6 +51,8 @@ public final class PsshAtomUtil { * @param data The scheme specific data. * @return The PSSH atom. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public static byte[] buildPsshAtom( UUID systemId, @Nullable UUID[] keyIds, @Nullable byte[] data) { int dataLength = data != null ? data.length : 0; @@ -132,6 +136,8 @@ public final class PsshAtomUtil { * @return The parsed scheme specific data. Null if the input is not a valid PSSH atom, or if the * PSSH atom has an unsupported version, or if the PSSH atom does not match the passed UUID. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") @Nullable public static byte[] parseSchemeSpecificData(byte[] atom, UUID uuid) { @Nullable PsshAtom parsedAtom = parsePsshAtom(atom); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java index 7676926c4d..19bd1a32c0 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java @@ -81,15 +81,17 @@ public final class Track { */ @Transformation public final int sampleTransformation; - /** - * Durations of edit list segments in the movie timescale. Null if there is no edit list. - */ - @Nullable public final long[] editListDurations; + /** Durations of edit list segments in the movie timescale. Null if there is no edit list. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + public final long[] editListDurations; - /** - * Media times for edit list segments in the track timescale. Null if there is no edit list. - */ - @Nullable public final long[] editListMediaTimes; + /** Media times for edit list segments in the track timescale. Null if there is no edit list. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + public final long[] editListMediaTimes; /** * For H264 video tracks, the length in bytes of the NALUnitLength field in each sample. 0 for @@ -99,10 +101,20 @@ public final class Track { @Nullable private final TrackEncryptionBox[] sampleDescriptionEncryptionBoxes; - public Track(int id, int type, long timescale, long movieTimescale, long durationUs, - Format format, @Transformation int sampleTransformation, - @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, int nalUnitLengthFieldLength, - @Nullable long[] editListDurations, @Nullable long[] editListMediaTimes) { + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + public Track( + int id, + int type, + long timescale, + long movieTimescale, + long durationUs, + Format format, + @Transformation int sampleTransformation, + @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, + int nalUnitLengthFieldLength, + @Nullable long[] editListDurations, + @Nullable long[] editListMediaTimes) { this.id = id; this.type = type; this.timescale = timescale; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java index a35d211aa4..1ada137976 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java @@ -52,7 +52,10 @@ public final class TrackEncryptionBox { * If {@link #perSampleIvSize} is 0, holds the default initialization vector as defined in the * track encryption box or sample group description box. Null otherwise. */ - @Nullable public final byte[] defaultInitializationVector; + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") + @Nullable + public final byte[] defaultInitializationVector; /** * @param isEncrypted See {@link #isEncrypted}. @@ -63,6 +66,8 @@ public final class TrackEncryptionBox { * @param defaultClearBlocks See {@link TrackOutput.CryptoData#clearBlocks}. * @param defaultInitializationVector See {@link #defaultInitializationVector}. */ + // nullness annotations are not applicable to primitive types + @SuppressWarnings("nullness:nullness.on.primitive") public TrackEncryptionBox( boolean isEncrypted, @Nullable String schemeType,