Java Code Examples for com.google.android.exoplayer2.util.MimeTypes#AUDIO_E_AC3

The following examples show how to use com.google.android.exoplayer2.util.MimeTypes#AUDIO_E_AC3 . 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: SsManifestParser.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
private static String fourCCToMimeType(String fourCC) {
  if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264")
      || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) {
    return MimeTypes.VIDEO_H264;
  } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL")
      || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) {
    return MimeTypes.AUDIO_AAC;
  } else if (fourCC.equalsIgnoreCase("TTML") || fourCC.equalsIgnoreCase("DFXP")) {
    return MimeTypes.APPLICATION_TTML;
  } else if (fourCC.equalsIgnoreCase("ac-3") || fourCC.equalsIgnoreCase("dac3")) {
    return MimeTypes.AUDIO_AC3;
  } else if (fourCC.equalsIgnoreCase("ec-3") || fourCC.equalsIgnoreCase("dec3")) {
    return MimeTypes.AUDIO_E_AC3;
  } else if (fourCC.equalsIgnoreCase("dtsc")) {
    return MimeTypes.AUDIO_DTS;
  } else if (fourCC.equalsIgnoreCase("dtsh") || fourCC.equalsIgnoreCase("dtsl")) {
    return MimeTypes.AUDIO_DTS_HD;
  } else if (fourCC.equalsIgnoreCase("dtse")) {
    return MimeTypes.AUDIO_DTS_EXPRESS;
  } else if (fourCC.equalsIgnoreCase("opus")) {
    return MimeTypes.AUDIO_OPUS;
  }
  return null;
}
 
Example 2
Source File: MediaCodecAudioRenderer.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link C.Encoding} constant to use for passthrough of the given format, or {@link
 * C#ENCODING_INVALID} if passthrough is not possible.
 */
@C.Encoding
protected int getPassthroughEncoding(int channelCount, String mimeType) {
  if (MimeTypes.AUDIO_E_AC3_JOC.equals(mimeType)) {
    // E-AC3 JOC is object-based so the output channel count is arbitrary.
    if (audioSink.supportsOutput(/* channelCount= */ Format.NO_VALUE, C.ENCODING_E_AC3_JOC)) {
      return MimeTypes.getEncoding(MimeTypes.AUDIO_E_AC3_JOC);
    }
    // E-AC3 receivers can decode JOC streams, but in 2-D rather than 3-D, so try to fall back.
    mimeType = MimeTypes.AUDIO_E_AC3;
  }

  @C.Encoding int encoding = MimeTypes.getEncoding(mimeType);
  if (audioSink.supportsOutput(channelCount, encoding)) {
    return encoding;
  } else {
    return C.ENCODING_INVALID;
  }
}
 
Example 3
Source File: MediaCodecAudioRenderer.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.Encoding} constant to use for passthrough of the given format, or {@link
 * C#ENCODING_INVALID} if passthrough is not possible.
 */
@C.Encoding
protected int getPassthroughEncoding(int channelCount, String mimeType) {
  if (MimeTypes.AUDIO_E_AC3_JOC.equals(mimeType)) {
    if (audioSink.supportsOutput(channelCount, C.ENCODING_E_AC3_JOC)) {
      return MimeTypes.getEncoding(MimeTypes.AUDIO_E_AC3_JOC);
    }
    // E-AC3 receivers can decode JOC streams, but in 2-D rather than 3-D, so try to fall back.
    mimeType = MimeTypes.AUDIO_E_AC3;
  }

  @C.Encoding int encoding = MimeTypes.getEncoding(mimeType);
  if (audioSink.supportsOutput(channelCount, encoding)) {
    return encoding;
  } else {
    return C.ENCODING_INVALID;
  }
}
 
Example 4
Source File: MediaCodecAudioRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C.Encoding} constant to use for passthrough of the given format, or {@link
 * C#ENCODING_INVALID} if passthrough is not possible.
 */
@C.Encoding
protected int getPassthroughEncoding(int channelCount, String mimeType) {
  if (MimeTypes.AUDIO_E_AC3_JOC.equals(mimeType)) {
    if (audioSink.supportsOutput(channelCount, C.ENCODING_E_AC3_JOC)) {
      return MimeTypes.getEncoding(MimeTypes.AUDIO_E_AC3_JOC);
    }
    // E-AC3 receivers can decode JOC streams, but in 2-D rather than 3-D, so try to fall back.
    mimeType = MimeTypes.AUDIO_E_AC3;
  }

  @C.Encoding int encoding = MimeTypes.getEncoding(mimeType);
  if (audioSink.supportsOutput(channelCount, encoding)) {
    return encoding;
  } else {
    return C.ENCODING_INVALID;
  }
}
 
Example 5
Source File: SsManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static String fourCCToMimeType(String fourCC) {
  if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264")
      || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) {
    return MimeTypes.VIDEO_H264;
  } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL")
      || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) {
    return MimeTypes.AUDIO_AAC;
  } else if (fourCC.equalsIgnoreCase("TTML") || fourCC.equalsIgnoreCase("DFXP")) {
    return MimeTypes.APPLICATION_TTML;
  } else if (fourCC.equalsIgnoreCase("ac-3") || fourCC.equalsIgnoreCase("dac3")) {
    return MimeTypes.AUDIO_AC3;
  } else if (fourCC.equalsIgnoreCase("ec-3") || fourCC.equalsIgnoreCase("dec3")) {
    return MimeTypes.AUDIO_E_AC3;
  } else if (fourCC.equalsIgnoreCase("dtsc")) {
    return MimeTypes.AUDIO_DTS;
  } else if (fourCC.equalsIgnoreCase("dtsh") || fourCC.equalsIgnoreCase("dtsl")) {
    return MimeTypes.AUDIO_DTS_HD;
  } else if (fourCC.equalsIgnoreCase("dtse")) {
    return MimeTypes.AUDIO_DTS_EXPRESS;
  } else if (fourCC.equalsIgnoreCase("opus")) {
    return MimeTypes.AUDIO_OPUS;
  }
  return null;
}
 
