当前位置: 首页>>代码示例>>Java>>正文


Java C.RESULT_BUFFER_READ属性代码示例

本文整理汇总了Java中com.google.android.exoplayer2.C.RESULT_BUFFER_READ属性的典型用法代码示例。如果您正苦于以下问题:Java C.RESULT_BUFFER_READ属性的具体用法?Java C.RESULT_BUFFER_READ怎么用?Java C.RESULT_BUFFER_READ使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.google.android.exoplayer2.C的用法示例。


在下文中一共展示了C.RESULT_BUFFER_READ属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readData

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean requireFormat) {
  if (pendingDiscontinuity) {
    return C.RESULT_NOTHING_READ;
  }
  if (sentEos) {
    buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
    return C.RESULT_BUFFER_READ;
  }
  int result = stream.readData(formatHolder, buffer, requireFormat);
  // TODO: Clear gapless playback metadata if a format was read (if applicable).
  if (endUs != C.TIME_END_OF_SOURCE && ((result == C.RESULT_BUFFER_READ
      && buffer.timeUs >= endUs) || (result == C.RESULT_NOTHING_READ
      && mediaPeriod.getBufferedPositionUs() == C.TIME_END_OF_SOURCE))) {
    buffer.clear();
    buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
    sentEos = true;
    return C.RESULT_BUFFER_READ;
  }
  if (result == C.RESULT_BUFFER_READ && !buffer.isEndOfStream()) {
    buffer.timeUs -= startUs;
  }
  return result;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:25,代码来源:ClippingMediaPeriod.java

示例2: readData

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean requireFormat) {
  if (streamState == STREAM_STATE_END_OF_STREAM) {
    buffer.addFlag(C.BUFFER_FLAG_END_OF_STREAM);
    return C.RESULT_BUFFER_READ;
  } else if (requireFormat || streamState == STREAM_STATE_SEND_FORMAT) {
    formatHolder.format = format;
    streamState = STREAM_STATE_SEND_SAMPLE;
    return C.RESULT_FORMAT_READ;
  }

  Assertions.checkState(streamState == STREAM_STATE_SEND_SAMPLE);
  if (!loadingFinished) {
    return C.RESULT_NOTHING_READ;
  } else {
    buffer.timeUs = 0;
    buffer.addFlag(C.BUFFER_FLAG_KEY_FRAME);
    buffer.ensureSpaceForWrite(sampleSize);
    buffer.data.put(sampleData, 0, sampleSize);
    streamState = STREAM_STATE_END_OF_STREAM;
    return C.RESULT_BUFFER_READ;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:SingleSampleMediaPeriod.java

示例3: readData

/**
 * Attempts to read from the queue.
 *
 * @param formatHolder A {@link FormatHolder} to populate in the case of reading a format.
 * @param buffer A {@link DecoderInputBuffer} to populate in the case of reading a sample or the
 *     end of the stream. If the end of the stream has been reached, the
 *     {@link C#BUFFER_FLAG_END_OF_STREAM} flag will be set on the buffer.
 * @param formatRequired Whether the caller requires that the format of the stream be read even if
 *     it's not changing. A sample will never be read if set to true, however it is still possible
 *     for the end of stream or nothing to be read.
 * @param loadingFinished True if an empty queue should be considered the end of the stream.
 * @param decodeOnlyUntilUs If a buffer is read, the {@link C#BUFFER_FLAG_DECODE_ONLY} flag will
 *     be set if the buffer's timestamp is less than this value.
 * @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ} or
 *     {@link C#RESULT_BUFFER_READ}.
 */
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer, boolean formatRequired,
    boolean loadingFinished, long decodeOnlyUntilUs) {
  int result = infoQueue.readData(formatHolder, buffer, formatRequired, loadingFinished,
      downstreamFormat, extrasHolder);
  switch (result) {
    case C.RESULT_FORMAT_READ:
      downstreamFormat = formatHolder.format;
      return C.RESULT_FORMAT_READ;
    case C.RESULT_BUFFER_READ:
      if (!buffer.isEndOfStream()) {
        if (buffer.timeUs < decodeOnlyUntilUs) {
          buffer.addFlag(C.BUFFER_FLAG_DECODE_ONLY);
        }
        // Read encryption data if the sample is encrypted.
        if (buffer.isEncrypted()) {
          readEncryptionData(buffer, extrasHolder);
        }
        // Write the sample data into the holder.
        buffer.ensureSpaceForWrite(extrasHolder.size);
        readData(extrasHolder.offset, buffer.data, extrasHolder.size);
        // Advance the read head.
        dropDownstreamTo(extrasHolder.nextOffset);
      }
      return C.RESULT_BUFFER_READ;
    case C.RESULT_NOTHING_READ:
      return C.RESULT_NOTHING_READ;
    default:
      throw new IllegalStateException();
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:46,代码来源:DefaultTrackOutput.java

示例4: render

@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
  if (!inputStreamEnded && pendingMetadataCount < MAX_PENDING_METADATA_COUNT) {
    buffer.clear();
    int result = readSource(formatHolder, buffer, false);
    if (result == C.RESULT_BUFFER_READ) {
      if (buffer.isEndOfStream()) {
        inputStreamEnded = true;
      } else if (buffer.isDecodeOnly()) {
        // Do nothing. Note this assumes that all metadata buffers can be decoded independently.
        // If we ever need to support a metadata format where this is not the case, we'll need to
        // pass the buffer to the decoder and discard the output.
      } else {
        buffer.subsampleOffsetUs = formatHolder.format.subsampleOffsetUs;
        buffer.flip();
        try {
          int index = (pendingMetadataIndex + pendingMetadataCount) % MAX_PENDING_METADATA_COUNT;
          pendingMetadata[index] = decoder.decode(buffer);
          pendingMetadataTimestamps[index] = buffer.timeUs;
          pendingMetadataCount++;
        } catch (MetadataDecoderException e) {
          throw ExoPlaybackException.createForRenderer(e, getIndex());
        }
      }
    }
  }

  if (pendingMetadataCount > 0 && pendingMetadataTimestamps[pendingMetadataIndex] <= positionUs) {
    invokeRenderer(pendingMetadata[pendingMetadataIndex]);
    pendingMetadata[pendingMetadataIndex] = null;
    pendingMetadataIndex = (pendingMetadataIndex + 1) % MAX_PENDING_METADATA_COUNT;
    pendingMetadataCount--;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:34,代码来源:MetadataRenderer.java

示例5: readData

@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean formatRequired) {
  buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
  return C.RESULT_BUFFER_READ;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:6,代码来源:EmptySampleStream.java

示例6: feedInputBuffer

private boolean feedInputBuffer() throws AudioDecoderException, ExoPlaybackException {
  if (decoder == null || decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM
      || inputStreamEnded) {
    // We need to reinitialize the decoder or the input stream has ended.
    return false;
  }

  if (inputBuffer == null) {
    inputBuffer = decoder.dequeueInputBuffer();
    if (inputBuffer == null) {
      return false;
    }
  }

  if (decoderReinitializationState == REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM) {
    inputBuffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
    decoder.queueInputBuffer(inputBuffer);
    inputBuffer = null;
    decoderReinitializationState = REINITIALIZATION_STATE_WAIT_END_OF_STREAM;
    return false;
  }

  int result;
  if (waitingForKeys) {
    // We've already read an encrypted sample into buffer, and are waiting for keys.
    result = C.RESULT_BUFFER_READ;
  } else {
    result = readSource(formatHolder, inputBuffer, false);
  }

  if (result == C.RESULT_NOTHING_READ) {
    return false;
  }
  if (result == C.RESULT_FORMAT_READ) {
    onInputFormatChanged(formatHolder.format);
    return true;
  }
  if (inputBuffer.isEndOfStream()) {
    inputStreamEnded = true;
    decoder.queueInputBuffer(inputBuffer);
    inputBuffer = null;
    return false;
  }
  boolean bufferEncrypted = inputBuffer.isEncrypted();
  waitingForKeys = shouldWaitForKeys(bufferEncrypted);
  if (waitingForKeys) {
    return false;
  }
  inputBuffer.flip();
  decoder.queueInputBuffer(inputBuffer);
  decoderReceivedBuffers = true;
  decoderCounters.inputBufferCount++;
  inputBuffer = null;
  return true;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:55,代码来源:SimpleDecoderAudioRenderer.java


注:本文中的com.google.android.exoplayer2.C.RESULT_BUFFER_READ属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。