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

The following examples show how to use com.google.android.exoplayer2.upstream.DefaultAllocator. 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: DefaultLoadControl.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds) {
  this(
      allocator,
      /* minBufferAudioMs= */ minBufferMs,
      /* minBufferVideoMs= */ minBufferMs,
      maxBufferMs,
      bufferForPlaybackMs,
      bufferForPlaybackAfterRebufferMs,
      targetBufferBytes,
      prioritizeTimeOverSizeThresholds,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #2
Source File: ExoPlayerHelper.java    From ExoPlayer-Wrapper with Apache License 2.0 6 votes vote down vote up
private void init() {
    // Measures bandwidth during playback. Can be null if not required.
    DefaultBandwidthMeter bandwidthMeter =
            new DefaultBandwidthMeter.Builder(mContext).build();

    // Produces DataSource instances through which media data is loaded.
    mDataSourceFactory = new DefaultDataSourceFactory(mContext,
            Util.getUserAgent(mContext, mContext.getString(R.string.app_name)), bandwidthMeter);


    // LoadControl that controls when the MediaSource buffers more media, and how much media is buffered.
    // LoadControl is injected when the player is created.
    //removed deprecated DefaultLoadControl creation method
    DefaultLoadControl.Builder builder = new DefaultLoadControl.Builder();
    builder.setAllocator(new DefaultAllocator(true, 2 * 1024 * 1024));
    builder.setBufferDurationsMs(5000, 5000, 5000, 5000);
    builder.setPrioritizeTimeOverSizeThresholds(true);
    mLoadControl = builder.createDefaultLoadControl();
}
 
Example #3
Source File: DefaultLoadControl.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds) {
  this(
      allocator,
      /* minBufferAudioMs= */ minBufferMs,
      /* minBufferVideoMs= */ minBufferMs,
      maxBufferMs,
      bufferForPlaybackMs,
      bufferForPlaybackAfterRebufferMs,
      targetBufferBytes,
      prioritizeTimeOverSizeThresholds,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #4
Source File: DefaultLoadControl.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds) {
  this(
      allocator,
      /* minBufferAudioMs= */ minBufferMs,
      /* minBufferVideoMs= */ minBufferMs,
      maxBufferMs,
      bufferForPlaybackMs,
      bufferForPlaybackAfterRebufferMs,
      targetBufferBytes,
      prioritizeTimeOverSizeThresholds,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #5
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds) {
  this(
      allocator,
      minBufferMs,
      maxBufferMs,
      bufferForPlaybackMs,
      bufferForPlaybackAfterRebufferMs,
      targetBufferBytes,
      prioritizeTimeOverSizeThresholds,
      null);
}
 
Example #6
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds) {
  this(
      allocator,
      minBufferMs,
      maxBufferMs,
      bufferForPlaybackMs,
      bufferForPlaybackAfterRebufferMs,
      targetBufferBytes,
      prioritizeTimeOverSizeThresholds,
      null);
}
 
Example #7
Source File: DownloadHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) {
  this.mediaSource = mediaSource;
  this.downloadHelper = downloadHelper;
  allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
  pendingMediaPeriods = new ArrayList<>();
  @SuppressWarnings("methodref.receiver.bound.invalid")
  Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage);
  this.downloadHelperHandler = downloadThreadHandler;
  mediaSourceThread = new HandlerThread("DownloadHelper");
  mediaSourceThread.start();
  mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this);
  mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE);
}
 