Example 6
Source File: SsManifestParser.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private static String fourCCToMimeType(String fourCC) {
  if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264")
      || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) {
    return MimeTypes.VIDEO_H264;
  } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL")
      || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) {
    return MimeTypes.AUDIO_AAC;
  } else if (fourCC.equalsIgnoreCase("TTML") || fourCC.equalsIgnoreCase("DFXP")) {
    return MimeTypes.APPLICATION_TTML;
  } else if (fourCC.equalsIgnoreCase("ac-3") || fourCC.equalsIgnoreCase("dac3")) {
    return MimeTypes.AUDIO_AC3;
  } else if (fourCC.equalsIgnoreCase("ec-3") || fourCC.equalsIgnoreCase("dec3")) {
    return MimeTypes.AUDIO_E_AC3;
  } else if (fourCC.equalsIgnoreCase("dtsc")) {
    return MimeTypes.AUDIO_DTS;
  } else if (fourCC.equalsIgnoreCase("dtsh") || fourCC.equalsIgnoreCase("dtsl")) {
    return MimeTypes.AUDIO_DTS_HD;
  } else if (fourCC.equalsIgnoreCase("dtse")) {
    return MimeTypes.AUDIO_DTS_EXPRESS;
  } else if (fourCC.equalsIgnoreCase("opus")) {
    return MimeTypes.AUDIO_OPUS;
  }
  return null;
}
 
Example 7
Source File: SsManifestParser.java    From K-Sonic with MIT License 6 votes vote down vote up
private static String fourCCToMimeType(String fourCC) {
  if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264")
      || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) {
    return MimeTypes.VIDEO_H264;
  } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL")
      || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) {
    return MimeTypes.AUDIO_AAC;
  } else if (fourCC.equalsIgnoreCase("TTML")) {
    return MimeTypes.APPLICATION_TTML;
  } else if (fourCC.equalsIgnoreCase("ac-3") || fourCC.equalsIgnoreCase("dac3")) {
    return MimeTypes.AUDIO_AC3;
  } else if (fourCC.equalsIgnoreCase("ec-3") || fourCC.equalsIgnoreCase("dec3")) {
    return MimeTypes.AUDIO_E_AC3;
  } else if (fourCC.equalsIgnoreCase("dtsc")) {
    return MimeTypes.AUDIO_DTS;
  } else if (fourCC.equalsIgnoreCase("dtsh") || fourCC.equalsIgnoreCase("dtsl")) {
    return MimeTypes.AUDIO_DTS_HD;
  } else if (fourCC.equalsIgnoreCase("dtse")) {
    return MimeTypes.AUDIO_DTS_EXPRESS;
  } else if (fourCC.equalsIgnoreCase("opus")) {
    return MimeTypes.AUDIO_OPUS;
  }
  return null;
}
 
