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


Java C.PcmEncoding方法代码示例

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


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

示例1: getPcmEncoding

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

示例2: WavHeader

import com.google.android.exoplayer2.C; //导入方法依赖的package包/类
public WavHeader(int numChannels, int sampleRateHz, int averageBytesPerSecond, int blockAlignment,
    int bitsPerSample, @C.PcmEncoding int encoding) {
  this.numChannels = numChannels;
  this.sampleRateHz = sampleRateHz;
  this.averageBytesPerSecond = averageBytesPerSecond;
  this.blockAlignment = blockAlignment;
  this.bitsPerSample = bitsPerSample;
  this.encoding = encoding;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:10,代码来源:WavHeader.java

示例3: getPcmFrameSize

import com.google.android.exoplayer2.C; //导入方法依赖的package包/类
/**
 * Returns the frame size for audio with {@code channelCount} channels in the specified encoding.
 *
 * @param pcmEncoding The encoding of the audio data.
 * @param channelCount The channel count.
 * @return The size of one audio frame in bytes.
 */
public static int getPcmFrameSize(@C.PcmEncoding int pcmEncoding, int channelCount) {
  switch (pcmEncoding) {
    case C.ENCODING_PCM_8BIT:
      return channelCount;
    case C.ENCODING_PCM_16BIT:
      return channelCount * 2;
    case C.ENCODING_PCM_24BIT:
      return channelCount * 3;
    case C.ENCODING_PCM_32BIT:
      return channelCount * 4;
    default:
      throw new IllegalArgumentException();
  }
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:22,代码来源:Util.java

示例4: peek

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

示例5: getEncoding

import com.google.android.exoplayer2.C; //导入方法依赖的package包/类
/** Returns the PCM encoding. **/
@C.PcmEncoding
public int getEncoding() {
  return encoding;
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:6,代码来源:WavHeader.java

示例6: configure

import com.google.android.exoplayer2.C; //导入方法依赖的package包/类
/**
 * Configures (or reconfigures) the audio track.
 *
 * @param mimeType The mime type.
 * @param channelCount The number of channels.
 * @param sampleRate The sample rate in Hz.
 * @param pcmEncoding For PCM formats, the encoding used. One of {@link C#ENCODING_PCM_16BIT},
 *     {@link C#ENCODING_PCM_16BIT}, {@link C#ENCODING_PCM_24BIT} and
 *     {@link C#ENCODING_PCM_32BIT}.
 * @param specifiedBufferSize A specific size for the playback buffer in bytes, or 0 to infer a
 *     suitable buffer size automatically.
 * @throws ConfigurationException If an error occurs configuring the track.
 */
public void configure(String mimeType, int channelCount, int sampleRate,
    @C.PcmEncoding int pcmEncoding, int specifiedBufferSize) throws ConfigurationException {
  configure(mimeType, channelCount, sampleRate, pcmEncoding, specifiedBufferSize, null);
}
 
开发者ID:sanjaysingh1990,项目名称:Exoplayer2Radio,代码行数:18,代码来源:AudioTrack.java


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