Example #8
Source File: DefaultLoadControl.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(DefaultAllocator allocator) {
  this(
      allocator,
      /* minBufferAudioMs= */ DEFAULT_MIN_BUFFER_MS,
      /* minBufferVideoMs= */ DEFAULT_MAX_BUFFER_MS,
      DEFAULT_MAX_BUFFER_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS,
      DEFAULT_TARGET_BUFFER_BYTES,
      DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #9
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds,
    PriorityTaskManager priorityTaskManager) {
  assertGreaterOrEqual(bufferForPlaybackMs, 0, "bufferForPlaybackMs", "0");
  assertGreaterOrEqual(
      bufferForPlaybackAfterRebufferMs, 0, "bufferForPlaybackAfterRebufferMs", "0");
  assertGreaterOrEqual(minBufferMs, bufferForPlaybackMs, "minBufferMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(maxBufferMs, minBufferMs, "maxBufferMs", "minBufferMs");

  this.allocator = allocator;
  minBufferUs = minBufferMs * 1000L;
  maxBufferUs = maxBufferMs * 1000L;
  bufferForPlaybackUs = bufferForPlaybackMs * 1000L;
  bufferForPlaybackAfterRebufferUs = bufferForPlaybackAfterRebufferMs * 1000L;
  targetBufferBytesOverwrite = targetBufferBytes;
  this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
  this.priorityTaskManager = priorityTaskManager;
}
 
Example #10
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(DefaultAllocator allocator) {
  this(
      allocator,
      DEFAULT_MIN_BUFFER_MS,
      DEFAULT_MAX_BUFFER_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS,
      DEFAULT_TARGET_BUFFER_BYTES,
      DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS);
}
 
Example #11
Source File: DownloadHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) {
  this.mediaSource = mediaSource;
  this.downloadHelper = downloadHelper;
  allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
  pendingMediaPeriods = new ArrayList<>();
  @SuppressWarnings("methodref.receiver.bound.invalid")
  Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage);
  this.downloadHelperHandler = downloadThreadHandler;
  mediaSourceThread = new HandlerThread("DownloadHelper");
  mediaSourceThread.start();
  mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this);
  mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE);
}
 
Example #12
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds,
    PriorityTaskManager priorityTaskManager) {
  assertGreaterOrEqual(bufferForPlaybackMs, 0, "bufferForPlaybackMs", "0");
  assertGreaterOrEqual(
      bufferForPlaybackAfterRebufferMs, 0, "bufferForPlaybackAfterRebufferMs", "0");
  assertGreaterOrEqual(minBufferMs, bufferForPlaybackMs, "minBufferMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(maxBufferMs, minBufferMs, "maxBufferMs", "minBufferMs");

  this.allocator = allocator;
  minBufferUs = minBufferMs * 1000L;
  maxBufferUs = maxBufferMs * 1000L;
  bufferForPlaybackUs = bufferForPlaybackMs * 1000L;
  bufferForPlaybackAfterRebufferUs = bufferForPlaybackAfterRebufferMs * 1000L;
  targetBufferBytesOverwrite = targetBufferBytes;
  this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
  this.priorityTaskManager = priorityTaskManager;
}
 
Example #13
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(DefaultAllocator allocator) {
  this(
      allocator,
      DEFAULT_MIN_BUFFER_MS,
      DEFAULT_MAX_BUFFER_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS,
      DEFAULT_TARGET_BUFFER_BYTES,
      DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS);
}
 
Example #14
Source File: DefaultLoadControl.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(DefaultAllocator allocator) {
  this(
      allocator,
      /* minBufferAudioMs= */ DEFAULT_MIN_BUFFER_MS,
      /* minBufferVideoMs= */ DEFAULT_MAX_BUFFER_MS,
      DEFAULT_MAX_BUFFER_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS,
      DEFAULT_TARGET_BUFFER_BYTES,
      DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #15
Source File: DownloadHelper.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
public MediaPreparer(MediaSource mediaSource, DownloadHelper downloadHelper) {
  this.mediaSource = mediaSource;
  this.downloadHelper = downloadHelper;
  allocator = new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE);
  pendingMediaPeriods = new ArrayList<>();
  @SuppressWarnings("methodref.receiver.bound.invalid")
  Handler downloadThreadHandler = Util.createHandler(this::handleDownloadHelperCallbackMessage);
  this.downloadHelperHandler = downloadThreadHandler;
  mediaSourceThread = new HandlerThread("DownloadHelper");
  mediaSourceThread.start();
  mediaSourceHandler = Util.createHandler(mediaSourceThread.getLooper(), /* callback= */ this);
  mediaSourceHandler.sendEmptyMessage(MESSAGE_PREPARE_SOURCE);
}
 
Example #16
Source File: DefaultLoadControl.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** @deprecated Use {@link Builder} instead. */
@Deprecated
public DefaultLoadControl(DefaultAllocator allocator) {
  this(
      allocator,
      /* minBufferAudioMs= */ DEFAULT_MIN_BUFFER_MS,
      /* minBufferVideoMs= */ DEFAULT_MAX_BUFFER_MS,
      DEFAULT_MAX_BUFFER_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS,
      DEFAULT_TARGET_BUFFER_BYTES,
      DEFAULT_PRIORITIZE_TIME_OVER_SIZE_THRESHOLDS,
      DEFAULT_BACK_BUFFER_DURATION_MS,
      DEFAULT_RETAIN_BACK_BUFFER_FROM_KEYFRAME);
}
 
Example #17
Source File: DefaultLoadControl.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
protected DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferAudioMs,
    int minBufferVideoMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds,
    int backBufferDurationMs,
    boolean retainBackBufferFromKeyframe) {
  assertGreaterOrEqual(bufferForPlaybackMs, 0, "bufferForPlaybackMs", "0");
  assertGreaterOrEqual(
      bufferForPlaybackAfterRebufferMs, 0, "bufferForPlaybackAfterRebufferMs", "0");
  assertGreaterOrEqual(
      minBufferAudioMs, bufferForPlaybackMs, "minBufferAudioMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferVideoMs, bufferForPlaybackMs, "minBufferVideoMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferAudioMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferAudioMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(
      minBufferVideoMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferVideoMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(maxBufferMs, minBufferAudioMs, "maxBufferMs", "minBufferAudioMs");
  assertGreaterOrEqual(maxBufferMs, minBufferVideoMs, "maxBufferMs", "minBufferVideoMs");
  assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0");

  this.allocator = allocator;
  this.minBufferAudioUs = C.msToUs(minBufferAudioMs);
  this.minBufferVideoUs = C.msToUs(minBufferVideoMs);
  this.maxBufferUs = C.msToUs(maxBufferMs);
  this.bufferForPlaybackUs = C.msToUs(bufferForPlaybackMs);
  this.bufferForPlaybackAfterRebufferUs = C.msToUs(bufferForPlaybackAfterRebufferMs);
  this.targetBufferBytesOverwrite = targetBufferBytes;
  this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
  this.backBufferDurationUs = C.msToUs(backBufferDurationMs);
  this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe;
}
 
Example #18
Source File: DefaultLoadControl.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/** Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class. */
@SuppressWarnings("deprecation")
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #19
Source File: DefaultLoadControl.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
protected DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferAudioMs,
    int minBufferVideoMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds,
    int backBufferDurationMs,
    boolean retainBackBufferFromKeyframe) {
  assertGreaterOrEqual(bufferForPlaybackMs, 0, "bufferForPlaybackMs", "0");
  assertGreaterOrEqual(
      bufferForPlaybackAfterRebufferMs, 0, "bufferForPlaybackAfterRebufferMs", "0");
  assertGreaterOrEqual(
      minBufferAudioMs, bufferForPlaybackMs, "minBufferAudioMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferVideoMs, bufferForPlaybackMs, "minBufferVideoMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferAudioMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferAudioMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(
      minBufferVideoMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferVideoMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(maxBufferMs, minBufferAudioMs, "maxBufferMs", "minBufferAudioMs");
  assertGreaterOrEqual(maxBufferMs, minBufferVideoMs, "maxBufferMs", "minBufferVideoMs");
  assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0");

  this.allocator = allocator;
  this.minBufferAudioUs = C.msToUs(minBufferAudioMs);
  this.minBufferVideoUs = C.msToUs(minBufferVideoMs);
  this.maxBufferUs = C.msToUs(maxBufferMs);
  this.bufferForPlaybackUs = C.msToUs(bufferForPlaybackMs);
  this.bufferForPlaybackAfterRebufferUs = C.msToUs(bufferForPlaybackAfterRebufferMs);
  this.targetBufferBytesOverwrite = targetBufferBytes;
  this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
  this.backBufferDurationUs = C.msToUs(backBufferDurationMs);
  this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe;
}
 
Example #20
Source File: DefaultLoadControl.java    From K-Sonic with MIT License 4 votes vote down vote up
/**
 * Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class.
 */
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #21
Source File: DefaultLoadControl.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/** Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class. */
@SuppressWarnings("deprecation")
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #22
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class.
 */
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #23
Source File: DefaultLoadControl.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class.
 */
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #24
Source File: DefaultLoadControl.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
protected DefaultLoadControl(
    DefaultAllocator allocator,
    int minBufferAudioMs,
    int minBufferVideoMs,
    int maxBufferMs,
    int bufferForPlaybackMs,
    int bufferForPlaybackAfterRebufferMs,
    int targetBufferBytes,
    boolean prioritizeTimeOverSizeThresholds,
    int backBufferDurationMs,
    boolean retainBackBufferFromKeyframe) {
  assertGreaterOrEqual(bufferForPlaybackMs, 0, "bufferForPlaybackMs", "0");
  assertGreaterOrEqual(
      bufferForPlaybackAfterRebufferMs, 0, "bufferForPlaybackAfterRebufferMs", "0");
  assertGreaterOrEqual(
      minBufferAudioMs, bufferForPlaybackMs, "minBufferAudioMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferVideoMs, bufferForPlaybackMs, "minBufferVideoMs", "bufferForPlaybackMs");
  assertGreaterOrEqual(
      minBufferAudioMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferAudioMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(
      minBufferVideoMs,
      bufferForPlaybackAfterRebufferMs,
      "minBufferVideoMs",
      "bufferForPlaybackAfterRebufferMs");
  assertGreaterOrEqual(maxBufferMs, minBufferAudioMs, "maxBufferMs", "minBufferAudioMs");
  assertGreaterOrEqual(maxBufferMs, minBufferVideoMs, "maxBufferMs", "minBufferVideoMs");
  assertGreaterOrEqual(backBufferDurationMs, 0, "backBufferDurationMs", "0");

  this.allocator = allocator;
  this.minBufferAudioUs = C.msToUs(minBufferAudioMs);
  this.minBufferVideoUs = C.msToUs(minBufferVideoMs);
  this.maxBufferUs = C.msToUs(maxBufferMs);
  this.bufferForPlaybackUs = C.msToUs(bufferForPlaybackMs);
  this.bufferForPlaybackAfterRebufferUs = C.msToUs(bufferForPlaybackAfterRebufferMs);
  this.targetBufferBytesOverwrite = targetBufferBytes;
  this.prioritizeTimeOverSizeThresholds = prioritizeTimeOverSizeThresholds;
  this.backBufferDurationUs = C.msToUs(backBufferDurationMs);
  this.retainBackBufferFromKeyframe = retainBackBufferFromKeyframe;
}
 
Example #25
Source File: DefaultLoadControl.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
/** Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class. */
@SuppressWarnings("deprecation")
public DefaultLoadControl() {
  this(new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE));
}
 
Example #26
Source File: DefaultLoadControl.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * Constructs a new instance.
 *
 * @param allocator The {@link DefaultAllocator} used by the loader.
 * @param minBufferMs The minimum duration of media that the player will attempt to ensure is
 *     buffered at all times, in milliseconds.
 * @param maxBufferMs The maximum duration of media that the player will attempt buffer, in
 *     milliseconds.
 * @param bufferForPlaybackMs The duration of media that must be buffered for playback to start or
 *     resume following a user action such as a seek, in milliseconds.
 * @param bufferForPlaybackAfterRebufferMs The default duration of media that must be buffered for
 *     playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by
 *     buffer depletion rather than a user action.
 * @param priorityTaskManager If not null, registers itself as a task with priority
 *     {@link C#PRIORITY_PLAYBACK} during loading periods, and unregisters itself during draining
 *     periods.
 */
public DefaultLoadControl(DefaultAllocator allocator, int minBufferMs, int maxBufferMs,
    long bufferForPlaybackMs, long bufferForPlaybackAfterRebufferMs,
    PriorityTaskManager priorityTaskManager) {
  this.allocator = allocator;
  minBufferUs = minBufferMs * 1000L;
  maxBufferUs = maxBufferMs * 1000L;
  bufferForPlaybackUs = bufferForPlaybackMs * 1000L;
  bufferForPlaybackAfterRebufferUs = bufferForPlaybackAfterRebufferMs * 1000L;
  this.priorityTaskManager = priorityTaskManager;
}
 
Example #27
Source File: BufferSizeAdaptationBuilder.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the {@link DefaultAllocator} used by the loader.
 *
 * @param allocator The {@link DefaultAllocator}.
 * @return This builder, for convenience.
 * @throws IllegalStateException If {@link #buildPlayerComponents()} has already been called.
 */
public BufferSizeAdaptationBuilder setAllocator(DefaultAllocator allocator) {
  Assertions.checkState(!buildCalled);
  this.allocator = allocator;
  return this;
}
 
Example #28
Source File: DefaultLoadControl.java    From Telegram-FOSS with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Sets the {@link DefaultAllocator} used by the loader.
 *
 * @param allocator The {@link DefaultAllocator}.
 * @return This builder, for convenience.
 * @throws IllegalStateException If {@link #createDefaultLoadControl()} has already been called.
 */
public Builder setAllocator(DefaultAllocator allocator) {
  Assertions.checkState(!createDefaultLoadControlCalled);
  this.allocator = allocator;
  return this;
}
 
Example #29
Source File: DefaultLoadControl.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Constructs a new instance.
 *
 * @param allocator The {@link DefaultAllocator} used by the loader.
 * @param minBufferMs The minimum duration of media that the player will attempt to ensure is
 *     buffered at all times, in milliseconds.
 * @param maxBufferMs The maximum duration of media that the player will attempt buffer, in
 *     milliseconds.
 * @param bufferForPlaybackMs The duration of media that must be buffered for playback to start or
 *     resume following a user action such as a seek, in milliseconds.
 * @param bufferForPlaybackAfterRebufferMs The default duration of media that must be buffered for
 *     playback to resume after a rebuffer, in milliseconds. A rebuffer is defined to be caused by
 *     buffer depletion rather than a user action.
 */
public DefaultLoadControl(DefaultAllocator allocator, int minBufferMs, int maxBufferMs,
    long bufferForPlaybackMs, long bufferForPlaybackAfterRebufferMs) {
  this(allocator, minBufferMs, maxBufferMs, bufferForPlaybackMs, bufferForPlaybackAfterRebufferMs,
      null);
}
 
Example #30
Source File: DefaultLoadControl.java    From K-Sonic with MIT License 2 votes vote down vote up
/**
 * Constructs a new instance, using the {@code DEFAULT_*} constants defined in this class.
 *
 * @param allocator The {@link DefaultAllocator} used by the loader.
 */
public DefaultLoadControl(DefaultAllocator allocator) {
  this(allocator, DEFAULT_MIN_BUFFER_MS, DEFAULT_MAX_BUFFER_MS, DEFAULT_BUFFER_FOR_PLAYBACK_MS,
      DEFAULT_BUFFER_FOR_PLAYBACK_AFTER_REBUFFER_MS);
}