Example 8
Source File: SsManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static String fourCCToMimeType(String fourCC) {
  if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264")
      || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) {
    return MimeTypes.VIDEO_H264;
  } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL")
      || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) {
    return MimeTypes.AUDIO_AAC;
  } else if (fourCC.equalsIgnoreCase("TTML")) {
    return MimeTypes.APPLICATION_TTML;
  } else if (fourCC.equalsIgnoreCase("ac-3") || fourCC.equalsIgnoreCase("dac3")) {
    return MimeTypes.AUDIO_AC3;
  } else if (fourCC.equalsIgnoreCase("ec-3") || fourCC.equalsIgnoreCase("dec3")) {
    return MimeTypes.AUDIO_E_AC3;
  } else if (fourCC.equalsIgnoreCase("dtsc")) {
    return MimeTypes.AUDIO_DTS;
  } else if (fourCC.equalsIgnoreCase("dtsh") || fourCC.equalsIgnoreCase("dtsl")) {
    return MimeTypes.AUDIO_DTS_HD;
  } else if (fourCC.equalsIgnoreCase("dtse")) {
    return MimeTypes.AUDIO_DTS_EXPRESS;
  } else if (fourCC.equalsIgnoreCase("opus")) {
    return MimeTypes.AUDIO_OPUS;
  }
  return null;
}
 
Example 9
Source File: DashManifestParser.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
protected static String parseEac3SupplementalProperties(List<Descriptor> supplementalProperties) {
  for (int i = 0; i < supplementalProperties.size(); i++) {
    Descriptor descriptor = supplementalProperties.get(i);
    String schemeIdUri = descriptor.schemeIdUri;
    if ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(schemeIdUri)
        && "ec+3".equals(descriptor.value)) {
      return MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return MimeTypes.AUDIO_E_AC3;
}
 
Example 10
Source File: DashManifestParser.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
protected static String parseEac3SupplementalProperties(List<Descriptor> supplementalProperties) {
  for (int i = 0; i < supplementalProperties.size(); i++) {
    Descriptor descriptor = supplementalProperties.get(i);
    String schemeIdUri = descriptor.schemeIdUri;
    if (("tag:dolby.com,2018:dash:EC3_ExtensionType:2018".equals(schemeIdUri)
            && "JOC".equals(descriptor.value))
        || ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(schemeIdUri)
            && "ec+3".equals(descriptor.value))) {
      return MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return MimeTypes.AUDIO_E_AC3;
}
 
Example 11
Source File: AudioTrack.java    From K-Sonic with MIT License 5 votes vote down vote up
@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;
  }
}
 
Example 12
Source File: MediaCodecUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns all {@link MediaCodecInfo}s for the given mime type, in the order given by {@link
 * MediaCodecList}.
 *
 * @param mimeType The MIME type.
 * @param secure Whether the decoder is required to support secure decryption. Always pass false
 *     unless secure decryption really is required.
 * @return A list of all {@link MediaCodecInfo}s for the given mime type, in the order given by
 *     {@link MediaCodecList}.
 * @throws DecoderQueryException If there was an error querying the available decoders.
 */
public static synchronized List<MediaCodecInfo> getDecoderInfos(String mimeType, boolean secure)
    throws DecoderQueryException {
  CodecKey key = new CodecKey(mimeType, secure);
  List<MediaCodecInfo> cachedDecoderInfos = decoderInfosCache.get(key);
  if (cachedDecoderInfos != null) {
    return cachedDecoderInfos;
  }
  MediaCodecListCompat mediaCodecList = Util.SDK_INT >= 21
      ? new MediaCodecListCompatV21(secure) : new MediaCodecListCompatV16();
  ArrayList<MediaCodecInfo> decoderInfos = getDecoderInfosInternal(key, mediaCodecList, mimeType);
  if (secure && decoderInfos.isEmpty() && 21 <= Util.SDK_INT && Util.SDK_INT <= 23) {
    // Some devices don't list secure decoders on API level 21 [Internal: b/18678462]. Try the
    // legacy path. We also try this path on API levels 22 and 23 as a defensive measure.
    mediaCodecList = new MediaCodecListCompatV16();
    decoderInfos = getDecoderInfosInternal(key, mediaCodecList, mimeType);
    if (!decoderInfos.isEmpty()) {
      Log.w(TAG, "MediaCodecList API didn't list secure decoder for: " + mimeType
          + ". Assuming: " + decoderInfos.get(0).name);
    }
  }
  if (MimeTypes.AUDIO_E_AC3_JOC.equals(mimeType)) {
    // E-AC3 decoders can decode JOC streams, but in 2-D rather than 3-D.
    CodecKey eac3Key = new CodecKey(MimeTypes.AUDIO_E_AC3, key.secure);
    ArrayList<MediaCodecInfo> eac3DecoderInfos =
        getDecoderInfosInternal(eac3Key, mediaCodecList, mimeType);
    decoderInfos.addAll(eac3DecoderInfos);
  }
  applyWorkarounds(mimeType, decoderInfos);
  List<MediaCodecInfo> unmodifiableDecoderInfos = Collections.unmodifiableList(decoderInfos);
  decoderInfosCache.put(key, unmodifiableDecoderInfos);
  return unmodifiableDecoderInfos;
}
 
Example 13
Source File: FfmpegLibrary.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the name of the FFmpeg decoder that could be used to decode {@code mimeType}.
 */
/* package */ static String getCodecName(String mimeType) {
  switch (mimeType) {
    case MimeTypes.AUDIO_AAC:
      return "aac";
    case MimeTypes.AUDIO_MPEG:
    case MimeTypes.AUDIO_MPEG_L1:
    case MimeTypes.AUDIO_MPEG_L2:
      return "mp3";
    case MimeTypes.AUDIO_AC3:
      return "ac3";
    case MimeTypes.AUDIO_E_AC3:
      return "eac3";
    case MimeTypes.AUDIO_TRUEHD:
      return "truehd";
    case MimeTypes.AUDIO_DTS:
    case MimeTypes.AUDIO_DTS_HD:
      return "dca";
    case MimeTypes.AUDIO_VORBIS:
      return "vorbis";
    case MimeTypes.AUDIO_OPUS:
      return "opus";
    case MimeTypes.AUDIO_AMR_NB:
      return "amrnb";
    case MimeTypes.AUDIO_AMR_WB:
      return "amrwb";
    case MimeTypes.AUDIO_FLAC:
      return "flac";
    case MimeTypes.AUDIO_ALAC:
      return "alac";
    default:
      return null;
  }
}
 
