com.google.android.exoplayer2.util.Util.castNonNull()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(261)

本文整理了Java中com.google.android.exoplayer2.util.Util.castNonNull()方法的一些代码示例,展示了Util.castNonNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.castNonNull()方法的具体详情如下:
包路径:com.google.android.exoplayer2.util.Util
类名称:Util
方法名:castNonNull

Util.castNonNull介绍

[英]Casts a nullable variable to a non-null variable without runtime null check.

Use Assertions#checkNotNull(Object) to throw if the value is null.
[中]将可空变量强制转换为非空变量,而无需运行时空检查。
如果值为null,则使用断言#checkNotNull(Object)抛出。

代码示例

代码示例来源:origin: google/ExoPlayer

/* package */ CommentFrame(Parcel in) {
 super(ID);
 language = castNonNull(in.readString());
 description = castNonNull(in.readString());
 text = castNonNull(in.readString());
}

代码示例来源:origin: google/ExoPlayer

/* package */ InternalFrame(Parcel in) {
 super(ID);
 domain = castNonNull(in.readString());
 description = castNonNull(in.readString());
 text = castNonNull(in.readString());
}

代码示例来源:origin: google/ExoPlayer

/* package */ UrlLinkFrame(Parcel in) {
 super(castNonNull(in.readString()));
 description = in.readString();
 url = castNonNull(in.readString());
}

代码示例来源:origin: google/ExoPlayer

/* package */ TextInformationFrame(Parcel in) {
 super(castNonNull(in.readString()));
 description = in.readString();
 value = castNonNull(in.readString());
}

代码示例来源:origin: google/ExoPlayer

/* package */ GeobFrame(Parcel in) {
 super(ID);
 mimeType = castNonNull(in.readString());
 filename = castNonNull(in.readString());
 description = castNonNull(in.readString());
 data = castNonNull(in.createByteArray());
}

代码示例来源:origin: google/ExoPlayer

/* package */ ApicFrame(Parcel in) {
 super(ID);
 mimeType = castNonNull(in.readString());
 description = castNonNull(in.readString());
 pictureType = in.readInt();
 pictureData = castNonNull(in.createByteArray());
}

代码示例来源:origin: google/ExoPlayer

/* package */ PrivFrame(Parcel in) {
 super(ID);
 owner = castNonNull(in.readString());
 privateData = castNonNull(in.createByteArray());
}

代码示例来源:origin: google/ExoPlayer

/* package */ EventMessage(Parcel in) {
 schemeIdUri = castNonNull(in.readString());
 value = castNonNull(in.readString());
 presentationTimeUs = in.readLong();
 durationMs = in.readLong();
 id = in.readLong();
 messageData = castNonNull(in.createByteArray());
}

代码示例来源:origin: google/ExoPlayer

/* package */ BinaryFrame(Parcel in) {
 super(castNonNull(in.readString()));
 data = castNonNull(in.createByteArray());
}

代码示例来源:origin: google/ExoPlayer

/**
 * Unregister a task.
 *
 * @param priority The priority of the task.
 */
public void remove(int priority) {
 synchronized (lock) {
  queue.remove(priority);
  highestPriority = queue.isEmpty() ? Integer.MIN_VALUE : Util.castNonNull(queue.peek());
  lock.notifyAll();
 }
}

代码示例来源:origin: google/ExoPlayer

/* package */ ChapterFrame(Parcel in) {
 super(ID);
 this.chapterId = castNonNull(in.readString());
 this.startTimeMs = in.readInt();
 this.endTimeMs = in.readInt();
 this.startOffset = in.readLong();
 this.endOffset = in.readLong();
 int subFrameCount = in.readInt();
 subFrames = new Id3Frame[subFrameCount];
 for (int i = 0; i < subFrameCount; i++) {
  subFrames[i] = in.readParcelable(Id3Frame.class.getClassLoader());
 }
}

代码示例来源:origin: google/ExoPlayer

private MdtaMetadataEntry(Parcel in) {
 key = Util.castNonNull(in.readString());
 value = new byte[in.readInt()];
 in.readByteArray(value);
 localeIndicator = in.readInt();
 typeIndicator = in.readInt();
}

代码示例来源:origin: google/ExoPlayer

/** Notifies listeners that a transfer ended. */
 protected final void transferEnded() {
  DataSpec dataSpec = castNonNull(this.dataSpec);
  for (int i = 0; i < listenerCount; i++) {
   listeners.get(i).onTransferEnd(/* source= */ this, dataSpec, isNetwork);
  }
  this.dataSpec = null;
 }
}

代码示例来源:origin: google/ExoPlayer

/* package */ ChapterTocFrame(Parcel in) {
 super(ID);
 this.elementId = castNonNull(in.readString());
 this.isRoot = in.readByte() != 0;
 this.isOrdered = in.readByte() != 0;
 this.children = in.createStringArray();
 int subFrameCount = in.readInt();
 subFrames = new Id3Frame[subFrameCount];
 for (int i = 0; i < subFrameCount; i++) {
  subFrames[i] = in.readParcelable(Id3Frame.class.getClassLoader());
 }
}

代码示例来源:origin: google/ExoPlayer

/**
 * Notifies listeners that bytes were transferred.
 *
 * @param bytesTransferred The number of bytes transferred since the previous call to this method
 *     (or if the first call, since the transfer was started).
 */
protected final void bytesTransferred(int bytesTransferred) {
 DataSpec dataSpec = castNonNull(this.dataSpec);
 for (int i = 0; i < listenerCount; i++) {
  listeners
    .get(i)
    .onBytesTransferred(/* source= */ this, dataSpec, isNetwork, bytesTransferred);
 }
}

代码示例来源:origin: google/ExoPlayer

/**
 * Skips any bytes that need skipping. Else does nothing.
 * <p>
 * This implementation is based roughly on {@code libcore.io.Streams.skipByReading()}.
 *
 * @throws InterruptedIOException If the thread is interrupted during the operation.
 * @throws EOFException If the end of the input stream is reached before the bytes are skipped.
 */
private void skipInternal() throws IOException {
 if (bytesSkipped == bytesToSkip) {
  return;
 }
 while (bytesSkipped != bytesToSkip) {
  int readLength = (int) Math.min(bytesToSkip - bytesSkipped, SKIP_BUFFER.length);
  int read = castNonNull(responseByteStream).read(SKIP_BUFFER, 0, readLength);
  if (Thread.currentThread().isInterrupted()) {
   throw new InterruptedIOException();
  }
  if (read == -1) {
   throw new EOFException();
  }
  bytesSkipped += read;
  bytesTransferred(read);
 }
}

代码示例来源:origin: google/ExoPlayer

int read = castNonNull(responseByteStream).read(buffer, offset, readLength);
if (read == -1) {
 if (bytesToRead != C.LENGTH_UNSET) {

代码示例来源:origin: google/ExoPlayer

private void maybeUpdateLatency(long systemTimeUs) {
 if (isOutputPcm
   && getLatencyMethod != null
   && systemTimeUs - lastLatencySampleTimeUs >= MIN_LATENCY_SAMPLE_INTERVAL_US) {
  try {
   // Compute the audio track latency, excluding the latency due to the buffer (leaving
   // latency due to the mixer and audio hardware driver).
   latencyUs =
     castNonNull((Integer) getLatencyMethod.invoke(Assertions.checkNotNull(audioTrack)))
         * 1000L
       - bufferSizeUs;
   // Sanity check that the latency is non-negative.
   latencyUs = Math.max(latencyUs, 0);
   // Sanity check that the latency isn't too large.
   if (latencyUs > MAX_LATENCY_US) {
    listener.onInvalidLatency(latencyUs);
    latencyUs = 0;
   }
  } catch (Exception e) {
   // The method existed, but doesn't work. Don't try again.
   getLatencyMethod = null;
  }
  lastLatencySampleTimeUs = systemTimeUs;
 }
}

代码示例来源:origin: google/ExoPlayer

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);
 break;
case MSG_REMOVE:
 MessageData<Integer> removeMessage = (MessageData<Integer>) Util.castNonNull(msg.obj);
 int fromIndex = removeMessage.index;
 int toIndex = removeMessage.customData;
 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);
case MSG_SET_SHUFFLE_ORDER:
 MessageData<ShuffleOrder> shuffleOrderMessage =
   (MessageData<ShuffleOrder>) Util.castNonNull(msg.obj);
 shuffleOrder = shuffleOrderMessage.customData;
 scheduleListenerNotification(shuffleOrderMessage.actionOnCompletion);
 break;
case MSG_ON_COMPLETION:
 List<Runnable> actionsOnCompletion = (List<Runnable>) Util.castNonNull(msg.obj);
 Handler handler = Assertions.checkNotNull(applicationThreadHandler);
 for (int i = 0; i < actionsOnCompletion.size(); i++) {

代码示例来源:origin: google/ExoPlayer

@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
 // Keep reading available samples as long as the sample time is not too far into the future.
 while (!hasReadStreamToEnd() && lastTimestampUs < positionUs + SAMPLE_WINDOW_DURATION_US) {
  buffer.clear();
  int result = readSource(formatHolder, buffer, /* formatRequired= */ false);
  if (result != C.RESULT_BUFFER_READ || buffer.isEndOfStream()) {
   return;
  }
  buffer.flip();
  lastTimestampUs = buffer.timeUs;
  if (listener != null) {
   float[] rotation = parseMetadata(buffer.data);
   if (rotation != null) {
    Util.castNonNull(listener).onCameraMotion(lastTimestampUs - offsetUs, rotation);
   }
  }
 }
}

相关文章