Migrate uses of deprecated DataSource factories

PiperOrigin-RevId: 389844289
This commit is contained in:
olly 2021-08-10 12:02:55 +01:00 committed by Christos Tsilopoulos
parent 937bc008c1
commit b627d70054
7 changed files with 12 additions and 14 deletions

View File

@ -23,7 +23,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi; import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@ -51,10 +50,10 @@ public final class DefaultDrmSessionManagerProvider implements DrmSessionManager
/** /**
* Sets the {@link HttpDataSource.Factory} to be used for creating {@link HttpMediaDrmCallback * Sets the {@link HttpDataSource.Factory} to be used for creating {@link HttpMediaDrmCallback
* HttpMediaDrmCallbacks} which executes key and provisioning requests over HTTP. If {@code null} * HttpMediaDrmCallbacks} which executes key and provisioning requests over HTTP. If {@code null}
* is passed the {@link DefaultHttpDataSourceFactory} is used. * is passed the {@link DefaultHttpDataSource.Factory} is used.
* *
* @param drmHttpDataSourceFactory The HTTP data source factory or {@code null} to use {@link * @param drmHttpDataSourceFactory The HTTP data source factory or {@code null} to use {@link
* DefaultHttpDataSourceFactory}. * DefaultHttpDataSource.Factory}.
*/ */
public void setDrmHttpDataSourceFactory( public void setDrmHttpDataSourceFactory(
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) { @Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {

View File

@ -25,7 +25,7 @@ import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider; import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback; import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.offline.StreamKey;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy; import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.google.android.exoplayer2.upstream.HttpDataSource; import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy; import com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy;
@ -83,7 +83,7 @@ public interface MediaSourceFactory {
* #setDrmSessionManager(DrmSessionManager) concrete DrmSessionManager} are provided. * #setDrmSessionManager(DrmSessionManager) concrete DrmSessionManager} are provided.
* *
* @param drmHttpDataSourceFactory The HTTP data source factory, or {@code null} to use {@link * @param drmHttpDataSourceFactory The HTTP data source factory, or {@code null} to use {@link
* DefaultHttpDataSourceFactory}. * DefaultHttpDataSource.Factory}.
* @return This factory, for convenience. * @return This factory, for convenience.
* @deprecated Use {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider)} and pass an * @deprecated Use {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider)} and pass an
* implementation that configures the returned {@link DrmSessionManager} with the desired * implementation that configures the returned {@link DrmSessionManager} with the desired

View File

@ -51,7 +51,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
* CacheDataSource.Factory cacheDataSourceFactory = * CacheDataSource.Factory cacheDataSourceFactory =
* new CacheDataSource.Factory() * new CacheDataSource.Factory()
* .setCache(cache) * .setCache(cache)
* .setUpstreamDataSourceFactory(new DefaultHttpDataSourceFactory(userAgent)); * .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory());
* // Create a downloader for the first representation of the first adaptation set of the first * // Create a downloader for the first representation of the first adaptation set of the first
* // period. * // period.
* DashDownloader dashDownloader = * DashDownloader dashDownloader =

View File

@ -44,7 +44,7 @@ import java.util.concurrent.Executor;
* CacheDataSource.Factory cacheDataSourceFactory = * CacheDataSource.Factory cacheDataSourceFactory =
* new CacheDataSource.Factory() * new CacheDataSource.Factory()
* .setCache(cache) * .setCache(cache)
* .setUpstreamDataSourceFactory(new DefaultHttpDataSourceFactory(userAgent)); * .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory());
* // Create a downloader for the first variant in a master playlist. * // Create a downloader for the first variant in a master playlist.
* HlsDownloader hlsDownloader = * HlsDownloader hlsDownloader =
* new HlsDownloader( * new HlsDownloader(

View File

@ -41,7 +41,7 @@ import java.util.concurrent.Executor;
* CacheDataSource.Factory cacheDataSourceFactory = * CacheDataSource.Factory cacheDataSourceFactory =
* new CacheDataSource.Factory() * new CacheDataSource.Factory()
* .setCache(cache) * .setCache(cache)
* .setUpstreamDataSourceFactory(new DefaultHttpDataSourceFactory(userAgent)); * .setUpstreamDataSourceFactory(new DefaultHttpDataSource.Factory());
* // Create a downloader for the first track of the first stream element. * // Create a downloader for the first track of the first stream element.
* SsDownloader ssDownloader = * SsDownloader ssDownloader =
* new SsDownloader( * new SsDownloader(

View File

@ -30,7 +30,7 @@ import com.google.android.exoplayer2.source.dash.manifest.Representation;
import com.google.android.exoplayer2.source.dash.offline.DashDownloader; import com.google.android.exoplayer2.source.dash.offline.DashDownloader;
import com.google.android.exoplayer2.testutil.HostActivity; import com.google.android.exoplayer2.testutil.HostActivity;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource; import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor; import com.google.android.exoplayer2.upstream.cache.NoOpCacheEvictor;
import com.google.android.exoplayer2.upstream.cache.SimpleCache; import com.google.android.exoplayer2.upstream.cache.SimpleCache;
@ -73,7 +73,7 @@ public final class DashDownloadTest {
cache = cache =
new SimpleCache( new SimpleCache(
tempFolder, new NoOpCacheEvictor(), new ExoDatabaseProvider(testRule.getActivity())); tempFolder, new NoOpCacheEvictor(), new ExoDatabaseProvider(testRule.getActivity()));
httpDataSourceFactory = new DefaultHttpDataSourceFactory("ExoPlayer", null); httpDataSourceFactory = new DefaultHttpDataSource.Factory();
offlineDataSourceFactory = new CacheDataSource.Factory().setCache(cache); offlineDataSourceFactory = new CacheDataSource.Factory().setCache(cache);
} }

View File

@ -35,7 +35,7 @@ import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
import com.google.android.exoplayer2.testutil.ActionSchedule; import com.google.android.exoplayer2.testutil.ActionSchedule;
import com.google.android.exoplayer2.testutil.HostActivity; import com.google.android.exoplayer2.testutil.HostActivity;
import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory; import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
@ -51,10 +51,9 @@ import org.junit.runner.RunWith;
public final class DashWidevineOfflineTest { public final class DashWidevineOfflineTest {
private static final String TAG = "DashWidevineOfflineTest"; private static final String TAG = "DashWidevineOfflineTest";
private static final String USER_AGENT = "ExoPlayerPlaybackTests";
private DashTestRunner testRunner; private DashTestRunner testRunner;
private DefaultHttpDataSourceFactory httpDataSourceFactory; private DefaultHttpDataSource.Factory httpDataSourceFactory;
private OfflineLicenseHelper offlineLicenseHelper; private OfflineLicenseHelper offlineLicenseHelper;
private byte[] offlineLicenseKeySetId; private byte[] offlineLicenseKeySetId;
@ -75,7 +74,7 @@ public final class DashWidevineOfflineTest {
boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264); boolean useL1Widevine = DashTestRunner.isL1WidevineAvailable(MimeTypes.VIDEO_H264);
String widevineLicenseUrl = DashTestData.getWidevineLicenseUrl(true, useL1Widevine); String widevineLicenseUrl = DashTestData.getWidevineLicenseUrl(true, useL1Widevine);
httpDataSourceFactory = new DefaultHttpDataSourceFactory(USER_AGENT); httpDataSourceFactory = new DefaultHttpDataSource.Factory();
if (Util.SDK_INT >= 18) { if (Util.SDK_INT >= 18) {
offlineLicenseHelper = offlineLicenseHelper =
OfflineLicenseHelper.newWidevineInstance( OfflineLicenseHelper.newWidevineInstance(