diff --git a/libraries/common/src/main/java/androidx/media3/common/AdOverlayInfo.java b/libraries/common/src/main/java/androidx/media3/common/AdOverlayInfo.java index 40d367aee9..e411912a9b 100644 --- a/libraries/common/src/main/java/androidx/media3/common/AdOverlayInfo.java +++ b/libraries/common/src/main/java/androidx/media3/common/AdOverlayInfo.java @@ -25,6 +25,7 @@ import android.view.View; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -77,6 +78,7 @@ public final class AdOverlayInfo { * * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setDetailedReason(@Nullable String detailedReason) { this.detailedReason = detailedReason; return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/AudioAttributes.java b/libraries/common/src/main/java/androidx/media3/common/AudioAttributes.java index b962fdc89a..11a8ef15bd 100644 --- a/libraries/common/src/main/java/androidx/media3/common/AudioAttributes.java +++ b/libraries/common/src/main/java/androidx/media3/common/AudioAttributes.java @@ -24,6 +24,7 @@ import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -94,30 +95,35 @@ public final class AudioAttributes implements Bundleable { } /** See {@link android.media.AudioAttributes.Builder#setContentType(int)} */ + @CanIgnoreReturnValue public Builder setContentType(@C.AudioContentType int contentType) { this.contentType = contentType; return this; } /** See {@link android.media.AudioAttributes.Builder#setFlags(int)} */ + @CanIgnoreReturnValue public Builder setFlags(@C.AudioFlags int flags) { this.flags = flags; return this; } /** See {@link android.media.AudioAttributes.Builder#setUsage(int)} */ + @CanIgnoreReturnValue public Builder setUsage(@C.AudioUsage int usage) { this.usage = usage; return this; } /** See {@link android.media.AudioAttributes.Builder#setAllowedCapturePolicy(int)}. */ + @CanIgnoreReturnValue public Builder setAllowedCapturePolicy(@C.AudioAllowedCapturePolicy int allowedCapturePolicy) { this.allowedCapturePolicy = allowedCapturePolicy; return this; } /** See {@link android.media.AudioAttributes.Builder#setSpatializationBehavior(int)}. */ + @CanIgnoreReturnValue public Builder setSpatializationBehavior(@C.SpatializationBehavior int spatializationBehavior) { this.spatializationBehavior = spatializationBehavior; return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/FlagSet.java b/libraries/common/src/main/java/androidx/media3/common/FlagSet.java index 4d9b908432..e67e4a6402 100644 --- a/libraries/common/src/main/java/androidx/media3/common/FlagSet.java +++ b/libraries/common/src/main/java/androidx/media3/common/FlagSet.java @@ -22,6 +22,7 @@ import android.util.SparseBooleanArray; import androidx.annotation.Nullable; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * A set of integer flags. @@ -53,6 +54,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder add(int flag) { checkState(!buildCalled); flags.append(flag, /* value= */ true); @@ -67,6 +69,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addIf(int flag, boolean condition) { if (condition) { return add(flag); @@ -81,6 +84,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addAll(int... flags) { for (int flag : flags) { add(flag); @@ -95,6 +99,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addAll(FlagSet flags) { for (int i = 0; i < flags.size(); i++) { add(flags.get(i)); @@ -109,6 +114,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder remove(int flag) { checkState(!buildCalled); flags.delete(flag); @@ -123,6 +129,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder removeIf(int flag, boolean condition) { if (condition) { return remove(flag); @@ -137,6 +144,7 @@ public final class FlagSet { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder removeAll(int... flags) { for (int flag : flags) { remove(flag); diff --git a/libraries/common/src/main/java/androidx/media3/common/Format.java b/libraries/common/src/main/java/androidx/media3/common/Format.java index b24b043009..b90881e636 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Format.java +++ b/libraries/common/src/main/java/androidx/media3/common/Format.java @@ -24,6 +24,7 @@ import androidx.media3.common.util.BundleableUtil; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.base.Joiner; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -248,6 +249,7 @@ public final class Format implements Bundleable { * @param id The {@link Format#id}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setId(@Nullable String id) { this.id = id; return this; @@ -260,6 +262,7 @@ public final class Format implements Bundleable { * @param id The {@link Format#id}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setId(int id) { this.id = Integer.toString(id); return this; @@ -271,6 +274,7 @@ public final class Format implements Bundleable { * @param label The {@link Format#label}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setLabel(@Nullable String label) { this.label = label; return this; @@ -282,6 +286,7 @@ public final class Format implements Bundleable { * @param language The {@link Format#language}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setLanguage(@Nullable String language) { this.language = language; return this; @@ -293,6 +298,7 @@ public final class Format implements Bundleable { * @param selectionFlags The {@link Format#selectionFlags}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setSelectionFlags(@C.SelectionFlags int selectionFlags) { this.selectionFlags = selectionFlags; return this; @@ -304,6 +310,7 @@ public final class Format implements Bundleable { * @param roleFlags The {@link Format#roleFlags}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setRoleFlags(@C.RoleFlags int roleFlags) { this.roleFlags = roleFlags; return this; @@ -315,6 +322,7 @@ public final class Format implements Bundleable { * @param averageBitrate The {@link Format#averageBitrate}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setAverageBitrate(int averageBitrate) { this.averageBitrate = averageBitrate; return this; @@ -326,6 +334,7 @@ public final class Format implements Bundleable { * @param peakBitrate The {@link Format#peakBitrate}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setPeakBitrate(int peakBitrate) { this.peakBitrate = peakBitrate; return this; @@ -337,6 +346,7 @@ public final class Format implements Bundleable { * @param codecs The {@link Format#codecs}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setCodecs(@Nullable String codecs) { this.codecs = codecs; return this; @@ -348,6 +358,7 @@ public final class Format implements Bundleable { * @param metadata The {@link Format#metadata}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setMetadata(@Nullable Metadata metadata) { this.metadata = metadata; return this; @@ -361,6 +372,7 @@ public final class Format implements Bundleable { * @param containerMimeType The {@link Format#containerMimeType}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setContainerMimeType(@Nullable String containerMimeType) { this.containerMimeType = containerMimeType; return this; @@ -374,6 +386,7 @@ public final class Format implements Bundleable { * @param sampleMimeType {@link Format#sampleMimeType}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setSampleMimeType(@Nullable String sampleMimeType) { this.sampleMimeType = sampleMimeType; return this; @@ -385,6 +398,7 @@ public final class Format implements Bundleable { * @param maxInputSize The {@link Format#maxInputSize}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setMaxInputSize(int maxInputSize) { this.maxInputSize = maxInputSize; return this; @@ -396,6 +410,7 @@ public final class Format implements Bundleable { * @param initializationData The {@link Format#initializationData}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setInitializationData(@Nullable List initializationData) { this.initializationData = initializationData; return this; @@ -407,6 +422,7 @@ public final class Format implements Bundleable { * @param drmInitData The {@link Format#drmInitData}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setDrmInitData(@Nullable DrmInitData drmInitData) { this.drmInitData = drmInitData; return this; @@ -418,6 +434,7 @@ public final class Format implements Bundleable { * @param subsampleOffsetUs The {@link Format#subsampleOffsetUs}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setSubsampleOffsetUs(long subsampleOffsetUs) { this.subsampleOffsetUs = subsampleOffsetUs; return this; @@ -431,6 +448,7 @@ public final class Format implements Bundleable { * @param width The {@link Format#width}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setWidth(int width) { this.width = width; return this; @@ -442,6 +460,7 @@ public final class Format implements Bundleable { * @param height The {@link Format#height}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setHeight(int height) { this.height = height; return this; @@ -453,6 +472,7 @@ public final class Format implements Bundleable { * @param frameRate The {@link Format#frameRate}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setFrameRate(float frameRate) { this.frameRate = frameRate; return this; @@ -464,6 +484,7 @@ public final class Format implements Bundleable { * @param rotationDegrees The {@link Format#rotationDegrees}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setRotationDegrees(int rotationDegrees) { this.rotationDegrees = rotationDegrees; return this; @@ -475,6 +496,7 @@ public final class Format implements Bundleable { * @param pixelWidthHeightRatio The {@link Format#pixelWidthHeightRatio}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setPixelWidthHeightRatio(float pixelWidthHeightRatio) { this.pixelWidthHeightRatio = pixelWidthHeightRatio; return this; @@ -486,6 +508,7 @@ public final class Format implements Bundleable { * @param projectionData The {@link Format#projectionData}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setProjectionData(@Nullable byte[] projectionData) { this.projectionData = projectionData; return this; @@ -497,6 +520,7 @@ public final class Format implements Bundleable { * @param stereoMode The {@link Format#stereoMode}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setStereoMode(@C.StereoMode int stereoMode) { this.stereoMode = stereoMode; return this; @@ -508,6 +532,7 @@ public final class Format implements Bundleable { * @param colorInfo The {@link Format#colorInfo}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setColorInfo(@Nullable ColorInfo colorInfo) { this.colorInfo = colorInfo; return this; @@ -521,6 +546,7 @@ public final class Format implements Bundleable { * @param channelCount The {@link Format#channelCount}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setChannelCount(int channelCount) { this.channelCount = channelCount; return this; @@ -532,6 +558,7 @@ public final class Format implements Bundleable { * @param sampleRate The {@link Format#sampleRate}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setSampleRate(int sampleRate) { this.sampleRate = sampleRate; return this; @@ -543,6 +570,7 @@ public final class Format implements Bundleable { * @param pcmEncoding The {@link Format#pcmEncoding}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setPcmEncoding(@C.PcmEncoding int pcmEncoding) { this.pcmEncoding = pcmEncoding; return this; @@ -554,6 +582,7 @@ public final class Format implements Bundleable { * @param encoderDelay The {@link Format#encoderDelay}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setEncoderDelay(int encoderDelay) { this.encoderDelay = encoderDelay; return this; @@ -565,6 +594,7 @@ public final class Format implements Bundleable { * @param encoderPadding The {@link Format#encoderPadding}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setEncoderPadding(int encoderPadding) { this.encoderPadding = encoderPadding; return this; @@ -578,6 +608,7 @@ public final class Format implements Bundleable { * @param accessibilityChannel The {@link Format#accessibilityChannel}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setAccessibilityChannel(int accessibilityChannel) { this.accessibilityChannel = accessibilityChannel; return this; @@ -591,6 +622,7 @@ public final class Format implements Bundleable { * @param cryptoType The {@link C.CryptoType}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setCryptoType(@C.CryptoType int cryptoType) { this.cryptoType = cryptoType; return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/MediaItem.java b/libraries/common/src/main/java/androidx/media3/common/MediaItem.java index 8d85132c19..a039251e84 100644 --- a/libraries/common/src/main/java/androidx/media3/common/MediaItem.java +++ b/libraries/common/src/main/java/androidx/media3/common/MediaItem.java @@ -29,6 +29,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.InlineMe; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -126,6 +127,7 @@ public final class MediaItem implements Bundleable { * *

By default {@link #DEFAULT_MEDIA_ID} is used. */ + @CanIgnoreReturnValue public Builder setMediaId(String mediaId) { this.mediaId = checkNotNull(mediaId); return this; @@ -138,6 +140,7 @@ public final class MediaItem implements Bundleable { * during {@link #build()} and no other {@code Builder} methods that would populate {@link * MediaItem#localConfiguration} should be called. */ + @CanIgnoreReturnValue public Builder setUri(@Nullable String uri) { return setUri(uri == null ? null : Uri.parse(uri)); } @@ -149,6 +152,7 @@ public final class MediaItem implements Bundleable { * during {@link #build()} and no other {@code Builder} methods that would populate {@link * MediaItem#localConfiguration} should be called. */ + @CanIgnoreReturnValue public Builder setUri(@Nullable Uri uri) { this.uri = uri; return this; @@ -163,12 +167,14 @@ public final class MediaItem implements Bundleable { * * @param mimeType The MIME type. */ + @CanIgnoreReturnValue public Builder setMimeType(@Nullable String mimeType) { this.mimeType = mimeType; return this; } /** Sets the {@link ClippingConfiguration}, defaults to {@link ClippingConfiguration#UNSET}. */ + @CanIgnoreReturnValue public Builder setClippingConfiguration(ClippingConfiguration clippingConfiguration) { this.clippingConfiguration = clippingConfiguration.buildUpon(); return this; @@ -178,6 +184,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setClippingConfiguration(ClippingConfiguration)} and {@link * ClippingConfiguration.Builder#setStartPositionMs(long)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setClipStartPositionMs(@IntRange(from = 0) long startPositionMs) { @@ -189,6 +196,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setClippingConfiguration(ClippingConfiguration)} and {@link * ClippingConfiguration.Builder#setEndPositionMs(long)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setClipEndPositionMs(long endPositionMs) { @@ -200,6 +208,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setClippingConfiguration(ClippingConfiguration)} and {@link * ClippingConfiguration.Builder#setRelativeToLiveWindow(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setClipRelativeToLiveWindow(boolean relativeToLiveWindow) { @@ -211,6 +220,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setClippingConfiguration(ClippingConfiguration)} and {@link * ClippingConfiguration.Builder#setRelativeToDefaultPosition(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setClipRelativeToDefaultPosition(boolean relativeToDefaultPosition) { @@ -222,6 +232,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setClippingConfiguration(ClippingConfiguration)} and {@link * ClippingConfiguration.Builder#setStartsAtKeyFrame(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setClipStartsAtKeyFrame(boolean startsAtKeyFrame) { @@ -230,6 +241,7 @@ public final class MediaItem implements Bundleable { } /** Sets the optional DRM configuration. */ + @CanIgnoreReturnValue public Builder setDrmConfiguration(@Nullable DrmConfiguration drmConfiguration) { this.drmConfiguration = drmConfiguration != null ? drmConfiguration.buildUpon() : new DrmConfiguration.Builder(); @@ -240,6 +252,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setLicenseUri(Uri)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmLicenseUri(@Nullable Uri licenseUri) { @@ -251,6 +264,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setLicenseUri(String)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmLicenseUri(@Nullable String licenseUri) { @@ -264,6 +278,7 @@ public final class MediaItem implements Bundleable { * DrmConfiguration.Builder#setLicenseRequestHeaders(Map)} doesn't accept null, use an empty * map to clear the headers. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmLicenseRequestHeaders( @@ -277,6 +292,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and pass the {@code uuid} to * {@link DrmConfiguration.Builder#Builder(UUID)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmUuid(@Nullable UUID uuid) { @@ -288,6 +304,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setMultiSession(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmMultiSession(boolean multiSession) { @@ -299,6 +316,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setForceDefaultLicenseUri(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmForceDefaultLicenseUri(boolean forceDefaultLicenseUri) { @@ -310,6 +328,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setPlayClearContentWithoutKey(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmPlayClearContentWithoutKey(boolean playClearContentWithoutKey) { @@ -321,6 +340,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setForceSessionsForAudioAndVideoTracks(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmSessionForClearPeriods(boolean sessionForClearPeriods) { @@ -334,6 +354,7 @@ public final class MediaItem implements Bundleable { * DrmConfiguration.Builder#setForcedSessionTrackTypes(List)} doesn't accept null, use an * empty list to clear the contents. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmSessionForClearTypes( @@ -347,6 +368,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setDrmConfiguration(DrmConfiguration)} and {@link * DrmConfiguration.Builder#setKeySetId(byte[])} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setDrmKeySetId(@Nullable byte[] keySetId) { @@ -363,6 +385,7 @@ public final class MediaItem implements Bundleable { *

If {@link #setUri} is passed a non-null {@code uri}, the stream keys are used to create a * {@link LocalConfiguration} object. Otherwise they will be ignored. */ + @CanIgnoreReturnValue @UnstableApi public Builder setStreamKeys(@Nullable List streamKeys) { this.streamKeys = @@ -377,6 +400,7 @@ public final class MediaItem implements Bundleable { * *

This method should only be called if {@link #setUri} is passed a non-null value. */ + @CanIgnoreReturnValue @UnstableApi public Builder setCustomCacheKey(@Nullable String customCacheKey) { this.customCacheKey = customCacheKey; @@ -388,6 +412,7 @@ public final class MediaItem implements Bundleable { * #setSubtitleConfigurations(List)} doesn't accept null, use an empty list to clear the * contents. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setSubtitles(@Nullable List subtitles) { @@ -401,6 +426,7 @@ public final class MediaItem implements Bundleable { * *

This method should only be called if {@link #setUri} is passed a non-null value. */ + @CanIgnoreReturnValue public Builder setSubtitleConfigurations(List subtitleConfigurations) { this.subtitleConfigurations = ImmutableList.copyOf(subtitleConfigurations); return this; @@ -411,6 +437,7 @@ public final class MediaItem implements Bundleable { * *

This method should only be called if {@link #setUri} is passed a non-null value. */ + @CanIgnoreReturnValue public Builder setAdsConfiguration(@Nullable AdsConfiguration adsConfiguration) { this.adsConfiguration = adsConfiguration; return this; @@ -421,6 +448,7 @@ public final class MediaItem implements Bundleable { * with {@link Uri#parse(String)} and pass the result to {@link * AdsConfiguration.Builder#Builder(Uri)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setAdTagUri(@Nullable String adTagUri) { @@ -431,6 +459,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setAdsConfiguration(AdsConfiguration)} and pass the {@code adTagUri} * to {@link AdsConfiguration.Builder#Builder(Uri)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setAdTagUri(@Nullable Uri adTagUri) { @@ -442,6 +471,7 @@ public final class MediaItem implements Bundleable { * {@link AdsConfiguration.Builder#Builder(Uri)} and the {@code adsId} to {@link * AdsConfiguration.Builder#setAdsId(Object)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setAdTagUri(@Nullable Uri adTagUri, @Nullable Object adsId) { @@ -451,6 +481,7 @@ public final class MediaItem implements Bundleable { } /** Sets the {@link LiveConfiguration}. Defaults to {@link LiveConfiguration#UNSET}. */ + @CanIgnoreReturnValue public Builder setLiveConfiguration(LiveConfiguration liveConfiguration) { this.liveConfiguration = liveConfiguration.buildUpon(); return this; @@ -460,6 +491,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setLiveConfiguration(LiveConfiguration)} and {@link * LiveConfiguration.Builder#setTargetOffsetMs(long)}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setLiveTargetOffsetMs(long liveTargetOffsetMs) { @@ -471,6 +503,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setLiveConfiguration(LiveConfiguration)} and {@link * LiveConfiguration.Builder#setMinOffsetMs(long)}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setLiveMinOffsetMs(long liveMinOffsetMs) { @@ -482,6 +515,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setLiveConfiguration(LiveConfiguration)} and {@link * LiveConfiguration.Builder#setMaxOffsetMs(long)}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setLiveMaxOffsetMs(long liveMaxOffsetMs) { @@ -493,6 +527,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setLiveConfiguration(LiveConfiguration)} and {@link * LiveConfiguration.Builder#setMinPlaybackSpeed(float)}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setLiveMinPlaybackSpeed(float minPlaybackSpeed) { @@ -504,6 +539,7 @@ public final class MediaItem implements Bundleable { * @deprecated Use {@link #setLiveConfiguration(LiveConfiguration)} and {@link * LiveConfiguration.Builder#setMaxPlaybackSpeed(float)}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setLiveMaxPlaybackSpeed(float maxPlaybackSpeed) { @@ -518,18 +554,21 @@ public final class MediaItem implements Bundleable { * *

This method should only be called if {@link #setUri} is passed a non-null value. */ + @CanIgnoreReturnValue public Builder setTag(@Nullable Object tag) { this.tag = tag; return this; } /** Sets the media metadata. */ + @CanIgnoreReturnValue public Builder setMediaMetadata(MediaMetadata mediaMetadata) { this.mediaMetadata = mediaMetadata; return this; } /** Sets the request metadata. */ + @CanIgnoreReturnValue public Builder setRequestMetadata(RequestMetadata requestMetadata) { this.requestMetadata = requestMetadata; return this; @@ -613,6 +652,7 @@ public final class MediaItem implements Bundleable { } /** Sets the {@link UUID} of the protection scheme. */ + @CanIgnoreReturnValue public Builder setScheme(UUID scheme) { this.scheme = scheme; return this; @@ -622,6 +662,7 @@ public final class MediaItem implements Bundleable { * @deprecated This only exists to support the deprecated {@link * MediaItem.Builder#setDrmUuid(UUID)}. */ + @CanIgnoreReturnValue @Deprecated private Builder setNullableScheme(@Nullable UUID scheme) { this.scheme = scheme; @@ -629,24 +670,28 @@ public final class MediaItem implements Bundleable { } /** Sets the optional default DRM license server URI. */ + @CanIgnoreReturnValue public Builder setLicenseUri(@Nullable Uri licenseUri) { this.licenseUri = licenseUri; return this; } /** Sets the optional default DRM license server URI. */ + @CanIgnoreReturnValue public Builder setLicenseUri(@Nullable String licenseUri) { this.licenseUri = licenseUri == null ? null : Uri.parse(licenseUri); return this; } /** Sets the optional request headers attached to DRM license requests. */ + @CanIgnoreReturnValue public Builder setLicenseRequestHeaders(Map licenseRequestHeaders) { this.licenseRequestHeaders = ImmutableMap.copyOf(licenseRequestHeaders); return this; } /** Sets whether multi session is enabled. */ + @CanIgnoreReturnValue public Builder setMultiSession(boolean multiSession) { this.multiSession = multiSession; return this; @@ -656,6 +701,7 @@ public final class MediaItem implements Bundleable { * Sets whether to always use the default DRM license server URI even if the media specifies * its own DRM license server URI. */ + @CanIgnoreReturnValue public Builder setForceDefaultLicenseUri(boolean forceDefaultLicenseUri) { this.forceDefaultLicenseUri = forceDefaultLicenseUri; return this; @@ -665,6 +711,7 @@ public final class MediaItem implements Bundleable { * Sets whether clear samples within protected content should be played when keys for the * encrypted part of the content have yet to be loaded. */ + @CanIgnoreReturnValue public Builder setPlayClearContentWithoutKey(boolean playClearContentWithoutKey) { this.playClearContentWithoutKey = playClearContentWithoutKey; return this; @@ -673,6 +720,7 @@ public final class MediaItem implements Bundleable { /** * @deprecated Use {@link #setForceSessionsForAudioAndVideoTracks(boolean)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated @InlineMe( @@ -690,6 +738,7 @@ public final class MediaItem implements Bundleable { *

This method overrides what has been set by previously calling {@link * #setForcedSessionTrackTypes(List)}. */ + @CanIgnoreReturnValue public Builder setForceSessionsForAudioAndVideoTracks( boolean forceSessionsForAudioAndVideoTracks) { this.setForcedSessionTrackTypes( @@ -709,6 +758,7 @@ public final class MediaItem implements Bundleable { *

This method overrides what has been set by previously calling {@link * #setForceSessionsForAudioAndVideoTracks(boolean)}. */ + @CanIgnoreReturnValue public Builder setForcedSessionTrackTypes( List<@C.TrackType Integer> forcedSessionTrackTypes) { this.forcedSessionTrackTypes = ImmutableList.copyOf(forcedSessionTrackTypes); @@ -722,6 +772,7 @@ public final class MediaItem implements Bundleable { * release an existing offline license (see {@code DefaultDrmSessionManager#setMode(int * mode,byte[] offlineLicenseKeySetId)}). */ + @CanIgnoreReturnValue public Builder setKeySetId(@Nullable byte[] keySetId) { this.keySetId = keySetId != null ? Arrays.copyOf(keySetId, keySetId.length) : null; return this; @@ -864,6 +915,7 @@ public final class MediaItem implements Bundleable { } /** Sets the ad tag URI to load. */ + @CanIgnoreReturnValue public Builder setAdTagUri(Uri adTagUri) { this.adTagUri = adTagUri; return this; @@ -875,6 +927,7 @@ public final class MediaItem implements Bundleable { *

See details on {@link AdsConfiguration#adsId} for how the ads identifier is used and how * it's calculated if not explicitly set. */ + @CanIgnoreReturnValue public Builder setAdsId(@Nullable Object adsId) { this.adsId = adsId; return this; @@ -1093,6 +1146,7 @@ public final class MediaItem implements Bundleable { * *

Defaults to {@link C#TIME_UNSET}, indicating the media-defined default will be used. */ + @CanIgnoreReturnValue public Builder setTargetOffsetMs(long targetOffsetMs) { this.targetOffsetMs = targetOffsetMs; return this; @@ -1105,6 +1159,7 @@ public final class MediaItem implements Bundleable { * *

Defaults to {@link C#TIME_UNSET}, indicating the media-defined default will be used. */ + @CanIgnoreReturnValue public Builder setMinOffsetMs(long minOffsetMs) { this.minOffsetMs = minOffsetMs; return this; @@ -1117,6 +1172,7 @@ public final class MediaItem implements Bundleable { * *

Defaults to {@link C#TIME_UNSET}, indicating the media-defined default will be used. */ + @CanIgnoreReturnValue public Builder setMaxOffsetMs(long maxOffsetMs) { this.maxOffsetMs = maxOffsetMs; return this; @@ -1127,6 +1183,7 @@ public final class MediaItem implements Bundleable { * *

Defaults to {@link C#RATE_UNSET}, indicating the media-defined default will be used. */ + @CanIgnoreReturnValue public Builder setMinPlaybackSpeed(float minPlaybackSpeed) { this.minPlaybackSpeed = minPlaybackSpeed; return this; @@ -1137,6 +1194,7 @@ public final class MediaItem implements Bundleable { * *

Defaults to {@link C#RATE_UNSET}, indicating the media-defined default will be used. */ + @CanIgnoreReturnValue public Builder setMaxPlaybackSpeed(float maxPlaybackSpeed) { this.maxPlaybackSpeed = maxPlaybackSpeed; return this; @@ -1329,42 +1387,49 @@ public final class MediaItem implements Bundleable { } /** Sets the {@link Uri} to the subtitle file. */ + @CanIgnoreReturnValue public Builder setUri(Uri uri) { this.uri = uri; return this; } /** Sets the MIME type. */ + @CanIgnoreReturnValue public Builder setMimeType(@Nullable String mimeType) { this.mimeType = mimeType; return this; } /** Sets the optional language of the subtitle file. */ + @CanIgnoreReturnValue public Builder setLanguage(@Nullable String language) { this.language = language; return this; } /** Sets the flags used for track selection. */ + @CanIgnoreReturnValue public Builder setSelectionFlags(@C.SelectionFlags int selectionFlags) { this.selectionFlags = selectionFlags; return this; } /** Sets the role flags. These are used for track selection. */ + @CanIgnoreReturnValue public Builder setRoleFlags(@C.RoleFlags int roleFlags) { this.roleFlags = roleFlags; return this; } /** Sets the optional label for this subtitle track. */ + @CanIgnoreReturnValue public Builder setLabel(@Nullable String label) { this.label = label; return this; } /** Sets the optional ID for this subtitle track. */ + @CanIgnoreReturnValue public Builder setId(@Nullable String id) { this.id = id; return this; @@ -1541,6 +1606,7 @@ public final class MediaItem implements Bundleable { * Sets the optional start position in milliseconds which must be a value larger than or equal * to zero (Default: 0). */ + @CanIgnoreReturnValue public Builder setStartPositionMs(@IntRange(from = 0) long startPositionMs) { Assertions.checkArgument(startPositionMs >= 0); this.startPositionMs = startPositionMs; @@ -1552,6 +1618,7 @@ public final class MediaItem implements Bundleable { * to zero, or {@link C#TIME_END_OF_SOURCE} to end when playback reaches the end of media * (Default: {@link C#TIME_END_OF_SOURCE}). */ + @CanIgnoreReturnValue public Builder setEndPositionMs(long endPositionMs) { Assertions.checkArgument(endPositionMs == C.TIME_END_OF_SOURCE || endPositionMs >= 0); this.endPositionMs = endPositionMs; @@ -1563,6 +1630,7 @@ public final class MediaItem implements Bundleable { * {@code false}, live streams end when playback reaches the end position in live window seen * when the media is first loaded (Default: {@code false}). */ + @CanIgnoreReturnValue public Builder setRelativeToLiveWindow(boolean relativeToLiveWindow) { this.relativeToLiveWindow = relativeToLiveWindow; return this; @@ -1572,6 +1640,7 @@ public final class MediaItem implements Bundleable { * Sets whether the start position and the end position are relative to the default position * in the window (Default: {@code false}). */ + @CanIgnoreReturnValue public Builder setRelativeToDefaultPosition(boolean relativeToDefaultPosition) { this.relativeToDefaultPosition = relativeToDefaultPosition; return this; @@ -1581,6 +1650,7 @@ public final class MediaItem implements Bundleable { * Sets whether the start point is guaranteed to be a key frame. If {@code false}, the * playback transition into the clip may not be seamless (Default: {@code false}). */ + @CanIgnoreReturnValue public Builder setStartsAtKeyFrame(boolean startsAtKeyFrame) { this.startsAtKeyFrame = startsAtKeyFrame; return this; @@ -1770,18 +1840,21 @@ public final class MediaItem implements Bundleable { } /** Sets the URI of the requested media, or null if not known or applicable. */ + @CanIgnoreReturnValue public Builder setMediaUri(@Nullable Uri mediaUri) { this.mediaUri = mediaUri; return this; } /** Sets the search query for the requested media, or null if not applicable. */ + @CanIgnoreReturnValue public Builder setSearchQuery(@Nullable String searchQuery) { this.searchQuery = searchQuery; return this; } /** Sets optional extras {@link Bundle}. */ + @CanIgnoreReturnValue public Builder setExtras(@Nullable Bundle extras) { this.extras = extras; return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/MediaMetadata.java b/libraries/common/src/main/java/androidx/media3/common/MediaMetadata.java index e32584785e..05d37b29de 100644 --- a/libraries/common/src/main/java/androidx/media3/common/MediaMetadata.java +++ b/libraries/common/src/main/java/androidx/media3/common/MediaMetadata.java @@ -29,6 +29,7 @@ import androidx.annotation.Nullable; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.base.Objects; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -114,30 +115,35 @@ public final class MediaMetadata implements Bundleable { } /** Sets the title. */ + @CanIgnoreReturnValue public Builder setTitle(@Nullable CharSequence title) { this.title = title; return this; } /** Sets the artist. */ + @CanIgnoreReturnValue public Builder setArtist(@Nullable CharSequence artist) { this.artist = artist; return this; } /** Sets the album title. */ + @CanIgnoreReturnValue public Builder setAlbumTitle(@Nullable CharSequence albumTitle) { this.albumTitle = albumTitle; return this; } /** Sets the album artist. */ + @CanIgnoreReturnValue public Builder setAlbumArtist(@Nullable CharSequence albumArtist) { this.albumArtist = albumArtist; return this; } /** Sets the display title. */ + @CanIgnoreReturnValue public Builder setDisplayTitle(@Nullable CharSequence displayTitle) { this.displayTitle = displayTitle; return this; @@ -148,24 +154,28 @@ public final class MediaMetadata implements Bundleable { * *

This is the secondary title of the media, unrelated to closed captions. */ + @CanIgnoreReturnValue public Builder setSubtitle(@Nullable CharSequence subtitle) { this.subtitle = subtitle; return this; } /** Sets the description. */ + @CanIgnoreReturnValue public Builder setDescription(@Nullable CharSequence description) { this.description = description; return this; } /** Sets the user {@link Rating}. */ + @CanIgnoreReturnValue public Builder setUserRating(@Nullable Rating userRating) { this.userRating = userRating; return this; } /** Sets the overall {@link Rating}. */ + @CanIgnoreReturnValue public Builder setOverallRating(@Nullable Rating overallRating) { this.overallRating = overallRating; return this; @@ -175,6 +185,7 @@ public final class MediaMetadata implements Bundleable { * @deprecated Use {@link #setArtworkData(byte[] data, Integer pictureType)} or {@link * #maybeSetArtworkData(byte[] data, int pictureType)}, providing a {@link PictureType}. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setArtworkData(@Nullable byte[] artworkData) { @@ -185,6 +196,7 @@ public final class MediaMetadata implements Bundleable { * Sets the artwork data as a compressed byte array with an associated {@link PictureType * artworkDataType}. */ + @CanIgnoreReturnValue public Builder setArtworkData( @Nullable byte[] artworkData, @Nullable @PictureType Integer artworkDataType) { this.artworkData = artworkData == null ? null : artworkData.clone(); @@ -200,6 +212,7 @@ public final class MediaMetadata implements Bundleable { *

Use {@link #setArtworkData(byte[], Integer)} to set the artwork data without checking the * {@link PictureType}. */ + @CanIgnoreReturnValue public Builder maybeSetArtworkData(byte[] artworkData, @PictureType int artworkDataType) { if (this.artworkData == null || Util.areEqual(artworkDataType, PICTURE_TYPE_FRONT_COVER) @@ -211,30 +224,35 @@ public final class MediaMetadata implements Bundleable { } /** Sets the artwork {@link Uri}. */ + @CanIgnoreReturnValue public Builder setArtworkUri(@Nullable Uri artworkUri) { this.artworkUri = artworkUri; return this; } /** Sets the track number. */ + @CanIgnoreReturnValue public Builder setTrackNumber(@Nullable Integer trackNumber) { this.trackNumber = trackNumber; return this; } /** Sets the total number of tracks. */ + @CanIgnoreReturnValue public Builder setTotalTrackCount(@Nullable Integer totalTrackCount) { this.totalTrackCount = totalTrackCount; return this; } /** Sets the {@link FolderType}. */ + @CanIgnoreReturnValue public Builder setFolderType(@Nullable @FolderType Integer folderType) { this.folderType = folderType; return this; } /** Sets whether the media is playable. */ + @CanIgnoreReturnValue public Builder setIsPlayable(@Nullable Boolean isPlayable) { this.isPlayable = isPlayable; return this; @@ -243,6 +261,7 @@ public final class MediaMetadata implements Bundleable { /** * @deprecated Use {@link #setRecordingYear(Integer)} instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Builder setYear(@Nullable Integer year) { @@ -250,6 +269,7 @@ public final class MediaMetadata implements Bundleable { } /** Sets the year of the recording date. */ + @CanIgnoreReturnValue public Builder setRecordingYear(@Nullable Integer recordingYear) { this.recordingYear = recordingYear; return this; @@ -260,6 +280,7 @@ public final class MediaMetadata implements Bundleable { * *

Value should be between 1 and 12. */ + @CanIgnoreReturnValue public Builder setRecordingMonth( @Nullable @IntRange(from = 1, to = 12) Integer recordingMonth) { this.recordingMonth = recordingMonth; @@ -271,12 +292,14 @@ public final class MediaMetadata implements Bundleable { * *

Value should be between 1 and 31. */ + @CanIgnoreReturnValue public Builder setRecordingDay(@Nullable @IntRange(from = 1, to = 31) Integer recordingDay) { this.recordingDay = recordingDay; return this; } /** Sets the year of the release date. */ + @CanIgnoreReturnValue public Builder setReleaseYear(@Nullable Integer releaseYear) { this.releaseYear = releaseYear; return this; @@ -287,6 +310,7 @@ public final class MediaMetadata implements Bundleable { * *

Value should be between 1 and 12. */ + @CanIgnoreReturnValue public Builder setReleaseMonth(@Nullable @IntRange(from = 1, to = 12) Integer releaseMonth) { this.releaseMonth = releaseMonth; return this; @@ -297,60 +321,70 @@ public final class MediaMetadata implements Bundleable { * *

Value should be between 1 and 31. */ + @CanIgnoreReturnValue public Builder setReleaseDay(@Nullable @IntRange(from = 1, to = 31) Integer releaseDay) { this.releaseDay = releaseDay; return this; } /** Sets the writer. */ + @CanIgnoreReturnValue public Builder setWriter(@Nullable CharSequence writer) { this.writer = writer; return this; } /** Sets the composer. */ + @CanIgnoreReturnValue public Builder setComposer(@Nullable CharSequence composer) { this.composer = composer; return this; } /** Sets the conductor. */ + @CanIgnoreReturnValue public Builder setConductor(@Nullable CharSequence conductor) { this.conductor = conductor; return this; } /** Sets the disc number. */ + @CanIgnoreReturnValue public Builder setDiscNumber(@Nullable Integer discNumber) { this.discNumber = discNumber; return this; } /** Sets the total number of discs. */ + @CanIgnoreReturnValue public Builder setTotalDiscCount(@Nullable Integer totalDiscCount) { this.totalDiscCount = totalDiscCount; return this; } /** Sets the genre. */ + @CanIgnoreReturnValue public Builder setGenre(@Nullable CharSequence genre) { this.genre = genre; return this; } /** Sets the compilation. */ + @CanIgnoreReturnValue public Builder setCompilation(@Nullable CharSequence compilation) { this.compilation = compilation; return this; } /** Sets the name of the station streaming the media. */ + @CanIgnoreReturnValue public Builder setStation(@Nullable CharSequence station) { this.station = station; return this; } /** Sets the extras {@link Bundle}. */ + @CanIgnoreReturnValue public Builder setExtras(@Nullable Bundle extras) { this.extras = extras; return this; @@ -365,6 +399,7 @@ public final class MediaMetadata implements Bundleable { *

In the event that multiple {@link Metadata.Entry} objects within the {@link Metadata} * relate to the same {@link MediaMetadata} field, then the last one will be used. */ + @CanIgnoreReturnValue @UnstableApi public Builder populateFromMetadata(Metadata metadata) { for (int i = 0; i < metadata.length(); i++) { @@ -384,6 +419,7 @@ public final class MediaMetadata implements Bundleable { *

In the event that multiple {@link Metadata.Entry} objects within any of the {@link * Metadata} relate to the same {@link MediaMetadata} field, then the last one will be used. */ + @CanIgnoreReturnValue @UnstableApi public Builder populateFromMetadata(List metadataList) { for (int i = 0; i < metadataList.size(); i++) { @@ -397,6 +433,7 @@ public final class MediaMetadata implements Bundleable { } /** Populates all the fields from {@code mediaMetadata}, provided they are non-null. */ + @CanIgnoreReturnValue @UnstableApi public Builder populate(@Nullable MediaMetadata mediaMetadata) { if (mediaMetadata == null) { diff --git a/libraries/common/src/main/java/androidx/media3/common/Player.java b/libraries/common/src/main/java/androidx/media3/common/Player.java index 4f2834b1ef..65fbcda652 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Player.java +++ b/libraries/common/src/main/java/androidx/media3/common/Player.java @@ -36,6 +36,7 @@ import androidx.media3.common.text.CueGroup; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.base.Objects; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -406,6 +407,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder add(@Command int command) { flagsBuilder.add(command); return this; @@ -419,6 +421,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addIf(@Command int command, boolean condition) { flagsBuilder.addIf(command, condition); return this; @@ -431,6 +434,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addAll(@Command int... commands) { flagsBuilder.addAll(commands); return this; @@ -443,6 +447,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addAll(Commands commands) { flagsBuilder.addAll(commands.flags); return this; @@ -454,6 +459,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder addAllCommands() { flagsBuilder.addAll(SUPPORTED_COMMANDS); return this; @@ -466,6 +472,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder remove(@Command int command) { flagsBuilder.remove(command); return this; @@ -479,6 +486,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder removeIf(@Command int command, boolean condition) { flagsBuilder.removeIf(command, condition); return this; @@ -491,6 +499,7 @@ public interface Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder removeAll(@Command int... commands) { flagsBuilder.removeAll(commands); return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/Timeline.java b/libraries/common/src/main/java/androidx/media3/common/Timeline.java index 14b04065f5..43dc1aed11 100644 --- a/libraries/common/src/main/java/androidx/media3/common/Timeline.java +++ b/libraries/common/src/main/java/androidx/media3/common/Timeline.java @@ -34,6 +34,7 @@ import androidx.media3.common.util.BundleUtil; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.InlineMe; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -261,6 +262,7 @@ public abstract class Timeline implements Bundleable { } /** Sets the data held by this window. */ + @CanIgnoreReturnValue @UnstableApi @SuppressWarnings("deprecation") public Window set( @@ -626,6 +628,7 @@ public abstract class Timeline implements Bundleable { * period is not within the window. * @return This period, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Period set( @Nullable Object id, @@ -662,6 +665,7 @@ public abstract class Timeline implements Bundleable { * information has yet to be loaded. * @return This period, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Period set( @Nullable Object id, diff --git a/libraries/common/src/main/java/androidx/media3/common/TrackSelectionParameters.java b/libraries/common/src/main/java/androidx/media3/common/TrackSelectionParameters.java index b7fe8176e3..1c2f7a633a 100644 --- a/libraries/common/src/main/java/androidx/media3/common/TrackSelectionParameters.java +++ b/libraries/common/src/main/java/androidx/media3/common/TrackSelectionParameters.java @@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.primitives.Ints; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -306,6 +307,7 @@ public class TrackSelectionParameters implements Bundleable { } /** Overrides the value of the builder with the value of {@link TrackSelectionParameters}. */ + @CanIgnoreReturnValue @UnstableApi protected Builder set(TrackSelectionParameters parameters) { init(parameters); @@ -319,6 +321,7 @@ public class TrackSelectionParameters implements Bundleable { * * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxVideoSizeSd() { return setMaxVideoSize(1279, 719); } @@ -328,6 +331,7 @@ public class TrackSelectionParameters implements Bundleable { * * @return This builder. */ + @CanIgnoreReturnValue public Builder clearVideoSizeConstraints() { return setMaxVideoSize(Integer.MAX_VALUE, Integer.MAX_VALUE); } @@ -339,6 +343,7 @@ public class TrackSelectionParameters implements Bundleable { * @param maxVideoHeight Maximum allowed video height in pixels. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxVideoSize(int maxVideoWidth, int maxVideoHeight) { this.maxVideoWidth = maxVideoWidth; this.maxVideoHeight = maxVideoHeight; @@ -351,6 +356,7 @@ public class TrackSelectionParameters implements Bundleable { * @param maxVideoFrameRate Maximum allowed video frame rate in hertz. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxVideoFrameRate(int maxVideoFrameRate) { this.maxVideoFrameRate = maxVideoFrameRate; return this; @@ -362,6 +368,7 @@ public class TrackSelectionParameters implements Bundleable { * @param maxVideoBitrate Maximum allowed video bitrate in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxVideoBitrate(int maxVideoBitrate) { this.maxVideoBitrate = maxVideoBitrate; return this; @@ -374,6 +381,7 @@ public class TrackSelectionParameters implements Bundleable { * @param minVideoHeight Minimum allowed video height in pixels. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMinVideoSize(int minVideoWidth, int minVideoHeight) { this.minVideoWidth = minVideoWidth; this.minVideoHeight = minVideoHeight; @@ -386,6 +394,7 @@ public class TrackSelectionParameters implements Bundleable { * @param minVideoFrameRate Minimum allowed video frame rate in hertz. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMinVideoFrameRate(int minVideoFrameRate) { this.minVideoFrameRate = minVideoFrameRate; return this; @@ -397,6 +406,7 @@ public class TrackSelectionParameters implements Bundleable { * @param minVideoBitrate Minimum allowed video bitrate in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMinVideoBitrate(int minVideoBitrate) { this.minVideoBitrate = minVideoBitrate; return this; @@ -411,6 +421,7 @@ public class TrackSelectionParameters implements Bundleable { * playback. * @return This builder. */ + @CanIgnoreReturnValue public Builder setViewportSizeToPhysicalDisplaySize( Context context, boolean viewportOrientationMayChange) { // Assume the viewport is fullscreen. @@ -424,6 +435,7 @@ public class TrackSelectionParameters implements Bundleable { * * @return This builder. */ + @CanIgnoreReturnValue public Builder clearViewportSizeConstraints() { return setViewportSize(Integer.MAX_VALUE, Integer.MAX_VALUE, true); } @@ -438,6 +450,7 @@ public class TrackSelectionParameters implements Bundleable { * playback. * @return This builder. */ + @CanIgnoreReturnValue public Builder setViewportSize( int viewportWidth, int viewportHeight, boolean viewportOrientationMayChange) { this.viewportWidth = viewportWidth; @@ -464,6 +477,7 @@ public class TrackSelectionParameters implements Bundleable { * empty list for no preference. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredVideoMimeTypes(String... mimeTypes) { preferredVideoMimeTypes = ImmutableList.copyOf(mimeTypes); return this; @@ -475,6 +489,7 @@ public class TrackSelectionParameters implements Bundleable { * @param preferredVideoRoleFlags Preferred video role flags. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredVideoRoleFlags(@C.RoleFlags int preferredVideoRoleFlags) { this.preferredVideoRoleFlags = preferredVideoRoleFlags; return this; @@ -503,6 +518,7 @@ public class TrackSelectionParameters implements Bundleable { * there's no default. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredAudioLanguages(String... preferredAudioLanguages) { this.preferredAudioLanguages = normalizeLanguageCodes(preferredAudioLanguages); return this; @@ -514,6 +530,7 @@ public class TrackSelectionParameters implements Bundleable { * @param preferredAudioRoleFlags Preferred audio role flags. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredAudioRoleFlags(@C.RoleFlags int preferredAudioRoleFlags) { this.preferredAudioRoleFlags = preferredAudioRoleFlags; return this; @@ -525,6 +542,7 @@ public class TrackSelectionParameters implements Bundleable { * @param maxAudioChannelCount Maximum allowed audio channel count. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxAudioChannelCount(int maxAudioChannelCount) { this.maxAudioChannelCount = maxAudioChannelCount; return this; @@ -536,6 +554,7 @@ public class TrackSelectionParameters implements Bundleable { * @param maxAudioBitrate Maximum allowed audio bitrate in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMaxAudioBitrate(int maxAudioBitrate) { this.maxAudioBitrate = maxAudioBitrate; return this; @@ -559,6 +578,7 @@ public class TrackSelectionParameters implements Bundleable { * empty list for no preference. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredAudioMimeTypes(String... mimeTypes) { preferredAudioMimeTypes = ImmutableList.copyOf(mimeTypes); return this; @@ -575,6 +595,7 @@ public class TrackSelectionParameters implements Bundleable { * @param context A {@link Context}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings( Context context) { if (Util.SDK_INT >= 19) { @@ -604,6 +625,7 @@ public class TrackSelectionParameters implements Bundleable { * track otherwise. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredTextLanguages(String... preferredTextLanguages) { this.preferredTextLanguages = normalizeLanguageCodes(preferredTextLanguages); return this; @@ -615,6 +637,7 @@ public class TrackSelectionParameters implements Bundleable { * @param preferredTextRoleFlags Preferred text role flags. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPreferredTextRoleFlags(@C.RoleFlags int preferredTextRoleFlags) { this.preferredTextRoleFlags = preferredTextRoleFlags; return this; @@ -627,6 +650,7 @@ public class TrackSelectionParameters implements Bundleable { * text track selections. * @return This builder. */ + @CanIgnoreReturnValue public Builder setIgnoredTextSelectionFlags(@C.SelectionFlags int ignoredTextSelectionFlags) { this.ignoredTextSelectionFlags = ignoredTextSelectionFlags; return this; @@ -641,6 +665,7 @@ public class TrackSelectionParameters implements Bundleable { * be selected if no preferred language track is available. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSelectUndeterminedTextLanguage(boolean selectUndeterminedTextLanguage) { this.selectUndeterminedTextLanguage = selectUndeterminedTextLanguage; return this; @@ -656,6 +681,7 @@ public class TrackSelectionParameters implements Bundleable { * video tracks. * @return This builder. */ + @CanIgnoreReturnValue public Builder setForceLowestBitrate(boolean forceLowestBitrate) { this.forceLowestBitrate = forceLowestBitrate; return this; @@ -669,18 +695,21 @@ public class TrackSelectionParameters implements Bundleable { * and video tracks. * @return This builder. */ + @CanIgnoreReturnValue public Builder setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate) { this.forceHighestSupportedBitrate = forceHighestSupportedBitrate; return this; } /** Adds an override, replacing any override for the same {@link TrackGroup}. */ + @CanIgnoreReturnValue public Builder addOverride(TrackSelectionOverride override) { overrides.put(override.mediaTrackGroup, override); return this; } /** Sets an override, replacing all existing overrides with the same track type. */ + @CanIgnoreReturnValue public Builder setOverrideForType(TrackSelectionOverride override) { clearOverridesOfType(override.getType()); overrides.put(override.mediaTrackGroup, override); @@ -688,12 +717,14 @@ public class TrackSelectionParameters implements Bundleable { } /** Removes the override for the provided media {@link TrackGroup}, if there is one. */ + @CanIgnoreReturnValue public Builder clearOverride(TrackGroup mediaTrackGroup) { overrides.remove(mediaTrackGroup); return this; } /** Removes all overrides of the provided track type. */ + @CanIgnoreReturnValue public Builder clearOverridesOfType(@C.TrackType int trackType) { Iterator it = overrides.values().iterator(); while (it.hasNext()) { @@ -706,6 +737,7 @@ public class TrackSelectionParameters implements Bundleable { } /** Removes all overrides. */ + @CanIgnoreReturnValue public Builder clearOverrides() { overrides.clear(); return this; @@ -719,6 +751,7 @@ public class TrackSelectionParameters implements Bundleable { * @return This builder. * @deprecated Use {@link #setTrackTypeDisabled(int, boolean)}. */ + @CanIgnoreReturnValue @Deprecated @UnstableApi public Builder setDisabledTrackTypes(Set<@C.TrackType Integer> disabledTrackTypes) { @@ -735,6 +768,7 @@ public class TrackSelectionParameters implements Bundleable { * @param disabled Whether the track type should be disabled. * @return This builder. */ + @CanIgnoreReturnValue public Builder setTrackTypeDisabled(@C.TrackType int trackType, boolean disabled) { if (disabled) { disabledTrackTypes.add(trackType); diff --git a/libraries/common/src/main/java/androidx/media3/common/text/Cue.java b/libraries/common/src/main/java/androidx/media3/common/text/Cue.java index 6b9d9ded28..475a29f9d3 100644 --- a/libraries/common/src/main/java/androidx/media3/common/text/Cue.java +++ b/libraries/common/src/main/java/androidx/media3/common/text/Cue.java @@ -36,6 +36,7 @@ import androidx.media3.common.Bundleable; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; import com.google.common.base.Objects; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -628,6 +629,7 @@ public final class Cue implements Bundleable { * * @see Cue#text */ + @CanIgnoreReturnValue public Builder setText(CharSequence text) { this.text = text; return this; @@ -649,6 +651,7 @@ public final class Cue implements Bundleable { * * @see Cue#bitmap */ + @CanIgnoreReturnValue public Builder setBitmap(Bitmap bitmap) { this.bitmap = bitmap; return this; @@ -672,6 +675,7 @@ public final class Cue implements Bundleable { * * @see Cue#textAlignment */ + @CanIgnoreReturnValue public Builder setTextAlignment(@Nullable Layout.Alignment textAlignment) { this.textAlignment = textAlignment; return this; @@ -695,6 +699,7 @@ public final class Cue implements Bundleable { * * @see Cue#multiRowAlignment */ + @CanIgnoreReturnValue public Builder setMultiRowAlignment(@Nullable Layout.Alignment multiRowAlignment) { this.multiRowAlignment = multiRowAlignment; return this; @@ -707,6 +712,7 @@ public final class Cue implements Bundleable { * @see Cue#line * @see Cue#lineType */ + @CanIgnoreReturnValue public Builder setLine(float line, @LineType int lineType) { this.line = line; this.lineType = lineType; @@ -739,6 +745,7 @@ public final class Cue implements Bundleable { * * @see Cue#lineAnchor */ + @CanIgnoreReturnValue public Builder setLineAnchor(@AnchorType int lineAnchor) { this.lineAnchor = lineAnchor; return this; @@ -760,6 +767,7 @@ public final class Cue implements Bundleable { * * @see Cue#position */ + @CanIgnoreReturnValue public Builder setPosition(float position) { this.position = position; return this; @@ -781,6 +789,7 @@ public final class Cue implements Bundleable { * * @see Cue#positionAnchor */ + @CanIgnoreReturnValue public Builder setPositionAnchor(@AnchorType int positionAnchor) { this.positionAnchor = positionAnchor; return this; @@ -802,6 +811,7 @@ public final class Cue implements Bundleable { * @see Cue#textSize * @see Cue#textSizeType */ + @CanIgnoreReturnValue public Builder setTextSize(float textSize, @TextSizeType int textSizeType) { this.textSize = textSize; this.textSizeType = textSizeType; @@ -834,6 +844,7 @@ public final class Cue implements Bundleable { * * @see Cue#size */ + @CanIgnoreReturnValue public Builder setSize(float size) { this.size = size; return this; @@ -855,6 +866,7 @@ public final class Cue implements Bundleable { * * @see Cue#bitmapHeight */ + @CanIgnoreReturnValue public Builder setBitmapHeight(float bitmapHeight) { this.bitmapHeight = bitmapHeight; return this; @@ -878,6 +890,7 @@ public final class Cue implements Bundleable { * @see Cue#windowColor * @see Cue#windowColorSet */ + @CanIgnoreReturnValue public Builder setWindowColor(@ColorInt int windowColor) { this.windowColor = windowColor; this.windowColorSet = true; @@ -885,6 +898,7 @@ public final class Cue implements Bundleable { } /** Sets {@link Cue#windowColorSet} to false. */ + @CanIgnoreReturnValue public Builder clearWindowColor() { this.windowColorSet = false; return this; @@ -915,12 +929,14 @@ public final class Cue implements Bundleable { * * @see Cue#verticalType */ + @CanIgnoreReturnValue public Builder setVerticalType(@VerticalType int verticalType) { this.verticalType = verticalType; return this; } /** Sets the shear angle for this Cue. */ + @CanIgnoreReturnValue public Builder setShearDegrees(float shearDegrees) { this.shearDegrees = shearDegrees; return this; diff --git a/libraries/common/src/main/java/androidx/media3/common/util/SystemHandlerWrapper.java b/libraries/common/src/main/java/androidx/media3/common/util/SystemHandlerWrapper.java index 7cd4f00a16..9c24087854 100644 --- a/libraries/common/src/main/java/androidx/media3/common/util/SystemHandlerWrapper.java +++ b/libraries/common/src/main/java/androidx/media3/common/util/SystemHandlerWrapper.java @@ -21,6 +21,7 @@ import android.os.Handler; import android.os.Looper; import androidx.annotation.GuardedBy; import androidx.annotation.Nullable; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; @@ -136,6 +137,7 @@ import java.util.List; @Nullable private android.os.Message message; @Nullable private SystemHandlerWrapper handler; + @CanIgnoreReturnValue public SystemMessage setMessage(android.os.Message message, SystemHandlerWrapper handler) { this.message = message; this.handler = handler; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/DataSpec.java b/libraries/datasource/src/main/java/androidx/media3/datasource/DataSpec.java index 646b5f274a..bbaf39f0f9 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/DataSpec.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/DataSpec.java @@ -24,6 +24,7 @@ import androidx.media3.common.C; import androidx.media3.common.MediaLibraryInfo; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -89,6 +90,7 @@ public final class DataSpec { * @param uriString The {@link DataSpec#uri}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setUri(String uriString) { this.uri = Uri.parse(uriString); return this; @@ -100,6 +102,7 @@ public final class DataSpec { * @param uri The {@link DataSpec#uri}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setUri(Uri uri) { this.uri = uri; return this; @@ -111,6 +114,7 @@ public final class DataSpec { * @param uriPositionOffset The {@link DataSpec#uriPositionOffset}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setUriPositionOffset(long uriPositionOffset) { this.uriPositionOffset = uriPositionOffset; return this; @@ -122,6 +126,7 @@ public final class DataSpec { * @param httpMethod The {@link DataSpec#httpMethod}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setHttpMethod(@HttpMethod int httpMethod) { this.httpMethod = httpMethod; return this; @@ -133,6 +138,7 @@ public final class DataSpec { * @param httpBody The {@link DataSpec#httpBody}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setHttpBody(@Nullable byte[] httpBody) { this.httpBody = httpBody; return this; @@ -148,6 +154,7 @@ public final class DataSpec { * @param httpRequestHeaders The {@link DataSpec#httpRequestHeaders}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setHttpRequestHeaders(Map httpRequestHeaders) { this.httpRequestHeaders = httpRequestHeaders; return this; @@ -159,6 +166,7 @@ public final class DataSpec { * @param position The {@link DataSpec#position}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setPosition(long position) { this.position = position; return this; @@ -170,6 +178,7 @@ public final class DataSpec { * @param length The {@link DataSpec#length}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setLength(long length) { this.length = length; return this; @@ -181,6 +190,7 @@ public final class DataSpec { * @param key The {@link DataSpec#key}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setKey(@Nullable String key) { this.key = key; return this; @@ -192,6 +202,7 @@ public final class DataSpec { * @param flags The {@link DataSpec#flags}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setFlags(@Flags int flags) { this.flags = flags; return this; @@ -203,6 +214,7 @@ public final class DataSpec { * @param customData The {@link DataSpec#customData}. * @return The builder. */ + @CanIgnoreReturnValue public Builder setCustomData(@Nullable Object customData) { this.customData = customData; return this; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultDataSource.java index 962db5a884..8a5e9d7df0 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultDataSource.java @@ -23,6 +23,7 @@ import androidx.media3.common.util.Assertions; import androidx.media3.common.util.Log; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.Collections; @@ -99,6 +100,7 @@ public final class DefaultDataSource implements DataSource { * @param transferListener The listener that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setTransferListener(@Nullable TransferListener transferListener) { this.transferListener = transferListener; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java index 59d8d4a40f..e29963f8ed 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/DefaultHttpDataSource.java @@ -34,6 +34,7 @@ import com.google.common.collect.ForwardingMap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Sets; import com.google.common.net.HttpHeaders; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; @@ -82,6 +83,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLIS; } + @CanIgnoreReturnValue @UnstableApi @Override public final Factory setDefaultRequestProperties(Map defaultRequestProperties) { @@ -99,6 +101,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * agent of the underlying platform. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setUserAgent(@Nullable String userAgent) { this.userAgent = userAgent; @@ -113,6 +116,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * @param connectTimeoutMs The connect timeout, in milliseconds, that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setConnectTimeoutMs(int connectTimeoutMs) { this.connectTimeoutMs = connectTimeoutMs; @@ -127,6 +131,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * @param readTimeoutMs The connect timeout, in milliseconds, that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setReadTimeoutMs(int readTimeoutMs) { this.readTimeoutMs = readTimeoutMs; @@ -141,6 +146,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * @param allowCrossProtocolRedirects Whether to allow cross protocol redirects. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects) { this.allowCrossProtocolRedirects = allowCrossProtocolRedirects; @@ -158,6 +164,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * predicate that was previously set. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setContentTypePredicate(@Nullable Predicate contentTypePredicate) { this.contentTypePredicate = contentTypePredicate; @@ -174,6 +181,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * @param transferListener The listener that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setTransferListener(@Nullable TransferListener transferListener) { this.transferListener = transferListener; @@ -184,6 +192,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou * Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a * POST request. */ + @CanIgnoreReturnValue @UnstableApi public Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects) { this.keepPostFor302Redirects = keepPostFor302Redirects; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/FileDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/FileDataSource.java index 555651f86e..2bbfa5eab2 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/FileDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/FileDataSource.java @@ -30,6 +30,7 @@ import androidx.media3.common.PlaybackException; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.FileNotFoundException; import java.io.IOException; import java.io.RandomAccessFile; @@ -82,6 +83,7 @@ public final class FileDataSource extends BaseDataSource { * @param listener The {@link TransferListener}. * @return This factory. */ + @CanIgnoreReturnValue public Factory setListener(@Nullable TransferListener listener) { this.listener = listener; return this; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpDataSource.java index 4f755b6ed1..cf17e7c070 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/HttpDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/HttpDataSource.java @@ -25,6 +25,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.base.Ascii; import com.google.common.base.Predicate; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.InterruptedIOException; import java.lang.annotation.Documented; @@ -157,6 +158,7 @@ public interface HttpDataSource extends DataSource { return createDataSourceInternal(defaultRequestProperties); } + @CanIgnoreReturnValue @Override public final Factory setDefaultRequestProperties(Map defaultRequestProperties) { this.defaultRequestProperties.clearAndSet(defaultRequestProperties); diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSink.java b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSink.java index c4995f82c0..d87fcfdacc 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSink.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSink.java @@ -28,6 +28,7 @@ import androidx.media3.common.util.Util; import androidx.media3.datasource.DataSink; import androidx.media3.datasource.DataSpec; import androidx.media3.datasource.cache.Cache.CacheException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -65,6 +66,7 @@ public final class CacheDataSink implements DataSink { * @param cache The cache to which data will be written. * @return This factory. */ + @CanIgnoreReturnValue public Factory setCache(Cache cache) { this.cache = cache; return this; @@ -83,6 +85,7 @@ public final class CacheDataSink implements DataSink { * fragmentation. * @return This factory. */ + @CanIgnoreReturnValue public Factory setFragmentSize(long fragmentSize) { this.fragmentSize = fragmentSize; return this; @@ -97,6 +100,7 @@ public final class CacheDataSink implements DataSink { * @param bufferSize The buffer size in bytes. * @return This factory. */ + @CanIgnoreReturnValue public Factory setBufferSize(int bufferSize) { this.bufferSize = bufferSize; return this; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSource.java b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSource.java index 66bb73e4ad..f0c8788c1f 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSource.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/CacheDataSource.java @@ -42,6 +42,7 @@ import androidx.media3.datasource.PriorityDataSource; import androidx.media3.datasource.TeeDataSource; import androidx.media3.datasource.TransferListener; import androidx.media3.datasource.cache.Cache.CacheException; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.InterruptedIOException; import java.lang.annotation.Documented; @@ -88,6 +89,7 @@ public final class CacheDataSource implements DataSource { * @param cache The cache that will be used. * @return This factory. */ + @CanIgnoreReturnValue public Factory setCache(Cache cache) { this.cache = cache; return this; @@ -111,6 +113,7 @@ public final class CacheDataSource implements DataSource { * @param cacheReadDataSourceFactory The {@link DataSource.Factory} for reading from the cache. * @return This factory. */ + @CanIgnoreReturnValue public Factory setCacheReadDataSourceFactory(DataSource.Factory cacheReadDataSourceFactory) { this.cacheReadDataSourceFactory = cacheReadDataSourceFactory; return this; @@ -126,6 +129,7 @@ public final class CacheDataSource implements DataSource { * DataSinks} for writing data to the cache, or {@code null} to disable writing. * @return This factory. */ + @CanIgnoreReturnValue public Factory setCacheWriteDataSinkFactory( @Nullable DataSink.Factory cacheWriteDataSinkFactory) { this.cacheWriteDataSinkFactory = cacheWriteDataSinkFactory; @@ -141,6 +145,7 @@ public final class CacheDataSource implements DataSource { * @param cacheKeyFactory The {@link CacheKeyFactory}. * @return This factory. */ + @CanIgnoreReturnValue public Factory setCacheKeyFactory(CacheKeyFactory cacheKeyFactory) { this.cacheKeyFactory = cacheKeyFactory; return this; @@ -162,6 +167,7 @@ public final class CacheDataSource implements DataSource { * cache, or {@code null} to cause failure in the case of a cache miss. * @return This factory. */ + @CanIgnoreReturnValue public Factory setUpstreamDataSourceFactory( @Nullable DataSource.Factory upstreamDataSourceFactory) { this.upstreamDataSourceFactory = upstreamDataSourceFactory; @@ -186,6 +192,7 @@ public final class CacheDataSource implements DataSource { * @param upstreamPriorityTaskManager The upstream {@link PriorityTaskManager}. * @return This factory. */ + @CanIgnoreReturnValue public Factory setUpstreamPriorityTaskManager( @Nullable PriorityTaskManager upstreamPriorityTaskManager) { this.upstreamPriorityTaskManager = upstreamPriorityTaskManager; @@ -210,6 +217,7 @@ public final class CacheDataSource implements DataSource { * @param upstreamPriority The priority to use when requesting data from upstream. * @return This factory. */ + @CanIgnoreReturnValue public Factory setUpstreamPriority(int upstreamPriority) { this.upstreamPriority = upstreamPriority; return this; @@ -223,6 +231,7 @@ public final class CacheDataSource implements DataSource { * @param flags The {@link CacheDataSource.Flags}. * @return This factory. */ + @CanIgnoreReturnValue public Factory setFlags(@CacheDataSource.Flags int flags) { this.flags = flags; return this; @@ -236,6 +245,7 @@ public final class CacheDataSource implements DataSource { * @param eventListener The {@link EventListener}. * @return This factory. */ + @CanIgnoreReturnValue public Factory setEventListener(@Nullable EventListener eventListener) { this.eventListener = eventListener; return this; diff --git a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/ContentMetadataMutations.java b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/ContentMetadataMutations.java index ddb6ef9aa7..73c782819f 100644 --- a/libraries/datasource/src/main/java/androidx/media3/datasource/cache/ContentMetadataMutations.java +++ b/libraries/datasource/src/main/java/androidx/media3/datasource/cache/ContentMetadataMutations.java @@ -20,6 +20,7 @@ import androidx.annotation.Nullable; import androidx.media3.common.C; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -81,6 +82,7 @@ public class ContentMetadataMutations { * @param value The value to be set. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ContentMetadataMutations set(String name, String value) { return checkAndSet(name, value); } @@ -92,6 +94,7 @@ public class ContentMetadataMutations { * @param value The value to be set. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ContentMetadataMutations set(String name, long value) { return checkAndSet(name, value); } @@ -103,6 +106,7 @@ public class ContentMetadataMutations { * @param value The value to be set. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ContentMetadataMutations set(String name, byte[] value) { return checkAndSet(name, Arrays.copyOf(value, value.length)); } @@ -113,6 +117,7 @@ public class ContentMetadataMutations { * @param name The name of the metadata value. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ContentMetadataMutations remove(String name) { removedValues.add(name); editedValues.remove(name); @@ -137,6 +142,7 @@ public class ContentMetadataMutations { return Collections.unmodifiableMap(hashMap); } + @CanIgnoreReturnValue private ContentMetadataMutations checkAndSet(String name, Object value) { editedValues.put(Assertions.checkNotNull(name), Assertions.checkNotNull(value)); removedValues.remove(name); diff --git a/libraries/datasource_cronet/build.gradle b/libraries/datasource_cronet/build.gradle index 2f7633d2d9..79b8389f57 100644 --- a/libraries/datasource_cronet/build.gradle +++ b/libraries/datasource_cronet/build.gradle @@ -24,6 +24,7 @@ dependencies { implementation project(modulePrefix + 'lib-common') implementation project(modulePrefix + 'lib-datasource') implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion androidTestImplementation 'androidx.test:rules:' + androidxTestRulesVersion diff --git a/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java b/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java index 056ece7591..e5d93dab8f 100644 --- a/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java +++ b/libraries/datasource_cronet/src/main/java/androidx/media3/datasource/cronet/CronetDataSource.java @@ -42,6 +42,7 @@ import com.google.common.base.Ascii; import com.google.common.base.Predicate; import com.google.common.net.HttpHeaders; import com.google.common.primitives.Longs; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.InterruptedIOException; import java.net.SocketTimeoutException; @@ -142,6 +143,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLIS; } + @CanIgnoreReturnValue @UnstableApi @Override public final Factory setDefaultRequestProperties(Map defaultRequestProperties) { @@ -162,6 +164,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * agent of the underlying {@link CronetEngine}. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setUserAgent(@Nullable String userAgent) { this.userAgent = userAgent; @@ -181,6 +184,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * UrlRequest.Builder#REQUEST_PRIORITY_*} constants. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setRequestPriority(int requestPriority) { this.requestPriority = requestPriority; @@ -195,6 +199,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * @param connectTimeoutMs The connect timeout, in milliseconds, that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setConnectionTimeoutMs(int connectTimeoutMs) { this.connectTimeoutMs = connectTimeoutMs; @@ -212,6 +217,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * @param resetTimeoutOnRedirects Whether the connect timeout is reset when a redirect occurs. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setResetTimeoutOnRedirects(boolean resetTimeoutOnRedirects) { this.resetTimeoutOnRedirects = resetTimeoutOnRedirects; @@ -228,6 +234,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * to the redirect url in the "Cookie" header. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setHandleSetCookieRequests(boolean handleSetCookieRequests) { this.handleSetCookieRequests = handleSetCookieRequests; @@ -242,6 +249,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * @param readTimeoutMs The connect timeout, in milliseconds, that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setReadTimeoutMs(int readTimeoutMs) { this.readTimeoutMs = readTimeoutMs; @@ -261,6 +269,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * predicate that was previously set. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setContentTypePredicate(@Nullable Predicate contentTypePredicate) { this.contentTypePredicate = contentTypePredicate; @@ -274,6 +283,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * Sets whether we should keep the POST method and body when we have HTTP 302 redirects for a * POST request. */ + @CanIgnoreReturnValue @UnstableApi public Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects) { this.keepPostFor302Redirects = keepPostFor302Redirects; @@ -293,6 +303,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * @param transferListener The listener that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setTransferListener(@Nullable TransferListener transferListener) { this.transferListener = transferListener; @@ -313,6 +324,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { * @deprecated Do not use {@link CronetDataSource} or its factory in cases where a suitable * {@link CronetEngine} is not available. Use the fallback factory directly in such cases. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public Factory setFallbackFactory(@Nullable HttpDataSource.Factory fallbackFactory) { diff --git a/libraries/datasource_okhttp/build.gradle b/libraries/datasource_okhttp/build.gradle index 2f67805d16..4eb8e6a69d 100644 --- a/libraries/datasource_okhttp/build.gradle +++ b/libraries/datasource_okhttp/build.gradle @@ -19,6 +19,7 @@ dependencies { implementation project(modulePrefix + 'lib-common') implementation project(modulePrefix + 'lib-datasource') implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion testImplementation project(modulePrefix + 'test-utils') diff --git a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java index aaa3fe8766..0ae8d58c07 100644 --- a/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java +++ b/libraries/datasource_okhttp/src/main/java/androidx/media3/datasource/okhttp/OkHttpDataSource.java @@ -40,6 +40,7 @@ import androidx.media3.datasource.TransferListener; import com.google.common.base.Predicate; import com.google.common.net.HttpHeaders; import com.google.common.util.concurrent.SettableFuture; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.InputStream; import java.io.InterruptedIOException; @@ -94,6 +95,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { defaultRequestProperties = new RequestProperties(); } + @CanIgnoreReturnValue @UnstableApi @Override public final Factory setDefaultRequestProperties(Map defaultRequestProperties) { @@ -111,6 +113,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { * agent of the underlying {@link OkHttpClient}. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setUserAgent(@Nullable String userAgent) { this.userAgent = userAgent; @@ -125,6 +128,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { * @param cacheControl The cache control that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setCacheControl(@Nullable CacheControl cacheControl) { this.cacheControl = cacheControl; @@ -142,6 +146,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { * predicate that was previously set. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setContentTypePredicate(@Nullable Predicate contentTypePredicate) { this.contentTypePredicate = contentTypePredicate; @@ -158,6 +163,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { * @param transferListener The listener that will be used. * @return This factory. */ + @CanIgnoreReturnValue @UnstableApi public Factory setTransferListener(@Nullable TransferListener transferListener) { this.transferListener = transferListener; diff --git a/libraries/datasource_rtmp/build.gradle b/libraries/datasource_rtmp/build.gradle index c00413dff1..5bd1725cda 100644 --- a/libraries/datasource_rtmp/build.gradle +++ b/libraries/datasource_rtmp/build.gradle @@ -18,6 +18,7 @@ dependencies { implementation project(modulePrefix + 'lib-datasource') implementation 'io.antmedia:rtmp-client:3.2.0' implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion testImplementation project(modulePrefix + 'lib-exoplayer') testImplementation project(modulePrefix + 'test-utils') diff --git a/libraries/datasource_rtmp/src/main/java/androidx/media3/datasource/rtmp/RtmpDataSource.java b/libraries/datasource_rtmp/src/main/java/androidx/media3/datasource/rtmp/RtmpDataSource.java index 7145e760f0..0659969e25 100644 --- a/libraries/datasource_rtmp/src/main/java/androidx/media3/datasource/rtmp/RtmpDataSource.java +++ b/libraries/datasource_rtmp/src/main/java/androidx/media3/datasource/rtmp/RtmpDataSource.java @@ -26,6 +26,7 @@ import androidx.media3.datasource.BaseDataSource; import androidx.media3.datasource.DataSource; import androidx.media3.datasource.DataSpec; import androidx.media3.datasource.TransferListener; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import io.antmedia.rtmp_client.RtmpClient; import io.antmedia.rtmp_client.RtmpClient.RtmpIOException; import java.io.IOException; @@ -53,6 +54,7 @@ public final class RtmpDataSource extends BaseDataSource { * @param transferListener The listener that will be used. * @return This factory. */ + @CanIgnoreReturnValue public Factory setTransferListener(@Nullable TransferListener transferListener) { this.transferListener = transferListener; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.java index 0de033fc9d..8eeceb08c6 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLivePlaybackSpeedControl.java @@ -25,6 +25,7 @@ import androidx.media3.common.MediaItem.LiveConfiguration; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * A {@link LivePlaybackSpeedControl} that adjusts the playback speed using a proportional @@ -125,6 +126,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * @param fallbackMinPlaybackSpeed The fallback minimum factor by which playback can be sped up. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setFallbackMinPlaybackSpeed(float fallbackMinPlaybackSpeed) { Assertions.checkArgument(0 < fallbackMinPlaybackSpeed && fallbackMinPlaybackSpeed <= 1f); this.fallbackMinPlaybackSpeed = fallbackMinPlaybackSpeed; @@ -140,6 +142,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * @param fallbackMaxPlaybackSpeed The fallback maximum factor by which playback can be sped up. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setFallbackMaxPlaybackSpeed(float fallbackMaxPlaybackSpeed) { Assertions.checkArgument(fallbackMaxPlaybackSpeed >= 1f); this.fallbackMaxPlaybackSpeed = fallbackMaxPlaybackSpeed; @@ -155,6 +158,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * milliseconds. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMinUpdateIntervalMs(long minUpdateIntervalMs) { Assertions.checkArgument(minUpdateIntervalMs > 0); this.minUpdateIntervalMs = minUpdateIntervalMs; @@ -173,6 +177,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * speed. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setProportionalControlFactor(float proportionalControlFactor) { Assertions.checkArgument(proportionalControlFactor > 0); this.proportionalControlFactorUs = proportionalControlFactor / C.MICROS_PER_SECOND; @@ -189,6 +194,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * used, in milliseconds. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMaxLiveOffsetErrorMsForUnitSpeed(long maxLiveOffsetErrorMsForUnitSpeed) { Assertions.checkArgument(maxLiveOffsetErrorMsForUnitSpeed > 0); this.maxLiveOffsetErrorUsForUnitSpeed = Util.msToUs(maxLiveOffsetErrorMsForUnitSpeed); @@ -203,6 +209,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * when the player is rebuffering, in milliseconds * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setTargetLiveOffsetIncrementOnRebufferMs( long targetLiveOffsetIncrementOnRebufferMs) { Assertions.checkArgument(targetLiveOffsetIncrementOnRebufferMs >= 0); @@ -225,6 +232,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC * @param minPossibleLiveOffsetSmoothingFactor The smoothing factor. Must be ≥ 0 and < 1. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMinPossibleLiveOffsetSmoothingFactor( float minPossibleLiveOffsetSmoothingFactor) { Assertions.checkArgument( diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLoadControl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLoadControl.java index 196d26098d..2077c1ee33 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLoadControl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultLoadControl.java @@ -29,6 +29,7 @@ import androidx.media3.exoplayer.source.TrackGroupArray; import androidx.media3.exoplayer.trackselection.ExoTrackSelection; import androidx.media3.exoplayer.upstream.Allocator; import androidx.media3.exoplayer.upstream.DefaultAllocator; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** The default {@link LoadControl} implementation. */ @UnstableApi @@ -133,6 +134,7 @@ public class DefaultLoadControl implements LoadControl { * @return This builder, for convenience. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setAllocator(DefaultAllocator allocator) { checkState(!buildCalled); this.allocator = allocator; @@ -154,6 +156,7 @@ public class DefaultLoadControl implements LoadControl { * @return This builder, for convenience. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setBufferDurationsMs( int minBufferMs, int maxBufferMs, @@ -185,6 +188,7 @@ public class DefaultLoadControl implements LoadControl { * @return This builder, for convenience. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setTargetBufferBytes(int targetBufferBytes) { checkState(!buildCalled); this.targetBufferBytes = targetBufferBytes; @@ -200,6 +204,7 @@ public class DefaultLoadControl implements LoadControl { * @return This builder, for convenience. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setPrioritizeTimeOverSizeThresholds(boolean prioritizeTimeOverSizeThresholds) { checkState(!buildCalled); this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds; @@ -216,6 +221,7 @@ public class DefaultLoadControl implements LoadControl { * @return This builder, for convenience. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setBackBuffer(int backBufferDurationMs, boolean retainBackBufferFromKeyframe) { checkState(!buildCalled); assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0"); diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java index e78a2f1b03..02a77a96e4 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/DefaultRenderersFactory.java @@ -42,6 +42,7 @@ import androidx.media3.exoplayer.trackselection.TrackSelector; import androidx.media3.exoplayer.video.MediaCodecVideoRenderer; import androidx.media3.exoplayer.video.VideoRendererEventListener; import androidx.media3.exoplayer.video.spherical.CameraMotionRenderer; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -124,6 +125,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * @param extensionRendererMode The extension renderer mode. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setExtensionRendererMode( @ExtensionRendererMode int extensionRendererMode) { this.extensionRendererMode = extensionRendererMode; @@ -139,6 +141,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory forceEnableMediaCodecAsynchronousQueueing() { codecAdapterFactory.forceEnableAsynchronous(); return this; @@ -151,6 +154,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory forceDisableMediaCodecAsynchronousQueueing() { codecAdapterFactory.forceDisableAsynchronous(); return this; @@ -165,6 +169,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * queueing. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled( boolean enabled) { codecAdapterFactory.experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(enabled); @@ -179,6 +184,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * initialization fails. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setEnableDecoderFallback(boolean enableDecoderFallback) { this.enableDecoderFallback = enableDecoderFallback; return this; @@ -192,6 +198,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * @param mediaCodecSelector The {@link MediaCodecSelector}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setMediaCodecSelector(MediaCodecSelector mediaCodecSelector) { this.mediaCodecSelector = mediaCodecSelector; return this; @@ -208,6 +215,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * @param enableFloatOutput Whether to enable use of floating point audio output, if available. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setEnableAudioFloatOutput(boolean enableFloatOutput) { this.enableFloatOutput = enableFloatOutput; return this; @@ -230,6 +238,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * available. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setEnableAudioOffload(boolean enableOffload) { this.enableOffload = enableOffload; return this; @@ -253,6 +262,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * android.media.AudioTrack#setPlaybackParams(PlaybackParams)}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setEnableAudioTrackPlaybackParams( boolean enableAudioTrackPlaybackParams) { this.enableAudioTrackPlaybackParams = enableAudioTrackPlaybackParams; @@ -269,6 +279,7 @@ public class DefaultRenderersFactory implements RenderersFactory { * seamlessly join an ongoing playback, in milliseconds. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultRenderersFactory setAllowedVideoJoiningTimeMs(long allowedVideoJoiningTimeMs) { this.allowedVideoJoiningTimeMs = allowedVideoJoiningTimeMs; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java index 939e808870..de32120a38 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayer.java @@ -70,6 +70,7 @@ import androidx.media3.extractor.DefaultExtractorsFactory; import androidx.media3.extractor.ExtractorsFactory; import com.google.common.base.Function; import com.google.common.base.Supplier; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; /** @@ -683,6 +684,7 @@ public interface ExoPlayer extends Player { * * @param timeoutMs The time limit in milliseconds. */ + @CanIgnoreReturnValue @UnstableApi public Builder experimentalSetForegroundModeTimeoutMs(long timeoutMs) { checkState(!buildCalled); @@ -697,6 +699,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setRenderersFactory(RenderersFactory renderersFactory) { checkState(!buildCalled); @@ -712,6 +715,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { checkState(!buildCalled); checkNotNull(mediaSourceFactory); @@ -726,6 +730,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setTrackSelector(TrackSelector trackSelector) { checkState(!buildCalled); @@ -741,6 +746,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setLoadControl(LoadControl loadControl) { checkState(!buildCalled); @@ -756,6 +762,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setBandwidthMeter(BandwidthMeter bandwidthMeter) { checkState(!buildCalled); @@ -772,6 +779,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setLooper(Looper looper) { checkState(!buildCalled); @@ -787,6 +795,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setAnalyticsCollector(AnalyticsCollector analyticsCollector) { checkState(!buildCalled); @@ -804,6 +813,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setPriorityTaskManager(@Nullable PriorityTaskManager priorityTaskManager) { checkState(!buildCalled); @@ -824,6 +834,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) { checkState(!buildCalled); this.audioAttributes = checkNotNull(audioAttributes); @@ -848,6 +859,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setWakeMode(@C.WakeMode int wakeMode) { checkState(!buildCalled); this.wakeMode = wakeMode; @@ -865,6 +877,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue public Builder setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy) { checkState(!buildCalled); this.handleAudioBecomingNoisy = handleAudioBecomingNoisy; @@ -878,6 +891,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setSkipSilenceEnabled(boolean skipSilenceEnabled) { checkState(!buildCalled); @@ -895,6 +909,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setVideoScalingMode(@C.VideoScalingMode int videoScalingMode) { checkState(!buildCalled); @@ -916,6 +931,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setVideoChangeFrameRateStrategy( @C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) { @@ -935,6 +951,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setUseLazyPreparation(boolean useLazyPreparation) { checkState(!buildCalled); @@ -949,6 +966,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setSeekParameters(SeekParameters seekParameters) { checkState(!buildCalled); @@ -964,6 +982,7 @@ public interface ExoPlayer extends Player { * @throws IllegalArgumentException If {@code seekBackIncrementMs} is non-positive. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setSeekBackIncrementMs(@IntRange(from = 1) long seekBackIncrementMs) { checkArgument(seekBackIncrementMs > 0); @@ -980,6 +999,7 @@ public interface ExoPlayer extends Player { * @throws IllegalArgumentException If {@code seekForwardIncrementMs} is non-positive. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setSeekForwardIncrementMs(@IntRange(from = 1) long seekForwardIncrementMs) { checkArgument(seekForwardIncrementMs > 0); @@ -999,6 +1019,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setReleaseTimeoutMs(long releaseTimeoutMs) { checkState(!buildCalled); @@ -1017,6 +1038,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setDetachSurfaceTimeoutMs(long detachSurfaceTimeoutMs) { checkState(!buildCalled); @@ -1036,6 +1058,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) { checkState(!buildCalled); @@ -1051,6 +1074,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setLivePlaybackSpeedControl(LivePlaybackSpeedControl livePlaybackSpeedControl) { checkState(!buildCalled); @@ -1073,6 +1097,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi public Builder setUsePlatformDiagnostics(boolean usePlatformDiagnostics) { checkState(!buildCalled); @@ -1088,6 +1113,7 @@ public interface ExoPlayer extends Player { * @return This builder. * @throws IllegalStateException If {@link #build()} has already been called. */ + @CanIgnoreReturnValue @UnstableApi @VisibleForTesting public Builder setClock(Clock clock) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java index 1ad8dc0cb6..95df21be23 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/ExoPlayerImpl.java @@ -105,6 +105,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener; import androidx.media3.exoplayer.video.spherical.CameraMotionListener; import androidx.media3.exoplayer.video.spherical.SphericalGLSurfaceView; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -397,6 +398,7 @@ import java.util.concurrent.TimeoutException; } } + @CanIgnoreReturnValue @SuppressWarnings("deprecation") // Returning deprecated class. @Override @Deprecated @@ -405,6 +407,7 @@ import java.util.concurrent.TimeoutException; return this; } + @CanIgnoreReturnValue @SuppressWarnings("deprecation") // Returning deprecated class. @Override @Deprecated @@ -413,6 +416,7 @@ import java.util.concurrent.TimeoutException; return this; } + @CanIgnoreReturnValue @SuppressWarnings("deprecation") // Returning deprecated class. @Override @Deprecated @@ -421,6 +425,7 @@ import java.util.concurrent.TimeoutException; return this; } + @CanIgnoreReturnValue @SuppressWarnings("deprecation") // Returning deprecated class. @Override @Deprecated diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java index 328416025a..1bd590368d 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/PlayerMessage.java @@ -27,6 +27,7 @@ import androidx.media3.common.util.Assertions; import androidx.media3.common.util.Clock; import androidx.media3.common.util.UnstableApi; import androidx.media3.exoplayer.Renderer.MessageType; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.TimeoutException; /** @@ -125,6 +126,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setType(int messageType) { Assertions.checkState(!isSent); this.type = messageType; @@ -143,6 +145,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setPayload(@Nullable Object payload) { Assertions.checkState(!isSent); this.payload = payload; @@ -158,6 +161,7 @@ public final class PlayerMessage { /** * @deprecated Use {@link #setLooper(Looper)} instead. */ + @CanIgnoreReturnValue @Deprecated public PlayerMessage setHandler(Handler handler) { return setLooper(handler.getLooper()); @@ -170,6 +174,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setLooper(Looper looper) { Assertions.checkState(!isSent); this.looper = looper; @@ -200,6 +205,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setPosition(long positionMs) { Assertions.checkState(!isSent); this.positionMs = positionMs; @@ -218,6 +224,7 @@ public final class PlayerMessage { * empty and the provided media item index is not within the bounds of the timeline. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setPosition(int mediaItemIndex, long positionMs) { Assertions.checkState(!isSent); Assertions.checkArgument(positionMs != C.TIME_UNSET); @@ -244,6 +251,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If {@link #send()} has already been called. */ + @CanIgnoreReturnValue public PlayerMessage setDeleteAfterDelivery(boolean deleteAfterDelivery) { Assertions.checkState(!isSent); this.deleteAfterDelivery = deleteAfterDelivery; @@ -262,6 +270,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If this message has already been sent. */ + @CanIgnoreReturnValue public PlayerMessage send() { Assertions.checkState(!isSent); if (positionMs == C.TIME_UNSET) { @@ -278,6 +287,7 @@ public final class PlayerMessage { * @return This message. * @throws IllegalStateException If this method is called before {@link #send()}. */ + @CanIgnoreReturnValue public synchronized PlayerMessage cancel() { Assertions.checkState(isSent); isCanceled = true; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java index 233fd18eed..3d9f7e5f53 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/SimpleExoPlayer.java @@ -55,6 +55,7 @@ import androidx.media3.exoplayer.upstream.BandwidthMeter; import androidx.media3.exoplayer.video.VideoFrameMetadataListener; import androidx.media3.exoplayer.video.spherical.CameraMotionListener; import androidx.media3.extractor.ExtractorsFactory; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; /** @@ -146,6 +147,7 @@ public class SimpleExoPlayer extends BasePlayer * @deprecated Use {@link ExoPlayer.Builder#experimentalSetForegroundModeTimeoutMs(long)} * instead. */ + @CanIgnoreReturnValue @Deprecated public Builder experimentalSetForegroundModeTimeoutMs(long timeoutMs) { wrappedBuilder.experimentalSetForegroundModeTimeoutMs(timeoutMs); @@ -155,6 +157,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setTrackSelector(TrackSelector)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setTrackSelector(TrackSelector trackSelector) { wrappedBuilder.setTrackSelector(trackSelector); @@ -164,6 +167,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setMediaSourceFactory(MediaSource.Factory)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { wrappedBuilder.setMediaSourceFactory(mediaSourceFactory); @@ -173,6 +177,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setLoadControl(LoadControl)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setLoadControl(LoadControl loadControl) { wrappedBuilder.setLoadControl(loadControl); @@ -182,6 +187,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setBandwidthMeter(BandwidthMeter)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setBandwidthMeter(BandwidthMeter bandwidthMeter) { wrappedBuilder.setBandwidthMeter(bandwidthMeter); @@ -191,6 +197,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setLooper(Looper)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setLooper(Looper looper) { wrappedBuilder.setLooper(looper); @@ -200,6 +207,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setAnalyticsCollector(AnalyticsCollector)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setAnalyticsCollector(AnalyticsCollector analyticsCollector) { wrappedBuilder.setAnalyticsCollector(analyticsCollector); @@ -210,6 +218,7 @@ public class SimpleExoPlayer extends BasePlayer * @deprecated Use {@link ExoPlayer.Builder#setPriorityTaskManager(PriorityTaskManager)} * instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setPriorityTaskManager(@Nullable PriorityTaskManager priorityTaskManager) { wrappedBuilder.setPriorityTaskManager(priorityTaskManager); @@ -220,6 +229,7 @@ public class SimpleExoPlayer extends BasePlayer * @deprecated Use {@link ExoPlayer.Builder#setAudioAttributes(AudioAttributes, boolean)} * instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) { wrappedBuilder.setAudioAttributes(audioAttributes, handleAudioFocus); @@ -229,6 +239,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setWakeMode(int)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setWakeMode(@C.WakeMode int wakeMode) { wrappedBuilder.setWakeMode(wakeMode); @@ -238,6 +249,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setHandleAudioBecomingNoisy(boolean)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy) { wrappedBuilder.setHandleAudioBecomingNoisy(handleAudioBecomingNoisy); @@ -247,6 +259,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setSkipSilenceEnabled(boolean)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setSkipSilenceEnabled(boolean skipSilenceEnabled) { wrappedBuilder.setSkipSilenceEnabled(skipSilenceEnabled); @@ -256,6 +269,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setVideoScalingMode(int)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setVideoScalingMode(@C.VideoScalingMode int videoScalingMode) { wrappedBuilder.setVideoScalingMode(videoScalingMode); @@ -265,6 +279,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setVideoChangeFrameRateStrategy(int)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setVideoChangeFrameRateStrategy( @C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) { @@ -275,6 +290,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setUseLazyPreparation(boolean)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setUseLazyPreparation(boolean useLazyPreparation) { wrappedBuilder.setUseLazyPreparation(useLazyPreparation); @@ -284,6 +300,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setSeekParameters(SeekParameters)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setSeekParameters(SeekParameters seekParameters) { wrappedBuilder.setSeekParameters(seekParameters); @@ -293,6 +310,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setSeekBackIncrementMs(long)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setSeekBackIncrementMs(@IntRange(from = 1) long seekBackIncrementMs) { wrappedBuilder.setSeekBackIncrementMs(seekBackIncrementMs); @@ -302,6 +320,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setSeekForwardIncrementMs(long)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setSeekForwardIncrementMs(@IntRange(from = 1) long seekForwardIncrementMs) { wrappedBuilder.setSeekForwardIncrementMs(seekForwardIncrementMs); @@ -311,6 +330,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setReleaseTimeoutMs(long)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setReleaseTimeoutMs(long releaseTimeoutMs) { wrappedBuilder.setReleaseTimeoutMs(releaseTimeoutMs); @@ -320,6 +340,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setDetachSurfaceTimeoutMs(long)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setDetachSurfaceTimeoutMs(long detachSurfaceTimeoutMs) { wrappedBuilder.setDetachSurfaceTimeoutMs(detachSurfaceTimeoutMs); @@ -329,6 +350,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setPauseAtEndOfMediaItems(boolean)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) { wrappedBuilder.setPauseAtEndOfMediaItems(pauseAtEndOfMediaItems); @@ -339,6 +361,7 @@ public class SimpleExoPlayer extends BasePlayer * @deprecated Use {@link * ExoPlayer.Builder#setLivePlaybackSpeedControl(LivePlaybackSpeedControl)} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setLivePlaybackSpeedControl(LivePlaybackSpeedControl livePlaybackSpeedControl) { wrappedBuilder.setLivePlaybackSpeedControl(livePlaybackSpeedControl); @@ -348,6 +371,7 @@ public class SimpleExoPlayer extends BasePlayer /** * @deprecated Use {@link ExoPlayer.Builder#setClock(Clock)} instead. */ + @CanIgnoreReturnValue @Deprecated @VisibleForTesting public Builder setClock(Clock clock) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java index 1704ed3ba3..c3bb029d38 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioSink.java @@ -56,6 +56,7 @@ import androidx.media3.extractor.Ac3Util; import androidx.media3.extractor.Ac4Util; import androidx.media3.extractor.DtsUtil; import androidx.media3.extractor.MpegAudioUtil; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.InlineMe; import com.google.errorprone.annotations.InlineMeValidationDisabled; import java.lang.annotation.Documented; @@ -286,6 +287,7 @@ public final class DefaultAudioSink implements AudioSink { * *

Default is {@link AudioCapabilities#DEFAULT_AUDIO_CAPABILITIES}. */ + @CanIgnoreReturnValue public Builder setAudioCapabilities(AudioCapabilities audioCapabilities) { checkNotNull(audioCapabilities); this.audioCapabilities = audioCapabilities; @@ -299,6 +301,7 @@ public final class DefaultAudioSink implements AudioSink { * *

The default value is an empty array. */ + @CanIgnoreReturnValue public Builder setAudioProcessors(AudioProcessor[] audioProcessors) { checkNotNull(audioProcessors); return setAudioProcessorChain(new DefaultAudioProcessorChain(audioProcessors)); @@ -311,6 +314,7 @@ public final class DefaultAudioSink implements AudioSink { * *

By default, no processing will be applied. */ + @CanIgnoreReturnValue public Builder setAudioProcessorChain(AudioProcessorChain audioProcessorChain) { checkNotNull(audioProcessorChain); this.audioProcessorChain = audioProcessorChain; @@ -325,6 +329,7 @@ public final class DefaultAudioSink implements AudioSink { * *

The default value is {@code false}. */ + @CanIgnoreReturnValue public Builder setEnableFloatOutput(boolean enableFloatOutput) { this.enableFloatOutput = enableFloatOutput; return this; @@ -338,6 +343,7 @@ public final class DefaultAudioSink implements AudioSink { * *

The default value is {@code false}. */ + @CanIgnoreReturnValue public Builder setEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams) { this.enableAudioTrackPlaybackParams = enableAudioTrackPlaybackParams; return this; @@ -353,6 +359,7 @@ public final class DefaultAudioSink implements AudioSink { * *

The default value is {@link #OFFLOAD_MODE_DISABLED}. */ + @CanIgnoreReturnValue public Builder setOffloadMode(@OffloadMode int offloadMode) { this.offloadMode = offloadMode; return this; @@ -364,6 +371,7 @@ public final class DefaultAudioSink implements AudioSink { * *

The default value is {@link AudioTrackBufferSizeProvider#DEFAULT}. */ + @CanIgnoreReturnValue public Builder setAudioTrackBufferSizeProvider( AudioTrackBufferSizeProvider audioTrackBufferSizeProvider) { this.audioTrackBufferSizeProvider = audioTrackBufferSizeProvider; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioTrackBufferSizeProvider.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioTrackBufferSizeProvider.java index 5083d92896..62c72a5722 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioTrackBufferSizeProvider.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/audio/DefaultAudioTrackBufferSizeProvider.java @@ -32,6 +32,7 @@ import androidx.media3.extractor.Ac3Util; import androidx.media3.extractor.Ac4Util; import androidx.media3.extractor.DtsUtil; import androidx.media3.extractor.MpegAudioUtil; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** Provide the buffer size to use when creating an {@link AudioTrack}. */ @UnstableApi @@ -78,6 +79,7 @@ public class DefaultAudioTrackBufferSizeProvider * Sets the minimum length for PCM {@link AudioTrack} buffers, in microseconds. Default is * {@value #MIN_PCM_BUFFER_DURATION_US}. */ + @CanIgnoreReturnValue public Builder setMinPcmBufferDurationUs(int minPcmBufferDurationUs) { this.minPcmBufferDurationUs = minPcmBufferDurationUs; return this; @@ -87,6 +89,7 @@ public class DefaultAudioTrackBufferSizeProvider * Sets the maximum length for PCM {@link AudioTrack} buffers, in microseconds. Default is * {@value #MAX_PCM_BUFFER_DURATION_US}. */ + @CanIgnoreReturnValue public Builder setMaxPcmBufferDurationUs(int maxPcmBufferDurationUs) { this.maxPcmBufferDurationUs = maxPcmBufferDurationUs; return this; @@ -96,6 +99,7 @@ public class DefaultAudioTrackBufferSizeProvider * Sets the multiplication factor to apply to the minimum buffer size requested. Default is * {@value #PCM_BUFFER_MULTIPLICATION_FACTOR}. */ + @CanIgnoreReturnValue public Builder setPcmBufferMultiplicationFactor(int pcmBufferMultiplicationFactor) { this.pcmBufferMultiplicationFactor = pcmBufferMultiplicationFactor; return this; @@ -105,6 +109,7 @@ public class DefaultAudioTrackBufferSizeProvider * Sets the length for passthrough {@link AudioTrack} buffers, in microseconds. Default is * {@value #PASSTHROUGH_BUFFER_DURATION_US}. */ + @CanIgnoreReturnValue public Builder setPassthroughBufferDurationUs(int passthroughBufferDurationUs) { this.passthroughBufferDurationUs = passthroughBufferDurationUs; return this; @@ -114,6 +119,7 @@ public class DefaultAudioTrackBufferSizeProvider * The length for offload {@link AudioTrack} buffers, in microseconds. Default is {@value * #OFFLOAD_BUFFER_DURATION_US}. */ + @CanIgnoreReturnValue public Builder setOffloadBufferDurationUs(int offloadBufferDurationUs) { this.offloadBufferDurationUs = offloadBufferDurationUs; return this; @@ -123,6 +129,7 @@ public class DefaultAudioTrackBufferSizeProvider * Sets the multiplication factor to apply to the passthrough buffer for AC3 to avoid underruns * on some devices (e.g., Broadcom 7271). Default is {@value #AC3_BUFFER_MULTIPLICATION_FACTOR}. */ + @CanIgnoreReturnValue public Builder setAc3BufferMultiplicationFactor(int ac3BufferMultiplicationFactor) { this.ac3BufferMultiplicationFactor = ac3BufferMultiplicationFactor; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/DefaultDrmSessionManager.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/DefaultDrmSessionManager.java index adcb450e28..9a345ffff7 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/DefaultDrmSessionManager.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/drm/DefaultDrmSessionManager.java @@ -47,6 +47,7 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -121,6 +122,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * @param keyRequestParameters A map with parameters. * @return This builder. */ + @CanIgnoreReturnValue public Builder setKeyRequestParameters(@Nullable Map keyRequestParameters) { this.keyRequestParameters.clear(); if (keyRequestParameters != null) { @@ -136,6 +138,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * @param exoMediaDrmProvider The {@link ExoMediaDrm.Provider}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setUuidAndExoMediaDrmProvider( UUID uuid, ExoMediaDrm.Provider exoMediaDrmProvider) { this.uuid = checkNotNull(uuid); @@ -153,6 +156,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * sessions. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMultiSession(boolean multiSession) { this.multiSession = multiSession; return this; @@ -172,6 +176,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * @throws IllegalArgumentException If {@code useDrmSessionsForClearContentTrackTypes} contains * track types other than {@link C#TRACK_TYPE_AUDIO} and {@link C#TRACK_TYPE_VIDEO}. */ + @CanIgnoreReturnValue public Builder setUseDrmSessionsForClearContent( @C.TrackType int... useDrmSessionsForClearContentTrackTypes) { for (@C.TrackType int trackType : useDrmSessionsForClearContentTrackTypes) { @@ -190,6 +195,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * played when keys for the encrypted part of the content have yet to be loaded. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPlayClearSamplesWithoutKeys(boolean playClearSamplesWithoutKeys) { this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys; return this; @@ -201,6 +207,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = checkNotNull(loadErrorHandlingPolicy); return this; @@ -221,6 +228,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager { * in milliseconds. Must be > 0 or {@link C#TIME_UNSET} to disable keep-alive. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSessionKeepaliveMs(long sessionKeepaliveMs) { checkArgument(sessionKeepaliveMs > 0 || sessionKeepaliveMs == C.TIME_UNSET); this.sessionKeepaliveMs = sessionKeepaliveMs; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/DefaultMediaCodecAdapterFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/DefaultMediaCodecAdapterFactory.java index d5de1d0bdd..0bca3b7140 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/DefaultMediaCodecAdapterFactory.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/mediacodec/DefaultMediaCodecAdapterFactory.java @@ -22,6 +22,7 @@ import androidx.media3.common.MimeTypes; import androidx.media3.common.util.Log; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -66,6 +67,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter. * * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultMediaCodecAdapterFactory forceEnableAsynchronous() { asynchronousMode = MODE_ENABLED; return this; @@ -76,6 +78,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter. * * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultMediaCodecAdapterFactory forceDisableAsynchronous() { asynchronousMode = MODE_DISABLED; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/offline/DownloadRequest.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/offline/DownloadRequest.java index d89552363b..487b998d0a 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/offline/DownloadRequest.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/offline/DownloadRequest.java @@ -28,6 +28,7 @@ import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -58,30 +59,35 @@ public final class DownloadRequest implements Parcelable { } /** Sets the {@link DownloadRequest#mimeType}. */ + @CanIgnoreReturnValue public Builder setMimeType(@Nullable String mimeType) { this.mimeType = mimeType; return this; } /** Sets the {@link DownloadRequest#streamKeys}. */ + @CanIgnoreReturnValue public Builder setStreamKeys(@Nullable List streamKeys) { this.streamKeys = streamKeys; return this; } /** Sets the {@link DownloadRequest#keySetId}. */ + @CanIgnoreReturnValue public Builder setKeySetId(@Nullable byte[] keySetId) { this.keySetId = keySetId; return this; } /** Sets the {@link DownloadRequest#customCacheKey}. */ + @CanIgnoreReturnValue public Builder setCustomCacheKey(@Nullable String customCacheKey) { this.customCacheKey = customCacheKey; return this; } /** Sets the {@link DownloadRequest#data}. */ + @CanIgnoreReturnValue public Builder setData(@Nullable byte[] data) { this.data = data; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/DefaultMediaSourceFactory.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/DefaultMediaSourceFactory.java index 6a55a3a13e..291fbbe340 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/DefaultMediaSourceFactory.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/DefaultMediaSourceFactory.java @@ -51,6 +51,7 @@ import androidx.media3.extractor.text.SubtitleExtractor; import com.google.common.base.Supplier; import com.google.common.collect.ImmutableList; import com.google.common.primitives.Ints; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; @@ -195,6 +196,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * should be used for subtitles instead of {@link SingleSampleMediaSource}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory experimentalUseProgressiveMediaSourceForSubtitles( boolean useProgressiveMediaSourceForSubtitles) { @@ -214,6 +216,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * @deprecated Use {@link #setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)} * instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public DefaultMediaSourceFactory setAdsLoaderProvider( @@ -233,6 +236,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * @deprecated Use {@link #setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)} * instead. */ + @CanIgnoreReturnValue @UnstableApi @Deprecated public DefaultMediaSourceFactory setAdViewProvider(@Nullable AdViewProvider adViewProvider) { @@ -251,6 +255,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * @param adViewProvider A provider for information about views for the ad playback UI. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultMediaSourceFactory setLocalAdInsertionComponents( AdsLoader.Provider adsLoaderProvider, AdViewProvider adViewProvider) { this.adsLoaderProvider = checkNotNull(adsLoaderProvider); @@ -267,6 +272,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultMediaSourceFactory clearLocalAdInsertionComponents() { this.adsLoaderProvider = null; this.adViewProvider = null; @@ -280,6 +286,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * @param dataSourceFactory The {@link DataSource.Factory}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public DefaultMediaSourceFactory setDataSourceFactory(DataSource.Factory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; delegateFactoryLoader.setDataSourceFactory(dataSourceFactory); @@ -296,6 +303,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * content, or {@code null} to remove a previously set {@link MediaSource.Factory}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setServerSideAdInsertionMediaSourceFactory( @Nullable MediaSource.Factory serverSideAdInsertionMediaSourceFactory) { @@ -310,6 +318,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * use the media-defined default. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setLiveTargetOffsetMs(long liveTargetOffsetMs) { this.liveTargetOffsetMs = liveTargetOffsetMs; @@ -323,6 +332,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * C#TIME_UNSET} to use the media-defined default. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setLiveMinOffsetMs(long liveMinOffsetMs) { this.liveMinOffsetMs = liveMinOffsetMs; @@ -336,6 +346,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * C#TIME_UNSET} to use the media-defined default. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setLiveMaxOffsetMs(long liveMaxOffsetMs) { this.liveMaxOffsetMs = liveMaxOffsetMs; @@ -349,6 +360,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * C#RATE_UNSET} to use the media-defined default. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setLiveMinSpeed(float minSpeed) { this.liveMinSpeed = minSpeed; @@ -362,12 +374,14 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { * C#RATE_UNSET} to use the media-defined default. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public DefaultMediaSourceFactory setLiveMaxSpeed(float maxSpeed) { this.liveMaxSpeed = maxSpeed; return this; } + @CanIgnoreReturnValue @UnstableApi @Override public DefaultMediaSourceFactory setDrmSessionManagerProvider( @@ -381,6 +395,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory { return this; } + @CanIgnoreReturnValue @UnstableApi @Override public DefaultMediaSourceFactory setLoadErrorHandlingPolicy( diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaSource.java index 807e336e8d..aef2e708a9 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/ProgressiveMediaSource.java @@ -35,6 +35,7 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; import androidx.media3.extractor.DefaultExtractorsFactory; import androidx.media3.extractor.Extractor; import androidx.media3.extractor.ExtractorsFactory; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * Provides one period that loads data from a {@link Uri} and extracted using an {@link Extractor}. @@ -155,6 +156,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes; } + @CanIgnoreReturnValue @Override public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = @@ -176,11 +178,13 @@ public final class ProgressiveMediaSource extends BaseMediaSource * MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setContinueLoadingCheckIntervalBytes(int continueLoadingCheckIntervalBytes) { this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes; return this; } + @CanIgnoreReturnValue @Override public Factory setDrmSessionManagerProvider( DrmSessionManagerProvider drmSessionManagerProvider) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SilenceMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SilenceMediaSource.java index 18d52dfa09..dc69afa713 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SilenceMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SilenceMediaSource.java @@ -35,6 +35,7 @@ import androidx.media3.exoplayer.FormatHolder; import androidx.media3.exoplayer.SeekParameters; import androidx.media3.exoplayer.trackselection.ExoTrackSelection; import androidx.media3.exoplayer.upstream.Allocator; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import org.checkerframework.checker.nullness.compatqual.NullableType; @@ -54,6 +55,7 @@ public final class SilenceMediaSource extends BaseMediaSource { * @param durationUs The duration of silent audio to output, in microseconds. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setDurationUs(@IntRange(from = 1) long durationUs) { this.durationUs = durationUs; return this; @@ -66,6 +68,7 @@ public final class SilenceMediaSource extends BaseMediaSource { * @param tag A tag for the media source. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setTag(@Nullable Object tag) { this.tag = tag; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SingleSampleMediaSource.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SingleSampleMediaSource.java index 5c0cb861c4..47b5655452 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SingleSampleMediaSource.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/source/SingleSampleMediaSource.java @@ -32,6 +32,7 @@ import androidx.media3.exoplayer.upstream.Allocator; import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy; import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** * Loads data at a given {@link Uri} as a single sample belonging to a single {@link MediaPeriod}. @@ -68,6 +69,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource { * @param tag A tag for the media source. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setTag(@Nullable Object tag) { this.tag = tag; return this; @@ -79,6 +81,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource { * #createMediaSource(MediaItem.SubtitleConfiguration, long)}). {@code trackId} will only be * used if {@link MediaItem.SubtitleConfiguration#id} is {@code null}. */ + @CanIgnoreReturnValue @Deprecated public Factory setTrackId(@Nullable String trackId) { this.trackId = trackId; @@ -92,6 +95,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource { * @param loadErrorHandlingPolicy A {@link LoadErrorHandlingPolicy}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setLoadErrorHandlingPolicy( @Nullable LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = @@ -110,6 +114,7 @@ public final class SingleSampleMediaSource extends BaseMediaSource { * normally by {@link SampleStream#maybeThrowError()}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setTreatLoadErrorsAsEndOfStream(boolean treatLoadErrorsAsEndOfStream) { this.treatLoadErrorsAsEndOfStream = treatLoadErrorsAsEndOfStream; return this; diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.java index e0020888e6..c4ea5ca2a8 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelector.java @@ -66,6 +66,7 @@ import com.google.common.collect.ComparisonChain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Ordering; import com.google.common.primitives.Ints; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -145,6 +146,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { delegate = new Parameters.Builder(context); } + @CanIgnoreReturnValue @Override protected ParametersBuilder set(TrackSelectionParameters parameters) { delegate.set(parameters); @@ -153,18 +155,21 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Video + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMaxVideoSizeSd() { delegate.setMaxVideoSizeSd(); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder clearVideoSizeConstraints() { delegate.clearVideoSizeConstraints(); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMaxVideoSize( int maxVideoWidth, int maxVideoHeight) { @@ -172,18 +177,21 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMaxVideoFrameRate(int maxVideoFrameRate) { delegate.setMaxVideoFrameRate(maxVideoFrameRate); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMaxVideoBitrate(int maxVideoBitrate) { delegate.setMaxVideoBitrate(maxVideoBitrate); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMinVideoSize( int minVideoWidth, int minVideoHeight) { @@ -191,12 +199,14 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMinVideoFrameRate(int minVideoFrameRate) { delegate.setMinVideoFrameRate(minVideoFrameRate); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setMinVideoBitrate(int minVideoBitrate) { delegate.setMinVideoBitrate(minVideoBitrate); @@ -211,6 +221,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setExceedVideoConstraintsIfNecessary( boolean exceedVideoConstraintsIfNecessary) { delegate.setExceedVideoConstraintsIfNecessary(exceedVideoConstraintsIfNecessary); @@ -228,6 +239,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed MIME types. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowVideoMixedMimeTypeAdaptiveness( boolean allowVideoMixedMimeTypeAdaptiveness) { delegate.setAllowVideoMixedMimeTypeAdaptiveness(allowVideoMixedMimeTypeAdaptiveness); @@ -242,6 +254,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * adaptation may not be completely seamless. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowVideoNonSeamlessAdaptiveness( boolean allowVideoNonSeamlessAdaptiveness) { delegate.setAllowVideoNonSeamlessAdaptiveness(allowVideoNonSeamlessAdaptiveness); @@ -257,6 +270,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * with mixed levels of decoder and hardware acceleration support. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowVideoMixedDecoderSupportAdaptiveness( boolean allowVideoMixedDecoderSupportAdaptiveness) { delegate.setAllowVideoMixedDecoderSupportAdaptiveness( @@ -264,6 +278,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setViewportSizeToPhysicalDisplaySize( Context context, boolean viewportOrientationMayChange) { @@ -271,12 +286,14 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder clearViewportSizeConstraints() { delegate.clearViewportSizeConstraints(); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setViewportSize( int viewportWidth, int viewportHeight, boolean viewportOrientationMayChange) { @@ -284,18 +301,21 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredVideoMimeType(@Nullable String mimeType) { delegate.setPreferredVideoMimeType(mimeType); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredVideoMimeTypes(String... mimeTypes) { delegate.setPreferredVideoMimeTypes(mimeTypes); return this; } + @CanIgnoreReturnValue @Override public DefaultTrackSelector.ParametersBuilder setPreferredVideoRoleFlags( @RoleFlags int preferredVideoRoleFlags) { @@ -305,30 +325,35 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Audio + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredAudioLanguage(@Nullable String preferredAudioLanguage) { delegate.setPreferredAudioLanguage(preferredAudioLanguage); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredAudioLanguages(String... preferredAudioLanguages) { delegate.setPreferredAudioLanguages(preferredAudioLanguages); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredAudioRoleFlags(@C.RoleFlags int preferredAudioRoleFlags) { delegate.setPreferredAudioRoleFlags(preferredAudioRoleFlags); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setMaxAudioChannelCount(int maxAudioChannelCount) { delegate.setMaxAudioChannelCount(maxAudioChannelCount); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setMaxAudioBitrate(int maxAudioBitrate) { delegate.setMaxAudioBitrate(maxAudioBitrate); @@ -343,6 +368,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setExceedAudioConstraintsIfNecessary( boolean exceedAudioConstraintsIfNecessary) { delegate.setExceedAudioConstraintsIfNecessary(exceedAudioConstraintsIfNecessary); @@ -358,6 +384,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed MIME types. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowAudioMixedMimeTypeAdaptiveness( boolean allowAudioMixedMimeTypeAdaptiveness) { delegate.setAllowAudioMixedMimeTypeAdaptiveness(allowAudioMixedMimeTypeAdaptiveness); @@ -373,6 +400,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed sample rates. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowAudioMixedSampleRateAdaptiveness( boolean allowAudioMixedSampleRateAdaptiveness) { delegate.setAllowAudioMixedSampleRateAdaptiveness(allowAudioMixedSampleRateAdaptiveness); @@ -388,6 +416,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed channel counts. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowAudioMixedChannelCountAdaptiveness( boolean allowAudioMixedChannelCountAdaptiveness) { delegate.setAllowAudioMixedChannelCountAdaptiveness(allowAudioMixedChannelCountAdaptiveness); @@ -403,6 +432,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * with mixed levels of decoder and hardware acceleration support. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowAudioMixedDecoderSupportAdaptiveness( boolean allowAudioMixedDecoderSupportAdaptiveness) { delegate.setAllowAudioMixedDecoderSupportAdaptiveness( @@ -410,12 +440,14 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredAudioMimeType(@Nullable String mimeType) { delegate.setPreferredAudioMimeType(mimeType); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredAudioMimeTypes(String... mimeTypes) { delegate.setPreferredAudioMimeTypes(mimeTypes); @@ -424,6 +456,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Text + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings( Context context) { @@ -431,24 +464,28 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredTextLanguage(@Nullable String preferredTextLanguage) { delegate.setPreferredTextLanguage(preferredTextLanguage); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredTextLanguages(String... preferredTextLanguages) { delegate.setPreferredTextLanguages(preferredTextLanguages); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setPreferredTextRoleFlags(@C.RoleFlags int preferredTextRoleFlags) { delegate.setPreferredTextRoleFlags(preferredTextRoleFlags); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setIgnoredTextSelectionFlags( @C.SelectionFlags int ignoredTextSelectionFlags) { @@ -456,6 +493,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setSelectUndeterminedTextLanguage( boolean selectUndeterminedTextLanguage) { @@ -466,6 +504,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { /** * @deprecated Use {@link #setIgnoredTextSelectionFlags}. */ + @CanIgnoreReturnValue @Deprecated public ParametersBuilder setDisabledTextTrackSelectionFlags( @C.SelectionFlags int disabledTextTrackSelectionFlags) { @@ -475,42 +514,49 @@ public class DefaultTrackSelector extends MappingTrackSelector { // General + @CanIgnoreReturnValue @Override public ParametersBuilder setForceLowestBitrate(boolean forceLowestBitrate) { delegate.setForceLowestBitrate(forceLowestBitrate); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate) { delegate.setForceHighestSupportedBitrate(forceHighestSupportedBitrate); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder addOverride(TrackSelectionOverride override) { delegate.addOverride(override); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder clearOverride(TrackGroup trackGroup) { delegate.clearOverride(trackGroup); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setOverrideForType(TrackSelectionOverride override) { delegate.setOverrideForType(override); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder clearOverridesOfType(@C.TrackType int trackType) { delegate.clearOverridesOfType(trackType); return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder clearOverrides() { delegate.clearOverrides(); @@ -520,6 +566,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { /** * @deprecated Use {@link #setTrackTypeDisabled(int, boolean)}. */ + @CanIgnoreReturnValue @Override @Deprecated @SuppressWarnings("deprecation") @@ -528,6 +575,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public ParametersBuilder setTrackTypeDisabled(@C.TrackType int trackType, boolean disabled) { delegate.setTrackTypeDisabled(trackType, disabled); @@ -546,6 +594,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setExceedRendererCapabilitiesIfNecessary( boolean exceedRendererCapabilitiesIfNecessary) { delegate.setExceedRendererCapabilitiesIfNecessary(exceedRendererCapabilitiesIfNecessary); @@ -566,6 +615,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param tunnelingEnabled Whether to enable tunneling if possible. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setTunnelingEnabled(boolean tunnelingEnabled) { delegate.setTunnelingEnabled(tunnelingEnabled); return this; @@ -577,6 +627,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param allowMultipleAdaptiveSelections Whether multiple adaptive selections are allowed. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setAllowMultipleAdaptiveSelections( boolean allowMultipleAdaptiveSelections) { delegate.setAllowMultipleAdaptiveSelections(allowMultipleAdaptiveSelections); @@ -593,6 +644,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param disabled Whether the renderer is disabled. * @return This builder. */ + @CanIgnoreReturnValue public ParametersBuilder setRendererDisabled(int rendererIndex, boolean disabled) { delegate.setRendererDisabled(rendererIndex, disabled); return this; @@ -622,6 +674,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#addOverride(TrackSelectionOverride)}. */ + @CanIgnoreReturnValue @Deprecated public ParametersBuilder setSelectionOverride( int rendererIndex, TrackGroupArray groups, @Nullable SelectionOverride override) { @@ -637,6 +690,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverride(TrackGroup)}. */ + @CanIgnoreReturnValue @Deprecated public ParametersBuilder clearSelectionOverride(int rendererIndex, TrackGroupArray groups) { delegate.clearSelectionOverride(rendererIndex, groups); @@ -650,6 +704,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverridesOfType(int)}. */ + @CanIgnoreReturnValue @Deprecated public ParametersBuilder clearSelectionOverrides(int rendererIndex) { delegate.clearSelectionOverrides(rendererIndex); @@ -662,6 +717,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverrides()}. */ + @CanIgnoreReturnValue @Deprecated public ParametersBuilder clearSelectionOverrides() { delegate.clearSelectionOverrides(); @@ -836,6 +892,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { Parameters.keyForField(Parameters.FIELD_RENDERER_DISABLED_INDICES))); } + @CanIgnoreReturnValue @Override protected Builder set(TrackSelectionParameters parameters) { super.set(parameters); @@ -844,48 +901,56 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Video + @CanIgnoreReturnValue @Override public Builder setMaxVideoSizeSd() { super.setMaxVideoSizeSd(); return this; } + @CanIgnoreReturnValue @Override public Builder clearVideoSizeConstraints() { super.clearVideoSizeConstraints(); return this; } + @CanIgnoreReturnValue @Override public Builder setMaxVideoSize(int maxVideoWidth, int maxVideoHeight) { super.setMaxVideoSize(maxVideoWidth, maxVideoHeight); return this; } + @CanIgnoreReturnValue @Override public Builder setMaxVideoFrameRate(int maxVideoFrameRate) { super.setMaxVideoFrameRate(maxVideoFrameRate); return this; } + @CanIgnoreReturnValue @Override public Builder setMaxVideoBitrate(int maxVideoBitrate) { super.setMaxVideoBitrate(maxVideoBitrate); return this; } + @CanIgnoreReturnValue @Override public Builder setMinVideoSize(int minVideoWidth, int minVideoHeight) { super.setMinVideoSize(minVideoWidth, minVideoHeight); return this; } + @CanIgnoreReturnValue @Override public Builder setMinVideoFrameRate(int minVideoFrameRate) { super.setMinVideoFrameRate(minVideoFrameRate); return this; } + @CanIgnoreReturnValue @Override public Builder setMinVideoBitrate(int minVideoBitrate) { super.setMinVideoBitrate(minVideoBitrate); @@ -900,6 +965,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public Builder setExceedVideoConstraintsIfNecessary( boolean exceedVideoConstraintsIfNecessary) { this.exceedVideoConstraintsIfNecessary = exceedVideoConstraintsIfNecessary; @@ -917,6 +983,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed MIME types. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowVideoMixedMimeTypeAdaptiveness( boolean allowVideoMixedMimeTypeAdaptiveness) { this.allowVideoMixedMimeTypeAdaptiveness = allowVideoMixedMimeTypeAdaptiveness; @@ -931,6 +998,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * adaptation may not be completely seamless. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowVideoNonSeamlessAdaptiveness( boolean allowVideoNonSeamlessAdaptiveness) { this.allowVideoNonSeamlessAdaptiveness = allowVideoNonSeamlessAdaptiveness; @@ -946,12 +1014,14 @@ public class DefaultTrackSelector extends MappingTrackSelector { * with mixed levels of decoder and hardware acceleration support. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowVideoMixedDecoderSupportAdaptiveness( boolean allowVideoMixedDecoderSupportAdaptiveness) { this.allowVideoMixedDecoderSupportAdaptiveness = allowVideoMixedDecoderSupportAdaptiveness; return this; } + @CanIgnoreReturnValue @Override public Builder setViewportSizeToPhysicalDisplaySize( Context context, boolean viewportOrientationMayChange) { @@ -959,12 +1029,14 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public Builder clearViewportSizeConstraints() { super.clearViewportSizeConstraints(); return this; } + @CanIgnoreReturnValue @Override public Builder setViewportSize( int viewportWidth, int viewportHeight, boolean viewportOrientationMayChange) { @@ -972,18 +1044,21 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredVideoMimeType(@Nullable String mimeType) { super.setPreferredVideoMimeType(mimeType); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredVideoMimeTypes(String... mimeTypes) { super.setPreferredVideoMimeTypes(mimeTypes); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredVideoRoleFlags(@RoleFlags int preferredVideoRoleFlags) { super.setPreferredVideoRoleFlags(preferredVideoRoleFlags); @@ -992,30 +1067,35 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Audio + @CanIgnoreReturnValue @Override public Builder setPreferredAudioLanguage(@Nullable String preferredAudioLanguage) { super.setPreferredAudioLanguage(preferredAudioLanguage); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredAudioLanguages(String... preferredAudioLanguages) { super.setPreferredAudioLanguages(preferredAudioLanguages); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredAudioRoleFlags(@C.RoleFlags int preferredAudioRoleFlags) { super.setPreferredAudioRoleFlags(preferredAudioRoleFlags); return this; } + @CanIgnoreReturnValue @Override public Builder setMaxAudioChannelCount(int maxAudioChannelCount) { super.setMaxAudioChannelCount(maxAudioChannelCount); return this; } + @CanIgnoreReturnValue @Override public Builder setMaxAudioBitrate(int maxAudioBitrate) { super.setMaxAudioBitrate(maxAudioBitrate); @@ -1030,6 +1110,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public Builder setExceedAudioConstraintsIfNecessary( boolean exceedAudioConstraintsIfNecessary) { this.exceedAudioConstraintsIfNecessary = exceedAudioConstraintsIfNecessary; @@ -1045,6 +1126,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed MIME types. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowAudioMixedMimeTypeAdaptiveness( boolean allowAudioMixedMimeTypeAdaptiveness) { this.allowAudioMixedMimeTypeAdaptiveness = allowAudioMixedMimeTypeAdaptiveness; @@ -1060,6 +1142,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed sample rates. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowAudioMixedSampleRateAdaptiveness( boolean allowAudioMixedSampleRateAdaptiveness) { this.allowAudioMixedSampleRateAdaptiveness = allowAudioMixedSampleRateAdaptiveness; @@ -1075,6 +1158,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * containing mixed channel counts. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowAudioMixedChannelCountAdaptiveness( boolean allowAudioMixedChannelCountAdaptiveness) { this.allowAudioMixedChannelCountAdaptiveness = allowAudioMixedChannelCountAdaptiveness; @@ -1090,18 +1174,21 @@ public class DefaultTrackSelector extends MappingTrackSelector { * with mixed levels of decoder and hardware acceleration support. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowAudioMixedDecoderSupportAdaptiveness( boolean allowAudioMixedDecoderSupportAdaptiveness) { this.allowAudioMixedDecoderSupportAdaptiveness = allowAudioMixedDecoderSupportAdaptiveness; return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredAudioMimeType(@Nullable String mimeType) { super.setPreferredAudioMimeType(mimeType); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredAudioMimeTypes(String... mimeTypes) { super.setPreferredAudioMimeTypes(mimeTypes); @@ -1133,6 +1220,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * DefaultTrackSelector#DefaultTrackSelector(TrackSelectionParameters, * ExoTrackSelection.Factory)} constructor. */ + @CanIgnoreReturnValue public Builder setConstrainAudioChannelCountToDeviceCapabilities(boolean enabled) { constrainAudioChannelCountToDeviceCapabilities = enabled; return this; @@ -1140,6 +1228,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { // Text + @CanIgnoreReturnValue @Override public Builder setPreferredTextLanguageAndRoleFlagsToCaptioningManagerSettings( Context context) { @@ -1147,30 +1236,35 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredTextLanguage(@Nullable String preferredTextLanguage) { super.setPreferredTextLanguage(preferredTextLanguage); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredTextLanguages(String... preferredTextLanguages) { super.setPreferredTextLanguages(preferredTextLanguages); return this; } + @CanIgnoreReturnValue @Override public Builder setPreferredTextRoleFlags(@C.RoleFlags int preferredTextRoleFlags) { super.setPreferredTextRoleFlags(preferredTextRoleFlags); return this; } + @CanIgnoreReturnValue @Override public Builder setIgnoredTextSelectionFlags(@C.SelectionFlags int ignoredTextSelectionFlags) { super.setIgnoredTextSelectionFlags(ignoredTextSelectionFlags); return this; } + @CanIgnoreReturnValue @Override public Builder setSelectUndeterminedTextLanguage(boolean selectUndeterminedTextLanguage) { super.setSelectUndeterminedTextLanguage(selectUndeterminedTextLanguage); @@ -1180,6 +1274,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { /** * @deprecated Use {@link #setIgnoredTextSelectionFlags}. */ + @CanIgnoreReturnValue @Deprecated public Builder setDisabledTextTrackSelectionFlags( @C.SelectionFlags int disabledTextTrackSelectionFlags) { @@ -1188,42 +1283,49 @@ public class DefaultTrackSelector extends MappingTrackSelector { // General + @CanIgnoreReturnValue @Override public Builder setForceLowestBitrate(boolean forceLowestBitrate) { super.setForceLowestBitrate(forceLowestBitrate); return this; } + @CanIgnoreReturnValue @Override public Builder setForceHighestSupportedBitrate(boolean forceHighestSupportedBitrate) { super.setForceHighestSupportedBitrate(forceHighestSupportedBitrate); return this; } + @CanIgnoreReturnValue @Override public Builder addOverride(TrackSelectionOverride override) { super.addOverride(override); return this; } + @CanIgnoreReturnValue @Override public Builder clearOverride(TrackGroup trackGroup) { super.clearOverride(trackGroup); return this; } + @CanIgnoreReturnValue @Override public Builder setOverrideForType(TrackSelectionOverride override) { super.setOverrideForType(override); return this; } + @CanIgnoreReturnValue @Override public Builder clearOverridesOfType(@C.TrackType int trackType) { super.clearOverridesOfType(trackType); return this; } + @CanIgnoreReturnValue @Override public Builder clearOverrides() { super.clearOverrides(); @@ -1233,6 +1335,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { /** * @deprecated Use {@link #setTrackTypeDisabled(int, boolean)}. */ + @CanIgnoreReturnValue @Override @Deprecated @SuppressWarnings("deprecation") @@ -1241,6 +1344,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { return this; } + @CanIgnoreReturnValue @Override public Builder setTrackTypeDisabled(@C.TrackType int trackType, boolean disabled) { super.setTrackTypeDisabled(trackType, disabled); @@ -1259,6 +1363,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * no selection can be made otherwise. * @return This builder. */ + @CanIgnoreReturnValue public Builder setExceedRendererCapabilitiesIfNecessary( boolean exceedRendererCapabilitiesIfNecessary) { this.exceedRendererCapabilitiesIfNecessary = exceedRendererCapabilitiesIfNecessary; @@ -1279,6 +1384,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param tunnelingEnabled Whether to enable tunneling if possible. * @return This builder. */ + @CanIgnoreReturnValue public Builder setTunnelingEnabled(boolean tunnelingEnabled) { this.tunnelingEnabled = tunnelingEnabled; return this; @@ -1290,6 +1396,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param allowMultipleAdaptiveSelections Whether multiple adaptive selections are allowed. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAllowMultipleAdaptiveSelections(boolean allowMultipleAdaptiveSelections) { this.allowMultipleAdaptiveSelections = allowMultipleAdaptiveSelections; return this; @@ -1305,6 +1412,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @param disabled Whether the renderer is disabled. * @return This builder. */ + @CanIgnoreReturnValue public Builder setRendererDisabled(int rendererIndex, boolean disabled) { if (rendererDisabledFlags.get(rendererIndex) == disabled) { // The disabled flag is unchanged. @@ -1344,6 +1452,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @deprecated Use {@link * TrackSelectionParameters.Builder#addOverride(TrackSelectionOverride)}. */ + @CanIgnoreReturnValue @Deprecated public Builder setSelectionOverride( int rendererIndex, TrackGroupArray groups, @Nullable SelectionOverride override) { @@ -1369,6 +1478,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverride(TrackGroup)}. */ + @CanIgnoreReturnValue @Deprecated public Builder clearSelectionOverride(int rendererIndex, TrackGroupArray groups) { Map overrides = @@ -1391,6 +1501,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverridesOfType(int)}. */ + @CanIgnoreReturnValue @Deprecated public Builder clearSelectionOverrides(int rendererIndex) { Map overrides = @@ -1409,6 +1520,7 @@ public class DefaultTrackSelector extends MappingTrackSelector { * @return This builder. * @deprecated Use {@link TrackSelectionParameters.Builder#clearOverrides()}. */ + @CanIgnoreReturnValue @Deprecated public Builder clearSelectionOverrides() { if (selectionOverrides.size() == 0) { diff --git a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.java b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.java index 0c9352f003..04f73c76ee 100644 --- a/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.java +++ b/libraries/exoplayer/src/main/java/androidx/media3/exoplayer/upstream/DefaultBandwidthMeter.java @@ -31,6 +31,7 @@ import androidx.media3.exoplayer.upstream.BandwidthMeter.EventListener.EventDisp import com.google.common.base.Ascii; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.HashMap; import java.util.Map; @@ -141,6 +142,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * @param slidingWindowMaxWeight The maximum weight for the sliding window. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSlidingWindowMaxWeight(int slidingWindowMaxWeight) { this.slidingWindowMaxWeight = slidingWindowMaxWeight; return this; @@ -153,6 +155,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * @param initialBitrateEstimate The initial bitrate estimate in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setInitialBitrateEstimate(long initialBitrateEstimate) { for (Integer networkType : initialBitrateEstimates.keySet()) { setInitialBitrateEstimate(networkType, initialBitrateEstimate); @@ -168,6 +171,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * @param initialBitrateEstimate The initial bitrate estimate in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setInitialBitrateEstimate( @C.NetworkType int networkType, long initialBitrateEstimate) { initialBitrateEstimates.put(networkType, initialBitrateEstimate); @@ -182,6 +186,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * estimates should be used. * @return This builder. */ + @CanIgnoreReturnValue public Builder setInitialBitrateEstimate(String countryCode) { initialBitrateEstimates = getInitialBitrateEstimatesForCountry(Ascii.toUpperCase(countryCode)); @@ -195,6 +200,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * @param clock The clock used to estimate bandwidth from data transfers. * @return This builder. */ + @CanIgnoreReturnValue public Builder setClock(Clock clock) { this.clock = clock; return this; @@ -206,6 +212,7 @@ public final class DefaultBandwidthMeter implements BandwidthMeter, TransferList * @param resetOnNetworkTypeChange Whether to reset if the network type changes. * @return This builder. */ + @CanIgnoreReturnValue public Builder setResetOnNetworkTypeChange(boolean resetOnNetworkTypeChange) { this.resetOnNetworkTypeChange = resetOnNetworkTypeChange; return this; diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java index 1e0b0338ba..328dc7caf2 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java @@ -165,6 +165,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; import com.google.common.collect.Range; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -12193,6 +12194,7 @@ public final class ExoPlayerTest { } /** Call {@link Renderer.WakeupListener#onSleep()} on the next {@link #render(long, long)} */ + @CanIgnoreReturnValue public FakeSleepRenderer sleepOnNextRender() { sleepOnNextRender.set(true); return this; diff --git a/libraries/exoplayer_dash/build.gradle b/libraries/exoplayer_dash/build.gradle index 69bfa22a63..61965c2851 100644 --- a/libraries/exoplayer_dash/build.gradle +++ b/libraries/exoplayer_dash/build.gradle @@ -25,6 +25,7 @@ android { dependencies { implementation project(modulePrefix + 'lib-exoplayer') + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion diff --git a/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java b/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java index 7abde693ba..c7706612b4 100644 --- a/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java +++ b/libraries/exoplayer_dash/src/main/java/androidx/media3/exoplayer/dash/DashMediaSource.java @@ -77,6 +77,7 @@ import androidx.media3.exoplayer.upstream.ParsingLoadable; import androidx.media3.exoplayer.util.SntpClient; import com.google.common.base.Charsets; import com.google.common.math.LongMath; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -158,6 +159,7 @@ public final class DashMediaSource extends BaseMediaSource { compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory(); } + @CanIgnoreReturnValue @Override public Factory setDrmSessionManagerProvider( DrmSessionManagerProvider drmSessionManagerProvider) { @@ -170,6 +172,7 @@ public final class DashMediaSource extends BaseMediaSource { return this; } + @CanIgnoreReturnValue @Override public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = @@ -190,6 +193,7 @@ public final class DashMediaSource extends BaseMediaSource { * @param fallbackTargetLiveOffsetMs The fallback live target offset in milliseconds. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setFallbackTargetLiveOffsetMs(long fallbackTargetLiveOffsetMs) { this.fallbackTargetLiveOffsetMs = fallbackTargetLiveOffsetMs; return this; @@ -201,6 +205,7 @@ public final class DashMediaSource extends BaseMediaSource { * @param manifestParser A parser for loaded manifest data. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setManifestParser( @Nullable ParsingLoadable.Parser manifestParser) { this.manifestParser = manifestParser; @@ -217,6 +222,7 @@ public final class DashMediaSource extends BaseMediaSource { * audio etc...). * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setCompositeSequenceableLoaderFactory( CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { this.compositeSequenceableLoaderFactory = diff --git a/libraries/exoplayer_hls/build.gradle b/libraries/exoplayer_hls/build.gradle index a9dcd052ab..fde8db9e4a 100644 --- a/libraries/exoplayer_hls/build.gradle +++ b/libraries/exoplayer_hls/build.gradle @@ -25,6 +25,7 @@ android { dependencies { implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion diff --git a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaSource.java b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaSource.java index 0cc5663a03..26c34e64a5 100644 --- a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaSource.java +++ b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaSource.java @@ -56,6 +56,7 @@ import androidx.media3.exoplayer.upstream.Allocator; import androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy; import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; import androidx.media3.extractor.Extractor; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -171,12 +172,14 @@ public final class HlsMediaSource extends BaseMediaSource * segments. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setExtractorFactory(@Nullable HlsExtractorFactory extractorFactory) { this.extractorFactory = extractorFactory != null ? extractorFactory : HlsExtractorFactory.DEFAULT; return this; } + @CanIgnoreReturnValue @Override public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = @@ -194,6 +197,7 @@ public final class HlsMediaSource extends BaseMediaSource * @param playlistParserFactory An {@link HlsPlaylistParserFactory}. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setPlaylistParserFactory(HlsPlaylistParserFactory playlistParserFactory) { this.playlistParserFactory = checkNotNull( @@ -210,6 +214,7 @@ public final class HlsMediaSource extends BaseMediaSource * @param playlistTrackerFactory A factory for {@link HlsPlaylistTracker} instances. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setPlaylistTrackerFactory(HlsPlaylistTracker.Factory playlistTrackerFactory) { this.playlistTrackerFactory = checkNotNull( @@ -229,6 +234,7 @@ public final class HlsMediaSource extends BaseMediaSource * audio etc...). * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setCompositeSequenceableLoaderFactory( CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { this.compositeSequenceableLoaderFactory = @@ -248,6 +254,7 @@ public final class HlsMediaSource extends BaseMediaSource * @param allowChunklessPreparation Whether chunkless preparation is allowed. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setAllowChunklessPreparation(boolean allowChunklessPreparation) { this.allowChunklessPreparation = allowChunklessPreparation; return this; @@ -272,6 +279,7 @@ public final class HlsMediaSource extends BaseMediaSource * @param metadataType The type of metadata to extract. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setMetadataType(@MetadataType int metadataType) { this.metadataType = metadataType; return this; @@ -286,11 +294,13 @@ public final class HlsMediaSource extends BaseMediaSource * @param useSessionKeys Whether to use #EXT-X-SESSION-KEY tags. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setUseSessionKeys(boolean useSessionKeys) { this.useSessionKeys = useSessionKeys; return this; } + @CanIgnoreReturnValue @Override public Factory setDrmSessionManagerProvider( DrmSessionManagerProvider drmSessionManagerProvider) { @@ -311,6 +321,7 @@ public final class HlsMediaSource extends BaseMediaSource * the time since the Unix epoch, in milliseconds. * @return This factory, for convenience. */ + @CanIgnoreReturnValue @VisibleForTesting /* package */ Factory setElapsedRealTimeOffsetMs(long elapsedRealTimeOffsetMs) { this.elapsedRealTimeOffsetMs = elapsedRealTimeOffsetMs; diff --git a/libraries/exoplayer_ima/build.gradle b/libraries/exoplayer_ima/build.gradle index 70397d8c5c..314e01ce9b 100644 --- a/libraries/exoplayer_ima/build.gradle +++ b/libraries/exoplayer_ima/build.gradle @@ -28,6 +28,7 @@ dependencies { api 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0' implementation project(modulePrefix + 'lib-exoplayer') implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion androidTestImplementation project(modulePrefix + 'test-utils') diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaAdsLoader.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaAdsLoader.java index b4637f248d..f90654a290 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaAdsLoader.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaAdsLoader.java @@ -56,6 +56,7 @@ import com.google.ads.interactivemedia.v3.api.UiElement; import com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -152,6 +153,7 @@ public final class ImaAdsLoader implements AdsLoader { * @param imaSdkSettings The {@link ImaSdkSettings}. * @return This builder, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Builder setImaSdkSettings(ImaSdkSettings imaSdkSettings) { this.imaSdkSettings = checkNotNull(imaSdkSettings); @@ -166,6 +168,7 @@ public final class ImaAdsLoader implements AdsLoader { * @param adErrorListener The ad error listener. * @return This builder, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Builder setAdErrorListener(AdErrorListener adErrorListener) { this.adErrorListener = checkNotNull(adErrorListener); @@ -179,6 +182,7 @@ public final class ImaAdsLoader implements AdsLoader { * @param adEventListener The ad event listener. * @return This builder, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Builder setAdEventListener(AdEventListener adEventListener) { this.adEventListener = checkNotNull(adEventListener); @@ -195,6 +199,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback */ + @CanIgnoreReturnValue @UnstableApi public Builder setVideoAdPlayerCallback( VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback) { @@ -209,6 +214,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRenderingSettings#setUiElements(Set) */ + @CanIgnoreReturnValue @UnstableApi public Builder setAdUiElements(Set adUiElements) { this.adUiElements = ImmutableSet.copyOf(checkNotNull(adUiElements)); @@ -222,6 +228,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdDisplayContainer#setCompanionSlots(Collection) */ + @CanIgnoreReturnValue @UnstableApi public Builder setCompanionAdSlots(Collection companionAdSlots) { this.companionAdSlots = ImmutableList.copyOf(checkNotNull(companionAdSlots)); @@ -240,6 +247,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRenderingSettings#setMimeTypes(List) */ + @CanIgnoreReturnValue @UnstableApi public Builder setAdMediaMimeTypes(List adMediaMimeTypes) { this.adMediaMimeTypes = ImmutableList.copyOf(checkNotNull(adMediaMimeTypes)); @@ -255,6 +263,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRequest#setContinuousPlayback(boolean) */ + @CanIgnoreReturnValue @UnstableApi public Builder setEnableContinuousPlayback(boolean enableContinuousPlayback) { this.enableContinuousPlayback = enableContinuousPlayback; @@ -274,6 +283,7 @@ public final class ImaAdsLoader implements AdsLoader { * C#TIME_UNSET} for no timeout. * @return This builder, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Builder setAdPreloadTimeoutMs(long adPreloadTimeoutMs) { checkArgument(adPreloadTimeoutMs == C.TIME_UNSET || adPreloadTimeoutMs > 0); @@ -288,6 +298,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRequest#setVastLoadTimeout(float) */ + @CanIgnoreReturnValue @UnstableApi public Builder setVastLoadTimeoutMs(@IntRange(from = 1) int vastLoadTimeoutMs) { checkArgument(vastLoadTimeoutMs > 0); @@ -302,6 +313,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRenderingSettings#setLoadVideoTimeout(int) */ + @CanIgnoreReturnValue @UnstableApi public Builder setMediaLoadTimeoutMs(@IntRange(from = 1) int mediaLoadTimeoutMs) { checkArgument(mediaLoadTimeoutMs > 0); @@ -316,6 +328,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRenderingSettings#setBitrateKbps(int) */ + @CanIgnoreReturnValue @UnstableApi public Builder setMaxMediaBitrate(@IntRange(from = 1) int bitrate) { checkArgument(bitrate > 0); @@ -332,6 +345,7 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see AdsRenderingSettings#setFocusSkipButtonWhenAvailable(boolean) */ + @CanIgnoreReturnValue @UnstableApi public Builder setFocusSkipButtonWhenAvailable(boolean focusSkipButtonWhenAvailable) { this.focusSkipButtonWhenAvailable = focusSkipButtonWhenAvailable; @@ -348,6 +362,7 @@ public final class ImaAdsLoader implements AdsLoader { * beginning playback. * @return This builder, for convenience. */ + @CanIgnoreReturnValue @UnstableApi public Builder setPlayAdBeforeStartPosition(boolean playAdBeforeStartPosition) { this.playAdBeforeStartPosition = playAdBeforeStartPosition; @@ -364,12 +379,14 @@ public final class ImaAdsLoader implements AdsLoader { * @return This builder, for convenience. * @see ImaSdkSettings#setDebugMode(boolean) */ + @CanIgnoreReturnValue @UnstableApi public Builder setDebugModeEnabled(boolean debugModeEnabled) { this.debugModeEnabled = debugModeEnabled; return this; } + @CanIgnoreReturnValue @VisibleForTesting /* package */ Builder setImaFactory(ImaUtil.ImaFactory imaFactory) { this.imaFactory = checkNotNull(imaFactory); diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java index e7d261c220..1f410a2e36 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java @@ -93,6 +93,7 @@ import com.google.ads.interactivemedia.v3.api.player.VideoProgressUpdate; import com.google.ads.interactivemedia.v3.api.player.VideoStreamPlayer; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.lang.annotation.Documented; import java.lang.annotation.Retention; @@ -134,6 +135,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou this.contentMediaSourceFactory = contentMediaSourceFactory; } + @CanIgnoreReturnValue @Override public MediaSource.Factory setLoadErrorHandlingPolicy( LoadErrorHandlingPolicy loadErrorHandlingPolicy) { @@ -141,6 +143,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou return this; } + @CanIgnoreReturnValue @Override public MediaSource.Factory setDrmSessionManagerProvider( DrmSessionManagerProvider drmSessionManagerProvider) { @@ -215,6 +218,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou * @param imaSdkSettings The {@link ImaSdkSettings}. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public AdsLoader.Builder setImaSdkSettings(ImaSdkSettings imaSdkSettings) { this.imaSdkSettings = imaSdkSettings; return this; @@ -227,6 +231,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou * @param adEventListener The ad event listener. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public AdsLoader.Builder setAdEventListener(AdEventListener adEventListener) { this.adEventListener = adEventListener; return this; @@ -239,6 +244,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou * @param adErrorListener The {@link AdErrorEvent.AdErrorListener}. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public AdsLoader.Builder setAdErrorListener(AdErrorEvent.AdErrorListener adErrorListener) { this.adErrorListener = adErrorListener; return this; @@ -251,6 +257,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou * @return This builder, for convenience. * @see AdDisplayContainer#setCompanionSlots(Collection) */ + @CanIgnoreReturnValue public AdsLoader.Builder setCompanionAdSlots(Collection companionAdSlots) { this.companionAdSlots = ImmutableList.copyOf(companionAdSlots); return this; @@ -264,6 +271,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou * @param state The state to resume with. * @return This builder, for convenience. */ + @CanIgnoreReturnValue public AdsLoader.Builder setAdsLoaderState(State state) { this.state = state; return this; diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder.java index e6664e7361..6a20ed5b5b 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionUriBuilder.java @@ -29,6 +29,7 @@ import com.google.ads.interactivemedia.v3.api.ImaSdkFactory; import com.google.ads.interactivemedia.v3.api.StreamRequest; import com.google.ads.interactivemedia.v3.api.StreamRequest.StreamFormat; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.HashMap; import java.util.Map; @@ -85,6 +86,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param adsId The ads identifier. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setAdsId(String adsId) { this.adsId = adsId; return this; @@ -96,6 +98,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param assetKey Live stream asset key. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setAssetKey(@Nullable String assetKey) { this.assetKey = assetKey; return this; @@ -109,6 +112,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param authToken Live stream authorization token. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setAuthToken(@Nullable String authToken) { this.authToken = authToken; return this; @@ -120,6 +124,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param contentSourceId VOD stream content source id. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setContentSourceId(@Nullable String contentSourceId) { this.contentSourceId = contentSourceId; return this; @@ -131,6 +136,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param videoId VOD stream video id. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setVideoId(@Nullable String videoId) { this.videoId = videoId; return this; @@ -142,6 +148,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param format {@link C#TYPE_DASH} or {@link C#TYPE_HLS}. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setFormat(@ContentType int format) { checkArgument(format == C.CONTENT_TYPE_DASH || format == C.CONTENT_TYPE_HLS); this.format = format; @@ -156,6 +163,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param apiKey Stream api key. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setApiKey(@Nullable String apiKey) { this.apiKey = apiKey; return this; @@ -169,6 +177,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param streamActivityMonitorId ID for debugging the stream with the stream activity monitor. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setStreamActivityMonitorId( @Nullable String streamActivityMonitorId) { this.streamActivityMonitorId = streamActivityMonitorId; @@ -187,6 +196,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param adTagParameters A map of extra parameters to pass to the ad server. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setAdTagParameters( Map adTagParameters) { this.adTagParameters = ImmutableMap.copyOf(adTagParameters); @@ -200,6 +210,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param manifestSuffix Stream manifest's suffix. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setManifestSuffix(@Nullable String manifestSuffix) { this.manifestSuffix = manifestSuffix; return this; @@ -213,6 +224,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param contentUrl Deep link to the content's screen. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setContentUrl(@Nullable String contentUrl) { this.contentUrl = contentUrl; return this; @@ -226,6 +238,7 @@ public final class ImaServerSideAdInsertionUriBuilder { * @param loadVideoTimeoutMs The timeout after which to give up resolving the video URI. * @return This instance, for convenience. */ + @CanIgnoreReturnValue public ImaServerSideAdInsertionUriBuilder setLoadVideoTimeoutMs(int loadVideoTimeoutMs) { this.loadVideoTimeoutMs = loadVideoTimeoutMs; return this; diff --git a/libraries/exoplayer_rtsp/build.gradle b/libraries/exoplayer_rtsp/build.gradle index 4bb58e0f85..0d53ded1d0 100644 --- a/libraries/exoplayer_rtsp/build.gradle +++ b/libraries/exoplayer_rtsp/build.gradle @@ -25,6 +25,7 @@ android { dependencies { implementation 'androidx.annotation:annotation:' + androidxAnnotationVersion + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java index c3bffe8db6..26d8078721 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/MediaDescription.java @@ -30,6 +30,7 @@ import androidx.media3.common.ParserException; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -149,6 +150,7 @@ import java.util.HashMap; * @param mediaTitle The assigned media title. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMediaTitle(String mediaTitle) { this.mediaTitle = mediaTitle; return this; @@ -160,6 +162,7 @@ import java.util.HashMap; * @param connection The connection parameter. * @return This builder. */ + @CanIgnoreReturnValue public Builder setConnection(String connection) { this.connection = connection; return this; @@ -171,6 +174,7 @@ import java.util.HashMap; * @param bitrate The estimated bitrate measured in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setBitrate(int bitrate) { this.bitrate = bitrate; return this; @@ -182,6 +186,7 @@ import java.util.HashMap; * @param key The encryption parameter. * @return This builder. */ + @CanIgnoreReturnValue public Builder setKey(String key) { this.key = key; return this; @@ -196,6 +201,7 @@ import java.util.HashMap; * @param attributeValue The value of the attribute, or "" if the attribute bears no value. * @return This builder. */ + @CanIgnoreReturnValue public Builder addAttribute(String attributeName, String attributeValue) { attributes.put(attributeName, attributeValue); return this; diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPacket.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPacket.java index a2811a8921..6df3023b37 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPacket.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtpPacket.java @@ -25,6 +25,7 @@ import androidx.media3.common.util.ParsableByteArray; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.math.IntMath; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.nio.ByteBuffer; /** @@ -71,24 +72,28 @@ public final class RtpPacket { private byte[] payloadData = EMPTY; /** Sets the {@link RtpPacket#padding}. The default is false. */ + @CanIgnoreReturnValue public Builder setPadding(boolean padding) { this.padding = padding; return this; } /** Sets {@link RtpPacket#marker}. The default is false. */ + @CanIgnoreReturnValue public Builder setMarker(boolean marker) { this.marker = marker; return this; } /** Sets {@link RtpPacket#payloadType}. The default is 0. */ + @CanIgnoreReturnValue public Builder setPayloadType(byte payloadType) { this.payloadType = payloadType; return this; } /** Sets {@link RtpPacket#sequenceNumber}. The default is 0. */ + @CanIgnoreReturnValue public Builder setSequenceNumber(int sequenceNumber) { checkArgument(sequenceNumber >= MIN_SEQUENCE_NUMBER && sequenceNumber <= MAX_SEQUENCE_NUMBER); this.sequenceNumber = sequenceNumber & 0xFFFF; @@ -96,18 +101,21 @@ public final class RtpPacket { } /** Sets {@link RtpPacket#timestamp}. The default is 0. */ + @CanIgnoreReturnValue public Builder setTimestamp(long timestamp) { this.timestamp = timestamp; return this; } /** Sets {@link RtpPacket#ssrc}. The default is 0. */ + @CanIgnoreReturnValue public Builder setSsrc(int ssrc) { this.ssrc = ssrc; return this; } /** Sets {@link RtpPacket#csrc}. The default is an empty byte array. */ + @CanIgnoreReturnValue public Builder setCsrc(byte[] csrc) { checkNotNull(csrc); this.csrc = csrc; @@ -115,6 +123,7 @@ public final class RtpPacket { } /** Sets {@link RtpPacket#payloadData}. The default is an empty byte array. */ + @CanIgnoreReturnValue public Builder setPayloadData(byte[] payloadData) { checkNotNull(payloadData); this.payloadData = payloadData; diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspHeaders.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspHeaders.java index edcf04fe1f..0a6d7b9d68 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspHeaders.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspHeaders.java @@ -23,6 +23,7 @@ import com.google.common.base.Ascii; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; import com.google.common.collect.Iterables; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; import java.util.Map; @@ -115,6 +116,7 @@ import java.util.Map; * @param headerValue The value of the header. * @return This builder. */ + @CanIgnoreReturnValue public Builder add(String headerName, String headerValue) { namesAndValuesBuilder.put(convertToStandardHeaderName(headerName.trim()), headerValue.trim()); return this; @@ -127,6 +129,7 @@ import java.util.Map; * <headerValue> * @return This builder. */ + @CanIgnoreReturnValue public Builder addAll(List headers) { for (int i = 0; i < headers.size(); i++) { String[] header = Util.splitAtFirst(headers.get(i), ":\\s?"); @@ -144,6 +147,7 @@ import java.util.Map; * header values. * @return This builder. */ + @CanIgnoreReturnValue public Builder addAll(Map headers) { for (Map.Entry header : headers.entrySet()) { add(header.getKey(), header.getValue()); diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaSource.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaSource.java index 3aa2d7f090..f0e5877a12 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaSource.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/RtspMediaSource.java @@ -39,6 +39,7 @@ import androidx.media3.exoplayer.source.MediaSourceFactory; import androidx.media3.exoplayer.source.SinglePeriodTimeline; import androidx.media3.exoplayer.upstream.Allocator; import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import javax.net.SocketFactory; @@ -89,6 +90,7 @@ public final class RtspMediaSource extends BaseMediaSource { * @param forceUseRtpTcp Whether force to use TCP for streaming. * @return This Factory, for convenience. */ + @CanIgnoreReturnValue public Factory setForceUseRtpTcp(boolean forceUseRtpTcp) { this.forceUseRtpTcp = forceUseRtpTcp; return this; @@ -100,6 +102,7 @@ public final class RtspMediaSource extends BaseMediaSource { * @param userAgent The user agent. * @return This Factory, for convenience. */ + @CanIgnoreReturnValue public Factory setUserAgent(String userAgent) { this.userAgent = userAgent; return this; @@ -112,6 +115,7 @@ public final class RtspMediaSource extends BaseMediaSource { * @param socketFactory A socket factory. * @return This Factory, for convenience. */ + @CanIgnoreReturnValue public Factory setSocketFactory(SocketFactory socketFactory) { this.socketFactory = socketFactory; return this; @@ -126,6 +130,7 @@ public final class RtspMediaSource extends BaseMediaSource { * @param debugLoggingEnabled Whether to log RTSP messages. * @return This Factory, for convenience. */ + @CanIgnoreReturnValue public Factory setDebugLoggingEnabled(boolean debugLoggingEnabled) { this.debugLoggingEnabled = debugLoggingEnabled; return this; @@ -140,6 +145,7 @@ public final class RtspMediaSource extends BaseMediaSource { * @param timeoutMs The timeout measured in milliseconds. * @return This Factory, for convenience. */ + @CanIgnoreReturnValue public Factory setTimeoutMs(@IntRange(from = 1) long timeoutMs) { checkArgument(timeoutMs > 0); this.timeoutMs = timeoutMs; diff --git a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/SessionDescription.java b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/SessionDescription.java index 5ed534fa90..f7fc7ae5fa 100644 --- a/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/SessionDescription.java +++ b/libraries/exoplayer_rtsp/src/main/java/androidx/media3/exoplayer/rtsp/SessionDescription.java @@ -25,6 +25,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.HashMap; /** @@ -66,6 +67,7 @@ import java.util.HashMap; * @param sessionName The {@link SessionDescription#sessionName}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSessionName(String sessionName) { this.sessionName = sessionName; return this; @@ -77,6 +79,7 @@ import java.util.HashMap; * @param sessionInfo The {@link SessionDescription#sessionInfo}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSessionInfo(String sessionInfo) { this.sessionInfo = sessionInfo; return this; @@ -88,6 +91,7 @@ import java.util.HashMap; * @param uri The {@link SessionDescription#uri}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setUri(Uri uri) { this.uri = uri; return this; @@ -101,6 +105,7 @@ import java.util.HashMap; * @param origin The {@link SessionDescription#origin}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setOrigin(String origin) { this.origin = origin; return this; @@ -112,6 +117,7 @@ import java.util.HashMap; * @param connection The {@link SessionDescription#connection}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setConnection(String connection) { this.connection = connection; return this; @@ -123,6 +129,7 @@ import java.util.HashMap; * @param bitrate The {@link SessionDescription#bitrate} in bits per second. * @return This builder. */ + @CanIgnoreReturnValue public Builder setBitrate(int bitrate) { this.bitrate = bitrate; return this; @@ -136,6 +143,7 @@ import java.util.HashMap; * @param timing The {@link SessionDescription#timing}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setTiming(String timing) { this.timing = timing; return this; @@ -147,6 +155,7 @@ import java.util.HashMap; * @param key The {@link SessionDescription#key}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setKey(String key) { this.key = key; return this; @@ -158,6 +167,7 @@ import java.util.HashMap; * @param emailAddress The {@link SessionDescription#emailAddress}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setEmailAddress(String emailAddress) { this.emailAddress = emailAddress; return this; @@ -169,6 +179,7 @@ import java.util.HashMap; * @param phoneNumber The {@link SessionDescription#phoneNumber}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; return this; @@ -181,6 +192,7 @@ import java.util.HashMap; * @param attributeValue The value of the attribute. * @return This builder. */ + @CanIgnoreReturnValue public Builder addAttribute(String attributeName, String attributeValue) { attributes.put(attributeName, attributeValue); return this; @@ -192,6 +204,7 @@ import java.util.HashMap; * @param mediaDescription The {@link MediaDescription}. * @return This builder. */ + @CanIgnoreReturnValue public Builder addMediaDescription(MediaDescription mediaDescription) { mediaDescriptionListBuilder.add(mediaDescription); return this; diff --git a/libraries/exoplayer_smoothstreaming/build.gradle b/libraries/exoplayer_smoothstreaming/build.gradle index 4b145ec6b3..8ac10f2835 100644 --- a/libraries/exoplayer_smoothstreaming/build.gradle +++ b/libraries/exoplayer_smoothstreaming/build.gradle @@ -25,6 +25,7 @@ android { dependencies { implementation project(modulePrefix + 'lib-exoplayer') + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion diff --git a/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/SsMediaSource.java b/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/SsMediaSource.java index b8231da9b1..1186cfc350 100644 --- a/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/SsMediaSource.java +++ b/libraries/exoplayer_smoothstreaming/src/main/java/androidx/media3/exoplayer/smoothstreaming/SsMediaSource.java @@ -64,6 +64,7 @@ import androidx.media3.exoplayer.upstream.Loader.LoadErrorAction; import androidx.media3.exoplayer.upstream.LoaderErrorThrower; import androidx.media3.exoplayer.upstream.ParsingLoadable; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; import java.util.List; @@ -136,6 +137,7 @@ public final class SsMediaSource extends BaseMediaSource compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory(); } + @CanIgnoreReturnValue @Override public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) { this.loadErrorHandlingPolicy = @@ -156,6 +158,7 @@ public final class SsMediaSource extends BaseMediaSource * default start position should precede the end of the live window. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setLivePresentationDelayMs(long livePresentationDelayMs) { this.livePresentationDelayMs = livePresentationDelayMs; return this; @@ -167,6 +170,7 @@ public final class SsMediaSource extends BaseMediaSource * @param manifestParser A parser for loaded manifest data. * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setManifestParser( @Nullable ParsingLoadable.Parser manifestParser) { this.manifestParser = manifestParser; @@ -182,6 +186,7 @@ public final class SsMediaSource extends BaseMediaSource * audio etc.). * @return This factory, for convenience. */ + @CanIgnoreReturnValue public Factory setCompositeSequenceableLoaderFactory( CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) { this.compositeSequenceableLoaderFactory = @@ -193,6 +198,7 @@ public final class SsMediaSource extends BaseMediaSource return this; } + @CanIgnoreReturnValue @Override public Factory setDrmSessionManagerProvider( DrmSessionManagerProvider drmSessionManagerProvider) { diff --git a/libraries/extractor/build.gradle b/libraries/extractor/build.gradle index 0864cd6c2f..6cd3a81b28 100644 --- a/libraries/extractor/build.gradle +++ b/libraries/extractor/build.gradle @@ -28,6 +28,7 @@ dependencies { implementation project(modulePrefix + 'lib-common') // TODO(b/203752187): Remove this dependency. implementation project(modulePrefix + 'lib-decoder') + compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/DefaultExtractorsFactory.java b/libraries/extractor/src/main/java/androidx/media3/extractor/DefaultExtractorsFactory.java index eff4e7c0fe..0b4e9da76d 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/DefaultExtractorsFactory.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/DefaultExtractorsFactory.java @@ -44,6 +44,7 @@ import androidx.media3.extractor.ts.PsExtractor; import androidx.media3.extractor.ts.TsExtractor; import androidx.media3.extractor.ts.TsPayloadReader; import androidx.media3.extractor.wav.WavExtractor; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -145,6 +146,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * assumption should be enabled for all extractors that support it. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setConstantBitrateSeekingEnabled( boolean constantBitrateSeekingEnabled) { this.constantBitrateSeekingEnabled = constantBitrateSeekingEnabled; @@ -169,6 +171,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * duration is unknown. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setConstantBitrateSeekingAlwaysEnabled( boolean constantBitrateSeekingAlwaysEnabled) { this.constantBitrateSeekingAlwaysEnabled = constantBitrateSeekingAlwaysEnabled; @@ -182,6 +185,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setAdtsExtractorFlags( @AdtsExtractor.Flags int flags) { this.adtsFlags = flags; @@ -195,6 +199,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setAmrExtractorFlags(@AmrExtractor.Flags int flags) { this.amrFlags = flags; return this; @@ -209,6 +214,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setFlacExtractorFlags( @FlacExtractor.Flags int flags) { this.flacFlags = flags; @@ -222,6 +228,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setMatroskaExtractorFlags( @MatroskaExtractor.Flags int flags) { this.matroskaFlags = flags; @@ -235,6 +242,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setMp4ExtractorFlags(@Mp4Extractor.Flags int flags) { this.mp4Flags = flags; return this; @@ -247,6 +255,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setFragmentedMp4ExtractorFlags( @FragmentedMp4Extractor.Flags int flags) { this.fragmentedMp4Flags = flags; @@ -260,6 +269,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setMp3ExtractorFlags(@Mp3Extractor.Flags int flags) { mp3Flags = flags; return this; @@ -272,6 +282,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param mode The mode to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setTsExtractorMode(@TsExtractor.Mode int mode) { tsMode = mode; return this; @@ -285,6 +296,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param flags The flags to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setTsExtractorFlags( @DefaultTsPayloadReaderFactory.Flags int flags) { tsFlags = flags; @@ -299,6 +311,7 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory { * @param timestampSearchBytes The number of search bytes to use. * @return The factory, for convenience. */ + @CanIgnoreReturnValue public synchronized DefaultExtractorsFactory setTsExtractorTimestampSearchBytes( int timestampSearchBytes) { tsTimestampSearchBytes = timestampSearchBytes; diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/text/ttml/TtmlStyle.java b/libraries/extractor/src/main/java/androidx/media3/extractor/text/ttml/TtmlStyle.java index b706154a0f..1cb59ae211 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/text/ttml/TtmlStyle.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/text/ttml/TtmlStyle.java @@ -22,6 +22,7 @@ import android.text.Layout; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import androidx.media3.common.text.TextAnnotation; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -125,6 +126,7 @@ import java.lang.annotation.Target; return linethrough == ON; } + @CanIgnoreReturnValue public TtmlStyle setLinethrough(boolean linethrough) { this.linethrough = linethrough ? ON : OFF; return this; @@ -134,16 +136,19 @@ import java.lang.annotation.Target; return underline == ON; } + @CanIgnoreReturnValue public TtmlStyle setUnderline(boolean underline) { this.underline = underline ? ON : OFF; return this; } + @CanIgnoreReturnValue public TtmlStyle setBold(boolean bold) { this.bold = bold ? ON : OFF; return this; } + @CanIgnoreReturnValue public TtmlStyle setItalic(boolean italic) { this.italic = italic ? ON : OFF; return this; @@ -154,6 +159,7 @@ import java.lang.annotation.Target; return fontFamily; } + @CanIgnoreReturnValue public TtmlStyle setFontFamily(@Nullable String fontFamily) { this.fontFamily = fontFamily; return this; @@ -166,6 +172,7 @@ import java.lang.annotation.Target; return fontColor; } + @CanIgnoreReturnValue public TtmlStyle setFontColor(int fontColor) { this.fontColor = fontColor; hasFontColor = true; @@ -183,6 +190,7 @@ import java.lang.annotation.Target; return backgroundColor; } + @CanIgnoreReturnValue public TtmlStyle setBackgroundColor(int backgroundColor) { this.backgroundColor = backgroundColor; hasBackgroundColor = true; @@ -193,6 +201,7 @@ import java.lang.annotation.Target; return hasBackgroundColor; } + @CanIgnoreReturnValue public TtmlStyle setShearPercentage(float shearPercentage) { this.shearPercentage = shearPercentage; return this; @@ -208,6 +217,7 @@ import java.lang.annotation.Target; * * @param ancestor the referential style to inherit from */ + @CanIgnoreReturnValue public TtmlStyle chain(@Nullable TtmlStyle ancestor) { return inherit(ancestor, true); } @@ -219,10 +229,12 @@ import java.lang.annotation.Target; * * @param ancestor the ancestor style to inherit from */ + @CanIgnoreReturnValue public TtmlStyle inherit(@Nullable TtmlStyle ancestor) { return inherit(ancestor, false); } + @CanIgnoreReturnValue private TtmlStyle inherit(@Nullable TtmlStyle ancestor, boolean chaining) { if (ancestor != null) { if (!hasFontColor && ancestor.hasFontColor) { @@ -276,6 +288,7 @@ import java.lang.annotation.Target; return this; } + @CanIgnoreReturnValue public TtmlStyle setId(@Nullable String id) { this.id = id; return this; @@ -286,6 +299,7 @@ import java.lang.annotation.Target; return id; } + @CanIgnoreReturnValue public TtmlStyle setRubyType(@RubyType int rubyType) { this.rubyType = rubyType; return this; @@ -295,6 +309,7 @@ import java.lang.annotation.Target; return rubyType; } + @CanIgnoreReturnValue public TtmlStyle setRubyPosition(@TextAnnotation.Position int position) { this.rubyPosition = position; return this; @@ -309,6 +324,7 @@ import java.lang.annotation.Target; return textAlign; } + @CanIgnoreReturnValue public TtmlStyle setTextAlign(@Nullable Layout.Alignment textAlign) { this.textAlign = textAlign; return this; @@ -319,6 +335,7 @@ import java.lang.annotation.Target; return multiRowAlign; } + @CanIgnoreReturnValue public TtmlStyle setMultiRowAlign(@Nullable Layout.Alignment multiRowAlign) { this.multiRowAlign = multiRowAlign; return this; @@ -329,6 +346,7 @@ import java.lang.annotation.Target; return textCombine == ON; } + @CanIgnoreReturnValue public TtmlStyle setTextCombine(boolean combine) { this.textCombine = combine ? ON : OFF; return this; @@ -339,16 +357,19 @@ import java.lang.annotation.Target; return textEmphasis; } + @CanIgnoreReturnValue public TtmlStyle setTextEmphasis(@Nullable TextEmphasis textEmphasis) { this.textEmphasis = textEmphasis; return this; } + @CanIgnoreReturnValue public TtmlStyle setFontSize(float fontSize) { this.fontSize = fontSize; return this; } + @CanIgnoreReturnValue public TtmlStyle setFontSizeUnit(int fontSizeUnit) { this.fontSizeUnit = fontSizeUnit; return this; diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCssStyle.java b/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCssStyle.java index 77713c1672..623f8fd057 100644 --- a/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCssStyle.java +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/text/webvtt/WebvttCssStyle.java @@ -25,6 +25,7 @@ import androidx.annotation.Nullable; import androidx.media3.common.text.TextAnnotation; import androidx.media3.common.util.UnstableApi; import com.google.common.base.Ascii; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -197,6 +198,7 @@ public final class WebvttCssStyle { return linethrough == ON; } + @CanIgnoreReturnValue public WebvttCssStyle setLinethrough(boolean linethrough) { this.linethrough = linethrough ? ON : OFF; return this; @@ -206,16 +208,19 @@ public final class WebvttCssStyle { return underline == ON; } + @CanIgnoreReturnValue public WebvttCssStyle setUnderline(boolean underline) { this.underline = underline ? ON : OFF; return this; } + @CanIgnoreReturnValue public WebvttCssStyle setBold(boolean bold) { this.bold = bold ? ON : OFF; return this; } + @CanIgnoreReturnValue public WebvttCssStyle setItalic(boolean italic) { this.italic = italic ? ON : OFF; return this; @@ -226,6 +231,7 @@ public final class WebvttCssStyle { return fontFamily; } + @CanIgnoreReturnValue public WebvttCssStyle setFontFamily(@Nullable String fontFamily) { this.fontFamily = fontFamily == null ? null : Ascii.toLowerCase(fontFamily); return this; @@ -238,6 +244,7 @@ public final class WebvttCssStyle { return fontColor; } + @CanIgnoreReturnValue public WebvttCssStyle setFontColor(int color) { this.fontColor = color; hasFontColor = true; @@ -255,6 +262,7 @@ public final class WebvttCssStyle { return backgroundColor; } + @CanIgnoreReturnValue public WebvttCssStyle setBackgroundColor(int backgroundColor) { this.backgroundColor = backgroundColor; hasBackgroundColor = true; @@ -265,11 +273,13 @@ public final class WebvttCssStyle { return hasBackgroundColor; } + @CanIgnoreReturnValue public WebvttCssStyle setFontSize(float fontSize) { this.fontSize = fontSize; return this; } + @CanIgnoreReturnValue public WebvttCssStyle setFontSizeUnit(@FontSizeUnit int unit) { this.fontSizeUnit = unit; return this; @@ -283,6 +293,7 @@ public final class WebvttCssStyle { return fontSize; } + @CanIgnoreReturnValue public WebvttCssStyle setRubyPosition(@TextAnnotation.Position int rubyPosition) { this.rubyPosition = rubyPosition; return this; @@ -292,6 +303,7 @@ public final class WebvttCssStyle { return rubyPosition; } + @CanIgnoreReturnValue public WebvttCssStyle setCombineUpright(boolean enabled) { this.combineUpright = enabled; return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/CommandButton.java b/libraries/session/src/main/java/androidx/media3/session/CommandButton.java index 8ac74eba5b..b8632b7617 100644 --- a/libraries/session/src/main/java/androidx/media3/session/CommandButton.java +++ b/libraries/session/src/main/java/androidx/media3/session/CommandButton.java @@ -26,6 +26,7 @@ import androidx.annotation.Nullable; import androidx.media3.common.Bundleable; import androidx.media3.common.Player; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -65,6 +66,7 @@ public final class CommandButton implements Bundleable { * @param sessionCommand The session command. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setSessionCommand(SessionCommand sessionCommand) { checkNotNull(sessionCommand, "sessionCommand should not be null."); checkArgument( @@ -83,6 +85,7 @@ public final class CommandButton implements Bundleable { * @param playerCommand The player command. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setPlayerCommand(@Player.Command int playerCommand) { checkArgument( sessionCommand == null, @@ -102,6 +105,7 @@ public final class CommandButton implements Bundleable { * @param resId The resource id of an icon. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setIconResId(@DrawableRes int resId) { iconResId = resId; return this; @@ -113,6 +117,7 @@ public final class CommandButton implements Bundleable { * @param displayName The display name. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setDisplayName(CharSequence displayName) { this.displayName = displayName; return this; @@ -124,6 +129,7 @@ public final class CommandButton implements Bundleable { * @param enabled Whether the button is enabled. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setEnabled(boolean enabled) { this.enabled = enabled; return this; @@ -135,6 +141,7 @@ public final class CommandButton implements Bundleable { * @param extras The extra {@link Bundle}. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder setExtras(Bundle extras) { this.extras = new Bundle(extras); return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaBrowser.java b/libraries/session/src/main/java/androidx/media3/session/MediaBrowser.java index fa8724db05..2ee3be9c96 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaBrowser.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaBrowser.java @@ -37,6 +37,7 @@ import androidx.media3.session.MediaLibraryService.LibraryParams; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.concurrent.Executor; import org.checkerframework.checker.initialization.qual.NotOnlyInitialized; import org.checkerframework.checker.initialization.qual.UnderInitialization; @@ -87,6 +88,7 @@ public final class MediaBrowser extends MediaController { * @param connectionHints A bundle containing the connection hints. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setConnectionHints(Bundle connectionHints) { this.connectionHints = new Bundle(checkNotNull(connectionHints)); return this; @@ -98,6 +100,7 @@ public final class MediaBrowser extends MediaController { * @param listener The listener. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setListener(Listener listener) { this.listener = checkNotNull(listener); return this; @@ -112,6 +115,7 @@ public final class MediaBrowser extends MediaController { * @param looper The looper. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setApplicationLooper(Looper looper) { applicationLooper = checkNotNull(looper); return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaController.java b/libraries/session/src/main/java/androidx/media3/session/MediaController.java index 7e51ee2d17..235ca6553f 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaController.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaController.java @@ -59,6 +59,7 @@ import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.List; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; @@ -222,6 +223,7 @@ public class MediaController implements Player { * @param connectionHints A bundle containing the connection hints. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setConnectionHints(Bundle connectionHints) { this.connectionHints = new Bundle(checkNotNull(connectionHints)); return this; @@ -233,6 +235,7 @@ public class MediaController implements Player { * @param listener The listener. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setListener(Listener listener) { this.listener = checkNotNull(listener); return this; @@ -247,6 +250,7 @@ public class MediaController implements Player { * @param looper The looper. * @return The builder to allow chaining. */ + @CanIgnoreReturnValue public Builder setApplicationLooper(Looper looper) { applicationLooper = checkNotNull(looper); return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaLibraryService.java b/libraries/session/src/main/java/androidx/media3/session/MediaLibraryService.java index 8533019b1d..233bc2a5b2 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaLibraryService.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaLibraryService.java @@ -39,6 +39,7 @@ import androidx.media3.session.MediaSession.ControllerInfo; import com.google.common.collect.ImmutableList; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -592,24 +593,28 @@ public abstract class MediaLibraryService extends MediaSessionService { } /** Sets whether the media items are recently played. */ + @CanIgnoreReturnValue public Builder setRecent(boolean recent) { this.recent = recent; return this; } /** Sets whether the media items can be played without an internet connection. */ + @CanIgnoreReturnValue public Builder setOffline(boolean offline) { this.offline = offline; return this; } /** Sets whether the media items are suggested. */ + @CanIgnoreReturnValue public Builder setSuggested(boolean suggested) { this.suggested = suggested; return this; } /** Set an extra {@link Bundle}. */ + @CanIgnoreReturnValue @UnstableApi public Builder setExtras(Bundle extras) { this.extras = checkNotNull(extras); diff --git a/libraries/session/src/main/java/androidx/media3/session/MediaStyleNotificationHelper.java b/libraries/session/src/main/java/androidx/media3/session/MediaStyleNotificationHelper.java index 082c0e36dc..b15df33919 100644 --- a/libraries/session/src/main/java/androidx/media3/session/MediaStyleNotificationHelper.java +++ b/libraries/session/src/main/java/androidx/media3/session/MediaStyleNotificationHelper.java @@ -30,6 +30,7 @@ import androidx.annotation.RequiresApi; import androidx.core.app.NotificationBuilderWithBuilderAccessor; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.checkerframework.checker.nullness.compatqual.NullableType; /** @@ -124,6 +125,7 @@ public class MediaStyleNotificationHelper { * * @param actions the indices of the actions to show in the compact notification view */ + @CanIgnoreReturnValue public MediaStyle setShowActionsInCompactView(int... actions) { actionsToShowInCompact = actions; return this; @@ -153,6 +155,7 @@ public class MediaStyleNotificationHelper { * * @param show whether to show a cancel button */ + @CanIgnoreReturnValue public MediaStyle setShowCancelButton(boolean show) { if (Build.VERSION.SDK_INT < 21) { showCancelButton = show; @@ -166,6 +169,7 @@ public class MediaStyleNotificationHelper { * * @param pendingIntent the intent to be sent when the cancel button is pressed */ + @CanIgnoreReturnValue public MediaStyle setCancelButtonIntent(PendingIntent pendingIntent) { cancelButtonIntent = pendingIntent; return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java b/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java index f128a1ff0d..655bf5634c 100644 --- a/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java +++ b/libraries/session/src/main/java/androidx/media3/session/PlayerInfo.java @@ -47,6 +47,7 @@ import androidx.media3.common.VideoSize; import androidx.media3.common.text.CueGroup; import androidx.media3.common.util.Assertions; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -127,154 +128,184 @@ import java.lang.annotation.Target; trackSelectionParameters = playerInfo.trackSelectionParameters; } + @CanIgnoreReturnValue public Builder setPlayerError(@Nullable PlaybackException playerError) { this.playerError = playerError; return this; } + @CanIgnoreReturnValue public Builder setMediaItemTransitionReason( @Player.MediaItemTransitionReason int mediaItemTransitionReason) { this.mediaItemTransitionReason = mediaItemTransitionReason; return this; } + @CanIgnoreReturnValue public Builder setSessionPositionInfo(SessionPositionInfo sessionPositionInfo) { this.sessionPositionInfo = sessionPositionInfo; return this; } + @CanIgnoreReturnValue public Builder setOldPositionInfo(PositionInfo oldPositionInfo) { this.oldPositionInfo = oldPositionInfo; return this; } + @CanIgnoreReturnValue public Builder setNewPositionInfo(PositionInfo newPositionInfo) { this.newPositionInfo = newPositionInfo; return this; } + @CanIgnoreReturnValue public Builder setDiscontinuityReason(@Player.DiscontinuityReason int discontinuityReason) { this.discontinuityReason = discontinuityReason; return this; } + @CanIgnoreReturnValue public Builder setPlaybackParameters(PlaybackParameters playbackParameters) { this.playbackParameters = playbackParameters; return this; } + @CanIgnoreReturnValue public Builder setRepeatMode(@Player.RepeatMode int repeatMode) { this.repeatMode = repeatMode; return this; } + @CanIgnoreReturnValue public Builder setShuffleModeEnabled(boolean shuffleModeEnabled) { this.shuffleModeEnabled = shuffleModeEnabled; return this; } + @CanIgnoreReturnValue public Builder setTimeline(Timeline timeline) { this.timeline = timeline; return this; } + @CanIgnoreReturnValue public Builder setVideoSize(VideoSize videoSize) { this.videoSize = videoSize; return this; } + @CanIgnoreReturnValue public Builder setPlaylistMetadata(MediaMetadata playlistMetadata) { this.playlistMetadata = playlistMetadata; return this; } + @CanIgnoreReturnValue public Builder setVolume(@FloatRange(from = 0, to = 1) float volume) { this.volume = volume; return this; } + @CanIgnoreReturnValue public Builder setAudioAttributes(AudioAttributes audioAttributes) { this.audioAttributes = audioAttributes; return this; } + @CanIgnoreReturnValue public Builder setCues(CueGroup cueGroup) { this.cueGroup = cueGroup; return this; } + @CanIgnoreReturnValue public Builder setDeviceInfo(DeviceInfo deviceInfo) { this.deviceInfo = deviceInfo; return this; } + @CanIgnoreReturnValue public Builder setDeviceVolume(int deviceVolume) { this.deviceVolume = deviceVolume; return this; } + @CanIgnoreReturnValue public Builder setDeviceMuted(boolean deviceMuted) { this.deviceMuted = deviceMuted; return this; } + @CanIgnoreReturnValue public Builder setPlayWhenReady(boolean playWhenReady) { this.playWhenReady = playWhenReady; return this; } + @CanIgnoreReturnValue public Builder setPlayWhenReadyChangedReason( @Player.PlayWhenReadyChangeReason int playWhenReadyChangedReason) { this.playWhenReadyChangedReason = playWhenReadyChangedReason; return this; } + @CanIgnoreReturnValue public Builder setIsPlaying(boolean isPlaying) { this.isPlaying = isPlaying; return this; } + @CanIgnoreReturnValue public Builder setIsLoading(boolean isLoading) { this.isLoading = isLoading; return this; } + @CanIgnoreReturnValue public Builder setPlaybackSuppressionReason( @PlaybackSuppressionReason int playbackSuppressionReason) { this.playbackSuppressionReason = playbackSuppressionReason; return this; } + @CanIgnoreReturnValue public Builder setPlaybackState(@State int playbackState) { this.playbackState = playbackState; return this; } + @CanIgnoreReturnValue public Builder setMediaMetadata(MediaMetadata mediaMetadata) { this.mediaMetadata = mediaMetadata; return this; } + @CanIgnoreReturnValue public Builder setSeekBackIncrement(long seekBackIncrementMs) { this.seekBackIncrementMs = seekBackIncrementMs; return this; } + @CanIgnoreReturnValue public Builder setSeekForwardIncrement(long seekForwardIncrementMs) { this.seekForwardIncrementMs = seekForwardIncrementMs; return this; } + @CanIgnoreReturnValue public Builder setMaxSeekToPreviousPositionMs(long maxSeekToPreviousPositionMs) { this.maxSeekToPreviousPositionMs = maxSeekToPreviousPositionMs; return this; } + @CanIgnoreReturnValue public Builder setCurrentTracks(Tracks tracks) { currentTracks = tracks; return this; } + @CanIgnoreReturnValue public Builder setTrackSelectionParameters(TrackSelectionParameters parameters) { trackSelectionParameters = parameters; return this; diff --git a/libraries/session/src/main/java/androidx/media3/session/SessionCommands.java b/libraries/session/src/main/java/androidx/media3/session/SessionCommands.java index fa9b6dabea..d255bfa970 100644 --- a/libraries/session/src/main/java/androidx/media3/session/SessionCommands.java +++ b/libraries/session/src/main/java/androidx/media3/session/SessionCommands.java @@ -29,6 +29,7 @@ import androidx.media3.common.util.Log; import androidx.media3.common.util.UnstableApi; import androidx.media3.session.SessionCommand.CommandCode; import com.google.common.collect.ImmutableSet; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -65,6 +66,7 @@ public final class SessionCommands implements Bundleable { * @param command A command to add. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder add(SessionCommand command) { commands.add(checkNotNull(command)); return this; @@ -77,6 +79,7 @@ public final class SessionCommands implements Bundleable { * @param commandCode A command code to build command and add. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder add(@CommandCode int commandCode) { checkArgument(commandCode != COMMAND_CODE_CUSTOM); commands.add(new SessionCommand(commandCode)); @@ -89,6 +92,7 @@ public final class SessionCommands implements Bundleable { * @param command A command to find. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder remove(SessionCommand command) { commands.remove(checkNotNull(command)); return this; @@ -101,6 +105,7 @@ public final class SessionCommands implements Bundleable { * @param commandCode A command code to find. * @return This builder for chaining. */ + @CanIgnoreReturnValue public Builder remove(@CommandCode int commandCode) { checkArgument(commandCode != COMMAND_CODE_CUSTOM); for (SessionCommand command : commands) { @@ -117,7 +122,8 @@ public final class SessionCommands implements Bundleable { * * @return This builder for chaining. */ - /* package */ Builder addAllSessionCommands() { + /* package */ @CanIgnoreReturnValue + Builder addAllSessionCommands() { addCommandCodes(SessionCommand.SESSION_COMMANDS); return this; } @@ -127,7 +133,8 @@ public final class SessionCommands implements Bundleable { * * @return This builder for chaining. */ - /* package */ Builder addAllLibraryCommands() { + /* package */ @CanIgnoreReturnValue + Builder addAllLibraryCommands() { addCommandCodes(SessionCommand.LIBRARY_COMMANDS); return this; } @@ -137,7 +144,8 @@ public final class SessionCommands implements Bundleable { * * @return This builder for chaining. */ - /* package */ Builder addAllPredefinedCommands() { + /* package */ @CanIgnoreReturnValue + Builder addAllPredefinedCommands() { addAllSessionCommands(); addAllLibraryCommands(); return this; diff --git a/libraries/test_exoplayer_playback/src/androidTest/java/androidx/media3/test/exoplayer/playback/gts/DashTestRunner.java b/libraries/test_exoplayer_playback/src/androidTest/java/androidx/media3/test/exoplayer/playback/gts/DashTestRunner.java index 16429406d3..6daa365853 100644 --- a/libraries/test_exoplayer_playback/src/androidTest/java/androidx/media3/test/exoplayer/playback/gts/DashTestRunner.java +++ b/libraries/test_exoplayer_playback/src/androidTest/java/androidx/media3/test/exoplayer/playback/gts/DashTestRunner.java @@ -59,6 +59,7 @@ import androidx.media3.test.utils.HostActivity.HostedTest; import androidx.test.core.app.ApplicationProvider; import androidx.test.platform.app.InstrumentationRegistry; import com.google.common.primitives.Ints; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -128,16 +129,19 @@ import java.util.List; this.activity = activity; } + @CanIgnoreReturnValue public DashTestRunner setStreamName(String streamName) { this.streamName = streamName; return this; } + @CanIgnoreReturnValue public DashTestRunner setFullPlaybackNoSeeking(boolean fullPlaybackNoSeeking) { this.fullPlaybackNoSeeking = fullPlaybackNoSeeking; return this; } + @CanIgnoreReturnValue public DashTestRunner setCanIncludeAdditionalVideoFormats( boolean canIncludeAdditionalVideoFormats) { this.canIncludeAdditionalVideoFormats = @@ -145,27 +149,32 @@ import java.util.List; return this; } + @CanIgnoreReturnValue public DashTestRunner setActionSchedule(ActionSchedule actionSchedule) { this.actionSchedule = actionSchedule; return this; } + @CanIgnoreReturnValue public DashTestRunner setOfflineLicenseKeySetId(byte[] offlineLicenseKeySetId) { this.offlineLicenseKeySetId = offlineLicenseKeySetId; return this; } + @CanIgnoreReturnValue public DashTestRunner setAudioVideoFormats(String audioFormat, String... videoFormats) { this.audioFormat = audioFormat; this.videoFormats = videoFormats; return this; } + @CanIgnoreReturnValue public DashTestRunner setManifestUrl(String manifestUrl) { this.manifestUrl = manifestUrl; return this; } + @CanIgnoreReturnValue public DashTestRunner setWidevineInfo(String mimeType, boolean videoIdRequiredInLicenseUrl) { this.useL1Widevine = isL1WidevineAvailable(mimeType); this.widevineLicenseUrl = @@ -173,6 +182,7 @@ import java.util.List; return this; } + @CanIgnoreReturnValue public DashTestRunner setDataSourceFactory(DataSource.Factory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; return this; diff --git a/libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java b/libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java index e08b20c595..db40129a99 100644 --- a/libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java +++ b/libraries/test_session_current/src/main/java/androidx/media3/session/MockPlayer.java @@ -44,6 +44,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -1329,17 +1330,20 @@ public class MockPlayer implements Player { applicationLooper = Util.getCurrentOrMainLooper(); } + @CanIgnoreReturnValue public Builder setChangePlayerStateWithTransportControl( boolean changePlayerStateWithTransportControl) { this.changePlayerStateWithTransportControl = changePlayerStateWithTransportControl; return this; } + @CanIgnoreReturnValue public Builder setApplicationLooper(Looper applicationLooper) { this.applicationLooper = applicationLooper; return this; } + @CanIgnoreReturnValue public Builder setMediaItems(int itemCount) { this.itemCount = itemCount; return this; diff --git a/libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java b/libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java index 45da31105f..4589a192fe 100644 --- a/libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java +++ b/libraries/test_session_current/src/main/java/androidx/media3/session/RemoteMediaSession.java @@ -85,6 +85,7 @@ import androidx.media3.common.util.Log; import androidx.media3.common.util.UnstableApi; import androidx.media3.test.session.common.IRemoteMediaSession; import androidx.media3.test.session.common.TestUtils; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CountDownLatch; @@ -503,6 +504,7 @@ public class RemoteMediaSession { bundle = new Bundle(); } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlayerError(@Nullable PlaybackException playerError) { if (playerError != null) { bundle.putBundle(KEY_PLAYER_ERROR, playerError.toBundle()); @@ -510,189 +512,226 @@ public class RemoteMediaSession { return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setDuration(long duration) { bundle.putLong(KEY_DURATION, duration); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentPosition(long pos) { bundle.putLong(KEY_CURRENT_POSITION, pos); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setBufferedPosition(long buffPos) { bundle.putLong(KEY_BUFFERED_POSITION, buffPos); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setBufferedPercentage(int bufferedPercentage) { bundle.putInt(KEY_BUFFERED_PERCENTAGE, bufferedPercentage); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setTotalBufferedDuration(long totalBufferedDuration) { bundle.putLong(KEY_TOTAL_BUFFERED_DURATION, totalBufferedDuration); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentLiveOffset(long currentLiveOffset) { bundle.putLong(KEY_CURRENT_LIVE_OFFSET, currentLiveOffset); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setContentDuration(long contentDuration) { bundle.putLong(KEY_CONTENT_DURATION, contentDuration); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setContentPosition(long contentPosition) { bundle.putLong(KEY_CONTENT_POSITION, contentPosition); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setContentBufferedPosition(long contentBufferedPosition) { bundle.putLong(KEY_CONTENT_BUFFERED_POSITION, contentBufferedPosition); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setIsPlayingAd(boolean isPlayingAd) { bundle.putBoolean(KEY_IS_PLAYING_AD, isPlayingAd); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentAdGroupIndex(int currentAdGroupIndex) { bundle.putInt(KEY_CURRENT_AD_GROUP_INDEX, currentAdGroupIndex); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentAdIndexInAdGroup(int currentAdIndexInAdGroup) { bundle.putInt(KEY_CURRENT_AD_INDEX_IN_AD_GROUP, currentAdIndexInAdGroup); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlaybackParameters(PlaybackParameters playbackParameters) { bundle.putBundle(KEY_PLAYBACK_PARAMETERS, playbackParameters.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setAudioAttributes(AudioAttributes audioAttributes) { bundle.putBundle(KEY_AUDIO_ATTRIBUTES, audioAttributes.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setTimeline(Timeline timeline) { bundle.putBundle(KEY_TIMELINE, timeline.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentMediaItemIndex(int index) { bundle.putInt(KEY_CURRENT_MEDIA_ITEM_INDEX, index); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentPeriodIndex(int index) { bundle.putInt(KEY_CURRENT_PERIOD_INDEX, index); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlaylistMetadata(MediaMetadata playlistMetadata) { bundle.putBundle(KEY_PLAYLIST_METADATA, playlistMetadata.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setVideoSize(VideoSize videoSize) { bundle.putBundle(KEY_VIDEO_SIZE, videoSize.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setVolume(float volume) { bundle.putFloat(KEY_VOLUME, volume); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentCues(CueGroup cueGroup) { bundle.putBundle(KEY_CURRENT_CUE_GROUP, cueGroup.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setDeviceInfo(DeviceInfo deviceInfo) { bundle.putBundle(KEY_DEVICE_INFO, deviceInfo.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setDeviceVolume(int volume) { bundle.putInt(KEY_DEVICE_VOLUME, volume); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setDeviceMuted(boolean muted) { bundle.putBoolean(KEY_DEVICE_MUTED, muted); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlayWhenReady(boolean playWhenReady) { bundle.putBoolean(KEY_PLAY_WHEN_READY, playWhenReady); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlaybackSuppressionReason( @Player.PlaybackSuppressionReason int playbackSuppressionReason) { bundle.putInt(KEY_PLAYBACK_SUPPRESSION_REASON, playbackSuppressionReason); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setPlaybackState(@Player.State int state) { bundle.putInt(KEY_PLAYBACK_STATE, state); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setIsPlaying(boolean isPlaying) { bundle.putBoolean(KEY_IS_PLAYING, isPlaying); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setIsLoading(boolean isLoading) { bundle.putBoolean(KEY_IS_LOADING, isLoading); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setRepeatMode(@Player.RepeatMode int repeatMode) { bundle.putInt(KEY_REPEAT_MODE, repeatMode); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setShuffleModeEnabled(boolean shuffleModeEnabled) { bundle.putBoolean(KEY_SHUFFLE_MODE_ENABLED, shuffleModeEnabled); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setSeekBackIncrement(long seekBackIncrementMs) { bundle.putLong(KEY_SEEK_BACK_INCREMENT_MS, seekBackIncrementMs); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setSeekForwardIncrement(long seekForwardIncrementMs) { bundle.putLong(KEY_SEEK_FORWARD_INCREMENT_MS, seekForwardIncrementMs); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setMediaMetadata(MediaMetadata mediaMetadata) { bundle.putBundle(KEY_MEDIA_METADATA, mediaMetadata.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setMaxSeekToPreviousPositionMs( long maxSeekToPreviousPositionMs) { bundle.putLong(KEY_MAX_SEEK_TO_PREVIOUS_POSITION_MS, maxSeekToPreviousPositionMs); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setTrackSelectionParameters( TrackSelectionParameters parameters) { bundle.putBundle(KEY_TRACK_SELECTION_PARAMETERS, parameters.toBundle()); return this; } + @CanIgnoreReturnValue public MockPlayerConfigBuilder setCurrentTracks(Tracks tracks) { bundle.putBundle(KEY_CURRENT_TRACKS, tracks.toBundle()); return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java index fb4402d60d..66611b6ac1 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ActionSchedule.java @@ -57,6 +57,7 @@ import androidx.media3.test.utils.Action.WaitForPlayWhenReady; import androidx.media3.test.utils.Action.WaitForPlaybackState; import androidx.media3.test.utils.Action.WaitForPositionDiscontinuity; import androidx.media3.test.utils.Action.WaitForTimelineChanged; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** Schedules a sequence of {@link Action}s for execution during a test. */ @@ -129,6 +130,7 @@ public final class ActionSchedule { * @param delayMs The delay in milliseconds. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder delay(long delayMs) { currentDelayMs += delayMs; return this; @@ -140,6 +142,7 @@ public final class ActionSchedule { * @param action The action to schedule. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder apply(Action action) { return appendActionNode(new ActionNode(action, currentDelayMs)); } @@ -151,6 +154,7 @@ public final class ActionSchedule { * @param intervalMs The interval between each repetition in milliseconds. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder repeat(Action action, long intervalMs) { return appendActionNode(new ActionNode(action, currentDelayMs, intervalMs)); } @@ -161,6 +165,7 @@ public final class ActionSchedule { * @param positionMs The seek position. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder seek(long positionMs) { return apply(new Seek(tag, positionMs)); } @@ -172,6 +177,7 @@ public final class ActionSchedule { * @param positionMs The seek position. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder seek(int mediaItemIndex, long positionMs) { return apply( new Seek(tag, mediaItemIndex, positionMs, /* catchIllegalSeekException= */ false)); @@ -185,6 +191,7 @@ public final class ActionSchedule { * @param catchIllegalSeekException Whether an illegal seek position should be caught or not. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder seek(int mediaItemIndex, long positionMs, boolean catchIllegalSeekException) { return apply(new Seek(tag, mediaItemIndex, positionMs, catchIllegalSeekException)); } @@ -208,6 +215,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForPendingPlayerCommands() { return apply(new WaitForPendingPlayerCommands(tag)); } @@ -219,6 +227,7 @@ public final class ActionSchedule { * @return The builder, for convenience. * @see Player#setPlaybackParameters(PlaybackParameters) */ + @CanIgnoreReturnValue public Builder setPlaybackParameters(PlaybackParameters playbackParameters) { return apply(new SetPlaybackParameters(tag, playbackParameters)); } @@ -228,6 +237,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder stop() { return apply(new Stop(tag)); } @@ -238,6 +248,7 @@ public final class ActionSchedule { * @param reset Whether the player should be reset. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder stop(boolean reset) { return apply(new Stop(tag, reset)); } @@ -247,6 +258,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder play() { return apply(new SetPlayWhenReady(tag, true)); } @@ -259,6 +271,7 @@ public final class ActionSchedule { * @param positionMs The position in that media item at which the player should be paused again. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder playUntilPosition(int mediaItemIndex, long positionMs) { return apply(new PlayUntilPosition(tag, mediaItemIndex, positionMs)); } @@ -270,6 +283,7 @@ public final class ActionSchedule { * @param mediaItemIndex The media item index at which the player should be paused again. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder playUntilStartOfMediaItem(int mediaItemIndex) { return apply(new PlayUntilPosition(tag, mediaItemIndex, /* positionMs= */ 0)); } @@ -279,6 +293,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder pause() { return apply(new SetPlayWhenReady(tag, false)); } @@ -288,6 +303,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder enableRenderer(int index) { return apply(new SetRendererDisabled(tag, index, false)); } @@ -297,6 +313,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder disableRenderer(int index) { return apply(new SetRendererDisabled(tag, index, true)); } @@ -306,6 +323,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder clearVideoSurface() { return apply(new ClearVideoSurface(tag)); } @@ -315,6 +333,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setVideoSurface() { return apply(new SetVideoSurface(tag)); } @@ -324,6 +343,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setAudioAttributes(AudioAttributes audioAttributes, boolean handleAudioFocus) { return apply(new SetAudioAttributes(tag, audioAttributes, handleAudioFocus)); } @@ -339,6 +359,7 @@ public final class ActionSchedule { * parameter is ignored. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMediaSources(int mediaItemIndex, long positionMs, MediaSource... sources) { return apply(new Action.SetMediaItems(tag, mediaItemIndex, positionMs, sources)); } @@ -349,6 +370,7 @@ public final class ActionSchedule { * @param resetPosition Whether the playback position should be reset. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMediaSources(boolean resetPosition, MediaSource... sources) { return apply(new Action.SetMediaItemsResetPosition(tag, resetPosition, sources)); } @@ -359,6 +381,7 @@ public final class ActionSchedule { * @param mediaSources The media sources to add. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setMediaSources(MediaSource... mediaSources) { return apply( new Action.SetMediaItems( @@ -373,6 +396,7 @@ public final class ActionSchedule { * @param mediaSources The media sources to add. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder addMediaSources(MediaSource... mediaSources) { return apply(new Action.AddMediaItems(tag, mediaSources)); } @@ -384,6 +408,7 @@ public final class ActionSchedule { * @param newIndex The index after the item has been moved. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder moveMediaItem(int currentIndex, int newIndex) { return apply(new Action.MoveMediaItem(tag, currentIndex, newIndex)); } @@ -394,6 +419,7 @@ public final class ActionSchedule { * @param index The index of the media item to be removed. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder removeMediaItem(int index) { return apply(new Action.RemoveMediaItem(tag, index)); } @@ -405,6 +431,7 @@ public final class ActionSchedule { * @param toIndex The end of the range of media items to be removed (exclusive). * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder removeMediaItems(int fromIndex, int toIndex) { return apply(new Action.RemoveMediaItems(tag, fromIndex, toIndex)); } @@ -414,6 +441,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder prepare() { return apply(new Action.Prepare(tag)); } @@ -423,6 +451,7 @@ public final class ActionSchedule { * * @return The builder. for convenience, */ + @CanIgnoreReturnValue public Builder clearMediaItems() { return apply(new Action.ClearMediaItems(tag)); } @@ -432,6 +461,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setRepeatMode(@Player.RepeatMode int repeatMode) { return apply(new SetRepeatMode(tag, repeatMode)); } @@ -442,6 +472,7 @@ public final class ActionSchedule { * @param shuffleOrder The shuffle order. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setShuffleOrder(ShuffleOrder shuffleOrder) { return apply(new SetShuffleOrder(tag, shuffleOrder)); } @@ -451,6 +482,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder setShuffleModeEnabled(boolean shuffleModeEnabled) { return apply(new SetShuffleModeEnabled(tag, shuffleModeEnabled)); } @@ -462,6 +494,7 @@ public final class ActionSchedule { * in milliseconds. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder sendMessage(Target target, long positionMs) { return apply(new SendMessages(tag, target, positionMs)); } @@ -474,6 +507,7 @@ public final class ActionSchedule { * @param positionMs The position at which the message should be sent, in milliseconds. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder sendMessage(Target target, int mediaItemIndex, long positionMs) { return apply( new SendMessages( @@ -489,6 +523,7 @@ public final class ActionSchedule { * @param deleteAfterDelivery Whether the message will be deleted after delivery. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder sendMessage( Target target, int mediaItemIndex, long positionMs, boolean deleteAfterDelivery) { return apply(new SendMessages(tag, target, mediaItemIndex, positionMs, deleteAfterDelivery)); @@ -499,6 +534,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForTimelineChanged() { return apply(new WaitForTimelineChanged(tag)); } @@ -510,6 +546,7 @@ public final class ActionSchedule { * @param expectedReason The expected reason of the timeline change. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForTimelineChanged( Timeline expectedTimeline, @Player.TimelineChangeReason int expectedReason) { return apply(new WaitForTimelineChanged(tag, expectedTimeline, expectedReason)); @@ -520,6 +557,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForPositionDiscontinuity() { return apply(new WaitForPositionDiscontinuity(tag)); } @@ -530,6 +568,7 @@ public final class ActionSchedule { * @param targetPlayWhenReady The target playWhenReady value. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForPlayWhenReady(boolean targetPlayWhenReady) { return apply(new WaitForPlayWhenReady(tag, targetPlayWhenReady)); } @@ -540,6 +579,7 @@ public final class ActionSchedule { * @param targetPlaybackState The target playback state. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForPlaybackState(@Player.State int targetPlaybackState) { return apply(new WaitForPlaybackState(tag, targetPlaybackState)); } @@ -550,6 +590,7 @@ public final class ActionSchedule { * @param targetIsLoading The target value of {@code player.isLoading()}. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForIsLoading(boolean targetIsLoading) { return apply(new WaitForIsLoading(tag, targetIsLoading)); } @@ -560,6 +601,7 @@ public final class ActionSchedule { * @param playerTarget The target to observe. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder waitForMessage(PlayerTarget playerTarget) { return apply(new WaitForMessage(tag, playerTarget)); } @@ -569,6 +611,7 @@ public final class ActionSchedule { * * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder executeRunnable(Runnable runnable) { return apply(new ExecuteRunnable(tag, runnable)); } @@ -579,6 +622,7 @@ public final class ActionSchedule { * @param exception The exception to throw. * @return The builder, for convenience. */ + @CanIgnoreReturnValue public Builder throwPlaybackException(ExoPlaybackException exception) { return apply(new ThrowPlaybackException(tag, exception)); } @@ -590,6 +634,7 @@ public final class ActionSchedule { return new ActionSchedule(rootNode, callbackAction); } + @CanIgnoreReturnValue private Builder appendActionNode(ActionNode actionNode) { previousNode.setNext(actionNode); previousNode = actionNode; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/CacheAsserts.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/CacheAsserts.java index b7bf6bcc47..3f20d466ed 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/CacheAsserts.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/CacheAsserts.java @@ -30,6 +30,7 @@ import androidx.media3.datasource.PlaceholderDataSource; import androidx.media3.datasource.cache.Cache; import androidx.media3.datasource.cache.CacheDataSource; import androidx.media3.test.utils.FakeDataSet.FakeData; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; @@ -52,6 +53,7 @@ public final class CacheAsserts { } } + @CanIgnoreReturnValue public RequestSet subset(String... uriStrings) { dataSpecs = new DataSpec[uriStrings.length]; for (int i = 0; i < dataSpecs.length; i++) { @@ -60,6 +62,7 @@ public final class CacheAsserts { return this; } + @CanIgnoreReturnValue public RequestSet subset(Uri... uris) { dataSpecs = new DataSpec[uris.length]; for (int i = 0; i < dataSpecs.length; i++) { @@ -68,6 +71,7 @@ public final class CacheAsserts { return this; } + @CanIgnoreReturnValue public RequestSet subset(DataSpec... dataSpecs) { this.dataSpecs = dataSpecs; return this; @@ -85,6 +89,7 @@ public final class CacheAsserts { return dataSpecs[i]; } + @CanIgnoreReturnValue public RequestSet useBoundedDataSpecFor(String uriString) { FakeData data = Assertions.checkStateNotNull(fakeDataSet.getData(uriString)); for (int i = 0; i < dataSpecs.length; i++) { diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/DataSourceContractTest.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/DataSourceContractTest.java index a7e50c97e2..74fa27a0f3 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/DataSourceContractTest.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/DataSourceContractTest.java @@ -43,6 +43,7 @@ import androidx.media3.datasource.DataSpec; import androidx.media3.datasource.TransferListener; import com.google.common.base.Ascii; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -664,17 +665,20 @@ public abstract class DataSourceContractTest { /** * Sets a human-readable name for this resource which will be shown in test failure messages. */ + @CanIgnoreReturnValue public Builder setName(String name) { this.name = name; return this; } /** Sets the URI where this resource is located. */ + @CanIgnoreReturnValue public Builder setUri(String uri) { return setUri(Uri.parse(uri)); } /** Sets the URI where this resource is located. */ + @CanIgnoreReturnValue public Builder setUri(Uri uri) { this.uri = uri; return this; @@ -685,6 +689,7 @@ public abstract class DataSourceContractTest { * *

Must be at least 5 bytes. */ + @CanIgnoreReturnValue public Builder setExpectedBytes(byte[] expectedBytes) { checkArgument(expectedBytes.length >= 5); this.expectedBytes = expectedBytes; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/DownloadBuilder.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/DownloadBuilder.java index b330c94786..9230f7e4c9 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/DownloadBuilder.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/DownloadBuilder.java @@ -23,6 +23,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.exoplayer.offline.Download; import androidx.media3.exoplayer.offline.DownloadProgress; import androidx.media3.exoplayer.offline.DownloadRequest; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -111,6 +112,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#uri */ + @CanIgnoreReturnValue public DownloadBuilder setUri(String uri) { this.uri = Uri.parse(uri); return this; @@ -119,6 +121,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#uri */ + @CanIgnoreReturnValue public DownloadBuilder setUri(Uri uri) { this.uri = uri; return this; @@ -127,6 +130,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#mimeType */ + @CanIgnoreReturnValue public DownloadBuilder setMimeType(String mimeType) { this.mimeType = mimeType; return this; @@ -135,6 +139,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#keySetId */ + @CanIgnoreReturnValue public DownloadBuilder setKeySetId(byte[] keySetId) { this.keySetId = keySetId; return this; @@ -143,6 +148,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#customCacheKey */ + @CanIgnoreReturnValue public DownloadBuilder setCacheKey(@Nullable String cacheKey) { this.cacheKey = cacheKey; return this; @@ -151,6 +157,7 @@ public final class DownloadBuilder { /** * @see Download#state */ + @CanIgnoreReturnValue public DownloadBuilder setState(@Download.State int state) { this.state = state; return this; @@ -159,6 +166,7 @@ public final class DownloadBuilder { /** * @see DownloadProgress#percentDownloaded */ + @CanIgnoreReturnValue public DownloadBuilder setPercentDownloaded(float percentDownloaded) { progress.percentDownloaded = percentDownloaded; return this; @@ -167,6 +175,7 @@ public final class DownloadBuilder { /** * @see DownloadProgress#bytesDownloaded */ + @CanIgnoreReturnValue public DownloadBuilder setBytesDownloaded(long bytesDownloaded) { progress.bytesDownloaded = bytesDownloaded; return this; @@ -175,6 +184,7 @@ public final class DownloadBuilder { /** * @see Download#contentLength */ + @CanIgnoreReturnValue public DownloadBuilder setContentLength(long contentLength) { this.contentLength = contentLength; return this; @@ -183,6 +193,7 @@ public final class DownloadBuilder { /** * @see Download#failureReason */ + @CanIgnoreReturnValue public DownloadBuilder setFailureReason(int failureReason) { this.failureReason = failureReason; return this; @@ -191,6 +202,7 @@ public final class DownloadBuilder { /** * @see Download#stopReason */ + @CanIgnoreReturnValue public DownloadBuilder setStopReason(int stopReason) { this.stopReason = stopReason; return this; @@ -199,6 +211,7 @@ public final class DownloadBuilder { /** * @see Download#startTimeMs */ + @CanIgnoreReturnValue public DownloadBuilder setStartTimeMs(long startTimeMs) { this.startTimeMs = startTimeMs; return this; @@ -207,6 +220,7 @@ public final class DownloadBuilder { /** * @see Download#updateTimeMs */ + @CanIgnoreReturnValue public DownloadBuilder setUpdateTimeMs(long updateTimeMs) { this.updateTimeMs = updateTimeMs; return this; @@ -215,6 +229,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#streamKeys */ + @CanIgnoreReturnValue public DownloadBuilder setStreamKeys(StreamKey... streamKeys) { this.streamKeys = Arrays.asList(streamKeys); return this; @@ -223,6 +238,7 @@ public final class DownloadBuilder { /** * @see DownloadRequest#data */ + @CanIgnoreReturnValue public DownloadBuilder setCustomMetadata(byte[] customMetadata) { this.customMetadata = customMetadata; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/Dumper.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/Dumper.java index e919596a3b..0e6b9bf8c9 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/Dumper.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/Dumper.java @@ -18,6 +18,7 @@ package androidx.media3.test.utils; import androidx.annotation.Nullable; import androidx.media3.common.C; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.Arrays; import java.util.Locale; @@ -44,15 +45,18 @@ public final class Dumper { sb = new StringBuilder(); } + @CanIgnoreReturnValue public Dumper add(String field, @Nullable Object value) { return addString(field + " = " + value + '\n'); } + @CanIgnoreReturnValue public Dumper add(Dumpable object) { object.dump(this); return this; } + @CanIgnoreReturnValue public Dumper add(String field, @Nullable byte[] value) { String string = String.format( @@ -64,16 +68,19 @@ public final class Dumper { return addString(string); } + @CanIgnoreReturnValue public Dumper addTime(String field, long time) { return add(field, time == C.TIME_UNSET ? "UNSET TIME" : time); } + @CanIgnoreReturnValue public Dumper startBlock(String name) { addString(name + ":\n"); indent += INDENT_SIZE_IN_SPACES; return this; } + @CanIgnoreReturnValue public Dumper endBlock() { indent -= INDENT_SIZE_IN_SPACES; return this; @@ -84,6 +91,7 @@ public final class Dumper { return sb.toString(); } + @CanIgnoreReturnValue private Dumper addString(String string) { for (int i = 0; i < indent; i++) { sb.append(' '); diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java index 0cb7b4d935..fd7844e210 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExoPlayerTestRunner.java @@ -44,6 +44,7 @@ import androidx.media3.exoplayer.source.MediaSource; import androidx.media3.exoplayer.trackselection.DefaultTrackSelector; import androidx.media3.exoplayer.upstream.BandwidthMeter; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -111,6 +112,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * runner. * @return This builder. */ + @CanIgnoreReturnValue public Builder setTimeline(Timeline timeline) { assertThat(mediaSources).isEmpty(); assertFalse(skipSettingMediaSources); @@ -126,6 +128,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param manifest A manifest to be used by a {@link FakeMediaSource} in the test runner. * @return This builder. */ + @CanIgnoreReturnValue public Builder setManifest(Object manifest) { assertThat(mediaSources).isEmpty(); assertFalse(skipSettingMediaSources); @@ -140,6 +143,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param positionMs The position in milliseconds to seek to. * @return This builder. */ + @CanIgnoreReturnValue public Builder initialSeek(int mediaItemIndex, long positionMs) { this.initialMediaItemIndex = mediaItemIndex; this.initialPositionMs = positionMs; @@ -156,6 +160,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param mediaSources The {@link MediaSource}s to be used by the test runner. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMediaSources(MediaSource... mediaSources) { assertThat(timeline).isNull(); assertThat(manifest).isNull(); @@ -173,6 +178,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param supportedFormats A list of supported {@link Format}s. * @return This builder. */ + @CanIgnoreReturnValue public Builder setSupportedFormats(Format... supportedFormats) { this.supportedFormats = supportedFormats; return this; @@ -185,6 +191,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * * @return This builder. */ + @CanIgnoreReturnValue public Builder skipSettingMediaSources() { assertThat(timeline).isNull(); assertThat(manifest).isNull(); @@ -197,6 +204,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setUseLazyPreparation(boolean) * @return This builder. */ + @CanIgnoreReturnValue public Builder setUseLazyPreparation(boolean useLazyPreparation) { testPlayerBuilder.setUseLazyPreparation(useLazyPreparation); return this; @@ -208,6 +216,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param pauseAtEndOfMediaItems Whether to pause at the end of media items. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) { this.pauseAtEndOfMediaItems = pauseAtEndOfMediaItems; return this; @@ -217,6 +226,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setTrackSelector(DefaultTrackSelector) * @return This builder. */ + @CanIgnoreReturnValue public Builder setTrackSelector(DefaultTrackSelector trackSelector) { testPlayerBuilder.setTrackSelector(trackSelector); return this; @@ -226,6 +236,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setLoadControl(LoadControl) * @return This builder. */ + @CanIgnoreReturnValue public Builder setLoadControl(LoadControl loadControl) { testPlayerBuilder.setLoadControl(loadControl); return this; @@ -235,6 +246,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setBandwidthMeter(BandwidthMeter) * @return This builder. */ + @CanIgnoreReturnValue public Builder setBandwidthMeter(BandwidthMeter bandwidthMeter) { this.testPlayerBuilder.setBandwidthMeter(bandwidthMeter); return this; @@ -244,6 +256,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setRenderers(Renderer...) * @return This builder. */ + @CanIgnoreReturnValue public Builder setRenderers(Renderer... renderers) { testPlayerBuilder.setRenderers(renderers); return this; @@ -253,6 +266,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setRenderersFactory(RenderersFactory) * @return This builder. */ + @CanIgnoreReturnValue public Builder setRenderersFactory(RenderersFactory renderersFactory) { testPlayerBuilder.setRenderersFactory(renderersFactory); return this; @@ -262,6 +276,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @see TestExoPlayerBuilder#setClock(Clock) * @return This builder. */ + @CanIgnoreReturnValue public Builder setClock(Clock clock) { testPlayerBuilder.setClock(clock); return this; @@ -274,6 +289,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param actionSchedule An {@link ActionSchedule} to be used by the test runner. * @return This builder. */ + @CanIgnoreReturnValue public Builder setActionSchedule(ActionSchedule actionSchedule) { this.actionSchedule = actionSchedule; return this; @@ -285,6 +301,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param surface The {@link Surface} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public Builder setVideoSurface(Surface surface) { this.surface = surface; return this; @@ -297,6 +314,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * to player events. * @return This builder. */ + @CanIgnoreReturnValue public Builder setPlayerListener(Player.Listener playerListener) { this.playerListener = playerListener; return this; @@ -308,6 +326,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param analyticsListener An {@link AnalyticsListener} to be registered. * @return This builder. */ + @CanIgnoreReturnValue public Builder setAnalyticsListener(AnalyticsListener analyticsListener) { this.analyticsListener = analyticsListener; return this; @@ -322,6 +341,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * or idle state. * @return This builder. */ + @CanIgnoreReturnValue public Builder setExpectedPlayerEndedCount(int expectedPlayerEndedCount) { this.expectedPlayerEndedCount = expectedPlayerEndedCount; return this; @@ -431,6 +451,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * * @return This test runner. */ + @CanIgnoreReturnValue public ExoPlayerTestRunner start() { return start(/* doPrepare= */ true); } @@ -442,6 +463,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @param doPrepare Whether the player should be prepared. * @return This test runner. */ + @CanIgnoreReturnValue public ExoPlayerTestRunner start(boolean doPrepare) { handler.post( () -> { @@ -496,6 +518,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @return This test runner. * @throws Exception If any exception occurred during playback, release, or due to a timeout. */ + @CanIgnoreReturnValue public ExoPlayerTestRunner blockUntilEnded(long timeoutMs) throws Exception { clock.onThreadBlocked(); if (!endedCountDownLatch.await(timeoutMs, MILLISECONDS)) { @@ -518,6 +541,7 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul * @throws TimeoutException If the action schedule did not finish within the specified timeout. * @throws InterruptedException If the test thread gets interrupted while waiting. */ + @CanIgnoreReturnValue public ExoPlayerTestRunner blockUntilActionScheduleFinished(long timeoutMs) throws TimeoutException, InterruptedException { clock.onThreadBlocked(); diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExtractorAsserts.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExtractorAsserts.java index 78ba466ed8..3aeb6965da 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExtractorAsserts.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/ExtractorAsserts.java @@ -33,6 +33,7 @@ import androidx.media3.test.utils.FakeExtractorInput.SimulatedIOException; import androidx.test.core.app.ApplicationProvider; import com.google.common.base.Joiner; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -147,11 +148,13 @@ public final class ExtractorAsserts { private @MonotonicNonNull String dumpFilesPrefix; private boolean deduplicateConsecutiveFormats; + @CanIgnoreReturnValue public Builder setDumpFilesPrefix(String dumpFilesPrefix) { this.dumpFilesPrefix = dumpFilesPrefix; return this; } + @CanIgnoreReturnValue public Builder setDeduplicateConsecutiveFormats(boolean deduplicateConsecutiveFormats) { this.deduplicateConsecutiveFormats = deduplicateConsecutiveFormats; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSet.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSet.java index a5253e0ca2..7d9e156d34 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSet.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSet.java @@ -21,6 +21,7 @@ import androidx.media3.common.C; import androidx.media3.common.util.Assertions; import androidx.media3.common.util.UnstableApi; import androidx.media3.datasource.DataSpec; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; @@ -154,12 +155,14 @@ public class FakeDataSet { * the {@link DataSpec#length} of the argument, including the case where the length is equal to * {@link C#LENGTH_UNSET}. */ + @CanIgnoreReturnValue public FakeData setSimulateUnknownLength(boolean simulateUnknownLength) { this.simulateUnknownLength = simulateUnknownLength; return this; } /** Appends to the underlying data. */ + @CanIgnoreReturnValue public FakeData appendReadData(byte[] data) { Assertions.checkState(data.length > 0); segments.add(new Segment(data, getLastSegment())); @@ -170,6 +173,7 @@ public class FakeDataSet { * Appends a data segment of the specified length. No actual data is available and the {@link * FakeDataSource} will perform no copy operations when this data is read. */ + @CanIgnoreReturnValue public FakeData appendReadData(int length) { Assertions.checkState(length > 0); segments.add(new Segment(length, getLastSegment())); @@ -177,12 +181,14 @@ public class FakeDataSet { } /** Appends an error in the underlying data. */ + @CanIgnoreReturnValue public FakeData appendReadError(IOException exception) { segments.add(new Segment(exception, getLastSegment())); return this; } /** Appends an action. */ + @CanIgnoreReturnValue public FakeData appendReadAction(Runnable action) { segments.add(new Segment(action, getLastSegment())); return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSource.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSource.java index bf02faac48..4c31ba9320 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSource.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeDataSource.java @@ -31,6 +31,7 @@ import androidx.media3.datasource.DataSourceException; import androidx.media3.datasource.DataSpec; import androidx.media3.test.utils.FakeDataSet.FakeData; import androidx.media3.test.utils.FakeDataSet.FakeData.Segment; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.util.ArrayList; @@ -51,11 +52,13 @@ public class FakeDataSource extends BaseDataSource { fakeDataSet = new FakeDataSet(); } + @CanIgnoreReturnValue public final Factory setFakeDataSet(FakeDataSet fakeDataSet) { this.fakeDataSet = fakeDataSet; return this; } + @CanIgnoreReturnValue public final Factory setIsNetwork(boolean isNetwork) { this.isNetwork = isNetwork; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExoMediaDrm.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExoMediaDrm.java index f7eb8d6978..600a6f9524 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExoMediaDrm.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExoMediaDrm.java @@ -40,6 +40,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.primitives.Bytes; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -85,6 +86,7 @@ public final class FakeExoMediaDrm implements ExoMediaDrm { * *

Defaults to true. */ + @CanIgnoreReturnValue public Builder setEnforceValidKeyResponses(boolean enforceValidKeyResponses) { this.enforceValidKeyResponses = enforceValidKeyResponses; return this; @@ -100,6 +102,7 @@ public final class FakeExoMediaDrm implements ExoMediaDrm { * *

Defaults to 0 (i.e. device is already provisioned). */ + @CanIgnoreReturnValue public Builder setProvisionsRequired(int provisionsRequired) { this.provisionsRequired = provisionsRequired; return this; @@ -110,6 +113,7 @@ public final class FakeExoMediaDrm implements ExoMediaDrm { * {@link #getKeyRequest(byte[], List, int, HashMap)} instead of the default behaviour of * throwing from {@link #openSession()}. */ + @CanIgnoreReturnValue public Builder throwNotProvisionedExceptionFromGetKeyRequest() { this.throwNotProvisionedExceptionFromGetKeyRequest = true; return this; @@ -123,6 +127,7 @@ public final class FakeExoMediaDrm implements ExoMediaDrm { * *

Defaults to {@link Integer#MAX_VALUE}. */ + @CanIgnoreReturnValue public Builder setMaxConcurrentSessions(int maxConcurrentSessions) { this.maxConcurrentSessions = maxConcurrentSessions; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExtractorInput.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExtractorInput.java index deec6c1c22..9ffb3116cc 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExtractorInput.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeExtractorInput.java @@ -23,6 +23,7 @@ import androidx.media3.common.C; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import androidx.media3.extractor.ExtractorInput; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.EOFException; import java.io.IOException; @@ -293,21 +294,25 @@ public final class FakeExtractorInput implements ExtractorInput { data = Util.EMPTY_BYTE_ARRAY; } + @CanIgnoreReturnValue public Builder setData(byte[] data) { this.data = data; return this; } + @CanIgnoreReturnValue public Builder setSimulateUnknownLength(boolean simulateUnknownLength) { this.simulateUnknownLength = simulateUnknownLength; return this; } + @CanIgnoreReturnValue public Builder setSimulatePartialReads(boolean simulatePartialReads) { this.simulatePartialReads = simulatePartialReads; return this; } + @CanIgnoreReturnValue public Builder setSimulateIOErrors(boolean simulateIOErrors) { this.simulateIOErrors = simulateIOErrors; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/TestExoPlayerBuilder.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/TestExoPlayerBuilder.java index ef866067fc..f5e02695bf 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/TestExoPlayerBuilder.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/TestExoPlayerBuilder.java @@ -34,6 +34,7 @@ import androidx.media3.exoplayer.source.MediaSource; import androidx.media3.exoplayer.trackselection.DefaultTrackSelector; import androidx.media3.exoplayer.upstream.BandwidthMeter; import androidx.media3.exoplayer.upstream.DefaultBandwidthMeter; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** A builder of {@link ExoPlayer} instances for testing. */ @@ -73,6 +74,7 @@ public class TestExoPlayerBuilder { * @param useLazyPreparation Whether to use lazy preparation. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setUseLazyPreparation(boolean useLazyPreparation) { this.useLazyPreparation = useLazyPreparation; return this; @@ -90,6 +92,7 @@ public class TestExoPlayerBuilder { * @param trackSelector The {@link DefaultTrackSelector} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setTrackSelector(DefaultTrackSelector trackSelector) { Assertions.checkNotNull(trackSelector); this.trackSelector = trackSelector; @@ -108,6 +111,7 @@ public class TestExoPlayerBuilder { * @param loadControl The {@link LoadControl} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setLoadControl(LoadControl loadControl) { this.loadControl = loadControl; return this; @@ -125,6 +129,7 @@ public class TestExoPlayerBuilder { * @param bandwidthMeter The {@link BandwidthMeter} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setBandwidthMeter(BandwidthMeter bandwidthMeter) { Assertions.checkNotNull(bandwidthMeter); this.bandwidthMeter = bandwidthMeter; @@ -144,6 +149,7 @@ public class TestExoPlayerBuilder { * @param renderers A list of {@link Renderer}s to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setRenderers(Renderer... renderers) { assertThat(renderersFactory).isNull(); this.renderers = renderers; @@ -169,6 +175,7 @@ public class TestExoPlayerBuilder { * @param renderersFactory A {@link RenderersFactory} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setRenderersFactory(RenderersFactory renderersFactory) { assertThat(renderers).isNull(); this.renderersFactory = renderersFactory; @@ -191,6 +198,7 @@ public class TestExoPlayerBuilder { * @param clock A {@link Clock} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setClock(Clock clock) { assertThat(clock).isNotNull(); this.clock = clock; @@ -208,6 +216,7 @@ public class TestExoPlayerBuilder { * @param looper The {@link Looper} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setLooper(Looper looper) { this.looper = looper; return this; @@ -237,6 +246,7 @@ public class TestExoPlayerBuilder { * @param mediaSourceFactory The {@link MediaSource.Factory} to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; @@ -248,6 +258,7 @@ public class TestExoPlayerBuilder { * @param seekBackIncrementMs The seek back increment to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setSeekBackIncrementMs(long seekBackIncrementMs) { this.seekBackIncrementMs = seekBackIncrementMs; return this; @@ -264,6 +275,7 @@ public class TestExoPlayerBuilder { * @param seekForwardIncrementMs The seek forward increment to be used by the player. * @return This builder. */ + @CanIgnoreReturnValue public TestExoPlayerBuilder setSeekForwardIncrementMs(long seekForwardIncrementMs) { this.seekForwardIncrementMs = seekForwardIncrementMs; return this; diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/WebServerDispatcher.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/WebServerDispatcher.java index 7471b075fb..5deda72c85 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/WebServerDispatcher.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/WebServerDispatcher.java @@ -33,6 +33,7 @@ import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -120,6 +121,7 @@ public class WebServerDispatcher extends Dispatcher { * * @return this builder, for convenience. */ + @CanIgnoreReturnValue public Builder setPath(String path) { this.path = path.startsWith("/") ? path : "/" + path; return this; @@ -130,6 +132,7 @@ public class WebServerDispatcher extends Dispatcher { * * @return this builder, for convenience. */ + @CanIgnoreReturnValue public Builder setData(byte[] data) { this.data = data; return this; @@ -140,6 +143,7 @@ public class WebServerDispatcher extends Dispatcher { * * @return this builder, for convenience. */ + @CanIgnoreReturnValue public Builder supportsRangeRequests(boolean supportsRangeRequests) { this.supportsRangeRequests = supportsRangeRequests; return this; @@ -153,6 +157,7 @@ public class WebServerDispatcher extends Dispatcher { * * @return this builder, for convenience. */ + @CanIgnoreReturnValue public Builder resolvesToUnknownLength(boolean resolvesToUnknownLength) { this.resolvesToUnknownLength = resolvesToUnknownLength; return this; @@ -164,6 +169,7 @@ public class WebServerDispatcher extends Dispatcher { * * @return this builder, for convenience. */ + @CanIgnoreReturnValue public Builder setGzipSupport(@GzipSupport int gzipSupport) { this.gzipSupport = gzipSupport; return this; diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTestResult.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTestResult.java index c2bd3241e2..79d1148ac6 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTestResult.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformationTestResult.java @@ -17,6 +17,7 @@ package androidx.media3.transformer; import androidx.annotation.Nullable; import androidx.media3.common.C; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.json.JSONException; import org.json.JSONObject; @@ -49,6 +50,7 @@ public class TransformationTestResult { * @param filePath The path. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setFilePath(@Nullable String filePath) { this.filePath = filePath; return this; @@ -63,6 +65,7 @@ public class TransformationTestResult { * @param elapsedTimeMs The time, in ms. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setElapsedTimeMs(long elapsedTimeMs) { this.elapsedTimeMs = elapsedTimeMs; return this; @@ -76,6 +79,7 @@ public class TransformationTestResult { * @param ssim The structural similarity index. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setSsim(double ssim) { this.ssim = ssim; return this; @@ -89,6 +93,7 @@ public class TransformationTestResult { * @param analysisException The {@link Exception} thrown during analysis. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setAnalysisException(@Nullable Exception analysisException) { this.analysisException = analysisException; return this; diff --git a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java index 1742c4edc9..e5a173c86b 100644 --- a/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java +++ b/libraries/transformer/src/androidTest/java/androidx/media3/transformer/TransformerAndroidTestRunner.java @@ -28,6 +28,7 @@ import androidx.media3.common.util.SystemClock; import androidx.media3.common.util.Util; import androidx.test.platform.app.InstrumentationRegistry; import com.google.common.base.Ascii; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.File; import java.io.IOException; import java.util.List; @@ -77,6 +78,7 @@ public class TransformerAndroidTestRunner { * @param timeoutSeconds The timeout. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setTimeoutSeconds(int timeoutSeconds) { this.timeoutSeconds = timeoutSeconds; return this; @@ -96,6 +98,7 @@ public class TransformerAndroidTestRunner { * @param maybeCalculateSsim Whether to try to calculate SSIM. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setMaybeCalculateSsim(boolean maybeCalculateSsim) { this.maybeCalculateSsim = maybeCalculateSsim; return this; @@ -115,6 +118,7 @@ public class TransformerAndroidTestRunner { * @param suppressAnalysisExceptions Whether to suppress analysis exceptions. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setSuppressAnalysisExceptions(boolean suppressAnalysisExceptions) { this.suppressAnalysisExceptions = suppressAnalysisExceptions; return this; @@ -130,6 +134,7 @@ public class TransformerAndroidTestRunner { * @param inputValues A {@link Map} of values to be written to the transformation summary. * @return This {@link Builder}. */ + @CanIgnoreReturnValue public Builder setInputValues(@Nullable Map inputValues) { this.inputValues = inputValues; return this; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultEncoderFactory.java b/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultEncoderFactory.java index a1df6d6934..e9ec7c0a27 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultEncoderFactory.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/DefaultEncoderFactory.java @@ -38,6 +38,7 @@ import androidx.media3.common.util.MediaFormatUtil; import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.ArrayList; import java.util.List; import org.checkerframework.checker.nullness.qual.RequiresNonNull; @@ -71,6 +72,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory { * *

The default value is {@link EncoderSelector#DEFAULT}. */ + @CanIgnoreReturnValue public Builder setVideoEncoderSelector(EncoderSelector encoderSelector) { this.encoderSelector = encoderSelector; return this; @@ -93,6 +95,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory { * *

The default value is {@link VideoEncoderSettings#DEFAULT}. */ + @CanIgnoreReturnValue public Builder setRequestedVideoEncoderSettings( VideoEncoderSettings requestedVideoEncoderSettings) { this.requestedVideoEncoderSettings = requestedVideoEncoderSettings; @@ -110,6 +113,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory { * *

The default value is {@code true}. */ + @CanIgnoreReturnValue public Builder setEnableFallback(boolean enableFallback) { this.enableFallback = enableFallback; return this; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/ScaleToFitTransformation.java b/libraries/transformer/src/main/java/androidx/media3/transformer/ScaleToFitTransformation.java index cf69a25896..4f586630ed 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/ScaleToFitTransformation.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/ScaleToFitTransformation.java @@ -24,6 +24,7 @@ import android.graphics.Matrix; import android.util.Size; import androidx.media3.common.util.GlUtil; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** @@ -61,6 +62,7 @@ public final class ScaleToFitTransformation implements MatrixTransformation { * @param scaleY The multiplier by which the frame will scale vertically, along the y-axis. * @return This builder. */ + @CanIgnoreReturnValue public Builder setScale(float scaleX, float scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; @@ -75,6 +77,7 @@ public final class ScaleToFitTransformation implements MatrixTransformation { * @param rotationDegrees The counterclockwise rotation, in degrees. * @return This builder. */ + @CanIgnoreReturnValue public Builder setRotationDegrees(float rotationDegrees) { this.rotationDegrees = rotationDegrees; return this; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationRequest.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationRequest.java index 0d114287e1..bfd86e5535 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationRequest.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationRequest.java @@ -25,6 +25,7 @@ import androidx.media3.common.util.UnstableApi; import androidx.media3.common.util.Util; import androidx.media3.exoplayer.source.MediaSource; import androidx.media3.extractor.mp4.Mp4Extractor; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** A media transformation request. */ @UnstableApi @@ -96,6 +97,7 @@ public final class TransformationRequest { * @param flattenForSlowMotion Whether to flatten for slow motion. * @return This builder. */ + @CanIgnoreReturnValue public Builder setFlattenForSlowMotion(boolean flattenForSlowMotion) { this.flattenForSlowMotion = flattenForSlowMotion; return this; @@ -112,6 +114,7 @@ public final class TransformationRequest { * @param scaleY The multiplier by which the frame will scale vertically, along the y-axis. * @return This builder. */ + @CanIgnoreReturnValue public Builder setScale(float scaleX, float scaleY) { this.scaleX = scaleX; this.scaleY = scaleY; @@ -130,6 +133,7 @@ public final class TransformationRequest { * @param rotationDegrees The counterclockwise rotation, in degrees. * @return This builder. */ + @CanIgnoreReturnValue public Builder setRotationDegrees(float rotationDegrees) { this.rotationDegrees = rotationDegrees; return this; @@ -150,6 +154,7 @@ public final class TransformationRequest { * @param outputHeight The output height of the displayed video, in pixels. * @return This builder. */ + @CanIgnoreReturnValue public Builder setResolution(int outputHeight) { this.outputHeight = outputHeight; return this; @@ -173,6 +178,7 @@ public final class TransformationRequest { * @throws IllegalArgumentException If the {@code videoMimeType} is non-null but not a video * {@linkplain MimeTypes MIME type}. */ + @CanIgnoreReturnValue public Builder setVideoMimeType(@Nullable String videoMimeType) { checkArgument( videoMimeType == null || MimeTypes.isVideo(videoMimeType), @@ -198,6 +204,7 @@ public final class TransformationRequest { * @throws IllegalArgumentException If the {@code audioMimeType} is non-null but not an audio * {@linkplain MimeTypes MIME type}. */ + @CanIgnoreReturnValue public Builder setAudioMimeType(@Nullable String audioMimeType) { checkArgument( audioMimeType == null || MimeTypes.isAudio(audioMimeType), @@ -217,6 +224,7 @@ public final class TransformationRequest { * @param enableRequestSdrToneMapping Whether to request tone-mapping down to SDR. * @return This builder. */ + @CanIgnoreReturnValue public Builder setEnableRequestSdrToneMapping(boolean enableRequestSdrToneMapping) { this.enableRequestSdrToneMapping = enableRequestSdrToneMapping; return this; @@ -235,6 +243,7 @@ public final class TransformationRequest { * dynamic range (HDR) signal. * @return This builder. */ + @CanIgnoreReturnValue public Builder experimental_setEnableHdrEditing(boolean enableHdrEditing) { this.enableHdrEditing = enableHdrEditing; return this; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationResult.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationResult.java index 7aba68e647..c13b63edf6 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationResult.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformationResult.java @@ -20,6 +20,7 @@ import static androidx.media3.common.util.Assertions.checkArgument; import androidx.annotation.Nullable; import androidx.media3.common.C; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; /** Information about the result of a successful transformation. */ @UnstableApi @@ -45,6 +46,7 @@ public final class TransformationResult { * *

Input must be positive or {@link C#TIME_UNSET}. */ + @CanIgnoreReturnValue public Builder setDurationMs(long durationMs) { checkArgument(durationMs > 0 || durationMs == C.TIME_UNSET); this.durationMs = durationMs; @@ -56,6 +58,7 @@ public final class TransformationResult { * *

Input must be positive or {@link C#LENGTH_UNSET}. */ + @CanIgnoreReturnValue public Builder setFileSizeBytes(long fileSizeBytes) { checkArgument(fileSizeBytes > 0 || fileSizeBytes == C.LENGTH_UNSET); this.fileSizeBytes = fileSizeBytes; @@ -67,6 +70,7 @@ public final class TransformationResult { * *

Input must be positive or {@link C#RATE_UNSET_INT}. */ + @CanIgnoreReturnValue public Builder setAverageAudioBitrate(int averageAudioBitrate) { checkArgument(averageAudioBitrate > 0 || averageAudioBitrate == C.RATE_UNSET_INT); this.averageAudioBitrate = averageAudioBitrate; @@ -78,6 +82,7 @@ public final class TransformationResult { * *

Input must be positive or {@link C#RATE_UNSET_INT}. */ + @CanIgnoreReturnValue public Builder setAverageVideoBitrate(int averageVideoBitrate) { checkArgument(averageVideoBitrate > 0 || averageVideoBitrate == C.RATE_UNSET_INT); this.averageVideoBitrate = averageVideoBitrate; @@ -89,6 +94,7 @@ public final class TransformationResult { * *

Input must be positive or {@code 0}. */ + @CanIgnoreReturnValue public Builder setVideoFrameCount(int videoFrameCount) { checkArgument(videoFrameCount >= 0); this.videoFrameCount = videoFrameCount; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java index 8332cbc4c5..0016bf3591 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java @@ -59,6 +59,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener; import androidx.media3.extractor.DefaultExtractorsFactory; import androidx.media3.extractor.mp4.Mp4Extractor; import com.google.common.collect.ImmutableList; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.lang.annotation.Documented; @@ -157,6 +158,7 @@ public final class Transformer { * @param transformationRequest The {@link TransformationRequest}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setTransformationRequest(TransformationRequest transformationRequest) { this.transformationRequest = transformationRequest; return this; @@ -175,6 +177,7 @@ public final class Transformer { * @param effects The {@linkplain GlEffect effects} to apply to each video frame. * @return This builder. */ + @CanIgnoreReturnValue public Builder setVideoEffects(List effects) { this.videoEffects = ImmutableList.copyOf(effects); return this; @@ -189,6 +192,7 @@ public final class Transformer { * @param mediaSourceFactory A {@link MediaSource.Factory}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setMediaSourceFactory(MediaSource.Factory mediaSourceFactory) { this.mediaSourceFactory = mediaSourceFactory; return this; @@ -205,6 +209,7 @@ public final class Transformer { * @param removeAudio Whether to remove the audio. * @return This builder. */ + @CanIgnoreReturnValue public Builder setRemoveAudio(boolean removeAudio) { this.removeAudio = removeAudio; return this; @@ -221,6 +226,7 @@ public final class Transformer { * @param removeVideo Whether to remove the video. * @return This builder. */ + @CanIgnoreReturnValue public Builder setRemoveVideo(boolean removeVideo) { this.removeVideo = removeVideo; return this; @@ -230,6 +236,7 @@ public final class Transformer { * @deprecated Use {@link TransformationRequest.Builder#setFlattenForSlowMotion(boolean)} * instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setFlattenForSlowMotion(boolean flattenForSlowMotion) { transformationRequest = @@ -241,6 +248,7 @@ public final class Transformer { * @deprecated This feature will be removed in a following release and the MIME type of the * output will always be MP4. */ + @CanIgnoreReturnValue @Deprecated public Builder setOutputMimeType(String outputMimeType) { this.containerMimeType = outputMimeType; @@ -251,6 +259,7 @@ public final class Transformer { * @deprecated Use {@link #addListener(Listener)}, {@link #removeListener(Listener)} or {@link * #removeAllListeners()} instead. */ + @CanIgnoreReturnValue @Deprecated public Builder setListener(Transformer.Listener listener) { this.listeners.clear(); @@ -266,6 +275,7 @@ public final class Transformer { * @param listener A {@link Transformer.Listener}. * @return This builder. */ + @CanIgnoreReturnValue public Builder addListener(Transformer.Listener listener) { this.listeners.add(listener); return this; @@ -279,6 +289,7 @@ public final class Transformer { * @param listener A {@link Transformer.Listener}. * @return This builder. */ + @CanIgnoreReturnValue public Builder removeListener(Transformer.Listener listener) { this.listeners.remove(listener); return this; @@ -291,6 +302,7 @@ public final class Transformer { * * @return This builder. */ + @CanIgnoreReturnValue public Builder removeAllListeners() { this.listeners.clear(); return this; @@ -306,6 +318,7 @@ public final class Transformer { * @param looper A {@link Looper}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setLooper(Looper looper) { this.looper = looper; this.listeners = listeners.copy(looper, (listener, flags) -> {}); @@ -320,6 +333,7 @@ public final class Transformer { * @param encoderFactory The {@link Codec.EncoderFactory} instance. * @return This builder. */ + @CanIgnoreReturnValue public Builder setEncoderFactory(Codec.EncoderFactory encoderFactory) { this.encoderFactory = encoderFactory; return this; @@ -333,6 +347,7 @@ public final class Transformer { * @param decoderFactory The {@link Codec.DecoderFactory} instance. * @return This builder. */ + @CanIgnoreReturnValue public Builder setDecoderFactory(Codec.DecoderFactory decoderFactory) { this.decoderFactory = decoderFactory; return this; @@ -350,6 +365,7 @@ public final class Transformer { * @param debugViewProvider Provider for debug views. * @return This builder. */ + @CanIgnoreReturnValue public Builder setDebugViewProvider(DebugViewProvider debugViewProvider) { this.debugViewProvider = debugViewProvider; return this; @@ -363,6 +379,7 @@ public final class Transformer { * @param clock The {@link Clock} instance. * @return This builder. */ + @CanIgnoreReturnValue @VisibleForTesting /* package */ Builder setClock(Clock clock) { this.clock = clock; @@ -378,6 +395,7 @@ public final class Transformer { * @param muxerFactory A {@link Muxer.Factory}. * @return This builder. */ + @CanIgnoreReturnValue @VisibleForTesting /* package */ Builder setMuxerFactory(Muxer.Factory muxerFactory) { this.muxerFactory = muxerFactory; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/VideoEncoderSettings.java b/libraries/transformer/src/main/java/androidx/media3/transformer/VideoEncoderSettings.java index d8c42784d1..c41ee71a06 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/VideoEncoderSettings.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/VideoEncoderSettings.java @@ -30,6 +30,7 @@ import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import androidx.media3.common.Format; import androidx.media3.common.util.UnstableApi; +import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -106,6 +107,7 @@ public final class VideoEncoderSettings { * @param bitrate The {@link VideoEncoderSettings#bitrate}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setBitrate(int bitrate) { this.bitrate = bitrate; return this; @@ -120,6 +122,7 @@ public final class VideoEncoderSettings { * @param bitrateMode The {@link VideoEncoderSettings#bitrateMode}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setBitrateMode(@BitrateMode int bitrateMode) { checkArgument(bitrateMode == BITRATE_MODE_VBR || bitrateMode == BITRATE_MODE_CBR); this.bitrateMode = bitrateMode; @@ -140,6 +143,7 @@ public final class VideoEncoderSettings { * @param encodingLevel The {@link VideoEncoderSettings#level}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setEncodingProfileLevel(int encodingProfile, int encodingLevel) { this.profile = encodingProfile; this.level = encodingLevel; @@ -153,6 +157,7 @@ public final class VideoEncoderSettings { * @param iFrameIntervalSeconds The {@link VideoEncoderSettings#iFrameIntervalSeconds}. * @return This builder. */ + @CanIgnoreReturnValue public Builder setiFrameIntervalSeconds(float iFrameIntervalSeconds) { this.iFrameIntervalSeconds = iFrameIntervalSeconds; return this; @@ -166,6 +171,7 @@ public final class VideoEncoderSettings { * @param priority The {@link MediaFormat#KEY_PRIORITY priority}. * @return This builder. */ + @CanIgnoreReturnValue @VisibleForTesting public Builder setEncoderPerformanceParameters(int operatingRate, int priority) { this.operatingRate = operatingRate; @@ -182,6 +188,7 @@ public final class VideoEncoderSettings { * *

Can not be enabled alongside setting a custom bitrate with {@link #setBitrate(int)}. */ + @CanIgnoreReturnValue public Builder setEnableHighQualityTargeting(boolean enableHighQualityTargeting) { this.enableHighQualityTargeting = enableHighQualityTargeting; return this;