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


Java DecoderInputBuffer.setFlags方法代码示例

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


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

示例1: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
@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,代码行数:26,代码来源:ClippingMediaPeriod.java

示例2: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
/**
 * 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 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 loadingFinished,
    long decodeOnlyUntilUs) {
  switch (infoQueue.readData(formatHolder, buffer, downstreamFormat, extrasHolder)) {
    case C.RESULT_NOTHING_READ:
      if (loadingFinished) {
        buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
        return C.RESULT_BUFFER_READ;
      }
      return C.RESULT_NOTHING_READ;
    case C.RESULT_FORMAT_READ:
      downstreamFormat = formatHolder.format;
      return C.RESULT_FORMAT_READ;
    case C.RESULT_BUFFER_READ:
      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;
    default:
      throw new IllegalStateException();
  }
}
 
开发者ID:zhanglibin123488,项目名称:videoPickPlayer,代码行数:44,代码来源:DefaultTrackOutput.java

示例3: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
@Override
public int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean formatRequired) {
  if (formatRequired || !readFormat) {
    formatHolder.format = format;
    readFormat = true;
    return C.RESULT_FORMAT_READ;
  } else {
    buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
    return C.RESULT_BUFFER_READ;
  }
}
 
开发者ID:y20k,项目名称:transistor,代码行数:13,代码来源:FakeSampleStream.java

示例4: read

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
/**
 * 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 a sample is read then the buffer is populated with information
 *     about the sample, but not its data. The size and absolute position of the data in the
 *     rolling buffer is stored in {@code extrasHolder}, along with an encryption id if present
 *     and the absolute position of the first byte that may still be required after the current
 *     sample has been read. May be null if the caller requires that the format of the stream be
 *     read even if it's not changing.
 * @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 downstreamFormat The current downstream {@link Format}. If the format of the next
 *     sample is different to the current downstream format then a format will be read.
 * @param extrasHolder The holder into which extra sample information should be written.
 * @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ}
 *     or {@link C#RESULT_BUFFER_READ}.
 */
@SuppressWarnings("ReferenceEquality")
public synchronized int read(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean formatRequired, boolean loadingFinished, Format downstreamFormat,
    SampleExtrasHolder extrasHolder) {
  if (!hasNextSample()) {
    if (loadingFinished) {
      buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
      return C.RESULT_BUFFER_READ;
    } else if (upstreamFormat != null
        && (formatRequired || upstreamFormat != downstreamFormat)) {
      formatHolder.format = upstreamFormat;
      return C.RESULT_FORMAT_READ;
    } else {
      return C.RESULT_NOTHING_READ;
    }
  }

  int relativeReadIndex = getRelativeIndex(readPosition);
  if (formatRequired || formats[relativeReadIndex] != downstreamFormat) {
    formatHolder.format = formats[relativeReadIndex];
    return C.RESULT_FORMAT_READ;
  }

  if (buffer.isFlagsOnly()) {
    return C.RESULT_NOTHING_READ;
  }

  buffer.timeUs = timesUs[relativeReadIndex];
  buffer.setFlags(flags[relativeReadIndex]);
  extrasHolder.size = sizes[relativeReadIndex];
  extrasHolder.offset = offsets[relativeReadIndex];
  extrasHolder.cryptoData = cryptoDatas[relativeReadIndex];

  readPosition++;
  return C.RESULT_BUFFER_READ;
}
 
开发者ID:y20k,项目名称:transistor,代码行数:58,代码来源:SampleMetadataQueue.java