Example 14
Source File: DashManifestParser.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
protected static String parseEac3SupplementalProperties(List<Descriptor> supplementalProperties) {
  for (int i = 0; i < supplementalProperties.size(); i++) {
    Descriptor descriptor = supplementalProperties.get(i);
    String schemeIdUri = descriptor.schemeIdUri;
    if ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(schemeIdUri)
        && "ec+3".equals(descriptor.value)) {
      return MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return MimeTypes.AUDIO_E_AC3;
}
 
Example 15
Source File: DashManifestParser.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
protected static String parseEac3SupplementalProperties(List<Descriptor> supplementalProperties) {
  for (int i = 0; i < supplementalProperties.size(); i++) {
    Descriptor descriptor = supplementalProperties.get(i);
    String schemeIdUri = descriptor.schemeIdUri;
    if ("tag:dolby.com,2014:dash:DolbyDigitalPlusExtensionType:2014".equals(schemeIdUri)
        && "ec+3".equals(descriptor.value)) {
      return MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return MimeTypes.AUDIO_E_AC3;
}
 
Example 16
Source File: FfmpegLibrary.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null}
 * if it's unsupported.
 */
/* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) {
  switch (mimeType) {
    case MimeTypes.AUDIO_AAC:
      return "aac";
    case MimeTypes.AUDIO_MPEG:
    case MimeTypes.AUDIO_MPEG_L1:
    case MimeTypes.AUDIO_MPEG_L2:
      return "mp3";
    case MimeTypes.AUDIO_AC3:
      return "ac3";
    case MimeTypes.AUDIO_E_AC3:
    case MimeTypes.AUDIO_E_AC3_JOC:
      return "eac3";
    case MimeTypes.AUDIO_TRUEHD:
      return "truehd";
    case MimeTypes.AUDIO_DTS:
    case MimeTypes.AUDIO_DTS_HD:
      return "dca";
    case MimeTypes.AUDIO_VORBIS:
      return "vorbis";
    case MimeTypes.AUDIO_OPUS:
      return "opus";
    case MimeTypes.AUDIO_AMR_NB:
      return "amrnb";
    case MimeTypes.AUDIO_AMR_WB:
      return "amrwb";
    case MimeTypes.AUDIO_FLAC:
      return "flac";
    case MimeTypes.AUDIO_ALAC:
      return "alac";
    case MimeTypes.AUDIO_RAW:
      if (encoding == C.ENCODING_PCM_MU_LAW) {
        return "pcm_mulaw";
      } else if (encoding == C.ENCODING_PCM_A_LAW) {
        return "pcm_alaw";
      } else {
        return null;
      }
    default:
      return null;
  }
}
 
Example 17
Source File: Ac3Util.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the E-AC-3 format given {@code data} containing the EC3SpecificBox according to ETSI TS
 * 102 366 Annex F. The reading position of {@code data} will be modified.
 *
 * @param data The EC3SpecificBox to parse.
 * @param trackId The track identifier to set on the format.
 * @param language The language to set on the format.
 * @param drmInitData {@link DrmInitData} to be included in the format.
 * @return The E-AC-3 format parsed from data in the header.
 */
public static Format parseEAc3AnnexFFormat(
    ParsableByteArray data, String trackId, String language, DrmInitData drmInitData) {
  data.skipBytes(2); // data_rate, num_ind_sub

  // Read the first independent substream.
  int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
  int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
  int nextByte = data.readUnsignedByte();
  int channelCount = CHANNEL_COUNT_BY_ACMOD[(nextByte & 0x0E) >> 1];
  if ((nextByte & 0x01) != 0) { // lfeon
    channelCount++;
  }

  // Read the first dependent substream.
  nextByte = data.readUnsignedByte();
  int numDepSub = ((nextByte & 0x1E) >> 1);
  if (numDepSub > 0) {
    int lowByteChanLoc = data.readUnsignedByte();
    // Read Lrs/Rrs pair
    // TODO: Read other channel configuration
    if ((lowByteChanLoc & 0x02) != 0) {
      channelCount += 2;
    }
  }
  String mimeType = MimeTypes.AUDIO_E_AC3;
  if (data.bytesLeft() > 0) {
    nextByte = data.readUnsignedByte();
    if ((nextByte & 0x01) != 0) { // flag_ec3_extension_type_a
      mimeType = MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return Format.createAudioSampleFormat(
      trackId,
      mimeType,
      /* codecs= */ null,
      Format.NO_VALUE,
      Format.NO_VALUE,
      channelCount,
      sampleRate,
      /* initializationData= */ null,
      drmInitData,
      /* selectionFlags= */ 0,
      language);
}
 
Example 18
Source File: FfmpegLibrary.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null}
 * if it's unsupported.
 */
/* package */ static @Nullable String getCodecName(String mimeType, @C.PcmEncoding int encoding) {
  switch (mimeType) {
    case MimeTypes.AUDIO_AAC:
      return "aac";
    case MimeTypes.AUDIO_MPEG:
    case MimeTypes.AUDIO_MPEG_L1:
    case MimeTypes.AUDIO_MPEG_L2:
      return "mp3";
    case MimeTypes.AUDIO_AC3:
      return "ac3";
    case MimeTypes.AUDIO_E_AC3:
      return "eac3";
    case MimeTypes.AUDIO_TRUEHD:
      return "truehd";
    case MimeTypes.AUDIO_DTS:
    case MimeTypes.AUDIO_DTS_HD:
      return "dca";
    case MimeTypes.AUDIO_VORBIS:
      return "vorbis";
    case MimeTypes.AUDIO_OPUS:
      return "opus";
    case MimeTypes.AUDIO_AMR_NB:
      return "amrnb";
    case MimeTypes.AUDIO_AMR_WB:
      return "amrwb";
    case MimeTypes.AUDIO_FLAC:
      return "flac";
    case MimeTypes.AUDIO_ALAC:
      return "alac";
    case MimeTypes.AUDIO_RAW:
      if (encoding == C.ENCODING_PCM_MU_LAW) {
        return "pcm_mulaw";
      } else if (encoding == C.ENCODING_PCM_A_LAW) {
        return "pcm_alaw";
      } else {
        return null;
      }
    default:
      return null;
  }
}
 
Example 19
Source File: AudioDecoder.java    From DanDanPlayForAndroid with MIT License 4 votes vote down vote up
/**
  * Returns the name of the FFmpeg decoder that could be used to decode the format, or {@code null}
  * if it's unsupported.
  */
private static @Nullable
String getCodecName(String mimeType, @C.PcmEncoding int encoding) {
   switch (mimeType) {
     case MimeTypes.AUDIO_AAC:
       return "aac";
     case MimeTypes.AUDIO_MPEG:
     case MimeTypes.AUDIO_MPEG_L1:
     case MimeTypes.AUDIO_MPEG_L2:
       return "mp3";
     case MimeTypes.AUDIO_AC3:
       return "ac3";
     case MimeTypes.AUDIO_E_AC3:
     case MimeTypes.AUDIO_E_AC3_JOC:
       return "eac3";
     case MimeTypes.AUDIO_TRUEHD:
       return "truehd";
     case MimeTypes.AUDIO_DTS:
     case MimeTypes.AUDIO_DTS_HD:
       return "dca";
     case MimeTypes.AUDIO_VORBIS:
       return "vorbis";
     case MimeTypes.AUDIO_OPUS:
       return "opus";
     case MimeTypes.AUDIO_AMR_NB:
       return "amrnb";
     case MimeTypes.AUDIO_AMR_WB:
       return "amrwb";
     case MimeTypes.AUDIO_FLAC:
       return "flac";
     case MimeTypes.AUDIO_ALAC:
       return "alac";
     case MimeTypes.AUDIO_RAW:
       if (encoding == C.ENCODING_PCM_MU_LAW) {
         return "pcm_mulaw";
       } else if (encoding == C.ENCODING_PCM_A_LAW) {
         return "pcm_alaw";
       } else {
         return null;
       }
     default:
       return null;
   }
 }
 
Example 20
Source File: Ac3Util.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns the E-AC-3 format given {@code data} containing the EC3SpecificBox according to ETSI TS
 * 102 366 Annex F. The reading position of {@code data} will be modified.
 *
 * @param data The EC3SpecificBox to parse.
 * @param trackId The track identifier to set on the format.
 * @param language The language to set on the format.
 * @param drmInitData {@link DrmInitData} to be included in the format.
 * @return The E-AC-3 format parsed from data in the header.
 */
public static Format parseEAc3AnnexFFormat(
    ParsableByteArray data, String trackId, String language, DrmInitData drmInitData) {
  data.skipBytes(2); // data_rate, num_ind_sub

  // Read the first independent substream.
  int fscod = (data.readUnsignedByte() & 0xC0) >> 6;
  int sampleRate = SAMPLE_RATE_BY_FSCOD[fscod];
  int nextByte = data.readUnsignedByte();
  int channelCount = CHANNEL_COUNT_BY_ACMOD[(nextByte & 0x0E) >> 1];
  if ((nextByte & 0x01) != 0) { // lfeon
    channelCount++;
  }

  // Read the first dependent substream.
  nextByte = data.readUnsignedByte();
  int numDepSub = ((nextByte & 0x1E) >> 1);
  if (numDepSub > 0) {
    int lowByteChanLoc = data.readUnsignedByte();
    // Read Lrs/Rrs pair
    // TODO: Read other channel configuration
    if ((lowByteChanLoc & 0x02) != 0) {
      channelCount += 2;
    }
  }
  String mimeType = MimeTypes.AUDIO_E_AC3;
  if (data.bytesLeft() > 0) {
    nextByte = data.readUnsignedByte();
    if ((nextByte & 0x01) != 0) { // flag_ec3_extension_type_a
      mimeType = MimeTypes.AUDIO_E_AC3_JOC;
    }
  }
  return Format.createAudioSampleFormat(
      trackId,
      mimeType,
      /* codecs= */ null,
      Format.NO_VALUE,
      Format.NO_VALUE,
      channelCount,
      sampleRate,
      /* initializationData= */ null,
      drmInitData,
      /* selectionFlags= */ 0,
      language);
}