Java Code Examples for com.google.android.exoplayer2.C#ENCODING_AC4

The following examples show how to use com.google.android.exoplayer2.C#ENCODING_AC4 . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MimeTypes.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .ENCODING_*} constant that corresponds to specified MIME type, if
 * it is an encoded (non-PCM) audio format, or {@link C#ENCODING_INVALID} otherwise.
 *
 * @param mimeType The MIME type.
 * @return The {@link C}{@code .ENCODING_*} constant that corresponds to a specified MIME type, or
 *     {@link C#ENCODING_INVALID}.
 */
public static @C.Encoding int getEncoding(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_E_AC3_JOC:
      return C.ENCODING_E_AC3_JOC;
    case MimeTypes.AUDIO_AC4:
      return C.ENCODING_AC4;
    case MimeTypes.AUDIO_DTS:
      return C.ENCODING_DTS;
    case MimeTypes.AUDIO_DTS_HD:
      return C.ENCODING_DTS_HD;
    case MimeTypes.AUDIO_TRUEHD:
      return C.ENCODING_DOLBY_TRUEHD;
    default:
      return C.ENCODING_INVALID;
  }
}
 
Example 2
Source File: DefaultAudioSink.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static int getFramesPerEncodedSample(@C.Encoding 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 || encoding == C.ENCODING_E_AC3_JOC) {
    return Ac3Util.parseEAc3SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_AC4) {
    return Ac4Util.parseAc4SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_DOLBY_TRUEHD) {
    int syncframeOffset = Ac3Util.findTrueHdSyncframeOffset(buffer);
    return syncframeOffset == C.INDEX_UNSET
        ? 0
        : (Ac3Util.parseTrueHdSyncframeAudioSampleCount(buffer, syncframeOffset)
            * Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT);
  } else {
    throw new IllegalStateException("Unexpected audio encoding: " + encoding);
  }
}
 
Example 3
Source File: MimeTypes.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .ENCODING_*} constant that corresponds to specified MIME type, if
 * it is an encoded (non-PCM) audio format, or {@link C#ENCODING_INVALID} otherwise.
 *
 * @param mimeType The MIME type.
 * @return The {@link C}{@code .ENCODING_*} constant that corresponds to a specified MIME type, or
 *     {@link C#ENCODING_INVALID}.
 */
public static @C.Encoding int getEncoding(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_E_AC3_JOC:
      return C.ENCODING_E_AC3_JOC;
    case MimeTypes.AUDIO_AC4:
      return C.ENCODING_AC4;
    case MimeTypes.AUDIO_DTS:
      return C.ENCODING_DTS;
    case MimeTypes.AUDIO_DTS_HD:
      return C.ENCODING_DTS_HD;
    case MimeTypes.AUDIO_TRUEHD:
      return C.ENCODING_DOLBY_TRUEHD;
    default:
      return C.ENCODING_INVALID;
  }
}
 
Example 4
Source File: DefaultAudioSink.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static int getFramesPerEncodedSample(@C.Encoding 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 || encoding == C.ENCODING_E_AC3_JOC) {
    return Ac3Util.parseEAc3SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_AC4) {
    return Ac4Util.parseAc4SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_DOLBY_TRUEHD) {
    int syncframeOffset = Ac3Util.findTrueHdSyncframeOffset(buffer);
    return syncframeOffset == C.INDEX_UNSET
        ? 0
        : (Ac3Util.parseTrueHdSyncframeAudioSampleCount(buffer, syncframeOffset)
            * Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT);
  } else {
    throw new IllegalStateException("Unexpected audio encoding: " + encoding);
  }
}
 
Example 5
Source File: MimeTypes.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .ENCODING_*} constant that corresponds to specified MIME type, if
 * it is an encoded (non-PCM) audio format, or {@link C#ENCODING_INVALID} otherwise.
 *
 * @param mimeType The MIME type.
 * @return The {@link C}{@code .ENCODING_*} constant that corresponds to a specified MIME type, or
 *     {@link C#ENCODING_INVALID}.
 */
public static @C.Encoding int getEncoding(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_E_AC3_JOC:
      return C.ENCODING_E_AC3_JOC;
    case MimeTypes.AUDIO_AC4:
      return C.ENCODING_AC4;
    case MimeTypes.AUDIO_DTS:
      return C.ENCODING_DTS;
    case MimeTypes.AUDIO_DTS_HD:
      return C.ENCODING_DTS_HD;
    case MimeTypes.AUDIO_TRUEHD:
      return C.ENCODING_DOLBY_TRUEHD;
    default:
      return C.ENCODING_INVALID;
  }
}
 
Example 6
Source File: DefaultAudioSink.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static int getFramesPerEncodedSample(@C.Encoding 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 || encoding == C.ENCODING_E_AC3_JOC) {
    return Ac3Util.parseEAc3SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_AC4) {
    return Ac4Util.parseAc4SyncframeAudioSampleCount(buffer);
  } else if (encoding == C.ENCODING_DOLBY_TRUEHD) {
    int syncframeOffset = Ac3Util.findTrueHdSyncframeOffset(buffer);
    return syncframeOffset == C.INDEX_UNSET
        ? 0
        : (Ac3Util.parseTrueHdSyncframeAudioSampleCount(buffer, syncframeOffset)
            * Ac3Util.TRUEHD_RECHUNK_SAMPLE_COUNT);
  } else {
    throw new IllegalStateException("Unexpected audio encoding: " + encoding);
  }
}
 
