Remove OkHttpDataSource
constructors & OkHttDataSourceFactory
Use `OkHttpDataSource.Factory` instead. PiperOrigin-RevId: 636585523
This commit is contained in:
parent
4986fdd1a6
commit
e150e0d39f
@ -199,6 +199,8 @@
|
||||
* Remove `setContentTypePredicate(Predicate)` method from
|
||||
`DefaultHttpDataSource`, `OkHttpDataSource` and `CronetDataSource`. Use
|
||||
the equivalent method on each `XXXDataSource.Factory` instead.
|
||||
* Remove `OkHttpDataSource` constructors and `OkHttpDataSourceFactory`.
|
||||
Use `OkHttpDataSource.Factory` instead.
|
||||
|
||||
## 1.4
|
||||
|
||||
|
@ -196,44 +196,6 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
|
||||
private long bytesToRead;
|
||||
private long bytesRead;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OkHttpDataSource.Factory} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
public OkHttpDataSource(Call.Factory callFactory) {
|
||||
this(callFactory, /* userAgent= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OkHttpDataSource.Factory} instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
public OkHttpDataSource(Call.Factory callFactory, @Nullable String userAgent) {
|
||||
this(callFactory, userAgent, /* cacheControl= */ null, /* defaultRequestProperties= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OkHttpDataSource.Factory} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
public OkHttpDataSource(
|
||||
Call.Factory callFactory,
|
||||
@Nullable String userAgent,
|
||||
@Nullable CacheControl cacheControl,
|
||||
@Nullable RequestProperties defaultRequestProperties) {
|
||||
this(
|
||||
callFactory,
|
||||
userAgent,
|
||||
cacheControl,
|
||||
defaultRequestProperties,
|
||||
/* contentTypePredicate= */ null);
|
||||
}
|
||||
|
||||
private OkHttpDataSource(
|
||||
Call.Factory callFactory,
|
||||
@Nullable String userAgent,
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package androidx.media3.datasource.okhttp;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.datasource.HttpDataSource;
|
||||
import androidx.media3.datasource.HttpDataSource.BaseFactory;
|
||||
import androidx.media3.datasource.TransferListener;
|
||||
import okhttp3.CacheControl;
|
||||
import okhttp3.Call;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OkHttpDataSource.Factory} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@UnstableApi
|
||||
public final class OkHttpDataSourceFactory extends BaseFactory {
|
||||
|
||||
private final Call.Factory callFactory;
|
||||
@Nullable private final String userAgent;
|
||||
@Nullable private final TransferListener listener;
|
||||
@Nullable private final CacheControl cacheControl;
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
|
||||
* by the sources created by the factory.
|
||||
*/
|
||||
public OkHttpDataSourceFactory(Call.Factory callFactory) {
|
||||
this(callFactory, /* userAgent= */ null, /* listener= */ null, /* cacheControl= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
|
||||
* by the sources created by the factory.
|
||||
* @param userAgent An optional User-Agent string.
|
||||
*/
|
||||
public OkHttpDataSourceFactory(Call.Factory callFactory, @Nullable String userAgent) {
|
||||
this(callFactory, userAgent, /* listener= */ null, /* cacheControl= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
|
||||
* by the sources created by the factory.
|
||||
* @param userAgent An optional User-Agent string.
|
||||
* @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header.
|
||||
*/
|
||||
public OkHttpDataSourceFactory(
|
||||
Call.Factory callFactory, @Nullable String userAgent, @Nullable CacheControl cacheControl) {
|
||||
this(callFactory, userAgent, /* listener= */ null, cacheControl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
|
||||
* by the sources created by the factory.
|
||||
* @param userAgent An optional User-Agent string.
|
||||
* @param listener An optional listener.
|
||||
*/
|
||||
public OkHttpDataSourceFactory(
|
||||
Call.Factory callFactory, @Nullable String userAgent, @Nullable TransferListener listener) {
|
||||
this(callFactory, userAgent, listener, /* cacheControl= */ null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance.
|
||||
*
|
||||
* @param callFactory A {@link Call.Factory} (typically an {@link okhttp3.OkHttpClient}) for use
|
||||
* by the sources created by the factory.
|
||||
* @param userAgent An optional User-Agent string.
|
||||
* @param listener An optional listener.
|
||||
* @param cacheControl An optional {@link CacheControl} for setting the Cache-Control header.
|
||||
*/
|
||||
public OkHttpDataSourceFactory(
|
||||
Call.Factory callFactory,
|
||||
@Nullable String userAgent,
|
||||
@Nullable TransferListener listener,
|
||||
@Nullable CacheControl cacheControl) {
|
||||
this.callFactory = callFactory;
|
||||
this.userAgent = userAgent;
|
||||
this.listener = listener;
|
||||
this.cacheControl = cacheControl;
|
||||
}
|
||||
|
||||
// Calls deprecated constructor.
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected OkHttpDataSource createDataSourceInternal(
|
||||
HttpDataSource.RequestProperties defaultRequestProperties) {
|
||||
OkHttpDataSource dataSource =
|
||||
new OkHttpDataSource(callFactory, userAgent, cacheControl, defaultRequestProperties);
|
||||
if (listener != null) {
|
||||
dataSource.addTransferListener(listener);
|
||||
}
|
||||
return dataSource;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user