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


Java CodecSpecificDataUtil.buildAacAudioSpecificConfig方法代码示例

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


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

示例1: parseHeader

import com.google.android.exoplayer.util.CodecSpecificDataUtil; //导入方法依赖的package包/类
/**
 * Parses the sample header.
 */
private void parseHeader() {
  adtsScratch.setPosition(0);

  if (!hasOutputFormat) {
    int audioObjectType = adtsScratch.readBits(2) + 1;
    int sampleRateIndex = adtsScratch.readBits(4);
    adtsScratch.skipBits(1);
    int channelConfig = adtsScratch.readBits(3);

    byte[] audioSpecificConfig = CodecSpecificDataUtil.buildAacAudioSpecificConfig(
        audioObjectType, sampleRateIndex, channelConfig);
    Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig(
        audioSpecificConfig);

    MediaFormat mediaFormat = MediaFormat.createAudioFormat(MimeTypes.AUDIO_AAC,
        MediaFormat.NO_VALUE, audioParams.second, audioParams.first,
        Collections.singletonList(audioSpecificConfig));
    frameDurationUs = (C.MICROS_PER_SECOND * 1024L) / mediaFormat.sampleRate;
    output.format(mediaFormat);
    hasOutputFormat = true;
  } else {
    adtsScratch.skipBits(10);
  }

  adtsScratch.skipBits(4);
  sampleSize = adtsScratch.readBits(13) - 2 /* the sync word */ - HEADER_SIZE;
  if (hasCrc) {
    sampleSize -= CRC_SIZE;
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:34,代码来源:AdtsReader.java

示例2: parseAdtsHeader

import com.google.android.exoplayer.util.CodecSpecificDataUtil; //导入方法依赖的package包/类
/**
 * Parses the sample header.
 */
private void parseAdtsHeader() {
  adtsScratch.setPosition(0);

  if (!hasOutputFormat) {
    int audioObjectType = adtsScratch.readBits(2) + 1;
    if (audioObjectType != 2) {
      // The stream indicates AAC-Main (1), AAC-SSR (3) or AAC-LTP (4). When the stream indicates
      // AAC-Main it's more likely that the stream contains HE-AAC (5), which cannot be
      // represented correctly in the 2 bit audio_object_type field in the ADTS header. In
      // practice when the stream indicates AAC-SSR or AAC-LTP it more commonly contains AAC-LC or
      // HE-AAC. Since most Android devices don't support AAC-Main, AAC-SSR or AAC-LTP, and since
      // indicating AAC-LC works for HE-AAC streams, we pretend that we're dealing with AAC-LC and
      // hope for the best. In practice this often works.
      // See: https://github.com/google/ExoPlayer/issues/774
      // See: https://github.com/google/ExoPlayer/issues/1383
      Log.w(TAG, "Detected audio object type: " + audioObjectType + ", but assuming AAC LC.");
      audioObjectType = 2;
    }

    int sampleRateIndex = adtsScratch.readBits(4);
    adtsScratch.skipBits(1);
    int channelConfig = adtsScratch.readBits(3);

    byte[] audioSpecificConfig = CodecSpecificDataUtil.buildAacAudioSpecificConfig(
        audioObjectType, sampleRateIndex, channelConfig);
    Pair<Integer, Integer> audioParams = CodecSpecificDataUtil.parseAacAudioSpecificConfig(
        audioSpecificConfig);

    MediaFormat mediaFormat = MediaFormat.createAudioFormat(null, MimeTypes.AUDIO_AAC,
        MediaFormat.NO_VALUE, MediaFormat.NO_VALUE, C.UNKNOWN_TIME_US, audioParams.second,
        audioParams.first, Collections.singletonList(audioSpecificConfig), null);
    // In this class a sample is an access unit, but the MediaFormat sample rate specifies the
    // number of PCM audio samples per second.
    sampleDurationUs = (C.MICROS_PER_SECOND * 1024) / mediaFormat.sampleRate;
    output.format(mediaFormat);
    hasOutputFormat = true;
  } else {
    adtsScratch.skipBits(10);
  }

  adtsScratch.skipBits(4);
  int sampleSize = adtsScratch.readBits(13) - 2 /* the sync word */ - HEADER_SIZE;
  if (hasCrc) {
    sampleSize -= CRC_SIZE;
  }

  setReadingSampleState(output, sampleDurationUs, 0, sampleSize);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:52,代码来源:AdtsReader.java


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