From a7c6cb4abbbe4279b17547df4f7a8720c95115be Mon Sep 17 00:00:00 2001 From: olly Date: Fri, 31 Jan 2020 17:56:28 +0000 Subject: [PATCH] Add some missing local @Nullable annotations PiperOrigin-RevId: 292564056 --- .../java/com/google/android/exoplayer2/Format.java | 10 ++++++---- .../source/hls/HlsSampleStreamWrapper.java | 13 +++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Format.java b/library/common/src/main/java/com/google/android/exoplayer2/Format.java index de49f57761..b7aaa04c1c 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Format.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Format.java @@ -1111,11 +1111,11 @@ public final class Format implements Parcelable { int trackType = MimeTypes.getTrackType(sampleMimeType); // Use manifest value only. - String id = manifestFormat.id; + @Nullable String id = manifestFormat.id; // Prefer manifest values, but fill in from sample format if missing. - String label = manifestFormat.label != null ? manifestFormat.label : this.label; - String language = this.language; + @Nullable String label = manifestFormat.label != null ? manifestFormat.label : this.label; + @Nullable String language = this.language; if ((trackType == C.TRACK_TYPE_TEXT || trackType == C.TRACK_TYPE_AUDIO) && manifestFormat.language != null) { language = manifestFormat.language; @@ -1123,7 +1123,7 @@ public final class Format implements Parcelable { // Prefer sample format values, but fill in from manifest if missing. int bitrate = this.bitrate == NO_VALUE ? manifestFormat.bitrate : this.bitrate; - String codecs = this.codecs; + @Nullable String codecs = this.codecs; if (codecs == null) { // The manifest format may be muxed, so filter only codecs of this format's type. If we still // have more than one codec then we're unable to uniquely identify which codec to fill in. @@ -1133,6 +1133,7 @@ public final class Format implements Parcelable { } } + @Nullable Metadata metadata = this.metadata == null ? manifestFormat.metadata @@ -1146,6 +1147,7 @@ public final class Format implements Parcelable { // Merge manifest and sample format values. @C.SelectionFlags int selectionFlags = this.selectionFlags | manifestFormat.selectionFlags; @C.RoleFlags int roleFlags = this.roleFlags | manifestFormat.roleFlags; + @Nullable DrmInitData drmInitData = DrmInitData.createSessionCreationData(manifestFormat.drmInitData, this.drmInitData); diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java index 5c62577a55..3e2f477b0c 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java @@ -1009,7 +1009,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; private void updateSampleStreams(@NullableType SampleStream[] streams) { hlsSampleStreams.clear(); - for (SampleStream stream : streams) { + for (@Nullable SampleStream stream : streams) { if (stream != null) { hlsSampleStreams.add((HlsSampleStream) stream); } @@ -1118,7 +1118,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; int primaryExtractorTrackIndex = C.INDEX_UNSET; int extractorTrackCount = sampleQueues.length; for (int i = 0; i < extractorTrackCount; i++) { - String sampleMimeType = sampleQueues[i].getUpstreamFormat().sampleMimeType; + @Nullable String sampleMimeType = sampleQueues[i].getUpstreamFormat().sampleMimeType; int trackType; if (MimeTypes.isVideo(sampleMimeType)) { trackType = C.TRACK_TYPE_VIDEO; @@ -1166,6 +1166,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; trackGroups[i] = new TrackGroup(formats); primaryTrackGroupIndex = i; } else { + @Nullable Format trackFormat = primaryExtractorTrackType == C.TRACK_TYPE_VIDEO && MimeTypes.isAudio(sampleFormat.sampleMimeType) @@ -1280,8 +1281,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ? playlistFormat.channelCount : sampleFormat.channelCount; int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType); - String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); - String mimeType = MimeTypes.getMediaMimeType(codecs); + @Nullable String codecs = Util.getCodecsOfType(playlistFormat.codecs, sampleTrackType); + @Nullable String mimeType = MimeTypes.getMediaMimeType(codecs); if (mimeType == null) { mimeType = sampleFormat.sampleMimeType; } @@ -1304,8 +1305,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; } private static boolean formatsMatch(Format manifestFormat, Format sampleFormat) { - String manifestFormatMimeType = manifestFormat.sampleMimeType; - String sampleFormatMimeType = sampleFormat.sampleMimeType; + @Nullable String manifestFormatMimeType = manifestFormat.sampleMimeType; + @Nullable String sampleFormatMimeType = sampleFormat.sampleMimeType; int manifestFormatTrackType = MimeTypes.getTrackType(manifestFormatMimeType); if (manifestFormatTrackType != C.TRACK_TYPE_TEXT) { return manifestFormatTrackType == MimeTypes.getTrackType(sampleFormatMimeType);