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


Java C.ENCODING_AC3属性代码示例

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


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

示例1: getEncodingForMimeType

/**
 * Returns the output audio encoding that will result from processing input in {@code mimeType}.
 * For non-passthrough audio formats, this is always {@link AudioFormat#ENCODING_PCM_16BIT}. For
 * passthrough formats it will be one of {@link AudioFormat}'s other {@code ENCODING_*} constants.
 * For non-audio formats, {@link AudioFormat#ENCODING_INVALID} will be returned.
 *
 * @param mimeType The MIME type of media that will be decoded (or passed through).
 * @return The corresponding {@link AudioFormat} encoding.
 */
public static int getEncodingForMimeType(String mimeType) {
  if (AUDIO_AC3.equals(mimeType)) {
    return C.ENCODING_AC3;
  }
  if (AUDIO_EC3.equals(mimeType)) {
    return C.ENCODING_E_AC3;
  }

  // All other audio formats will be decoded to 16-bit PCM.
  return isAudio(mimeType) ? AudioFormat.ENCODING_PCM_16BIT : AudioFormat.ENCODING_INVALID;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:20,代码来源:MimeTypes.java

示例2: getEncodingForMimeType

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:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:14,代码来源:AudioTrack.java

示例3: getFramesPerEncodedSample

private static int getFramesPerEncodedSample(int encoding, ByteBuffer buffer) {
  if (encoding == C.ENCODING_DTS || encoding == C.ENCODING_DTS_HD) {
    return DtsUtil.parseDtsAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_AC3) {
    return Ac3Util.getAc3SyncframeAudioSampleCount();
  } else if (encoding == C.ENCODING_E_AC3) {
    return Ac3Util.parseEAc3SyncframeAudioSampleCount(buffer);
  } else {
    throw new IllegalStateException("Unexpected audio encoding: " + encoding);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:11,代码来源:AudioTrack.java

示例4: reconfigure

/**
 * Reconfigures the audio track to play back media in {@code format}.
 *
 * @param format Specifies the channel count and sample rate to play back.
 * @param specifiedBufferSize A specific size for the playback buffer in bytes, or 0 to use a
 *          size inferred from the format.
 */
public void reconfigure(MediaFormat format, int specifiedBufferSize) {
  int channelCount = format.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
  int channelConfig;
  switch (channelCount) {
    case 1:
      channelConfig = AudioFormat.CHANNEL_OUT_MONO;
      break;
    case 2:
      channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
      break;
    case 6:
      channelConfig = AudioFormat.CHANNEL_OUT_5POINT1;
      break;
    case 8:
      channelConfig = AudioFormat.CHANNEL_OUT_7POINT1;
      break;
    default:
      throw new IllegalArgumentException("Unsupported channel count: " + channelCount);
  }

  int sampleRate = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
  String mimeType = format.getString(MediaFormat.KEY_MIME);

  // TODO: Does channelConfig determine channelCount?
  int encoding = MimeTypes.getEncodingForMimeType(mimeType);
  boolean isAc3 = encoding == C.ENCODING_AC3 || encoding == C.ENCODING_E_AC3;
  if (isInitialized() && this.sampleRate == sampleRate && this.channelConfig == channelConfig
      && !this.isAc3 && !isAc3) {
    // We already have an existing audio track with the correct sample rate and channel config.
    return;
  }

  reset();

  this.encoding = encoding;
  this.sampleRate = sampleRate;
  this.channelConfig = channelConfig;
  this.isAc3 = isAc3;
  ac3Bitrate = UNKNOWN_AC3_BITRATE; // Calculated on receiving the first buffer if isAc3 is true.
  frameSize = 2 * channelCount; // 2 bytes per 16 bit sample * number of channels.
  minBufferSize = android.media.AudioTrack.getMinBufferSize(sampleRate, channelConfig, encoding);
  Assertions.checkState(minBufferSize != android.media.AudioTrack.ERROR_BAD_VALUE);

  if (specifiedBufferSize != 0) {
    bufferSize = specifiedBufferSize;
  } else {
    int multipliedBufferSize = minBufferSize * BUFFER_MULTIPLICATION_FACTOR;
    int minAppBufferSize = (int) durationUsToFrames(MIN_BUFFER_DURATION_US) * frameSize;
    int maxAppBufferSize = (int) Math.max(minBufferSize,
        durationUsToFrames(MAX_BUFFER_DURATION_US) * frameSize);
    bufferSize = multipliedBufferSize < minAppBufferSize
        ? minAppBufferSize
        : multipliedBufferSize > maxAppBufferSize
            ? maxAppBufferSize
            : multipliedBufferSize;
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:64,代码来源:AudioTrack.java

示例5: needsPassthroughWorkarounds

/**
 * Returns whether to work around problems with passthrough audio tracks.
 * See [Internal: b/18899620, b/19187573, b/21145353].
 */
private boolean needsPassthroughWorkarounds() {
  return Util.SDK_INT < 23
      && (targetEncoding == C.ENCODING_AC3 || targetEncoding == C.ENCODING_E_AC3);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:8,代码来源:AudioTrack.java


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