Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ public static MediaCodecProfileAndLevel getHevcBaseLayerCodecProfileAndLevel(For
public static String getAlternativeCodecMimeType(Format format) {
if (MimeTypes.AUDIO_E_AC3_JOC.equals(format.sampleMimeType)) {
// E-AC3 decoders can decode JOC streams, but in 2-D rather than 3-D.
return MimeTypes.AUDIO_E_AC3;
// Some devices (e.g. Pixel) integrate an EAC3 decoder that does not support EAC3-JOC
// stream decoding.
return supportsEac3JocFallbackDecoding() ? MimeTypes.AUDIO_E_AC3 : null;
}
if (MimeTypes.AUDIO_DTS_HD.equals(format.sampleMimeType)
|| MimeTypes.AUDIO_DTS_UHD_P2.equals(format.sampleMimeType)) {
Expand Down Expand Up @@ -419,6 +421,25 @@ public static String getAlternativeCodecMimeType(Format format) {

// Internal methods.

/**
* Returns whether the device supports decoding E-AC3 JOC streams using a standard E-AC3 decoder
* (in 2-D rather than 3-D).
*
* <p>Some devices (e.g. Pixel) have an E-AC3 decoder that cannot handle E-AC3 JOC streams at
* all, even in degraded 2-D mode.
*/
private static boolean supportsEac3JocFallbackDecoding() {
String manufacturer = Build.MANUFACTURER;
String brand = Build.BRAND;
String model = Build.MODEL;

boolean isGoogle =
"Google".equalsIgnoreCase(manufacturer) && "google".equalsIgnoreCase(brand);
boolean isPixelModel = model != null && model.startsWith("Pixel");

return !(isGoogle && isPixelModel);
}

/**
* Returns {@link MediaCodecInfo}s for the given codec {@link CodecKey} in the order given by
* {@code mediaCodecList}.
Expand Down