Commit 57dbf22b by ibaker Committed by microkatz

Annotate methods that always return `this` with `@CanIgnoreReturnValue`

It's always safe to ignore the result of these methods, because the
caller already has a reference to the returned value.

PiperOrigin-RevId: 462388947
(cherry picked from commit 21cab612)
parent 8f305631
Showing with 618 additions and 0 deletions
......@@ -24,6 +24,7 @@ dependencies {
implementation project(modulePrefix + 'library-common')
implementation project(modulePrefix + 'library-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
......
......@@ -41,6 +41,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;
......@@ -140,6 +141,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLIS;
}
@CanIgnoreReturnValue
@Override
public final Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties) {
this.defaultRequestProperties.clearAndSet(defaultRequestProperties);
......@@ -159,6 +161,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* agent of the underlying {@link CronetEngine}.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setUserAgent(@Nullable String userAgent) {
this.userAgent = userAgent;
if (internalFallbackFactory != null) {
......@@ -177,6 +180,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* UrlRequest.Builder#REQUEST_PRIORITY_*} constants.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setRequestPriority(int requestPriority) {
this.requestPriority = requestPriority;
return this;
......@@ -190,6 +194,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* @param connectTimeoutMs The connect timeout, in milliseconds, that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setConnectionTimeoutMs(int connectTimeoutMs) {
this.connectTimeoutMs = connectTimeoutMs;
if (internalFallbackFactory != null) {
......@@ -206,6 +211,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* @param resetTimeoutOnRedirects Whether the connect timeout is reset when a redirect occurs.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setResetTimeoutOnRedirects(boolean resetTimeoutOnRedirects) {
this.resetTimeoutOnRedirects = resetTimeoutOnRedirects;
return this;
......@@ -221,6 +227,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* to the redirect url in the "Cookie" header.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setHandleSetCookieRequests(boolean handleSetCookieRequests) {
this.handleSetCookieRequests = handleSetCookieRequests;
return this;
......@@ -234,6 +241,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* @param readTimeoutMs The connect timeout, in milliseconds, that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setReadTimeoutMs(int readTimeoutMs) {
this.readTimeoutMs = readTimeoutMs;
if (internalFallbackFactory != null) {
......@@ -252,6 +260,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* predicate that was previously set.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
this.contentTypePredicate = contentTypePredicate;
if (internalFallbackFactory != null) {
......@@ -264,6 +273,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
public Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects) {
this.keepPostFor302Redirects = keepPostFor302Redirects;
if (internalFallbackFactory != null) {
......@@ -282,6 +292,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
* @param transferListener The listener that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setTransferListener(@Nullable TransferListener transferListener) {
this.transferListener = transferListener;
if (internalFallbackFactory != null) {
......@@ -301,6 +312,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
@Deprecated
public Factory setFallbackFactory(@Nullable HttpDataSource.Factory fallbackFactory) {
this.fallbackFactory = fallbackFactory;
......
......@@ -28,6 +28,7 @@ dependencies {
api 'com.google.ads.interactivemedia.v3:interactivemedia:3.26.0'
implementation project(modulePrefix + 'library-core')
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 + 'testutils')
......
......@@ -55,6 +55,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
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;
......@@ -151,6 +152,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @param imaSdkSettings The {@link ImaSdkSettings}.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setImaSdkSettings(ImaSdkSettings imaSdkSettings) {
this.imaSdkSettings = checkNotNull(imaSdkSettings);
return this;
......@@ -164,6 +166,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @param adErrorListener The ad error listener.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setAdErrorListener(AdErrorListener adErrorListener) {
this.adErrorListener = checkNotNull(adErrorListener);
return this;
......@@ -176,6 +179,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @param adEventListener The ad event listener.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setAdEventListener(AdEventListener adEventListener) {
this.adEventListener = checkNotNull(adEventListener);
return this;
......@@ -191,6 +195,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback
*/
@CanIgnoreReturnValue
public Builder setVideoAdPlayerCallback(
VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback) {
this.videoAdPlayerCallback = checkNotNull(videoAdPlayerCallback);
......@@ -204,6 +209,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRenderingSettings#setUiElements(Set)
*/
@CanIgnoreReturnValue
public Builder setAdUiElements(Set<UiElement> adUiElements) {
this.adUiElements = ImmutableSet.copyOf(checkNotNull(adUiElements));
return this;
......@@ -216,6 +222,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdDisplayContainer#setCompanionSlots(Collection)
*/
@CanIgnoreReturnValue
public Builder setCompanionAdSlots(Collection<CompanionAdSlot> companionAdSlots) {
this.companionAdSlots = ImmutableList.copyOf(checkNotNull(companionAdSlots));
return this;
......@@ -233,6 +240,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRenderingSettings#setMimeTypes(List)
*/
@CanIgnoreReturnValue
public Builder setAdMediaMimeTypes(List<String> adMediaMimeTypes) {
this.adMediaMimeTypes = ImmutableList.copyOf(checkNotNull(adMediaMimeTypes));
return this;
......@@ -247,6 +255,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRequest#setContinuousPlayback(boolean)
*/
@CanIgnoreReturnValue
public Builder setEnableContinuousPlayback(boolean enableContinuousPlayback) {
this.enableContinuousPlayback = enableContinuousPlayback;
return this;
......@@ -265,6 +274,7 @@ public final class ImaAdsLoader implements AdsLoader {
* C#TIME_UNSET} for no timeout.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setAdPreloadTimeoutMs(long adPreloadTimeoutMs) {
checkArgument(adPreloadTimeoutMs == C.TIME_UNSET || adPreloadTimeoutMs > 0);
this.adPreloadTimeoutMs = adPreloadTimeoutMs;
......@@ -278,6 +288,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRequest#setVastLoadTimeout(float)
*/
@CanIgnoreReturnValue
public Builder setVastLoadTimeoutMs(@IntRange(from = 1) int vastLoadTimeoutMs) {
checkArgument(vastLoadTimeoutMs > 0);
this.vastLoadTimeoutMs = vastLoadTimeoutMs;
......@@ -291,6 +302,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRenderingSettings#setLoadVideoTimeout(int)
*/
@CanIgnoreReturnValue
public Builder setMediaLoadTimeoutMs(@IntRange(from = 1) int mediaLoadTimeoutMs) {
checkArgument(mediaLoadTimeoutMs > 0);
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
......@@ -304,6 +316,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRenderingSettings#setBitrateKbps(int)
*/
@CanIgnoreReturnValue
public Builder setMaxMediaBitrate(@IntRange(from = 1) int bitrate) {
checkArgument(bitrate > 0);
this.mediaBitrate = bitrate;
......@@ -319,6 +332,7 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see AdsRenderingSettings#setFocusSkipButtonWhenAvailable(boolean)
*/
@CanIgnoreReturnValue
public Builder setFocusSkipButtonWhenAvailable(boolean focusSkipButtonWhenAvailable) {
this.focusSkipButtonWhenAvailable = focusSkipButtonWhenAvailable;
return this;
......@@ -334,6 +348,7 @@ public final class ImaAdsLoader implements AdsLoader {
* beginning playback.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setPlayAdBeforeStartPosition(boolean playAdBeforeStartPosition) {
this.playAdBeforeStartPosition = playAdBeforeStartPosition;
return this;
......@@ -349,11 +364,13 @@ public final class ImaAdsLoader implements AdsLoader {
* @return This builder, for convenience.
* @see ImaSdkSettings#setDebugMode(boolean)
*/
@CanIgnoreReturnValue
public Builder setDebugModeEnabled(boolean debugModeEnabled) {
this.debugModeEnabled = debugModeEnabled;
return this;
}
@CanIgnoreReturnValue
@VisibleForTesting
/* package */ Builder setImaFactory(ImaUtil.ImaFactory imaFactory) {
this.imaFactory = checkNotNull(imaFactory);
......
......@@ -92,6 +92,7 @@ import com.google.android.exoplayer2.util.ConditionVariable;
import com.google.android.exoplayer2.util.Util;
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;
......@@ -132,6 +133,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
this.contentMediaSourceFactory = contentMediaSourceFactory;
}
@CanIgnoreReturnValue
@Override
public MediaSource.Factory setLoadErrorHandlingPolicy(
LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
......@@ -139,6 +141,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
return this;
}
@CanIgnoreReturnValue
@Override
public MediaSource.Factory setDrmSessionManagerProvider(
DrmSessionManagerProvider drmSessionManagerProvider) {
......@@ -213,6 +216,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;
......@@ -225,6 +229,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;
......@@ -237,6 +242,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;
......@@ -249,6 +255,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
* @return This builder, for convenience.
* @see AdDisplayContainer#setCompanionSlots(Collection)
*/
@CanIgnoreReturnValue
public AdsLoader.Builder setCompanionAdSlots(Collection<CompanionAdSlot> companionAdSlots) {
this.companionAdSlots = ImmutableList.copyOf(companionAdSlots);
return this;
......@@ -262,6 +269,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;
......
......@@ -28,6 +28,7 @@ import com.google.ads.interactivemedia.v3.api.StreamRequest.StreamFormat;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.C.ContentType;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.HashMap;
import java.util.Map;
......@@ -83,6 +84,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;
......@@ -94,6 +96,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;
......@@ -107,6 +110,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;
......@@ -118,6 +122,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;
......@@ -129,6 +134,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;
......@@ -140,6 +146,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;
......@@ -154,6 +161,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;
......@@ -167,6 +175,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;
......@@ -185,6 +194,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<String, String> adTagParameters) {
this.adTagParameters = ImmutableMap.copyOf(adTagParameters);
......@@ -198,6 +208,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;
......@@ -211,6 +222,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;
......@@ -224,6 +236,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;
......
......@@ -18,6 +18,7 @@ dependencies {
implementation 'androidx.collection:collection:' + androidxCollectionVersion
implementation 'androidx.concurrent:concurrent-futures:' + androidxFuturesVersion
api 'androidx.media2:media2-session:' + androidxMedia2Version
compileOnly 'com.google.errorprone:error_prone_annotations:' + errorProneVersion
compileOnly 'org.checkerframework:checker-compat-qual:' + checkerframeworkCompatVersion
compileOnly 'org.checkerframework:checker-qual:' + checkerframeworkVersion
compileOnly 'org.jetbrains.kotlin:kotlin-annotations-jvm:' + kotlinAnnotationsVersion
......
......@@ -36,6 +36,7 @@ import androidx.media2.session.SessionCommand;
import androidx.media2.session.SessionCommandGroup;
import androidx.media2.session.SessionResult;
import com.google.android.exoplayer2.util.Assertions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.List;
......@@ -394,6 +395,7 @@ public final class SessionCallbackBuilder {
* @see MediaSession.SessionCallback#onSetRating(MediaSession, ControllerInfo, String, Rating)
* @see androidx.media2.session.MediaController#setRating(String, Rating)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setRatingCallback(@Nullable RatingCallback ratingCallback) {
this.ratingCallback = ratingCallback;
return this;
......@@ -408,6 +410,7 @@ public final class SessionCallbackBuilder {
* Bundle)
* @see androidx.media2.session.MediaController#sendCustomCommand(SessionCommand, Bundle)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setCustomCommandProvider(
@Nullable CustomCommandProvider customCommandProvider) {
this.customCommandProvider = customCommandProvider;
......@@ -425,6 +428,7 @@ public final class SessionCallbackBuilder {
* @see androidx.media2.session.MediaController#setMediaItem(String)
* @see androidx.media2.session.MediaController#setPlaylist(List, MediaMetadata)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setMediaItemProvider(
@Nullable MediaItemProvider mediaItemProvider) {
this.mediaItemProvider = mediaItemProvider;
......@@ -437,6 +441,7 @@ public final class SessionCallbackBuilder {
* @param allowedCommandProvider A allowed command provider.
* @return This builder.
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setAllowedCommandProvider(
@Nullable AllowedCommandProvider allowedCommandProvider) {
this.allowedCommandProvider = allowedCommandProvider;
......@@ -453,6 +458,7 @@ public final class SessionCallbackBuilder {
* @see MediaController#skipBackward()
* @see MediaController#skipForward()
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setSkipCallback(@Nullable SkipCallback skipCallback) {
this.skipCallback = skipCallback;
return this;
......@@ -465,6 +471,7 @@ public final class SessionCallbackBuilder {
* @return This builder.
* @see MediaSession.SessionCallback#onPostConnect(MediaSession, ControllerInfo)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setPostConnectCallback(
@Nullable PostConnectCallback postConnectCallback) {
this.postConnectCallback = postConnectCallback;
......@@ -478,6 +485,7 @@ public final class SessionCallbackBuilder {
* @return This builder.
* @see MediaSession.SessionCallback#onDisconnected(MediaSession, ControllerInfo)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setDisconnectedCallback(
@Nullable DisconnectedCallback disconnectedCallback) {
this.disconnectedCallback = disconnectedCallback;
......@@ -493,6 +501,7 @@ public final class SessionCallbackBuilder {
* @see MediaSession.SessionCallback#onRewind(MediaSession, MediaSession.ControllerInfo)
* @see #setSeekTimeoutMs(int)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setRewindIncrementMs(int rewindMs) {
this.rewindMs = rewindMs;
return this;
......@@ -507,6 +516,7 @@ public final class SessionCallbackBuilder {
* @see MediaSession.SessionCallback#onFastForward(MediaSession, MediaSession.ControllerInfo)
* @see #setSeekTimeoutMs(int)
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setFastForwardIncrementMs(int fastForwardMs) {
this.fastForwardMs = fastForwardMs;
return this;
......@@ -521,6 +531,7 @@ public final class SessionCallbackBuilder {
* forever.
* @return This builder.
*/
@CanIgnoreReturnValue
public SessionCallbackBuilder setSeekTimeoutMs(int seekTimeoutMs) {
this.seekTimeoutMs = seekTimeoutMs;
return this;
......
......@@ -19,6 +19,7 @@ dependencies {
implementation project(modulePrefix + 'library-common')
implementation project(modulePrefix + 'library-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 + 'testutils')
......
......@@ -39,6 +39,7 @@ import com.google.android.exoplayer2.util.Util;
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;
......@@ -93,6 +94,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
defaultRequestProperties = new RequestProperties();
}
@CanIgnoreReturnValue
@Override
public final Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties) {
this.defaultRequestProperties.clearAndSet(defaultRequestProperties);
......@@ -109,6 +111,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
* agent of the underlying {@link OkHttpClient}.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setUserAgent(@Nullable String userAgent) {
this.userAgent = userAgent;
return this;
......@@ -122,6 +125,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
* @param cacheControl The cache control that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setCacheControl(@Nullable CacheControl cacheControl) {
this.cacheControl = cacheControl;
return this;
......@@ -138,6 +142,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
* predicate that was previously set.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
this.contentTypePredicate = contentTypePredicate;
return this;
......@@ -153,6 +158,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
* @param transferListener The listener that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setTransferListener(@Nullable TransferListener transferListener) {
this.transferListener = transferListener;
return this;
......
......@@ -18,6 +18,7 @@ dependencies {
implementation project(modulePrefix + 'library-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 + 'library-core')
testImplementation project(modulePrefix + 'testutils')
......
......@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.upstream.BaseDataSource;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.antmedia.rtmp_client.RtmpClient;
import io.antmedia.rtmp_client.RtmpClient.RtmpIOException;
import java.io.IOException;
......@@ -51,6 +52,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;
......
......@@ -29,6 +29,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.metadata.Metadata;
import com.google.android.exoplayer2.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 {
*
* <p>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
@Deprecated
public Builder setArtworkData(@Nullable byte[] artworkData) {
return setArtworkData(artworkData, /* artworkDataType= */ null);
......@@ -184,6 +195,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();
......@@ -199,6 +211,7 @@ public final class MediaMetadata implements Bundleable {
* <p>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)
......@@ -210,30 +223,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;
......@@ -242,12 +260,14 @@ public final class MediaMetadata implements Bundleable {
/**
* @deprecated Use {@link #setRecordingYear(Integer)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setYear(@Nullable Integer year) {
return setRecordingYear(year);
}
/** Sets the year of the recording date. */
@CanIgnoreReturnValue
public Builder setRecordingYear(@Nullable Integer recordingYear) {
this.recordingYear = recordingYear;
return this;
......@@ -258,6 +278,7 @@ public final class MediaMetadata implements Bundleable {
*
* <p>Value should be between 1 and 12.
*/
@CanIgnoreReturnValue
public Builder setRecordingMonth(
@Nullable @IntRange(from = 1, to = 12) Integer recordingMonth) {
this.recordingMonth = recordingMonth;
......@@ -269,12 +290,14 @@ public final class MediaMetadata implements Bundleable {
*
* <p>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;
......@@ -285,6 +308,7 @@ public final class MediaMetadata implements Bundleable {
*
* <p>Value should be between 1 and 12.
*/
@CanIgnoreReturnValue
public Builder setReleaseMonth(@Nullable @IntRange(from = 1, to = 12) Integer releaseMonth) {
this.releaseMonth = releaseMonth;
return this;
......@@ -295,60 +319,70 @@ public final class MediaMetadata implements Bundleable {
*
* <p>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;
......@@ -363,6 +397,7 @@ public final class MediaMetadata implements Bundleable {
* <p>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
public Builder populateFromMetadata(Metadata metadata) {
for (int i = 0; i < metadata.length(); i++) {
Metadata.Entry entry = metadata.get(i);
......@@ -381,6 +416,7 @@ public final class MediaMetadata implements Bundleable {
* <p>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
public Builder populateFromMetadata(List<Metadata> metadataList) {
for (int i = 0; i < metadataList.size(); i++) {
Metadata metadata = metadataList.get(i);
......@@ -393,6 +429,7 @@ public final class MediaMetadata implements Bundleable {
}
/** Populates all the fields from {@code mediaMetadata}, provided they are non-null. */
@CanIgnoreReturnValue
public Builder populate(@Nullable MediaMetadata mediaMetadata) {
if (mediaMetadata == null) {
return this;
......
......@@ -40,6 +40,7 @@ import com.google.android.exoplayer2.util.FlagSet;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoSize;
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;
......@@ -405,6 +406,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;
......@@ -418,6 +420,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;
......@@ -430,6 +433,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;
......@@ -442,6 +446,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;
......@@ -453,6 +458,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;
......@@ -465,6 +471,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;
......@@ -478,6 +485,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;
......@@ -490,6 +498,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;
......
......@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.BundleUtil;
import com.google.android.exoplayer2.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
@SuppressWarnings("deprecation")
public Window set(
Object uid,
......@@ -624,6 +626,7 @@ public abstract class Timeline implements Bundleable {
* period is not within the window.
* @return This period, for convenience.
*/
@CanIgnoreReturnValue
public Period set(
@Nullable Object id,
@Nullable Object uid,
......@@ -659,6 +662,7 @@ public abstract class Timeline implements Bundleable {
* information has yet to be loaded.
* @return This period, for convenience.
*/
@CanIgnoreReturnValue
public Period set(
@Nullable Object id,
@Nullable Object uid,
......
......@@ -25,6 +25,7 @@ import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.Bundleable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -95,30 +96,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;
......
......@@ -35,6 +35,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Bundleable;
import com.google.android.exoplayer2.util.Assertions;
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;
......@@ -621,6 +622,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#text
*/
@CanIgnoreReturnValue
public Builder setText(CharSequence text) {
this.text = text;
return this;
......@@ -642,6 +644,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#bitmap
*/
@CanIgnoreReturnValue
public Builder setBitmap(Bitmap bitmap) {
this.bitmap = bitmap;
return this;
......@@ -665,6 +668,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#textAlignment
*/
@CanIgnoreReturnValue
public Builder setTextAlignment(@Nullable Layout.Alignment textAlignment) {
this.textAlignment = textAlignment;
return this;
......@@ -688,6 +692,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#multiRowAlignment
*/
@CanIgnoreReturnValue
public Builder setMultiRowAlignment(@Nullable Layout.Alignment multiRowAlignment) {
this.multiRowAlignment = multiRowAlignment;
return this;
......@@ -700,6 +705,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;
......@@ -732,6 +738,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#lineAnchor
*/
@CanIgnoreReturnValue
public Builder setLineAnchor(@AnchorType int lineAnchor) {
this.lineAnchor = lineAnchor;
return this;
......@@ -753,6 +760,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#position
*/
@CanIgnoreReturnValue
public Builder setPosition(float position) {
this.position = position;
return this;
......@@ -774,6 +782,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#positionAnchor
*/
@CanIgnoreReturnValue
public Builder setPositionAnchor(@AnchorType int positionAnchor) {
this.positionAnchor = positionAnchor;
return this;
......@@ -795,6 +804,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;
......@@ -827,6 +837,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#size
*/
@CanIgnoreReturnValue
public Builder setSize(float size) {
this.size = size;
return this;
......@@ -848,6 +859,7 @@ public final class Cue implements Bundleable {
*
* @see Cue#bitmapHeight
*/
@CanIgnoreReturnValue
public Builder setBitmapHeight(float bitmapHeight) {
this.bitmapHeight = bitmapHeight;
return this;
......@@ -871,6 +883,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;
......@@ -878,6 +891,7 @@ public final class Cue implements Bundleable {
}
/** Sets {@link Cue#windowColorSet} to false. */
@CanIgnoreReturnValue
public Builder clearWindowColor() {
this.windowColorSet = false;
return this;
......@@ -908,12 +922,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;
......
......@@ -24,6 +24,7 @@ import static java.lang.annotation.ElementType.TYPE_USE;
import android.view.View;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -76,6 +77,7 @@ public final class AdOverlayInfo {
*
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setDetailedReason(@Nullable String detailedReason) {
this.detailedReason = detailedReason;
return this;
......
......@@ -20,6 +20,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkState;
import android.util.SparseBooleanArray;
import androidx.annotation.Nullable;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/**
* A set of integer flags.
......@@ -50,6 +51,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);
......@@ -64,6 +66,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);
......@@ -78,6 +81,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);
......@@ -92,6 +96,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));
......@@ -106,6 +111,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);
......@@ -120,6 +126,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);
......@@ -134,6 +141,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);
......
......@@ -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;
......
......@@ -23,6 +23,7 @@ import android.os.SystemClock;
import com.google.android.exoplayer2.MediaItem.LiveConfiguration;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/**
* A {@link LivePlaybackSpeedControl} that adjusts the playback speed using a proportional
......@@ -122,6 +123,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;
......@@ -137,6 +139,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;
......@@ -152,6 +155,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;
......@@ -170,6 +174,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;
......@@ -186,6 +191,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);
......@@ -200,6 +206,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);
......@@ -222,6 +229,7 @@ public final class DefaultLivePlaybackSpeedControl implements LivePlaybackSpeedC
* @param minPossibleLiveOffsetSmoothingFactor The smoothing factor. Must be &ge; 0 and &lt; 1.
* @return This builder, for convenience.
*/
@CanIgnoreReturnValue
public Builder setMinPossibleLiveOffsetSmoothingFactor(
float minPossibleLiveOffsetSmoothingFactor) {
Assertions.checkArgument(
......
......@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.upstream.DefaultAllocator;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/** The default {@link LoadControl} implementation. */
public class DefaultLoadControl implements LoadControl {
......@@ -130,6 +131,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;
......@@ -151,6 +153,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,
......@@ -182,6 +185,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;
......@@ -197,6 +201,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;
......@@ -213,6 +218,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");
......
......@@ -41,6 +41,7 @@ import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.video.MediaCodecVideoRenderer;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
import com.google.android.exoplayer2.video.spherical.CameraMotionRenderer;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -122,6 +123,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;
......@@ -137,6 +139,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
*
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultRenderersFactory forceEnableMediaCodecAsynchronousQueueing() {
codecAdapterFactory.forceEnableAsynchronous();
return this;
......@@ -149,6 +152,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
*
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultRenderersFactory forceDisableMediaCodecAsynchronousQueueing() {
codecAdapterFactory.forceDisableAsynchronous();
return this;
......@@ -163,6 +167,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
* queueing.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultRenderersFactory experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(
boolean enabled) {
codecAdapterFactory.experimentalSetSynchronizeCodecInteractionsWithQueueingEnabled(enabled);
......@@ -177,6 +182,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
* initialization fails.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultRenderersFactory setEnableDecoderFallback(boolean enableDecoderFallback) {
this.enableDecoderFallback = enableDecoderFallback;
return this;
......@@ -190,6 +196,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;
......@@ -206,6 +213,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;
......@@ -228,6 +236,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
* available.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultRenderersFactory setEnableAudioOffload(boolean enableOffload) {
this.enableOffload = enableOffload;
return this;
......@@ -251,6 +260,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;
......@@ -267,6 +277,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;
......
......@@ -63,6 +63,7 @@ import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
/**
......@@ -667,6 +668,7 @@ public interface ExoPlayer extends Player {
*
* @param timeoutMs The time limit in milliseconds.
*/
@CanIgnoreReturnValue
public Builder experimentalSetForegroundModeTimeoutMs(long timeoutMs) {
checkState(!buildCalled);
foregroundModeTimeoutMs = timeoutMs;
......@@ -680,6 +682,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setRenderersFactory(RenderersFactory renderersFactory) {
checkState(!buildCalled);
checkNotNull(renderersFactory);
......@@ -694,6 +697,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);
......@@ -708,6 +712,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setTrackSelector(TrackSelector trackSelector) {
checkState(!buildCalled);
checkNotNull(trackSelector);
......@@ -722,6 +727,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setLoadControl(LoadControl loadControl) {
checkState(!buildCalled);
checkNotNull(loadControl);
......@@ -736,6 +742,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setBandwidthMeter(BandwidthMeter bandwidthMeter) {
checkState(!buildCalled);
checkNotNull(bandwidthMeter);
......@@ -751,6 +758,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setLooper(Looper looper) {
checkState(!buildCalled);
checkNotNull(looper);
......@@ -765,6 +773,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setAnalyticsCollector(AnalyticsCollector analyticsCollector) {
checkState(!buildCalled);
checkNotNull(analyticsCollector);
......@@ -781,6 +790,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setPriorityTaskManager(@Nullable PriorityTaskManager priorityTaskManager) {
checkState(!buildCalled);
this.priorityTaskManager = priorityTaskManager;
......@@ -800,6 +810,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);
......@@ -824,6 +835,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;
......@@ -841,6 +853,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;
......@@ -854,6 +867,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setSkipSilenceEnabled(boolean skipSilenceEnabled) {
checkState(!buildCalled);
this.skipSilenceEnabled = skipSilenceEnabled;
......@@ -870,6 +884,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setVideoScalingMode(@C.VideoScalingMode int videoScalingMode) {
checkState(!buildCalled);
this.videoScalingMode = videoScalingMode;
......@@ -890,6 +905,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setVideoChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) {
checkState(!buildCalled);
......@@ -908,6 +924,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setUseLazyPreparation(boolean useLazyPreparation) {
checkState(!buildCalled);
this.useLazyPreparation = useLazyPreparation;
......@@ -921,6 +938,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setSeekParameters(SeekParameters seekParameters) {
checkState(!buildCalled);
this.seekParameters = checkNotNull(seekParameters);
......@@ -935,6 +953,7 @@ public interface ExoPlayer extends Player {
* @throws IllegalArgumentException If {@code seekBackIncrementMs} is non-positive.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setSeekBackIncrementMs(@IntRange(from = 1) long seekBackIncrementMs) {
checkArgument(seekBackIncrementMs > 0);
checkState(!buildCalled);
......@@ -950,6 +969,7 @@ public interface ExoPlayer extends Player {
* @throws IllegalArgumentException If {@code seekForwardIncrementMs} is non-positive.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setSeekForwardIncrementMs(@IntRange(from = 1) long seekForwardIncrementMs) {
checkArgument(seekForwardIncrementMs > 0);
checkState(!buildCalled);
......@@ -968,6 +988,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setReleaseTimeoutMs(long releaseTimeoutMs) {
checkState(!buildCalled);
this.releaseTimeoutMs = releaseTimeoutMs;
......@@ -985,6 +1006,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setDetachSurfaceTimeoutMs(long detachSurfaceTimeoutMs) {
checkState(!buildCalled);
this.detachSurfaceTimeoutMs = detachSurfaceTimeoutMs;
......@@ -1003,6 +1025,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) {
checkState(!buildCalled);
this.pauseAtEndOfMediaItems = pauseAtEndOfMediaItems;
......@@ -1017,6 +1040,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setLivePlaybackSpeedControl(LivePlaybackSpeedControl livePlaybackSpeedControl) {
checkState(!buildCalled);
this.livePlaybackSpeedControl = checkNotNull(livePlaybackSpeedControl);
......@@ -1038,6 +1062,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
public Builder setUsePlatformDiagnostics(boolean usePlatformDiagnostics) {
checkState(!buildCalled);
this.usePlatformDiagnostics = usePlatformDiagnostics;
......@@ -1052,6 +1077,7 @@ public interface ExoPlayer extends Player {
* @return This builder.
* @throws IllegalStateException If {@link #build()} has already been called.
*/
@CanIgnoreReturnValue
@VisibleForTesting
public Builder setClock(Clock clock) {
checkState(!buildCalled);
......
......@@ -94,6 +94,7 @@ import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.android.exoplayer2.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;
......@@ -386,6 +387,7 @@ import java.util.concurrent.TimeoutException;
}
}
@CanIgnoreReturnValue
@SuppressWarnings("deprecation") // Returning deprecated class.
@Override
@Deprecated
......@@ -394,6 +396,7 @@ import java.util.concurrent.TimeoutException;
return this;
}
@CanIgnoreReturnValue
@SuppressWarnings("deprecation") // Returning deprecated class.
@Override
@Deprecated
......@@ -402,6 +405,7 @@ import java.util.concurrent.TimeoutException;
return this;
}
@CanIgnoreReturnValue
@SuppressWarnings("deprecation") // Returning deprecated class.
@Override
@Deprecated
......@@ -410,6 +414,7 @@ import java.util.concurrent.TimeoutException;
return this;
}
@CanIgnoreReturnValue
@SuppressWarnings("deprecation") // Returning deprecated class.
@Override
@Deprecated
......
......@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Renderer.MessageType;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Clock;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.concurrent.TimeoutException;
/**
......@@ -118,6 +119,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;
......@@ -136,6 +138,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;
......@@ -151,6 +154,7 @@ public final class PlayerMessage {
/**
* @deprecated Use {@link #setLooper(Looper)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public PlayerMessage setHandler(Handler handler) {
return setLooper(handler.getLooper());
......@@ -163,6 +167,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;
......@@ -193,6 +198,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;
......@@ -211,6 +217,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);
......@@ -237,6 +244,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;
......@@ -255,6 +263,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) {
......@@ -271,6 +280,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;
......
......@@ -45,6 +45,7 @@ import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
import com.google.android.exoplayer2.video.VideoSize;
import com.google.android.exoplayer2.video.spherical.CameraMotionListener;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.List;
/**
......@@ -135,6 +136,7 @@ public class SimpleExoPlayer extends BasePlayer
* @deprecated Use {@link ExoPlayer.Builder#experimentalSetForegroundModeTimeoutMs(long)}
* instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder experimentalSetForegroundModeTimeoutMs(long timeoutMs) {
wrappedBuilder.experimentalSetForegroundModeTimeoutMs(timeoutMs);
......@@ -144,6 +146,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setTrackSelector(TrackSelector)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setTrackSelector(TrackSelector trackSelector) {
wrappedBuilder.setTrackSelector(trackSelector);
......@@ -153,6 +156,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);
......@@ -162,6 +166,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setLoadControl(LoadControl)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setLoadControl(LoadControl loadControl) {
wrappedBuilder.setLoadControl(loadControl);
......@@ -171,6 +176,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setBandwidthMeter(BandwidthMeter)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setBandwidthMeter(BandwidthMeter bandwidthMeter) {
wrappedBuilder.setBandwidthMeter(bandwidthMeter);
......@@ -180,6 +186,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setLooper(Looper)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setLooper(Looper looper) {
wrappedBuilder.setLooper(looper);
......@@ -189,6 +196,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setAnalyticsCollector(AnalyticsCollector)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setAnalyticsCollector(AnalyticsCollector analyticsCollector) {
wrappedBuilder.setAnalyticsCollector(analyticsCollector);
......@@ -199,6 +207,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);
......@@ -209,6 +218,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);
......@@ -218,6 +228,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);
......@@ -227,6 +238,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setHandleAudioBecomingNoisy(boolean)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setHandleAudioBecomingNoisy(boolean handleAudioBecomingNoisy) {
wrappedBuilder.setHandleAudioBecomingNoisy(handleAudioBecomingNoisy);
......@@ -236,6 +248,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setSkipSilenceEnabled(boolean)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setSkipSilenceEnabled(boolean skipSilenceEnabled) {
wrappedBuilder.setSkipSilenceEnabled(skipSilenceEnabled);
......@@ -245,6 +258,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);
......@@ -254,6 +268,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setVideoChangeFrameRateStrategy(int)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setVideoChangeFrameRateStrategy(
@C.VideoChangeFrameRateStrategy int videoChangeFrameRateStrategy) {
......@@ -264,6 +279,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setUseLazyPreparation(boolean)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setUseLazyPreparation(boolean useLazyPreparation) {
wrappedBuilder.setUseLazyPreparation(useLazyPreparation);
......@@ -273,6 +289,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setSeekParameters(SeekParameters)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setSeekParameters(SeekParameters seekParameters) {
wrappedBuilder.setSeekParameters(seekParameters);
......@@ -282,6 +299,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);
......@@ -291,6 +309,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);
......@@ -300,6 +319,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setReleaseTimeoutMs(long)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setReleaseTimeoutMs(long releaseTimeoutMs) {
wrappedBuilder.setReleaseTimeoutMs(releaseTimeoutMs);
......@@ -309,6 +329,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setDetachSurfaceTimeoutMs(long)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setDetachSurfaceTimeoutMs(long detachSurfaceTimeoutMs) {
wrappedBuilder.setDetachSurfaceTimeoutMs(detachSurfaceTimeoutMs);
......@@ -318,6 +339,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setPauseAtEndOfMediaItems(boolean)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setPauseAtEndOfMediaItems(boolean pauseAtEndOfMediaItems) {
wrappedBuilder.setPauseAtEndOfMediaItems(pauseAtEndOfMediaItems);
......@@ -328,6 +350,7 @@ public class SimpleExoPlayer extends BasePlayer
* @deprecated Use {@link
* ExoPlayer.Builder#setLivePlaybackSpeedControl(LivePlaybackSpeedControl)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setLivePlaybackSpeedControl(LivePlaybackSpeedControl livePlaybackSpeedControl) {
wrappedBuilder.setLivePlaybackSpeedControl(livePlaybackSpeedControl);
......@@ -337,6 +360,7 @@ public class SimpleExoPlayer extends BasePlayer
/**
* @deprecated Use {@link ExoPlayer.Builder#setClock(Clock)} instead.
*/
@CanIgnoreReturnValue
@Deprecated
@VisibleForTesting
public Builder setClock(Clock clock) {
......
......@@ -48,6 +48,7 @@ import com.google.android.exoplayer2.util.ConditionVariable;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.InlineMe;
import com.google.errorprone.annotations.InlineMeValidationDisabled;
import java.lang.annotation.Documented;
......@@ -277,6 +278,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>Default is {@link AudioCapabilities#DEFAULT_AUDIO_CAPABILITIES}.
*/
@CanIgnoreReturnValue
public Builder setAudioCapabilities(AudioCapabilities audioCapabilities) {
checkNotNull(audioCapabilities);
this.audioCapabilities = audioCapabilities;
......@@ -290,6 +292,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>The default value is an empty array.
*/
@CanIgnoreReturnValue
public Builder setAudioProcessors(AudioProcessor[] audioProcessors) {
checkNotNull(audioProcessors);
return setAudioProcessorChain(new DefaultAudioProcessorChain(audioProcessors));
......@@ -302,6 +305,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>By default, no processing will be applied.
*/
@CanIgnoreReturnValue
public Builder setAudioProcessorChain(AudioProcessorChain audioProcessorChain) {
checkNotNull(audioProcessorChain);
this.audioProcessorChain = audioProcessorChain;
......@@ -316,6 +320,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>The default value is {@code false}.
*/
@CanIgnoreReturnValue
public Builder setEnableFloatOutput(boolean enableFloatOutput) {
this.enableFloatOutput = enableFloatOutput;
return this;
......@@ -329,6 +334,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>The default value is {@code false}.
*/
@CanIgnoreReturnValue
public Builder setEnableAudioTrackPlaybackParams(boolean enableAudioTrackPlaybackParams) {
this.enableAudioTrackPlaybackParams = enableAudioTrackPlaybackParams;
return this;
......@@ -344,6 +350,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>The default value is {@link #OFFLOAD_MODE_DISABLED}.
*/
@CanIgnoreReturnValue
public Builder setOffloadMode(@OffloadMode int offloadMode) {
this.offloadMode = offloadMode;
return this;
......@@ -355,6 +362,7 @@ public final class DefaultAudioSink implements AudioSink {
*
* <p>The default value is {@link AudioTrackBufferSizeProvider#DEFAULT}.
*/
@CanIgnoreReturnValue
public Builder setAudioTrackBufferSizeProvider(
AudioTrackBufferSizeProvider audioTrackBufferSizeProvider) {
this.audioTrackBufferSizeProvider = audioTrackBufferSizeProvider;
......
......@@ -26,6 +26,7 @@ import android.media.AudioTrack;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.audio.DefaultAudioSink.OutputMode;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/** Provide the buffer size to use when creating an {@link AudioTrack}. */
public class DefaultAudioTrackBufferSizeProvider
......@@ -71,6 +72,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;
......@@ -80,6 +82,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;
......@@ -89,6 +92,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;
......@@ -98,6 +102,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;
......@@ -107,6 +112,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;
......@@ -116,6 +122,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;
......
......@@ -45,6 +45,7 @@ import com.google.android.exoplayer2.util.Util;
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;
......@@ -118,6 +119,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
* @param keyRequestParameters A map with parameters.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setKeyRequestParameters(@Nullable Map<String, String> keyRequestParameters) {
this.keyRequestParameters.clear();
if (keyRequestParameters != null) {
......@@ -133,6 +135,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);
......@@ -150,6 +153,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
* sessions.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setMultiSession(boolean multiSession) {
this.multiSession = multiSession;
return this;
......@@ -169,6 +173,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) {
......@@ -187,6 +192,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;
......@@ -198,6 +204,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;
......@@ -218,6 +225,7 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
* in milliseconds. Must be &gt; 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;
......
......@@ -21,6 +21,7 @@ import androidx.annotation.IntDef;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
......@@ -64,6 +65,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter.
*
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaCodecAdapterFactory forceEnableAsynchronous() {
asynchronousMode = MODE_ENABLED;
return this;
......@@ -74,6 +76,7 @@ public final class DefaultMediaCodecAdapterFactory implements MediaCodecAdapter.
*
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaCodecAdapterFactory forceDisableAsynchronous() {
asynchronousMode = MODE_DISABLED;
return this;
......
......@@ -26,6 +26,7 @@ import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.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;
......@@ -55,30 +56,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<StreamKey> 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;
......
......@@ -50,6 +50,7 @@ import com.google.android.exoplayer2.util.Util;
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;
......@@ -190,6 +191,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* should be used for subtitles instead of {@link SingleSampleMediaSource}.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory experimentalUseProgressiveMediaSourceForSubtitles(
boolean useProgressiveMediaSourceForSubtitles) {
this.useProgressiveMediaSourceForSubtitles = useProgressiveMediaSourceForSubtitles;
......@@ -208,6 +210,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* @deprecated Use {@link #setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)}
* instead.
*/
@CanIgnoreReturnValue
@Deprecated
public DefaultMediaSourceFactory setAdsLoaderProvider(
@Nullable AdsLoader.Provider adsLoaderProvider) {
......@@ -226,6 +229,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* @deprecated Use {@link #setLocalAdInsertionComponents(AdsLoader.Provider, AdViewProvider)}
* instead.
*/
@CanIgnoreReturnValue
@Deprecated
public DefaultMediaSourceFactory setAdViewProvider(@Nullable AdViewProvider adViewProvider) {
this.adViewProvider = adViewProvider;
......@@ -243,6 +247,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);
......@@ -259,6 +264,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
*
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory clearLocalAdInsertionComponents() {
this.adsLoaderProvider = null;
this.adViewProvider = null;
......@@ -272,6 +278,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);
......@@ -288,6 +295,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
public DefaultMediaSourceFactory setServerSideAdInsertionMediaSourceFactory(
@Nullable MediaSource.Factory serverSideAdInsertionMediaSourceFactory) {
this.serverSideAdInsertionMediaSourceFactory = serverSideAdInsertionMediaSourceFactory;
......@@ -301,6 +309,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* use the media-defined default.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory setLiveTargetOffsetMs(long liveTargetOffsetMs) {
this.liveTargetOffsetMs = liveTargetOffsetMs;
return this;
......@@ -313,6 +322,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* C#TIME_UNSET} to use the media-defined default.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory setLiveMinOffsetMs(long liveMinOffsetMs) {
this.liveMinOffsetMs = liveMinOffsetMs;
return this;
......@@ -325,6 +335,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* C#TIME_UNSET} to use the media-defined default.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory setLiveMaxOffsetMs(long liveMaxOffsetMs) {
this.liveMaxOffsetMs = liveMaxOffsetMs;
return this;
......@@ -337,6 +348,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* C#RATE_UNSET} to use the media-defined default.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory setLiveMinSpeed(float minSpeed) {
this.liveMinSpeed = minSpeed;
return this;
......@@ -349,11 +361,13 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
* C#RATE_UNSET} to use the media-defined default.
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public DefaultMediaSourceFactory setLiveMaxSpeed(float maxSpeed) {
this.liveMaxSpeed = maxSpeed;
return this;
}
@CanIgnoreReturnValue
@Override
public DefaultMediaSourceFactory setDrmSessionManagerProvider(
DrmSessionManagerProvider drmSessionManagerProvider) {
......@@ -366,6 +380,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
return this;
}
@CanIgnoreReturnValue
@Override
public DefaultMediaSourceFactory setLoadErrorHandlingPolicy(
LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
......
......@@ -34,6 +34,7 @@ import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/**
* Provides one period that loads data from a {@link Uri} and extracted using an {@link Extractor}.
......@@ -153,6 +154,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
}
@CanIgnoreReturnValue
@Override
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
this.loadErrorHandlingPolicy =
......@@ -174,11 +176,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) {
......
......@@ -33,6 +33,7 @@ import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import org.checkerframework.checker.nullness.compatqual.NullableType;
......@@ -51,6 +52,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;
......@@ -63,6 +65,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;
......
......@@ -31,6 +31,7 @@ import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.MimeTypes;
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}.
......@@ -66,6 +67,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;
......@@ -77,6 +79,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;
......@@ -90,6 +93,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 =
......@@ -108,6 +112,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;
......
......@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.util.Util;
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;
......@@ -136,6 +137,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;
......@@ -148,6 +150,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);
......@@ -163,6 +166,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);
......@@ -177,6 +181,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));
......@@ -190,6 +195,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;
......@@ -201,6 +207,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;
......
......@@ -155,6 +155,7 @@ import com.google.android.exoplayer2.util.Util;
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;
......@@ -12183,6 +12184,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;
......
......@@ -25,6 +25,7 @@ android {
dependencies {
implementation project(modulePrefix + 'library-core')
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
......
......@@ -76,6 +76,7 @@ import com.google.android.exoplayer2.util.SntpClient;
import com.google.android.exoplayer2.util.Util;
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;
......@@ -156,6 +157,7 @@ public final class DashMediaSource extends BaseMediaSource {
compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory();
}
@CanIgnoreReturnValue
@Override
public Factory setDrmSessionManagerProvider(
DrmSessionManagerProvider drmSessionManagerProvider) {
......@@ -168,6 +170,7 @@ public final class DashMediaSource extends BaseMediaSource {
return this;
}
@CanIgnoreReturnValue
@Override
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
this.loadErrorHandlingPolicy =
......@@ -188,6 +191,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;
......@@ -199,6 +203,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<? extends DashManifest> manifestParser) {
this.manifestParser = manifestParser;
......@@ -215,6 +220,7 @@ public final class DashMediaSource extends BaseMediaSource {
* audio etc...).
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public Factory setCompositeSequenceableLoaderFactory(
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory =
......
......@@ -23,6 +23,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.util.Assertions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -87,6 +88,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;
......@@ -98,6 +100,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;
......@@ -109,6 +112,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;
......@@ -120,6 +124,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;
......@@ -131,6 +136,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;
......@@ -146,6 +152,7 @@ public final class DataSpec {
* @param httpRequestHeaders The {@link DataSpec#httpRequestHeaders}.
* @return The builder.
*/
@CanIgnoreReturnValue
public Builder setHttpRequestHeaders(Map<String, String> httpRequestHeaders) {
this.httpRequestHeaders = httpRequestHeaders;
return this;
......@@ -157,6 +164,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;
......@@ -168,6 +176,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;
......@@ -179,6 +188,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;
......@@ -190,6 +200,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;
......@@ -201,6 +212,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;
......
......@@ -22,6 +22,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
......@@ -98,6 +99,7 @@ public final class DefaultDataSource implements DataSource {
* @param transferListener The listener that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setTransferListener(@Nullable TransferListener transferListener) {
this.transferListener = transferListener;
return this;
......
......@@ -33,6 +33,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;
......@@ -81,6 +82,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLIS;
}
@CanIgnoreReturnValue
@Override
public final Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties) {
this.defaultRequestProperties.clearAndSet(defaultRequestProperties);
......@@ -97,6 +99,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* agent of the underlying platform.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setUserAgent(@Nullable String userAgent) {
this.userAgent = userAgent;
return this;
......@@ -110,6 +113,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* @param connectTimeoutMs The connect timeout, in milliseconds, that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setConnectTimeoutMs(int connectTimeoutMs) {
this.connectTimeoutMs = connectTimeoutMs;
return this;
......@@ -123,6 +127,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* @param readTimeoutMs The connect timeout, in milliseconds, that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setReadTimeoutMs(int readTimeoutMs) {
this.readTimeoutMs = readTimeoutMs;
return this;
......@@ -136,6 +141,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* @param allowCrossProtocolRedirects Whether to allow cross protocol redirects.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setAllowCrossProtocolRedirects(boolean allowCrossProtocolRedirects) {
this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
return this;
......@@ -152,6 +158,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* predicate that was previously set.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setContentTypePredicate(@Nullable Predicate<String> contentTypePredicate) {
this.contentTypePredicate = contentTypePredicate;
return this;
......@@ -167,6 +174,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
* @param transferListener The listener that will be used.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setTransferListener(@Nullable TransferListener transferListener) {
this.transferListener = transferListener;
return this;
......@@ -176,6 +184,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
public Factory setKeepPostFor302Redirects(boolean keepPostFor302Redirects) {
this.keepPostFor302Redirects = keepPostFor302Redirects;
return this;
......
......@@ -29,6 +29,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
......@@ -80,6 +81,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;
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.PlaybackException;
import com.google.android.exoplayer2.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;
......@@ -152,6 +153,7 @@ public interface HttpDataSource extends DataSource {
return createDataSourceInternal(defaultRequestProperties);
}
@CanIgnoreReturnValue
@Override
public final Factory setDefaultRequestProperties(Map<String, String> defaultRequestProperties) {
this.defaultRequestProperties.clearAndSet(defaultRequestProperties);
......
......@@ -27,6 +27,7 @@ import com.google.android.exoplayer2.upstream.cache.Cache.CacheException;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
......@@ -63,6 +64,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;
......@@ -81,6 +83,7 @@ public final class CacheDataSink implements DataSink {
* fragmentation.
* @return This factory.
*/
@CanIgnoreReturnValue
public Factory setFragmentSize(long fragmentSize) {
this.fragmentSize = fragmentSize;
return this;
......@@ -95,6 +98,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;
......
......@@ -41,6 +41,7 @@ import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.upstream.cache.Cache.CacheException;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.lang.annotation.Documented;
......@@ -86,6 +87,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;
......@@ -109,6 +111,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;
......@@ -124,6 +127,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;
......@@ -139,6 +143,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;
......@@ -160,6 +165,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;
......@@ -184,6 +190,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;
......@@ -208,6 +215,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;
......@@ -221,6 +229,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;
......@@ -234,6 +243,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;
......
......@@ -19,6 +19,7 @@ import android.net.Uri;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Assertions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
......@@ -79,6 +80,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);
}
......@@ -90,6 +92,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);
}
......@@ -101,6 +104,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));
}
......@@ -111,6 +115,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);
......@@ -135,6 +140,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);
......
......@@ -28,6 +28,7 @@ dependencies {
implementation project(modulePrefix + 'library-common')
// TODO(b/203752187): Remove this dependency.
implementation project(modulePrefix + 'library-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
......
......@@ -43,6 +43,7 @@ import com.google.android.exoplayer2.extractor.ts.TsPayloadReader;
import com.google.android.exoplayer2.extractor.wav.WavExtractor;
import com.google.android.exoplayer2.util.FileTypes;
import com.google.android.exoplayer2.util.TimestampAdjuster;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
......@@ -143,6 +144,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;
......@@ -167,6 +169,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;
......@@ -180,6 +183,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;
......@@ -193,6 +197,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;
......@@ -207,6 +212,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;
......@@ -220,6 +226,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;
......@@ -233,6 +240,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;
......@@ -245,6 +253,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;
......@@ -258,6 +267,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;
......@@ -270,6 +280,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;
......@@ -283,6 +294,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;
......@@ -297,6 +309,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;
......
......@@ -22,6 +22,7 @@ import android.text.Layout;
import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.text.span.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;
......
......@@ -24,6 +24,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.text.span.TextAnnotation;
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;
......@@ -195,6 +196,7 @@ public final class WebvttCssStyle {
return linethrough == ON;
}
@CanIgnoreReturnValue
public WebvttCssStyle setLinethrough(boolean linethrough) {
this.linethrough = linethrough ? ON : OFF;
return this;
......@@ -204,16 +206,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;
......@@ -224,6 +229,7 @@ public final class WebvttCssStyle {
return fontFamily;
}
@CanIgnoreReturnValue
public WebvttCssStyle setFontFamily(@Nullable String fontFamily) {
this.fontFamily = fontFamily == null ? null : Ascii.toLowerCase(fontFamily);
return this;
......@@ -236,6 +242,7 @@ public final class WebvttCssStyle {
return fontColor;
}
@CanIgnoreReturnValue
public WebvttCssStyle setFontColor(int color) {
this.fontColor = color;
hasFontColor = true;
......@@ -253,6 +260,7 @@ public final class WebvttCssStyle {
return backgroundColor;
}
@CanIgnoreReturnValue
public WebvttCssStyle setBackgroundColor(int backgroundColor) {
this.backgroundColor = backgroundColor;
hasBackgroundColor = true;
......@@ -263,11 +271,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;
......@@ -281,6 +291,7 @@ public final class WebvttCssStyle {
return fontSize;
}
@CanIgnoreReturnValue
public WebvttCssStyle setRubyPosition(@TextAnnotation.Position int rubyPosition) {
this.rubyPosition = rubyPosition;
return this;
......@@ -290,6 +301,7 @@ public final class WebvttCssStyle {
return rubyPosition;
}
@CanIgnoreReturnValue
public WebvttCssStyle setCombineUpright(boolean enabled) {
this.combineUpright = enabled;
return this;
......
......@@ -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
......
......@@ -55,6 +55,7 @@ import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
......@@ -169,12 +170,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 =
......@@ -192,6 +195,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(
......@@ -208,6 +212,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(
......@@ -227,6 +232,7 @@ public final class HlsMediaSource extends BaseMediaSource
* audio etc...).
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public Factory setCompositeSequenceableLoaderFactory(
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory =
......@@ -246,6 +252,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;
......@@ -270,6 +277,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;
......@@ -284,11 +292,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) {
......@@ -309,6 +319,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;
......
......@@ -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
......
......@@ -29,6 +29,7 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.ParserException;
import com.google.android.exoplayer2.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;
......@@ -147,6 +148,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;
......@@ -158,6 +160,7 @@ import java.util.HashMap;
* @param connection The connection parameter.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setConnection(String connection) {
this.connection = connection;
return this;
......@@ -169,6 +172,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;
......@@ -180,6 +184,7 @@ import java.util.HashMap;
* @param key The encryption parameter.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setKey(String key) {
this.key = key;
return this;
......@@ -194,6 +199,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;
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.ParsableByteArray;
import com.google.android.exoplayer2.util.Util;
import com.google.common.math.IntMath;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer;
/**
......@@ -69,24 +70,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;
......@@ -94,18 +99,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;
......@@ -113,6 +121,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;
......
......@@ -22,6 +22,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;
......@@ -113,6 +114,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;
......@@ -125,6 +127,7 @@ import java.util.Map;
* &lt;headerValue&gt;
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder addAll(List<String> headers) {
for (int i = 0; i < headers.size(); i++) {
String[] header = Util.splitAtFirst(headers.get(i), ":\\s?");
......@@ -142,6 +145,7 @@ import java.util.Map;
* header values.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder addAll(Map<String, String> headers) {
for (Map.Entry<String, String> header : headers.entrySet()) {
add(header.getKey(), header.getValue());
......
......@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import javax.net.SocketFactory;
......@@ -87,6 +88,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;
......@@ -98,6 +100,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;
......@@ -110,6 +113,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;
......@@ -124,6 +128,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;
......@@ -138,6 +143,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;
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.util.Util;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.util.HashMap;
/**
......@@ -64,6 +65,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;
......@@ -75,6 +77,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;
......@@ -86,6 +89,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;
......@@ -99,6 +103,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;
......@@ -110,6 +115,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;
......@@ -121,6 +127,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;
......@@ -134,6 +141,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;
......@@ -145,6 +153,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;
......@@ -156,6 +165,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;
......@@ -167,6 +177,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;
......@@ -179,6 +190,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;
......@@ -190,6 +202,7 @@ import java.util.HashMap;
* @param mediaDescription The {@link MediaDescription}.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder addMediaDescription(MediaDescription mediaDescription) {
mediaDescriptionListBuilder.add(mediaDescription);
return this;
......
......@@ -25,6 +25,7 @@ android {
dependencies {
implementation project(modulePrefix + 'library-core')
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
......
......@@ -63,6 +63,7 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.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.List;
......@@ -134,6 +135,7 @@ public final class SsMediaSource extends BaseMediaSource
compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory();
}
@CanIgnoreReturnValue
@Override
public Factory setLoadErrorHandlingPolicy(LoadErrorHandlingPolicy loadErrorHandlingPolicy) {
this.loadErrorHandlingPolicy =
......@@ -154,6 +156,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;
......@@ -165,6 +168,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<? extends SsManifest> manifestParser) {
this.manifestParser = manifestParser;
......@@ -180,6 +184,7 @@ public final class SsMediaSource extends BaseMediaSource
* audio etc.).
* @return This factory, for convenience.
*/
@CanIgnoreReturnValue
public Factory setCompositeSequenceableLoaderFactory(
CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory) {
this.compositeSequenceableLoaderFactory =
......@@ -191,6 +196,7 @@ public final class SsMediaSource extends BaseMediaSource
return this;
}
@CanIgnoreReturnValue
@Override
public Factory setDrmSessionManagerProvider(
DrmSessionManagerProvider drmSessionManagerProvider) {
......
......@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.transformer;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.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;
......
......@@ -28,6 +28,7 @@ import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.SystemClock;
import com.google.android.exoplayer2.util.Util;
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<String, Object> inputValues) {
this.inputValues = inputValues;
return this;
......
......@@ -37,6 +37,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.ColorInfo;
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;
......@@ -69,6 +70,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
*
* <p>The default value is {@link EncoderSelector#DEFAULT}.
*/
@CanIgnoreReturnValue
public Builder setVideoEncoderSelector(EncoderSelector encoderSelector) {
this.encoderSelector = encoderSelector;
return this;
......@@ -91,6 +93,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
*
* <p>The default value is {@link VideoEncoderSettings#DEFAULT}.
*/
@CanIgnoreReturnValue
public Builder setRequestedVideoEncoderSettings(
VideoEncoderSettings requestedVideoEncoderSettings) {
this.requestedVideoEncoderSettings = requestedVideoEncoderSettings;
......@@ -108,6 +111,7 @@ public final class DefaultEncoderFactory implements Codec.EncoderFactory {
*
* <p>The default value is {@code true}.
*/
@CanIgnoreReturnValue
public Builder setEnableFallback(boolean enableFallback) {
this.enableFallback = enableFallback;
return this;
......
......@@ -23,6 +23,7 @@ import static java.lang.Math.min;
import android.graphics.Matrix;
import android.util.Size;
import com.google.android.exoplayer2.util.GlUtil;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/**
......@@ -59,6 +60,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;
......@@ -73,6 +75,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;
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.extractor.mp4.Mp4Extractor;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/** A media transformation request. */
public final class TransformationRequest {
......@@ -94,6 +95,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;
......@@ -110,6 +112,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;
......@@ -128,6 +131,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;
......@@ -148,6 +152,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;
......@@ -171,6 +176,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),
......@@ -196,6 +202,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),
......@@ -215,6 +222,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;
......@@ -233,6 +241,7 @@ public final class TransformationRequest {
* dynamic range (HDR) signal.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder experimental_setEnableHdrEditing(boolean enableHdrEditing) {
this.enableHdrEditing = enableHdrEditing;
return this;
......
......@@ -19,6 +19,7 @@ import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
/** Information about the result of a successful transformation. */
public final class TransformationResult {
......@@ -43,6 +44,7 @@ public final class TransformationResult {
*
* <p>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;
......@@ -54,6 +56,7 @@ public final class TransformationResult {
*
* <p>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;
......@@ -65,6 +68,7 @@ public final class TransformationResult {
*
* <p>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;
......@@ -76,6 +80,7 @@ public final class TransformationResult {
*
* <p>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;
......@@ -87,6 +92,7 @@ public final class TransformationResult {
*
* <p>Input must be positive or {@code 0}.
*/
@CanIgnoreReturnValue
public Builder setVideoFrameCount(int videoFrameCount) {
checkArgument(videoFrameCount >= 0);
this.videoFrameCount = videoFrameCount;
......
......@@ -58,6 +58,7 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoRendererEventListener;
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;
......@@ -155,6 +156,7 @@ public final class Transformer {
* @param transformationRequest The {@link TransformationRequest}.
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder setTransformationRequest(TransformationRequest transformationRequest) {
this.transformationRequest = transformationRequest;
return this;
......@@ -173,6 +175,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<GlEffect> effects) {
this.videoEffects = ImmutableList.copyOf(effects);
return this;
......@@ -187,6 +190,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;
......@@ -203,6 +207,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;
......@@ -219,6 +224,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;
......@@ -228,6 +234,7 @@ public final class Transformer {
* @deprecated Use {@link TransformationRequest.Builder#setFlattenForSlowMotion(boolean)}
* instead.
*/
@CanIgnoreReturnValue
@Deprecated
public Builder setFlattenForSlowMotion(boolean flattenForSlowMotion) {
transformationRequest =
......@@ -239,6 +246,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;
......@@ -249,6 +257,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();
......@@ -264,6 +273,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;
......@@ -277,6 +287,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;
......@@ -289,6 +300,7 @@ public final class Transformer {
*
* @return This builder.
*/
@CanIgnoreReturnValue
public Builder removeAllListeners() {
this.listeners.clear();
return this;
......@@ -304,6 +316,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) -> {});
......@@ -318,6 +331,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;
......@@ -331,6 +345,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;
......@@ -348,6 +363,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;
......@@ -361,6 +377,7 @@ public final class Transformer {
* @param clock The {@link Clock} instance.
* @return This builder.
*/
@CanIgnoreReturnValue
@VisibleForTesting
/* package */ Builder setClock(Clock clock) {
this.clock = clock;
......@@ -376,6 +393,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;
......
......@@ -29,6 +29,7 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.exoplayer2.Format;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -104,6 +105,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;
......@@ -118,6 +120,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;
......@@ -138,6 +141,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;
......@@ -151,6 +155,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;
......@@ -164,6 +169,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;
......@@ -180,6 +186,7 @@ public final class VideoEncoderSettings {
*
* <p>Can not be enabled alongside setting a custom bitrate with {@link #setBitrate(int)}.
*/
@CanIgnoreReturnValue
public Builder setEnableHighQualityTargeting(boolean enableHighQualityTargeting) {
this.enableHighQualityTargeting = enableHighQualityTargeting;
return this;
......
......@@ -59,6 +59,7 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
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;
......
......@@ -29,6 +29,7 @@ import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.IOException;
import java.util.ArrayList;
......@@ -50,6 +51,7 @@ public final class CacheAsserts {
}
}
@CanIgnoreReturnValue
public RequestSet subset(String... uriStrings) {
dataSpecs = new DataSpec[uriStrings.length];
for (int i = 0; i < dataSpecs.length; i++) {
......@@ -58,6 +60,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++) {
......@@ -66,6 +69,7 @@ public final class CacheAsserts {
return this;
}
@CanIgnoreReturnValue
public RequestSet subset(DataSpec... dataSpecs) {
this.dataSpecs = dataSpecs;
return this;
......@@ -83,6 +87,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++) {
......
......@@ -42,6 +42,7 @@ import com.google.android.exoplayer2.util.Assertions;
import com.google.android.exoplayer2.util.Util;
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;
......@@ -662,17 +663,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;
......@@ -683,6 +687,7 @@ public abstract class DataSourceContractTest {
*
* <p>Must be at least 5 bytes.
*/
@CanIgnoreReturnValue
public Builder setExpectedBytes(byte[] expectedBytes) {
checkArgument(expectedBytes.length >= 5);
this.expectedBytes = expectedBytes;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment