Java Code Examples for com.google.android.exoplayer2.util.Util#castNonNull()

The following examples show how to use com.google.android.exoplayer2.util.Util#castNonNull() . 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: DrmInitData.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
SchemeData(Parcel in) {
  uuid = new UUID(in.readLong(), in.readLong());
  licenseServerUrl = in.readString();
  mimeType = Util.castNonNull(in.readString());
  data = in.createByteArray();
  requiresSecureDecryption = in.readByte() != 0;
}
 
Example 2
Source File: MdtaMetadataEntry.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private MdtaMetadataEntry(Parcel in) {
  key = Util.castNonNull(in.readString());
  value = new byte[in.readInt()];
  in.readByteArray(value);
  localeIndicator = in.readInt();
  typeIndicator = in.readInt();
}
 
Example 3
Source File: DrmInitData.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
SchemeData(Parcel in) {
  uuid = new UUID(in.readLong(), in.readLong());
  licenseServerUrl = in.readString();
  mimeType = Util.castNonNull(in.readString());
  data = in.createByteArray();
  requiresSecureDecryption = in.readByte() != 0;
}
 
Example 4
Source File: MlltFrame.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
MlltFrame(Parcel in) {
  super(ID);
  this.mpegFramesBetweenReference = in.readInt();
  this.bytesBetweenReference = in.readInt();
  this.millisecondsBetweenReference = in.readInt();
  this.bytesDeviations = Util.castNonNull(in.createIntArray());
  this.millisecondsDeviations = Util.castNonNull(in.createIntArray());
}
 
Example 5
Source File: DefaultTrackSelector.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
Parameters(Parcel in) {
  super(in);
  // Video
  this.maxVideoWidth = in.readInt();
  this.maxVideoHeight = in.readInt();
  this.maxVideoFrameRate = in.readInt();
  this.maxVideoBitrate = in.readInt();
  this.exceedVideoConstraintsIfNecessary = Util.readBoolean(in);
  this.allowVideoMixedMimeTypeAdaptiveness = Util.readBoolean(in);
  this.allowVideoNonSeamlessAdaptiveness = Util.readBoolean(in);
  this.viewportWidth = in.readInt();
  this.viewportHeight = in.readInt();
  this.viewportOrientationMayChange = Util.readBoolean(in);
  // Audio
  this.maxAudioChannelCount = in.readInt();
  this.maxAudioBitrate = in.readInt();
  this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in);
  this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in);
  this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in);
  this.allowAudioMixedChannelCountAdaptiveness = Util.readBoolean(in);
  // General
  this.forceLowestBitrate = Util.readBoolean(in);
  this.forceHighestSupportedBitrate = Util.readBoolean(in);
  this.exceedRendererCapabilitiesIfNecessary = Util.readBoolean(in);
  this.tunnelingAudioSessionId = in.readInt();
  // Overrides
  this.selectionOverrides = readSelectionOverrides(in);
  this.rendererDisabledFlags = Util.castNonNull(in.readSparseBooleanArray());
  // Deprecated fields.
  this.allowMixedMimeAdaptiveness = allowVideoMixedMimeTypeAdaptiveness;
  this.allowNonSeamlessAdaptiveness = allowVideoNonSeamlessAdaptiveness;
}
 
Example 6
Source File: MdtaMetadataEntry.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private MdtaMetadataEntry(Parcel in) {
  key = Util.castNonNull(in.readString());
  value = new byte[in.readInt()];
  in.readByteArray(value);
  localeIndicator = in.readInt();
  typeIndicator = in.readInt();
}
 
Example 7
Source File: MlltFrame.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
MlltFrame(Parcel in) {
  super(ID);
  this.mpegFramesBetweenReference = in.readInt();
  this.bytesBetweenReference = in.readInt();
  this.millisecondsBetweenReference = in.readInt();
  this.bytesDeviations = Util.castNonNull(in.createIntArray());
  this.millisecondsDeviations = Util.castNonNull(in.createIntArray());
}
 
Example 8
Source File: DefaultTrackSelector.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
Parameters(Parcel in) {
  super(in);
  // Video
  this.maxVideoWidth = in.readInt();
  this.maxVideoHeight = in.readInt();
  this.maxVideoFrameRate = in.readInt();
  this.maxVideoBitrate = in.readInt();
  this.exceedVideoConstraintsIfNecessary = Util.readBoolean(in);
  this.allowVideoMixedMimeTypeAdaptiveness = Util.readBoolean(in);
  this.allowVideoNonSeamlessAdaptiveness = Util.readBoolean(in);
  this.viewportWidth = in.readInt();
  this.viewportHeight = in.readInt();
  this.viewportOrientationMayChange = Util.readBoolean(in);
  // Audio
  this.maxAudioChannelCount = in.readInt();
  this.maxAudioBitrate = in.readInt();
  this.exceedAudioConstraintsIfNecessary = Util.readBoolean(in);
  this.allowAudioMixedMimeTypeAdaptiveness = Util.readBoolean(in);
  this.allowAudioMixedSampleRateAdaptiveness = Util.readBoolean(in);
  this.allowAudioMixedChannelCountAdaptiveness = Util.readBoolean(in);
  // General
  this.forceLowestBitrate = Util.readBoolean(in);
  this.forceHighestSupportedBitrate = Util.readBoolean(in);
  this.exceedRendererCapabilitiesIfNecessary = Util.readBoolean(in);
  this.tunnelingAudioSessionId = in.readInt();
  // Overrides
  this.selectionOverrides = readSelectionOverrides(in);
  this.rendererDisabledFlags = Util.castNonNull(in.readSparseBooleanArray());
  // Deprecated fields.
  this.allowMixedMimeAdaptiveness = allowVideoMixedMimeTypeAdaptiveness;
  this.allowNonSeamlessAdaptiveness = allowVideoNonSeamlessAdaptiveness;
}
 
Example 9
Source File: MdtaMetadataEntry.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private MdtaMetadataEntry(Parcel in) {
  key = Util.castNonNull(in.readString());
  value = new byte[in.readInt()];
  in.readByteArray(value);
  localeIndicator = in.readInt();
  typeIndicator = in.readInt();
}
 
Example 10
Source File: MlltFrame.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
MlltFrame(Parcel in) {
  super(ID);
  this.mpegFramesBetweenReference = in.readInt();
  this.bytesBetweenReference = in.readInt();
  this.millisecondsBetweenReference = in.readInt();
  this.bytesDeviations = Util.castNonNull(in.createIntArray());
  this.millisecondsDeviations = Util.castNonNull(in.createIntArray());
}
 
