com.google.android.exoplayer2.upstream.TeeDataSource Java Examples

The following examples show how to use com.google.android.exoplayer2.upstream.TeeDataSource. 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: CacheDataSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 * @param cacheKeyFactory An optional factory for cache keys.
 */
public CacheDataSource(
    Cache cache,
    DataSource upstream,
    DataSource cacheReadDataSource,
    @Nullable DataSink cacheWriteDataSink,
    @Flags int flags,
    @Nullable EventListener eventListener,
    @Nullable CacheKeyFactory cacheKeyFactory) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.cacheKeyFactory =
      cacheKeyFactory != null ? cacheKeyFactory : CacheUtil.DEFAULT_CACHE_KEY_FACTORY;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}
 
Example #2
Source File: CacheDataSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 * @param cacheKeyFactory An optional factory for cache keys.
 */
public CacheDataSource(
    Cache cache,
    DataSource upstream,
    DataSource cacheReadDataSource,
    DataSink cacheWriteDataSink,
    @Flags int flags,
    @Nullable EventListener eventListener,
    @Nullable CacheKeyFactory cacheKeyFactory) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.cacheKeyFactory =
      cacheKeyFactory != null ? cacheKeyFactory : CacheUtil.DEFAULT_CACHE_KEY_FACTORY;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}
 
Example #3
Source File: CacheDataSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 * @param cacheKeyFactory An optional factory for cache keys.
 */
public CacheDataSource(
    Cache cache,
    DataSource upstream,
    DataSource cacheReadDataSource,
    DataSink cacheWriteDataSink,
    @Flags int flags,
    @Nullable EventListener eventListener,
    @Nullable CacheKeyFactory cacheKeyFactory) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.cacheKeyFactory =
      cacheKeyFactory != null ? cacheKeyFactory : CacheUtil.DEFAULT_CACHE_KEY_FACTORY;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}
 
Example #4
Source File: CacheDataSource.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE} and {@link
 *     #FLAG_IGNORE_CACHE_ON_ERROR} or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 */
public CacheDataSource(Cache cache, DataSource upstream, DataSource cacheReadDataSource,
    DataSink cacheWriteDataSink, @Flags int flags, @Nullable EventListener eventListener) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}
 
Example #5
Source File: CacheDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 * @param cacheKeyFactory An optional factory for cache keys.
 */
public CacheDataSource(
    Cache cache,
    DataSource upstream,
    DataSource cacheReadDataSource,
    @Nullable DataSink cacheWriteDataSink,
    @Flags int flags,
    @Nullable EventListener eventListener,
    @Nullable CacheKeyFactory cacheKeyFactory) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.cacheKeyFactory =
      cacheKeyFactory != null ? cacheKeyFactory : CacheUtil.DEFAULT_CACHE_KEY_FACTORY;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}
 
Example #6
Source File: CacheDataSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs an instance with arbitrary {@link DataSource} and {@link DataSink} instances for
 * reading and writing the cache. One use of this constructor is to allow data to be transformed
 * before it is written to disk.
 *
 * @param cache The cache.
 * @param upstream A {@link DataSource} for reading data not in the cache.
 * @param cacheReadDataSource A {@link DataSource} for reading data from the cache.
 * @param cacheWriteDataSink A {@link DataSink} for writing data to the cache. If null, cache is
 *     accessed read-only.
 * @param flags A combination of {@link #FLAG_BLOCK_ON_CACHE}, {@link #FLAG_IGNORE_CACHE_ON_ERROR}
 *     and {@link #FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS}, or 0.
 * @param eventListener An optional {@link EventListener} to receive events.
 * @param cacheKeyFactory An optional factory for cache keys.
 */
public CacheDataSource(
    Cache cache,
    DataSource upstream,
    DataSource cacheReadDataSource,
    @Nullable DataSink cacheWriteDataSink,
    @Flags int flags,
    @Nullable EventListener eventListener,
    @Nullable CacheKeyFactory cacheKeyFactory) {
  this.cache = cache;
  this.cacheReadDataSource = cacheReadDataSource;
  this.cacheKeyFactory =
      cacheKeyFactory != null ? cacheKeyFactory : CacheUtil.DEFAULT_CACHE_KEY_FACTORY;
  this.blockOnCache = (flags & FLAG_BLOCK_ON_CACHE) != 0;
  this.ignoreCacheOnError = (flags & FLAG_IGNORE_CACHE_ON_ERROR) != 0;
  this.ignoreCacheForUnsetLengthRequests =
      (flags & FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS) != 0;
  this.upstreamDataSource = upstream;
  if (cacheWriteDataSink != null) {
    this.cacheWriteDataSource = new TeeDataSource(upstream, cacheWriteDataSink);
  } else {
    this.cacheWriteDataSource = null;
  }
  this.eventListener = eventListener;
}