Example 7
Source File: DefaultAudioSink.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static int getMaximumEncodedRateBytesPerSecond(@C.Encoding int encoding) {
  switch (encoding) {
    case C.ENCODING_AC3:
      return 640 * 1000 / 8;
    case C.ENCODING_E_AC3:
    case C.ENCODING_E_AC3_JOC:
      return 6144 * 1000 / 8;
    case C.ENCODING_AC4:
      return 2688 * 1000 / 8;
    case C.ENCODING_DTS:
      // DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s.
      return 1536 * 1000 / 8;
    case C.ENCODING_DTS_HD:
      return 18000 * 1000 / 8;
    case C.ENCODING_DOLBY_TRUEHD:
      return 24500 * 1000 / 8;
    case C.ENCODING_INVALID:
    case C.ENCODING_PCM_16BIT:
    case C.ENCODING_PCM_24BIT:
    case C.ENCODING_PCM_32BIT:
    case C.ENCODING_PCM_8BIT:
    case C.ENCODING_PCM_A_LAW:
    case C.ENCODING_PCM_FLOAT:
    case C.ENCODING_PCM_MU_LAW:
    case Format.NO_VALUE:
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 8
Source File: DefaultAudioSink.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static int getMaximumEncodedRateBytesPerSecond(@C.Encoding int encoding) {
  switch (encoding) {
    case C.ENCODING_AC3:
      return 640 * 1000 / 8;
    case C.ENCODING_E_AC3:
    case C.ENCODING_E_AC3_JOC:
      return 6144 * 1000 / 8;
    case C.ENCODING_AC4:
      return 2688 * 1000 / 8;
    case C.ENCODING_DTS:
      // DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s.
      return 1536 * 1000 / 8;
    case C.ENCODING_DTS_HD:
      return 18000 * 1000 / 8;
    case C.ENCODING_DOLBY_TRUEHD:
      return 24500 * 1000 / 8;
    case C.ENCODING_INVALID:
    case C.ENCODING_PCM_16BIT:
    case C.ENCODING_PCM_24BIT:
    case C.ENCODING_PCM_32BIT:
    case C.ENCODING_PCM_8BIT:
    case C.ENCODING_PCM_A_LAW:
    case C.ENCODING_PCM_FLOAT:
    case C.ENCODING_PCM_MU_LAW:
    case Format.NO_VALUE:
    default:
      throw new IllegalArgumentException();
  }
}
 
Example 9
Source File: DefaultAudioSink.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static int getMaximumEncodedRateBytesPerSecond(@C.Encoding int encoding) {
  switch (encoding) {
    case C.ENCODING_AC3:
      return 640 * 1000 / 8;
    case C.ENCODING_E_AC3:
    case C.ENCODING_E_AC3_JOC:
      return 6144 * 1000 / 8;
    case C.ENCODING_AC4:
      return 2688 * 1000 / 8;
    case C.ENCODING_DTS:
      // DTS allows an 'open' bitrate, but we assume the maximum listed value: 1536 kbit/s.
      return 1536 * 1000 / 8;
    case C.ENCODING_DTS_HD:
      return 18000 * 1000 / 8;
    case C.ENCODING_DOLBY_TRUEHD:
      return 24500 * 1000 / 8;
    case C.ENCODING_INVALID:
    case C.ENCODING_PCM_16BIT:
    case C.ENCODING_PCM_24BIT:
    case C.ENCODING_PCM_32BIT:
    case C.ENCODING_PCM_8BIT:
    case C.ENCODING_PCM_A_LAW:
    case C.ENCODING_PCM_FLOAT:
    case C.ENCODING_PCM_MU_LAW:
    case Format.NO_VALUE:
    default:
      throw new IllegalArgumentException();
  }
}