Example 11
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private boolean handleMessage(Message msg) {
  switch (msg.what) {
    case MSG_ADD:
      MessageData<Collection<MediaSourceHolder>> addMessage =
          (MessageData<Collection<MediaSourceHolder>>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndInsert(addMessage.index, addMessage.customData.size());
      addMediaSourcesInternal(addMessage.index, addMessage.customData);
      scheduleTimelineUpdate(addMessage.onCompletionAction);
      break;
    case MSG_REMOVE:
      MessageData<Integer> removeMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      int fromIndex = removeMessage.index;
      int toIndex = removeMessage.customData;
      if (fromIndex == 0 && toIndex == shuffleOrder.getLength()) {
        shuffleOrder = shuffleOrder.cloneAndClear();
      } else {
        shuffleOrder = shuffleOrder.cloneAndRemove(fromIndex, toIndex);
      }
      for (int index = toIndex - 1; index >= fromIndex; index--) {
        removeMediaSourceInternal(index);
      }
      scheduleTimelineUpdate(removeMessage.onCompletionAction);
      break;
    case MSG_MOVE:
      MessageData<Integer> moveMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndRemove(moveMessage.index, moveMessage.index + 1);
      shuffleOrder = shuffleOrder.cloneAndInsert(moveMessage.customData, 1);
      moveMediaSourceInternal(moveMessage.index, moveMessage.customData);
      scheduleTimelineUpdate(moveMessage.onCompletionAction);
      break;
    case MSG_SET_SHUFFLE_ORDER:
      MessageData<ShuffleOrder> shuffleOrderMessage =
          (MessageData<ShuffleOrder>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrderMessage.customData;
      scheduleTimelineUpdate(shuffleOrderMessage.onCompletionAction);
      break;
    case MSG_UPDATE_TIMELINE:
      updateTimelineAndScheduleOnCompletionActions();
      break;
    case MSG_ON_COMPLETION:
      Set<HandlerAndRunnable> actions = (Set<HandlerAndRunnable>) Util.castNonNull(msg.obj);
      dispatchOnCompletionActions(actions);
      break;
    default:
      throw new IllegalStateException();
  }
  return true;
}
 
Example 12
Source File: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private boolean handleMessage(Message msg) {
  switch (msg.what) {
    case MSG_ADD:
      MessageData<Collection<MediaSourceHolder>> addMessage =
          (MessageData<Collection<MediaSourceHolder>>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndInsert(addMessage.index, addMessage.customData.size());
      addMediaSourcesInternal(addMessage.index, addMessage.customData);
      scheduleTimelineUpdate(addMessage.onCompletionAction);
      break;
    case MSG_REMOVE:
      MessageData<Integer> removeMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      int fromIndex = removeMessage.index;
      int toIndex = removeMessage.customData;
      if (fromIndex == 0 && toIndex == shuffleOrder.getLength()) {
        shuffleOrder = shuffleOrder.cloneAndClear();
      } else {
        shuffleOrder = shuffleOrder.cloneAndRemove(fromIndex, toIndex);
      }
      for (int index = toIndex - 1; index >= fromIndex; index--) {
        removeMediaSourceInternal(index);
      }
      scheduleTimelineUpdate(removeMessage.onCompletionAction);
      break;
    case MSG_MOVE:
      MessageData<Integer> moveMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndRemove(moveMessage.index, moveMessage.index + 1);
      shuffleOrder = shuffleOrder.cloneAndInsert(moveMessage.customData, 1);
      moveMediaSourceInternal(moveMessage.index, moveMessage.customData);
      scheduleTimelineUpdate(moveMessage.onCompletionAction);
      break;
    case MSG_SET_SHUFFLE_ORDER:
      MessageData<ShuffleOrder> shuffleOrderMessage =
          (MessageData<ShuffleOrder>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrderMessage.customData;
      scheduleTimelineUpdate(shuffleOrderMessage.onCompletionAction);
      break;
    case MSG_UPDATE_TIMELINE:
      updateTimelineAndScheduleOnCompletionActions();
      break;
    case MSG_ON_COMPLETION:
      Set<HandlerAndRunnable> actions = (Set<HandlerAndRunnable>) Util.castNonNull(msg.obj);
      dispatchOnCompletionActions(actions);
      break;
    default:
      throw new IllegalStateException();
  }
  return true;
}
 
Example 13
Source File: DrmInitData.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
DrmInitData(Parcel in) {
  schemeType = in.readString();
  schemeDatas = Util.castNonNull(in.createTypedArray(SchemeData.CREATOR));
  schemeDataCount = schemeDatas.length;
}
 
Example 14
Source File: DrmInitData.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
DrmInitData(Parcel in) {
  schemeType = in.readString();
  schemeDatas = Util.castNonNull(in.createTypedArray(SchemeData.CREATOR));
  schemeDataCount = schemeDatas.length;
}
 
Example 15
Source File: DefaultDrmSession.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private void onKeysRequired() {
  if (mode == DefaultDrmSessionManager.MODE_PLAYBACK && state == STATE_OPENED_WITH_KEYS) {
    Util.castNonNull(sessionId);
    doLicense(/* allowRetry= */ false);
  }
}
 
Example 16
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private boolean handleMessage(Message msg) {
  switch (msg.what) {
    case MSG_ADD:
      MessageData<Collection<MediaSourceHolder>> addMessage =
          (MessageData<Collection<MediaSourceHolder>>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndInsert(addMessage.index, addMessage.customData.size());
      addMediaSourcesInternal(addMessage.index, addMessage.customData);
      scheduleTimelineUpdate(addMessage.onCompletionAction);
      break;
    case MSG_REMOVE:
      MessageData<Integer> removeMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      int fromIndex = removeMessage.index;
      int toIndex = removeMessage.customData;
      if (fromIndex == 0 && toIndex == shuffleOrder.getLength()) {
        shuffleOrder = shuffleOrder.cloneAndClear();
      } else {
        shuffleOrder = shuffleOrder.cloneAndRemove(fromIndex, toIndex);
      }
      for (int index = toIndex - 1; index >= fromIndex; index--) {
        removeMediaSourceInternal(index);
      }
      scheduleTimelineUpdate(removeMessage.onCompletionAction);
      break;
    case MSG_MOVE:
      MessageData<Integer> moveMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrder.cloneAndRemove(moveMessage.index, moveMessage.index + 1);
      shuffleOrder = shuffleOrder.cloneAndInsert(moveMessage.customData, 1);
      moveMediaSourceInternal(moveMessage.index, moveMessage.customData);
      scheduleTimelineUpdate(moveMessage.onCompletionAction);
      break;
    case MSG_SET_SHUFFLE_ORDER:
      MessageData<ShuffleOrder> shuffleOrderMessage =
          (MessageData<ShuffleOrder>) Util.castNonNull(msg.obj);
      shuffleOrder = shuffleOrderMessage.customData;
      scheduleTimelineUpdate(shuffleOrderMessage.onCompletionAction);
      break;
    case MSG_UPDATE_TIMELINE:
      updateTimelineAndScheduleOnCompletionActions();
      break;
    case MSG_ON_COMPLETION:
      Set<HandlerAndRunnable> actions = (Set<HandlerAndRunnable>) Util.castNonNull(msg.obj);
      dispatchOnCompletionActions(actions);
      break;
    default:
      throw new IllegalStateException();
  }
  return true;
}
 
Example 17
Source File: DrmInitData.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
DrmInitData(Parcel in) {
  schemeType = in.readString();
  schemeDatas = Util.castNonNull(in.createTypedArray(SchemeData.CREATOR));
  schemeDataCount = schemeDatas.length;
}
 
Example 18
Source File: DefaultDrmSession.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
@RequiresNonNull("sessionId")
private void doLicense(boolean allowRetry) {
  if (isPlaceholderSession) {
    return;
  }
  byte[] sessionId = Util.castNonNull(this.sessionId);
  switch (mode) {
    case DefaultDrmSessionManager.MODE_PLAYBACK:
    case DefaultDrmSessionManager.MODE_QUERY:
      if (offlineLicenseKeySetId == null) {
        postKeyRequest(sessionId, ExoMediaDrm.KEY_TYPE_STREAMING, allowRetry);
      } else if (state == STATE_OPENED_WITH_KEYS || restoreKeys()) {
        long licenseDurationRemainingSec = getLicenseDurationRemainingSec();
        if (mode == DefaultDrmSessionManager.MODE_PLAYBACK
            && licenseDurationRemainingSec <= MAX_LICENSE_DURATION_TO_RENEW_SECONDS) {
          Log.d(
              TAG,
              "Offline license has expired or will expire soon. "
                  + "Remaining seconds: "
                  + licenseDurationRemainingSec);
          postKeyRequest(sessionId, ExoMediaDrm.KEY_TYPE_OFFLINE, allowRetry);
        } else if (licenseDurationRemainingSec <= 0) {
          onError(new KeysExpiredException());
        } else {
          state = STATE_OPENED_WITH_KEYS;
          eventDispatcher.dispatch(DefaultDrmSessionEventListener::onDrmKeysRestored);
        }
      }
      break;
    case DefaultDrmSessionManager.MODE_DOWNLOAD:
      if (offlineLicenseKeySetId == null || restoreKeys()) {
        postKeyRequest(sessionId, ExoMediaDrm.KEY_TYPE_OFFLINE, allowRetry);
      }
      break;
    case DefaultDrmSessionManager.MODE_RELEASE:
      Assertions.checkNotNull(offlineLicenseKeySetId);
      Assertions.checkNotNull(this.sessionId);
      // It's not necessary to restore the key (and open a session to do that) before releasing it
      // but this serves as a good sanity/fast-failure check.
      if (restoreKeys()) {
        postKeyRequest(offlineLicenseKeySetId, ExoMediaDrm.KEY_TYPE_RELEASE, allowRetry);
      }
      break;
    default:
      break;
  }
}
 
Example 19
Source File: DefaultDrmSession.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private void onKeysRequired() {
  if (mode == DefaultDrmSessionManager.MODE_PLAYBACK && state == STATE_OPENED_WITH_KEYS) {
    Util.castNonNull(sessionId);
    doLicense(/* allowRetry= */ false);
  }
}
 
Example 20
Source File: DrmInitData.java    From MediaSDK with Apache License 2.0 4 votes vote down vote up
SchemeData(Parcel in) {
  uuid = new UUID(in.readLong(), in.readLong());
  licenseServerUrl = in.readString();
  mimeType = Util.castNonNull(in.readString());
  data = in.createByteArray();
}