com.google.android.exoplayer2.upstream.HttpDataSource.Factory Java Examples

The following examples show how to use com.google.android.exoplayer2.upstream.HttpDataSource.Factory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpMediaDrmCallback.java    From K-Sonic with MIT License 6 votes vote down vote up
private static byte[] executePost(HttpDataSource.Factory dataSourceFactory, String url,
    byte[] data, Map<String, String> requestProperties) throws IOException {
  HttpDataSource dataSource = dataSourceFactory.createDataSource();
  if (requestProperties != null) {
    for (Map.Entry<String, String> requestProperty : requestProperties.entrySet()) {
      dataSource.setRequestProperty(requestProperty.getKey(), requestProperty.getValue());
    }
  }
  DataSpec dataSpec = new DataSpec(Uri.parse(url), data, 0, 0, C.LENGTH_UNSET, null,
      DataSpec.FLAG_ALLOW_GZIP);
  DataSourceInputStream inputStream = new DataSourceInputStream(dataSource, dataSpec);
  try {
    return Util.toByteArray(inputStream);
  } finally {
    Util.closeQuietly(inputStream);
  }
}
 
Example #2
Source File: HttpMediaDrmCallback.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * @deprecated Use {@link HttpMediaDrmCallback#HttpMediaDrmCallback(String, Factory)}. Request
 *     properties can be set by calling {@link #setKeyRequestProperty(String, String)}.
 * @param defaultUrl The default license URL.
 * @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @param keyRequestProperties Request properties to set when making key requests, or null.
 */
@Deprecated
public HttpMediaDrmCallback(String defaultUrl, HttpDataSource.Factory dataSourceFactory,
    Map<String, String> keyRequestProperties) {
  this.dataSourceFactory = dataSourceFactory;
  this.defaultUrl = defaultUrl;
  this.keyRequestProperties = new HashMap<>();
  if (keyRequestProperties != null) {
    this.keyRequestProperties.putAll(keyRequestProperties);
  }
}
 
Example #3
Source File: OfflineLicenseHelper.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
      null);
}
 
Example #4
Source File: OfflineLicenseHelper.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
 *     to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 * @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
 *     MediaDrmCallback, HashMap)
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    Factory httpDataSourceFactory,
    @Nullable HashMap<String, String> optionalKeyRequestParameters)
    throws UnsupportedDrmException {
  return new OfflineLicenseHelper<>(C.WIDEVINE_UUID,
      FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID),
      new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory),
      optionalKeyRequestParameters);
}
 
Example #5
Source File: OfflineLicenseHelper.java    From Telegram with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
      null);
}
 
Example #6
Source File: OfflineLicenseHelper.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
 *     to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 * @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
 *     MediaDrmCallback, HashMap)
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    Factory httpDataSourceFactory,
    @Nullable HashMap<String, String> optionalKeyRequestParameters)
    throws UnsupportedDrmException {
  return new OfflineLicenseHelper<>(C.WIDEVINE_UUID,
      FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID),
      new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory),
      optionalKeyRequestParameters);
}
 
Example #7
Source File: OfflineLicenseHelper.java    From Telegram-FOSS with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
      null);
}
 
Example #8
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
 *     to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 * @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
 *     MediaDrmCallback, HashMap, Handler, DefaultDrmSessionEventListener)
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    Factory httpDataSourceFactory,
    HashMap<String, String> optionalKeyRequestParameters)
    throws UnsupportedDrmException {
  return new OfflineLicenseHelper<>(C.WIDEVINE_UUID,
      FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID),
      new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory),
      optionalKeyRequestParameters);
}
 
Example #9
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
      null);
}
 
Example #10
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
 *     to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 * @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
 *     MediaDrmCallback, HashMap, Handler, DefaultDrmSessionEventListener)
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    Factory httpDataSourceFactory,
    HashMap<String, String> optionalKeyRequestParameters)
    throws UnsupportedDrmException {
  return new OfflineLicenseHelper<>(C.WIDEVINE_UUID,
      FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID),
      new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory),
      optionalKeyRequestParameters);
}
 
Example #11
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, boolean forceDefaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory,
      null);
}
 
Example #12
Source File: OfflineLicenseHelper.java    From MediaSDK with Apache License 2.0 3 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
 *     include their own license URL.
 * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
 *     to {@link MediaDrm#getKeyRequest}. May be null.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 * @see DefaultDrmSessionManager.Builder
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    Factory httpDataSourceFactory,
    @Nullable Map<String, String> optionalKeyRequestParameters)
    throws UnsupportedDrmException {
  return new OfflineLicenseHelper<>(
      C.WIDEVINE_UUID,
      FrameworkMediaDrm.DEFAULT_PROVIDER,
      new HttpMediaDrmCallback(defaultLicenseUrl, forceDefaultLicenseUrl, httpDataSourceFactory),
      optionalKeyRequestParameters);
}
 
Example #13
Source File: HttpMediaDrmCallback.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * @param defaultUrl The default license URL.
 * @param dataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 */
public HttpMediaDrmCallback(String defaultUrl, HttpDataSource.Factory dataSourceFactory) {
  this(defaultUrl, dataSourceFactory, null);
}
 
Example #14
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null);
}
 
Example #15
Source File: OfflineLicenseHelper.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #releaseResources()} when
 * you're done with the helper instance.
 *
 * @param licenseUrl The default license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String licenseUrl, Factory httpDataSourceFactory) throws UnsupportedDrmException {
  return newWidevineInstance(
      new HttpMediaDrmCallback(licenseUrl, httpDataSourceFactory), null);
}
 
Example #16
Source File: OfflineLicenseHelper.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null);
}
 
Example #17
Source File: OfflineLicenseHelper.java    From TelePlus-Android with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null);
}
 
Example #18
Source File: OfflineLicenseHelper.java    From Telegram with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null);
}
 
Example #19
Source File: OfflineLicenseHelper.java    From MediaSDK with Apache License 2.0 2 votes vote down vote up
/**
 * Instantiates a new instance which uses Widevine CDM. Call {@link #release()} when the instance
 * is no longer required.
 *
 * @param defaultLicenseUrl The default license URL. Used for key requests that do not specify
 *     their own license URL.
 * @param httpDataSourceFactory A factory from which to obtain {@link HttpDataSource} instances.
 * @return A new instance which uses Widevine CDM.
 * @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
 *     instantiated.
 */
public static OfflineLicenseHelper<FrameworkMediaCrypto> newWidevineInstance(
    String defaultLicenseUrl, Factory httpDataSourceFactory)
    throws UnsupportedDrmException {
  return newWidevineInstance(defaultLicenseUrl, false, httpDataSourceFactory, null);
}