示例5: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
@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);
  if (result == C.RESULT_FORMAT_READ) {
    // Clear gapless playback metadata if the start/end points don't match the media.
    Format format = formatHolder.format;
    int encoderDelay = startUs != 0 ? 0 : format.encoderDelay;
    int encoderPadding = endUs != C.TIME_END_OF_SOURCE ? 0 : format.encoderPadding;
    formatHolder.format = format.copyWithGaplessInfo(encoderDelay, encoderPadding);
    return C.RESULT_FORMAT_READ;
  }
  if (endUs != C.TIME_END_OF_SOURCE
      && ((result == C.RESULT_BUFFER_READ && buffer.timeUs >= endUs)
          || (result == C.RESULT_NOTHING_READ
              && 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:y20k,项目名称:transistor,代码行数:34,代码来源:ClippingMediaPeriod.java

示例6: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
/**
 * 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 a sample is read then the buffer is populated with information
 *     about the sample, but not its data. The size and absolute position of the data in the
 *     rolling buffer is stored in {@code extrasHolder}, along with an encryption id if present
 *     and the absolute position of the first byte that may still be required after the current
 *     sample has been read. May be null if the caller requires that the format of the stream be
 *     read even if it's not changing.
 * @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 downstreamFormat The current downstream {@link Format}. If the format of the next
 *     sample is different to the current downstream format then a format will be read.
 * @param extrasHolder The holder into which extra sample information should be written.
 * @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ}
 *     or {@link C#RESULT_BUFFER_READ}.
 */
@SuppressWarnings("ReferenceEquality")
public synchronized int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean formatRequired, boolean loadingFinished, Format downstreamFormat,
    BufferExtrasHolder extrasHolder) {
  if (queueSize == 0) {
    if (loadingFinished) {
      buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
      return C.RESULT_BUFFER_READ;
    } else if (upstreamFormat != null
        && (formatRequired || upstreamFormat != downstreamFormat)) {
      formatHolder.format = upstreamFormat;
      return C.RESULT_FORMAT_READ;
    } else {
      return C.RESULT_NOTHING_READ;
    }
  }

  if (formatRequired || formats[relativeReadIndex] != downstreamFormat) {
    formatHolder.format = formats[relativeReadIndex];
    return C.RESULT_FORMAT_READ;
  }

  if (buffer.isFlagsOnly()) {
    return C.RESULT_NOTHING_READ;
  }

  buffer.timeUs = timesUs[relativeReadIndex];
  buffer.setFlags(flags[relativeReadIndex]);
  extrasHolder.size = sizes[relativeReadIndex];
  extrasHolder.offset = offsets[relativeReadIndex];
  extrasHolder.encryptionKeyId = encryptionKeys[relativeReadIndex];

  largestDequeuedTimestampUs = Math.max(largestDequeuedTimestampUs, buffer.timeUs);
  queueSize--;
  relativeReadIndex++;
  absoluteReadIndex++;
  if (relativeReadIndex == capacity) {
    // Wrap around.
    relativeReadIndex = 0;
  }

  extrasHolder.nextOffset = queueSize > 0 ? offsets[relativeReadIndex]
      : extrasHolder.offset + extrasHolder.size;
  return C.RESULT_BUFFER_READ;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:67,代码来源:DefaultTrackOutput.java

示例7: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
@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,代码行数:7,代码来源:EmptySampleStream.java

示例8: readData

import com.google.android.exoplayer2.decoder.DecoderInputBuffer; //导入方法依赖的package包/类
/**
 * 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 a sample is read then the buffer is populated with information
 *     about the sample, but not its data. The size and absolute position of the data in the
 *     rolling buffer is stored in {@code extrasHolder}, along with an encryption id if present
 *     and the absolute position of the first byte that may still be required after the current
 *     sample has been read. May be null if the caller requires that the format of the stream be
 *     read even if it's not changing.
 * @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 downstreamFormat The current downstream {@link Format}. If the format of the next
 *     sample is different to the current downstream format then a format will be read.
 * @param extrasHolder The holder into which extra sample information should be written.
 * @return The result, which can be {@link C#RESULT_NOTHING_READ}, {@link C#RESULT_FORMAT_READ}
 *     or {@link C#RESULT_BUFFER_READ}.
 */
@SuppressWarnings("ReferenceEquality")
public synchronized int readData(FormatHolder formatHolder, DecoderInputBuffer buffer,
    boolean formatRequired, boolean loadingFinished, Format downstreamFormat,
    BufferExtrasHolder extrasHolder) {
  if (queueSize == 0) {
    if (loadingFinished) {
      buffer.setFlags(C.BUFFER_FLAG_END_OF_STREAM);
      return C.RESULT_BUFFER_READ;
    } else if (upstreamFormat != null
        && (formatRequired || upstreamFormat != downstreamFormat)) {
      formatHolder.format = upstreamFormat;
      return C.RESULT_FORMAT_READ;
    } else {
      return C.RESULT_NOTHING_READ;
    }
  }

  if (formatRequired || formats[relativeReadIndex] != downstreamFormat) {
    formatHolder.format = formats[relativeReadIndex];
    return C.RESULT_FORMAT_READ;
  }

  buffer.timeUs = timesUs[relativeReadIndex];
  buffer.setFlags(flags[relativeReadIndex]);
  extrasHolder.size = sizes[relativeReadIndex];
  extrasHolder.offset = offsets[relativeReadIndex];
  extrasHolder.encryptionKeyId = encryptionKeys[relativeReadIndex];

  largestDequeuedTimestampUs = Math.max(largestDequeuedTimestampUs, buffer.timeUs);
  queueSize--;
  relativeReadIndex++;
  absoluteReadIndex++;
  if (relativeReadIndex == capacity) {
    // Wrap around.
    relativeReadIndex = 0;
  }

  extrasHolder.nextOffset = queueSize > 0 ? offsets[relativeReadIndex]
      : extrasHolder.offset + extrasHolder.size;
  return C.RESULT_BUFFER_READ;
}
 
开发者ID:jcodeing,项目名称:K-Sonic,代码行数:63,代码来源:DefaultTrackOutput.java


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