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


Java C.ENCODING_INVALID属性代码示例

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


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

示例1: getPcmEncoding

/**
 * Converts a sample bit depth to a corresponding PCM encoding constant.
 *
 * @param bitDepth The bit depth. Supported values are 8, 16, 24 and 32.
 * @return The corresponding encoding. One of {@link C#ENCODING_PCM_8BIT},
 *     {@link C#ENCODING_PCM_16BIT}, {@link C#ENCODING_PCM_24BIT} and
 *     {@link C#ENCODING_PCM_32BIT}. If the bit depth is unsupported then
 *     {@link C#ENCODING_INVALID} is returned.
 */
@C.PcmEncoding
public static int getPcmEncoding(int bitDepth) {
  switch (bitDepth) {
    case 8:
      return C.ENCODING_PCM_8BIT;
    case 16:
      return C.ENCODING_PCM_16BIT;
    case 24:
      return C.ENCODING_PCM_24BIT;
    case 32:
      return C.ENCODING_PCM_32BIT;
    default:
      return C.ENCODING_INVALID;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:24,代码来源:Util.java

示例2: ResamplingAudioProcessor

/**
 * Creates a new audio processor that converts audio data to {@link C#ENCODING_PCM_16BIT}.
 */
public ResamplingAudioProcessor() {
  sampleRateHz = Format.NO_VALUE;
  channelCount = Format.NO_VALUE;
  encoding = C.ENCODING_INVALID;
  buffer = EMPTY_BUFFER;
  outputBuffer = EMPTY_BUFFER;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:10,代码来源:ResamplingAudioProcessor.java

示例3: reset

@Override
public void reset() {
  flush();
  buffer = EMPTY_BUFFER;
  sampleRateHz = Format.NO_VALUE;
  channelCount = Format.NO_VALUE;
  encoding = C.ENCODING_INVALID;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:8,代码来源:ResamplingAudioProcessor.java

示例4: getEncodingForMimeType

@C.Encoding
private static int getEncodingForMimeType(String mimeType) {
  switch (mimeType) {
    case MimeTypes.AUDIO_AC3:
      return C.ENCODING_AC3;
    case MimeTypes.AUDIO_E_AC3:
      return C.ENCODING_E_AC3;
    case MimeTypes.AUDIO_DTS:
      return C.ENCODING_DTS;
    case MimeTypes.AUDIO_DTS_HD:
      return C.ENCODING_DTS_HD;
    default:
      return C.ENCODING_INVALID;
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:15,代码来源:AudioTrack.java

示例5: peek

/**
 * Peeks and returns a {@code WavHeader}.
 *
 * @param input Input stream to peek the WAV header from.
 * @throws ParserException If the input file is an incorrect RIFF WAV.
 * @throws IOException If peeking from the input fails.
 * @throws InterruptedException If interrupted while peeking from input.
 * @return A new {@code WavHeader} peeked from {@code input}, or null if the input is not a
 *     supported WAV format.
 */
public static WavHeader peek(ExtractorInput input) throws IOException, InterruptedException {
  Assertions.checkNotNull(input);

  // Allocate a scratch buffer large enough to store the format chunk.
  ParsableByteArray scratch = new ParsableByteArray(16);

  // Attempt to read the RIFF chunk.
  ChunkHeader chunkHeader = ChunkHeader.peek(input, scratch);
  if (chunkHeader.id != Util.getIntegerCodeForString("RIFF")) {
    return null;
  }

  input.peekFully(scratch.data, 0, 4);
  scratch.setPosition(0);
  int riffFormat = scratch.readInt();
  if (riffFormat != Util.getIntegerCodeForString("WAVE")) {
    Log.e(TAG, "Unsupported RIFF format: " + riffFormat);
    return null;
  }

  // Skip chunks until we find the format chunk.
  chunkHeader = ChunkHeader.peek(input, scratch);
  while (chunkHeader.id != Util.getIntegerCodeForString("fmt ")) {
    input.advancePeekPosition((int) chunkHeader.size);
    chunkHeader = ChunkHeader.peek(input, scratch);
  }

  Assertions.checkState(chunkHeader.size >= 16);
  input.peekFully(scratch.data, 0, 16);
  scratch.setPosition(0);
  int type = scratch.readLittleEndianUnsignedShort();
  int numChannels = scratch.readLittleEndianUnsignedShort();
  int sampleRateHz = scratch.readLittleEndianUnsignedIntToInt();
  int averageBytesPerSecond = scratch.readLittleEndianUnsignedIntToInt();
  int blockAlignment = scratch.readLittleEndianUnsignedShort();
  int bitsPerSample = scratch.readLittleEndianUnsignedShort();

  int expectedBlockAlignment = numChannels * bitsPerSample / 8;
  if (blockAlignment != expectedBlockAlignment) {
    throw new ParserException("Expected block alignment: " + expectedBlockAlignment + "; got: "
        + blockAlignment);
  }

  @C.PcmEncoding int encoding = Util.getPcmEncoding(bitsPerSample);
  if (encoding == C.ENCODING_INVALID) {
    Log.e(TAG, "Unsupported WAV bit depth: " + bitsPerSample);
    return null;
  }

  if (type != TYPE_PCM && type != TYPE_WAVE_FORMAT_EXTENSIBLE) {
    Log.e(TAG, "Unsupported WAV format type: " + type);
    return null;
  }

  // If present, skip extensionSize, validBitsPerSample, channelMask, subFormatGuid, ...
  input.advancePeekPosition((int) chunkHeader.size - 16);

  return new WavHeader(numChannels, sampleRateHz, averageBytesPerSecond, blockAlignment,
      bitsPerSample, encoding);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:70,代码来源:WavHeaderReader.java

示例6: isActive

@Override
public boolean isActive() {
  return encoding != C.ENCODING_INVALID && encoding != C.ENCODING_PCM_16BIT;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:4,代码来源:ResamplingAudioProcessor.java

示例7: queueInput

@Override
public void queueInput(ByteBuffer inputBuffer) {
  // Prepare the output buffer.
  int position = inputBuffer.position();
  int limit = inputBuffer.limit();
  int size = limit - position;
  int resampledSize;
  switch (encoding) {
    case C.ENCODING_PCM_8BIT:
      resampledSize = size * 2;
      break;
    case C.ENCODING_PCM_24BIT:
      resampledSize = (size / 3) * 2;
      break;
    case C.ENCODING_PCM_32BIT:
      resampledSize = size / 2;
      break;
    case C.ENCODING_PCM_16BIT:
    case C.ENCODING_INVALID:
    case Format.NO_VALUE:
    default:
      throw new IllegalStateException();
  }
  if (buffer.capacity() < resampledSize) {
    buffer = ByteBuffer.allocateDirect(resampledSize).order(ByteOrder.nativeOrder());
  } else {
    buffer.clear();
  }

  // Resample the little endian input and update the input/output buffers.
  switch (encoding) {
    case C.ENCODING_PCM_8BIT:
      // 8->16 bit resampling. Shift each byte from [0, 256) to [-128, 128) and scale up.
      for (int i = position; i < limit; i++) {
        buffer.put((byte) 0);
        buffer.put((byte) ((inputBuffer.get(i) & 0xFF) - 128));
      }
      break;
    case C.ENCODING_PCM_24BIT:
      // 24->16 bit resampling. Drop the least significant byte.
      for (int i = position; i < limit; i += 3) {
        buffer.put(inputBuffer.get(i + 1));
        buffer.put(inputBuffer.get(i + 2));
      }
      break;
    case C.ENCODING_PCM_32BIT:
      // 32->16 bit resampling. Drop the two least significant bytes.
      for (int i = position; i < limit; i += 4) {
        buffer.put(inputBuffer.get(i + 2));
        buffer.put(inputBuffer.get(i + 3));
      }
      break;
    case C.ENCODING_PCM_16BIT:
    case C.ENCODING_INVALID:
    case Format.NO_VALUE:
    default:
      // Never happens.
      throw new IllegalStateException();
  }
  inputBuffer.position(inputBuffer.limit());
  buffer.flip();
  outputBuffer = buffer;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:63,代码来源:ResamplingAudioProcessor.java


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