mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Rollback of 0aa23b08b1
*** Original commit *** Add capability flags for hardware and decoder support Issue: google/ExoPlayer#9565 *** PiperOrigin-RevId: 416170329
This commit is contained in:
parent
9cdcc58770
commit
bf1224186c
6 changed files with 30 additions and 204 deletions
|
|
@ -60,16 +60,16 @@ public interface RendererCapabilities {
|
||||||
@interface AdaptiveSupport {}
|
@interface AdaptiveSupport {}
|
||||||
|
|
||||||
/** A mask to apply to {@link Capabilities} to obtain the {@link AdaptiveSupport} only. */
|
/** A mask to apply to {@link Capabilities} to obtain the {@link AdaptiveSupport} only. */
|
||||||
int ADAPTIVE_SUPPORT_MASK = 0b11 << 3;
|
int ADAPTIVE_SUPPORT_MASK = 0b11000;
|
||||||
/** The {@link Renderer} can seamlessly adapt between formats. */
|
/** The {@link Renderer} can seamlessly adapt between formats. */
|
||||||
int ADAPTIVE_SEAMLESS = 0b10 << 3;
|
int ADAPTIVE_SEAMLESS = 0b10000;
|
||||||
/**
|
/**
|
||||||
* The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity
|
* The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity
|
||||||
* (~50-100ms) when adaptation occurs.
|
* (~50-100ms) when adaptation occurs.
|
||||||
*/
|
*/
|
||||||
int ADAPTIVE_NOT_SEAMLESS = 0b01 << 3;
|
int ADAPTIVE_NOT_SEAMLESS = 0b01000;
|
||||||
/** The {@link Renderer} does not support adaptation between formats. */
|
/** The {@link Renderer} does not support adaptation between formats. */
|
||||||
int ADAPTIVE_NOT_SUPPORTED = 0;
|
int ADAPTIVE_NOT_SUPPORTED = 0b00000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Level of renderer support for tunneling. One of {@link #TUNNELING_SUPPORTED} or {@link
|
* Level of renderer support for tunneling. One of {@link #TUNNELING_SUPPORTED} or {@link
|
||||||
|
|
@ -80,62 +80,20 @@ public interface RendererCapabilities {
|
||||||
@IntDef({TUNNELING_SUPPORTED, TUNNELING_NOT_SUPPORTED})
|
@IntDef({TUNNELING_SUPPORTED, TUNNELING_NOT_SUPPORTED})
|
||||||
@interface TunnelingSupport {}
|
@interface TunnelingSupport {}
|
||||||
|
|
||||||
/** A mask to apply to {@link Capabilities} to obtain {@link TunnelingSupport} only. */
|
/** A mask to apply to {@link Capabilities} to obtain the {@link TunnelingSupport} only. */
|
||||||
int TUNNELING_SUPPORT_MASK = 0b1 << 5;
|
int TUNNELING_SUPPORT_MASK = 0b100000;
|
||||||
/** The {@link Renderer} supports tunneled output. */
|
/** The {@link Renderer} supports tunneled output. */
|
||||||
int TUNNELING_SUPPORTED = 0b1 << 5;
|
int TUNNELING_SUPPORTED = 0b100000;
|
||||||
/** The {@link Renderer} does not support tunneled output. */
|
/** The {@link Renderer} does not support tunneled output. */
|
||||||
int TUNNELING_NOT_SUPPORTED = 0;
|
int TUNNELING_NOT_SUPPORTED = 0b000000;
|
||||||
|
|
||||||
/**
|
|
||||||
* Level of renderer support for hardware acceleration. One of {@link
|
|
||||||
* #HARDWARE_ACCELERATION_SUPPORTED} and {@link #HARDWARE_ACCELERATION_NOT_SUPPORTED}.
|
|
||||||
*
|
|
||||||
* <p>For video renderers, the level of support is indicated for non-tunneled output.
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
@IntDef({
|
|
||||||
HARDWARE_ACCELERATION_SUPPORTED,
|
|
||||||
HARDWARE_ACCELERATION_NOT_SUPPORTED,
|
|
||||||
})
|
|
||||||
@interface HardwareAccelerationSupport {}
|
|
||||||
/** A mask to apply to {@link Capabilities} to obtain {@link HardwareAccelerationSupport} only. */
|
|
||||||
int HARDWARE_ACCELERATION_SUPPORT_MASK = 0b1 << 6;
|
|
||||||
/** The renderer is able to use hardware acceleration. */
|
|
||||||
int HARDWARE_ACCELERATION_SUPPORTED = 0b1 << 6;
|
|
||||||
/** The renderer is not able to use hardware acceleration. */
|
|
||||||
int HARDWARE_ACCELERATION_NOT_SUPPORTED = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Level of decoder support. One of {@link #DECODER_SUPPORT_PRIMARY} and {@link
|
|
||||||
* #DECODER_SUPPORT_FALLBACK}.
|
|
||||||
*
|
|
||||||
* <p>For video renderers, the level of support is indicated for non-tunneled output.
|
|
||||||
*/
|
|
||||||
@Documented
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
@IntDef({
|
|
||||||
DECODER_SUPPORT_PRIMARY,
|
|
||||||
DECODER_SUPPORT_FALLBACK,
|
|
||||||
})
|
|
||||||
@interface DecoderSupport {}
|
|
||||||
/** A mask to apply to {@link Capabilities} to obtain {@link DecoderSupport} only. */
|
|
||||||
int MODE_SUPPORT_MASK = 0b1 << 7;
|
|
||||||
/** The renderer is able to use the primary decoder for the format's MIME type. */
|
|
||||||
int DECODER_SUPPORT_PRIMARY = 0b1 << 7;
|
|
||||||
/** The renderer will use a fallback decoder. */
|
|
||||||
int DECODER_SUPPORT_FALLBACK = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combined renderer capabilities.
|
* Combined renderer capabilities.
|
||||||
*
|
*
|
||||||
* <p>This is a bitwise OR of {@link C.FormatSupport}, {@link AdaptiveSupport}, {@link
|
* <p>This is a bitwise OR of {@link C.FormatSupport}, {@link AdaptiveSupport} and {@link
|
||||||
* TunnelingSupport}, {@link HardwareAccelerationSupport} and {@link DecoderSupport}. Use {@link
|
* TunnelingSupport}. Use {@link #getFormatSupport(int)}, {@link #getAdaptiveSupport(int)} or
|
||||||
* #getFormatSupport}, {@link #getAdaptiveSupport}, {@link #getTunnelingSupport}, {@link
|
* {@link #getTunnelingSupport(int)} to obtain the individual flags. And use {@link #create(int)}
|
||||||
* #getHardwareAccelerationSupport} and {@link #getDecoderSupport} to obtain individual
|
* or {@link #create(int, int, int)} to create the combined capabilities.
|
||||||
* components. Use {@link #create(int)}, {@link #create(int, int, int)} or {@link #create(int,
|
|
||||||
* int, int, int, int)} to create combined capabilities from individual components.
|
|
||||||
*
|
*
|
||||||
* <p>Possible values:
|
* <p>Possible values:
|
||||||
*
|
*
|
||||||
|
|
@ -153,11 +111,6 @@ public interface RendererCapabilities {
|
||||||
* #TUNNELING_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}. Only set if the level of
|
* #TUNNELING_SUPPORTED} and {@link #TUNNELING_NOT_SUPPORTED}. Only set if the level of
|
||||||
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
|
* support for the format itself is {@link C#FORMAT_HANDLED} or {@link
|
||||||
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
* C#FORMAT_EXCEEDS_CAPABILITIES}.
|
||||||
* <li>{@link HardwareAccelerationSupport}: The level of support for hardware acceleration. One
|
|
||||||
* of {@link #HARDWARE_ACCELERATION_SUPPORTED} and {@link
|
|
||||||
* #HARDWARE_ACCELERATION_NOT_SUPPORTED}.
|
|
||||||
* <li>{@link DecoderSupport}: The level of decoder support. One of {@link
|
|
||||||
* #DECODER_SUPPORT_PRIMARY} and {@link #DECODER_SUPPORT_FALLBACK}.
|
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@Documented
|
@Documented
|
||||||
|
|
@ -169,10 +122,8 @@ public interface RendererCapabilities {
|
||||||
/**
|
/**
|
||||||
* Returns {@link Capabilities} for the given {@link C.FormatSupport}.
|
* Returns {@link Capabilities} for the given {@link C.FormatSupport}.
|
||||||
*
|
*
|
||||||
* <p>{@link AdaptiveSupport} is set to {@link #ADAPTIVE_NOT_SUPPORTED}, {@link TunnelingSupport}
|
* <p>The {@link AdaptiveSupport} is set to {@link #ADAPTIVE_NOT_SUPPORTED} and {{@link
|
||||||
* is set to {@link #TUNNELING_NOT_SUPPORTED}, {@link HardwareAccelerationSupport} is set to
|
* TunnelingSupport} is set to {@link #TUNNELING_NOT_SUPPORTED}.
|
||||||
* {@link #HARDWARE_ACCELERATION_NOT_SUPPORTED} and {@link DecoderSupport} is set to {@link
|
|
||||||
* #DECODER_SUPPORT_PRIMARY}.
|
|
||||||
*
|
*
|
||||||
* @param formatSupport The {@link C.FormatSupport}.
|
* @param formatSupport The {@link C.FormatSupport}.
|
||||||
* @return The combined {@link Capabilities} of the given {@link C.FormatSupport}, {@link
|
* @return The combined {@link Capabilities} of the given {@link C.FormatSupport}, {@link
|
||||||
|
|
@ -187,53 +138,19 @@ public interface RendererCapabilities {
|
||||||
* Returns {@link Capabilities} combining the given {@link C.FormatSupport}, {@link
|
* Returns {@link Capabilities} combining the given {@link C.FormatSupport}, {@link
|
||||||
* AdaptiveSupport} and {@link TunnelingSupport}.
|
* AdaptiveSupport} and {@link TunnelingSupport}.
|
||||||
*
|
*
|
||||||
* <p>{@link HardwareAccelerationSupport} is set to {@link #HARDWARE_ACCELERATION_NOT_SUPPORTED}
|
|
||||||
* and {@link DecoderSupport} is set to {@link #DECODER_SUPPORT_PRIMARY}.
|
|
||||||
*
|
|
||||||
* @param formatSupport The {@link C.FormatSupport}.
|
* @param formatSupport The {@link C.FormatSupport}.
|
||||||
* @param adaptiveSupport The {@link AdaptiveSupport}.
|
* @param adaptiveSupport The {@link AdaptiveSupport}.
|
||||||
* @param tunnelingSupport The {@link TunnelingSupport}.
|
* @param tunnelingSupport The {@link TunnelingSupport}.
|
||||||
* @return The combined {@link Capabilities}.
|
* @return The combined {@link Capabilities}.
|
||||||
*/
|
*/
|
||||||
@Capabilities
|
|
||||||
static int create(
|
|
||||||
@C.FormatSupport int formatSupport,
|
|
||||||
@AdaptiveSupport int adaptiveSupport,
|
|
||||||
@TunnelingSupport int tunnelingSupport) {
|
|
||||||
return create(
|
|
||||||
formatSupport,
|
|
||||||
adaptiveSupport,
|
|
||||||
tunnelingSupport,
|
|
||||||
HARDWARE_ACCELERATION_NOT_SUPPORTED,
|
|
||||||
DECODER_SUPPORT_PRIMARY);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns {@link Capabilities} combining the given {@link C.FormatSupport}, {@link
|
|
||||||
* AdaptiveSupport}, {@link TunnelingSupport}, {@link HardwareAccelerationSupport} and {@link
|
|
||||||
* DecoderSupport}.
|
|
||||||
*
|
|
||||||
* @param formatSupport The {@link C.FormatSupport}.
|
|
||||||
* @param adaptiveSupport The {@link AdaptiveSupport}.
|
|
||||||
* @param tunnelingSupport The {@link TunnelingSupport}.
|
|
||||||
* @param hardwareAccelerationSupport The {@link HardwareAccelerationSupport}.
|
|
||||||
* @param decoderSupport The {@link DecoderSupport}.
|
|
||||||
* @return The combined {@link Capabilities}.
|
|
||||||
*/
|
|
||||||
// Suppression needed for IntDef casting.
|
// Suppression needed for IntDef casting.
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
@Capabilities
|
@Capabilities
|
||||||
static int create(
|
static int create(
|
||||||
@C.FormatSupport int formatSupport,
|
@C.FormatSupport int formatSupport,
|
||||||
@AdaptiveSupport int adaptiveSupport,
|
@AdaptiveSupport int adaptiveSupport,
|
||||||
@TunnelingSupport int tunnelingSupport,
|
@TunnelingSupport int tunnelingSupport) {
|
||||||
@HardwareAccelerationSupport int hardwareAccelerationSupport,
|
return formatSupport | adaptiveSupport | tunnelingSupport;
|
||||||
@DecoderSupport int decoderSupport) {
|
|
||||||
return formatSupport
|
|
||||||
| adaptiveSupport
|
|
||||||
| tunnelingSupport
|
|
||||||
| hardwareAccelerationSupport
|
|
||||||
| decoderSupport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -275,32 +192,6 @@ public interface RendererCapabilities {
|
||||||
return supportFlags & TUNNELING_SUPPORT_MASK;
|
return supportFlags & TUNNELING_SUPPORT_MASK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link HardwareAccelerationSupport} from the combined {@link Capabilities}.
|
|
||||||
*
|
|
||||||
* @param supportFlags The combined {@link Capabilities}.
|
|
||||||
* @return The {@link HardwareAccelerationSupport} only.
|
|
||||||
*/
|
|
||||||
// Suppression needed for IntDef casting.
|
|
||||||
@SuppressLint("WrongConstant")
|
|
||||||
@HardwareAccelerationSupport
|
|
||||||
static int getHardwareAccelerationSupport(@Capabilities int supportFlags) {
|
|
||||||
return supportFlags & HARDWARE_ACCELERATION_SUPPORT_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link DecoderSupport} from the combined {@link Capabilities}.
|
|
||||||
*
|
|
||||||
* @param supportFlags The combined {@link Capabilities}.
|
|
||||||
* @return The {@link DecoderSupport} only.
|
|
||||||
*/
|
|
||||||
// Suppression needed for IntDef casting.
|
|
||||||
@SuppressLint("WrongConstant")
|
|
||||||
@DecoderSupport
|
|
||||||
static int getDecoderSupport(@Capabilities int supportFlags) {
|
|
||||||
return supportFlags & MODE_SUPPORT_MASK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the name of the {@link Renderer}. */
|
/** Returns the name of the {@link Renderer}. */
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,7 +314,6 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||||
// format's MIME type, according to the MediaCodecSelector.
|
// format's MIME type, according to the MediaCodecSelector.
|
||||||
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
||||||
boolean isFormatSupported = decoderInfo.isFormatSupported(format);
|
boolean isFormatSupported = decoderInfo.isFormatSupported(format);
|
||||||
boolean isPreferredDecoder = true;
|
|
||||||
if (!isFormatSupported) {
|
if (!isFormatSupported) {
|
||||||
// Check whether any of the other decoders support the format.
|
// Check whether any of the other decoders support the format.
|
||||||
for (int i = 1; i < decoderInfos.size(); i++) {
|
for (int i = 1; i < decoderInfos.size(); i++) {
|
||||||
|
|
@ -322,31 +321,18 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
|
||||||
if (otherDecoderInfo.isFormatSupported(format)) {
|
if (otherDecoderInfo.isFormatSupported(format)) {
|
||||||
decoderInfo = otherDecoderInfo;
|
decoderInfo = otherDecoderInfo;
|
||||||
isFormatSupported = true;
|
isFormatSupported = true;
|
||||||
isPreferredDecoder = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@C.FormatSupport
|
|
||||||
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
|
||||||
@AdaptiveSupport
|
@AdaptiveSupport
|
||||||
int adaptiveSupport =
|
int adaptiveSupport =
|
||||||
isFormatSupported && decoderInfo.isSeamlessAdaptationSupported(format)
|
isFormatSupported && decoderInfo.isSeamlessAdaptationSupported(format)
|
||||||
? ADAPTIVE_SEAMLESS
|
? ADAPTIVE_SEAMLESS
|
||||||
: ADAPTIVE_NOT_SEAMLESS;
|
: ADAPTIVE_NOT_SEAMLESS;
|
||||||
@HardwareAccelerationSupport
|
@C.FormatSupport
|
||||||
int hardwareAccelerationSupport =
|
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
||||||
decoderInfo.hardwareAccelerated
|
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
||||||
? HARDWARE_ACCELERATION_SUPPORTED
|
|
||||||
: HARDWARE_ACCELERATION_NOT_SUPPORTED;
|
|
||||||
@DecoderSupport
|
|
||||||
int decoderSupport = isPreferredDecoder ? DECODER_SUPPORT_PRIMARY : DECODER_SUPPORT_FALLBACK;
|
|
||||||
return RendererCapabilities.create(
|
|
||||||
formatSupport,
|
|
||||||
adaptiveSupport,
|
|
||||||
tunnelingSupport,
|
|
||||||
hardwareAccelerationSupport,
|
|
||||||
decoderSupport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -216,19 +216,6 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
||||||
return bestRendererSupport;
|
return bestRendererSupport;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the {@link Capabilities} of the renderer for an individual track.
|
|
||||||
*
|
|
||||||
* @param rendererIndex The renderer index.
|
|
||||||
* @param groupIndex The index of the track group to which the track belongs.
|
|
||||||
* @param trackIndex The index of the track within the track group.
|
|
||||||
* @return The {@link Capabilities}.
|
|
||||||
*/
|
|
||||||
@Capabilities
|
|
||||||
public int getCapabilities(int rendererIndex, int groupIndex, int trackIndex) {
|
|
||||||
return rendererFormatSupports[rendererIndex][groupIndex][trackIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the extent to which an individual track is supported by the renderer.
|
* Returns the extent to which an individual track is supported by the renderer.
|
||||||
*
|
*
|
||||||
|
|
@ -240,7 +227,7 @@ public abstract class MappingTrackSelector extends TrackSelector {
|
||||||
@FormatSupport
|
@FormatSupport
|
||||||
public int getTrackSupport(int rendererIndex, int groupIndex, int trackIndex) {
|
public int getTrackSupport(int rendererIndex, int groupIndex, int trackIndex) {
|
||||||
return RendererCapabilities.getFormatSupport(
|
return RendererCapabilities.getFormatSupport(
|
||||||
getCapabilities(rendererIndex, groupIndex, trackIndex));
|
rendererFormatSupports[rendererIndex][groupIndex][trackIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.util;
|
package com.google.android.exoplayer2.util;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.DECODER_SUPPORT_FALLBACK;
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.HARDWARE_ACCELERATION_SUPPORTED;
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.getDecoderSupport;
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.getFormatSupport;
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.getHardwareAccelerationSupport;
|
|
||||||
import static com.google.android.exoplayer2.util.Util.getFormatSupportString;
|
|
||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
|
|
@ -35,7 +29,6 @@ import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
|
import com.google.android.exoplayer2.Player.PlaybackSuppressionReason;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities;
|
import com.google.android.exoplayer2.RendererCapabilities;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
import com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport;
|
||||||
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
|
|
@ -283,16 +276,9 @@ public class EventLogger implements AnalyticsListener {
|
||||||
logd(" Group:" + trackGroup.id + ", adaptive_supported=" + adaptiveSupport + " [");
|
logd(" Group:" + trackGroup.id + ", adaptive_supported=" + adaptiveSupport + " [");
|
||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
|
||||||
@Capabilities
|
String formatSupport =
|
||||||
int capabilities =
|
Util.getFormatSupportString(
|
||||||
mappedTrackInfo.getCapabilities(rendererIndex, groupIndex, trackIndex);
|
mappedTrackInfo.getTrackSupport(rendererIndex, groupIndex, trackIndex));
|
||||||
String formatSupport = getFormatSupportString(getFormatSupport(capabilities));
|
|
||||||
String hardwareAccelerationSupport =
|
|
||||||
getHardwareAccelerationSupport(capabilities) == HARDWARE_ACCELERATION_SUPPORTED
|
|
||||||
? ", accelerated=YES"
|
|
||||||
: "";
|
|
||||||
String decoderSupport =
|
|
||||||
getDecoderSupport(capabilities) == DECODER_SUPPORT_FALLBACK ? ", fallback=YES" : "";
|
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
+ status
|
+ status
|
||||||
|
|
@ -301,9 +287,7 @@ public class EventLogger implements AnalyticsListener {
|
||||||
+ ", "
|
+ ", "
|
||||||
+ Format.toLogString(trackGroup.getFormat(trackIndex))
|
+ Format.toLogString(trackGroup.getFormat(trackIndex))
|
||||||
+ ", supported="
|
+ ", supported="
|
||||||
+ formatSupport
|
+ formatSupport);
|
||||||
+ hardwareAccelerationSupport
|
|
||||||
+ decoderSupport);
|
|
||||||
}
|
}
|
||||||
logd(" ]");
|
logd(" ]");
|
||||||
}
|
}
|
||||||
|
|
@ -331,7 +315,7 @@ public class EventLogger implements AnalyticsListener {
|
||||||
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
|
||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
String status = getTrackStatusString(false);
|
String status = getTrackStatusString(false);
|
||||||
String formatSupport = getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
|
String formatSupport = Util.getFormatSupportString(C.FORMAT_UNSUPPORTED_TYPE);
|
||||||
logd(
|
logd(
|
||||||
" "
|
" "
|
||||||
+ status
|
+ status
|
||||||
|
|
|
||||||
|
|
@ -374,7 +374,6 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
// format's MIME type, according to the MediaCodecSelector.
|
// format's MIME type, according to the MediaCodecSelector.
|
||||||
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
MediaCodecInfo decoderInfo = decoderInfos.get(0);
|
||||||
boolean isFormatSupported = decoderInfo.isFormatSupported(format);
|
boolean isFormatSupported = decoderInfo.isFormatSupported(format);
|
||||||
boolean isPreferredDecoder = true;
|
|
||||||
if (!isFormatSupported) {
|
if (!isFormatSupported) {
|
||||||
// Check whether any of the other decoders support the format.
|
// Check whether any of the other decoders support the format.
|
||||||
for (int i = 1; i < decoderInfos.size(); i++) {
|
for (int i = 1; i < decoderInfos.size(); i++) {
|
||||||
|
|
@ -382,26 +381,15 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
if (otherDecoderInfo.isFormatSupported(format)) {
|
if (otherDecoderInfo.isFormatSupported(format)) {
|
||||||
decoderInfo = otherDecoderInfo;
|
decoderInfo = otherDecoderInfo;
|
||||||
isFormatSupported = true;
|
isFormatSupported = true;
|
||||||
isPreferredDecoder = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@C.FormatSupport
|
|
||||||
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
|
||||||
@AdaptiveSupport
|
@AdaptiveSupport
|
||||||
int adaptiveSupport =
|
int adaptiveSupport =
|
||||||
decoderInfo.isSeamlessAdaptationSupported(format)
|
decoderInfo.isSeamlessAdaptationSupported(format)
|
||||||
? ADAPTIVE_SEAMLESS
|
? ADAPTIVE_SEAMLESS
|
||||||
: ADAPTIVE_NOT_SEAMLESS;
|
: ADAPTIVE_NOT_SEAMLESS;
|
||||||
@HardwareAccelerationSupport
|
|
||||||
int hardwareAccelerationSupport =
|
|
||||||
decoderInfo.hardwareAccelerated
|
|
||||||
? HARDWARE_ACCELERATION_SUPPORTED
|
|
||||||
: HARDWARE_ACCELERATION_NOT_SUPPORTED;
|
|
||||||
@DecoderSupport
|
|
||||||
int decoderSupport = isPreferredDecoder ? DECODER_SUPPORT_PRIMARY : DECODER_SUPPORT_FALLBACK;
|
|
||||||
|
|
||||||
@TunnelingSupport int tunnelingSupport = TUNNELING_NOT_SUPPORTED;
|
@TunnelingSupport int tunnelingSupport = TUNNELING_NOT_SUPPORTED;
|
||||||
if (isFormatSupported) {
|
if (isFormatSupported) {
|
||||||
List<MediaCodecInfo> tunnelingDecoderInfos =
|
List<MediaCodecInfo> tunnelingDecoderInfos =
|
||||||
|
|
@ -420,13 +408,9 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@C.FormatSupport
|
||||||
return RendererCapabilities.create(
|
int formatSupport = isFormatSupported ? C.FORMAT_HANDLED : C.FORMAT_EXCEEDS_CAPABILITIES;
|
||||||
formatSupport,
|
return RendererCapabilities.create(formatSupport, adaptiveSupport, tunnelingSupport);
|
||||||
adaptiveSupport,
|
|
||||||
tunnelingSupport,
|
|
||||||
hardwareAccelerationSupport,
|
|
||||||
decoderSupport);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ package com.google.android.exoplayer2.audio;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.C.FORMAT_HANDLED;
|
import static com.google.android.exoplayer2.C.FORMAT_HANDLED;
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.ADAPTIVE_NOT_SEAMLESS;
|
import static com.google.android.exoplayer2.RendererCapabilities.ADAPTIVE_NOT_SEAMLESS;
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.DECODER_SUPPORT_PRIMARY;
|
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_NOT_SUPPORTED;
|
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_NOT_SUPPORTED;
|
||||||
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_SUPPORTED;
|
import static com.google.android.exoplayer2.RendererCapabilities.TUNNELING_SUPPORTED;
|
||||||
import static com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM;
|
import static com.google.android.exoplayer2.testutil.FakeSampleStream.FakeSampleStreamItem.END_OF_STREAM_ITEM;
|
||||||
|
|
@ -93,11 +92,7 @@ public class DecoderAudioRendererTest {
|
||||||
@Test
|
@Test
|
||||||
public void supportsFormatAtApi19() {
|
public void supportsFormatAtApi19() {
|
||||||
assertThat(audioRenderer.supportsFormat(FORMAT))
|
assertThat(audioRenderer.supportsFormat(FORMAT))
|
||||||
.isEqualTo(
|
.isEqualTo(ADAPTIVE_NOT_SEAMLESS | TUNNELING_NOT_SUPPORTED | FORMAT_HANDLED);
|
||||||
ADAPTIVE_NOT_SEAMLESS
|
|
||||||
| TUNNELING_NOT_SUPPORTED
|
|
||||||
| FORMAT_HANDLED
|
|
||||||
| DECODER_SUPPORT_PRIMARY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Config(sdk = 21)
|
@Config(sdk = 21)
|
||||||
|
|
@ -105,8 +100,7 @@ public class DecoderAudioRendererTest {
|
||||||
public void supportsFormatAtApi21() {
|
public void supportsFormatAtApi21() {
|
||||||
// From API 21, tunneling is supported.
|
// From API 21, tunneling is supported.
|
||||||
assertThat(audioRenderer.supportsFormat(FORMAT))
|
assertThat(audioRenderer.supportsFormat(FORMAT))
|
||||||
.isEqualTo(
|
.isEqualTo(ADAPTIVE_NOT_SEAMLESS | TUNNELING_SUPPORTED | FORMAT_HANDLED);
|
||||||
ADAPTIVE_NOT_SEAMLESS | TUNNELING_SUPPORTED | FORMAT_HANDLED | DECODER_SUPPORT_PRIMARY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue