mirror of
https://github.com/androidx/media.git
synced 2025-05-03 21:57:46 +08:00
Add debug logging when codec support checks fail
Issue: #2034 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=138698239
This commit is contained in:
parent
aefc5165fd
commit
2620045b0d
@ -29,6 +29,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
@ -73,7 +74,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
|
||||
*/
|
||||
@SuppressLint("HandlerLeak")
|
||||
public ExoPlayerImpl(Renderer[] renderers, TrackSelector trackSelector, LoadControl loadControl) {
|
||||
Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION);
|
||||
Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION + " [" + Util.DEVICE_DEBUG_INFO + "]");
|
||||
Assertions.checkState(renderers.length > 0);
|
||||
this.renderers = Assertions.checkNotNull(renderers);
|
||||
this.trackSelector = Assertions.checkNotNull(trackSelector);
|
||||
|
@ -21,6 +21,7 @@ import android.media.MediaCodecInfo.AudioCapabilities;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
import android.media.MediaCodecInfo.CodecProfileLevel;
|
||||
import android.media.MediaCodecInfo.VideoCapabilities;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import com.google.android.exoplayer2.util.Assertions;
|
||||
import com.google.android.exoplayer2.util.MimeTypes;
|
||||
@ -32,6 +33,8 @@ import com.google.android.exoplayer2.util.Util;
|
||||
@TargetApi(16)
|
||||
public final class MediaCodecInfo {
|
||||
|
||||
public static final String TAG = "MediaCodecInfo";
|
||||
|
||||
/**
|
||||
* The name of the decoder.
|
||||
* <p>
|
||||
@ -111,6 +114,7 @@ public final class MediaCodecInfo {
|
||||
return true;
|
||||
}
|
||||
if (!mimeType.equals(codecMimeType)) {
|
||||
logNoSupport("codec.mime " + codec + ", " + codecMimeType);
|
||||
return false;
|
||||
}
|
||||
Pair<Integer, Integer> codecProfileAndLevel = MediaCodecUtil.getCodecProfileAndLevel(codec);
|
||||
@ -124,6 +128,7 @@ public final class MediaCodecInfo {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
logNoSupport("codec.profileLevel, " + codec + ", " + codecMimeType);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -139,10 +144,19 @@ public final class MediaCodecInfo {
|
||||
@TargetApi(21)
|
||||
public boolean isVideoSizeSupportedV21(int width, int height) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("size.caps");
|
||||
return false;
|
||||
}
|
||||
VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
|
||||
return videoCapabilities != null && videoCapabilities.isSizeSupported(width, height);
|
||||
if (videoCapabilities == null) {
|
||||
logNoSupport("size.vCaps");
|
||||
return false;
|
||||
}
|
||||
if (!videoCapabilities.isSizeSupported(width, height)) {
|
||||
logNoSupport("size.support, " + width + "x" + height);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -158,11 +172,19 @@ public final class MediaCodecInfo {
|
||||
@TargetApi(21)
|
||||
public boolean isVideoSizeAndRateSupportedV21(int width, int height, double frameRate) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("sizeAndRate.caps");
|
||||
return false;
|
||||
}
|
||||
VideoCapabilities videoCapabilities = capabilities.getVideoCapabilities();
|
||||
return videoCapabilities != null && videoCapabilities.areSizeAndRateSupported(width, height,
|
||||
frameRate);
|
||||
if (videoCapabilities == null) {
|
||||
logNoSupport("sizeAndRate.vCaps");
|
||||
return false;
|
||||
}
|
||||
if (!videoCapabilities.areSizeAndRateSupported(width, height, frameRate)) {
|
||||
logNoSupport("sizeAndRate.support, " + width + "x" + height + "x" + frameRate);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,10 +198,19 @@ public final class MediaCodecInfo {
|
||||
@TargetApi(21)
|
||||
public boolean isAudioSampleRateSupportedV21(int sampleRate) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("sampleRate.caps");
|
||||
return false;
|
||||
}
|
||||
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
|
||||
return audioCapabilities != null && audioCapabilities.isSampleRateSupported(sampleRate);
|
||||
if (audioCapabilities == null) {
|
||||
logNoSupport("sampleRate.aCaps");
|
||||
return false;
|
||||
}
|
||||
if (!audioCapabilities.isSampleRateSupported(sampleRate)) {
|
||||
logNoSupport("sampleRate.support, " + sampleRate);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -193,10 +224,24 @@ public final class MediaCodecInfo {
|
||||
@TargetApi(21)
|
||||
public boolean isAudioChannelCountSupportedV21(int channelCount) {
|
||||
if (capabilities == null) {
|
||||
logNoSupport("channelCount.caps");
|
||||
return false;
|
||||
}
|
||||
AudioCapabilities audioCapabilities = capabilities.getAudioCapabilities();
|
||||
return audioCapabilities != null && audioCapabilities.getMaxInputChannelCount() >= channelCount;
|
||||
if (audioCapabilities == null) {
|
||||
logNoSupport("channelCount.aCaps");
|
||||
return false;
|
||||
}
|
||||
if (audioCapabilities.getMaxInputChannelCount() < channelCount) {
|
||||
logNoSupport("channelCount.support, " + channelCount);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void logNoSupport(String message) {
|
||||
Log.d(TAG, "FalseCheck [" + message + "] [" + name + ", " + mimeType + "] ["
|
||||
+ Util.DEVICE_DEBUG_INFO + "]");
|
||||
}
|
||||
|
||||
private static boolean isAdaptive(CodecCapabilities capabilities) {
|
||||
|
@ -297,8 +297,9 @@ public final class MediaCodecUtil {
|
||||
for (CodecProfileLevel profileLevel : decoderInfo.getProfileLevels()) {
|
||||
result = Math.max(avcLevelToMaxFrameSize(profileLevel.level), result);
|
||||
}
|
||||
// We assume support for at least 360p.
|
||||
result = Math.max(result, 480 * 360);
|
||||
// We assume support for at least 480p (SDK_INT >= 21) or 360p (SDK_INT < 21), which are
|
||||
// the levels mandated by the Android CDD.
|
||||
result = Math.max(result, Util.SDK_INT >= 21 ? (720 * 480) : (480 * 360));
|
||||
}
|
||||
maxH264DecodableFrameSize = result;
|
||||
}
|
||||
|
@ -85,6 +85,12 @@ public final class Util {
|
||||
*/
|
||||
public static final String MODEL = Build.MODEL;
|
||||
|
||||
/**
|
||||
* A concise description of the device that it can be useful to log for debugging purposes.
|
||||
*/
|
||||
public static final String DEVICE_DEBUG_INFO = DEVICE + ", " + MODEL + ", " + MANUFACTURER + ", "
|
||||
+ SDK_INT;
|
||||
|
||||
private static final String TAG = "Util";
|
||||
private static final Pattern XS_DATE_TIME_PATTERN = Pattern.compile(
|
||||
"(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]"
|
||||
|
@ -23,6 +23,7 @@ import android.media.MediaCrypto;
|
||||
import android.media.MediaFormat;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import com.google.android.exoplayer2.C;
|
||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||
@ -198,6 +199,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer {
|
||||
}
|
||||
} else {
|
||||
decoderCapable = format.width * format.height <= MediaCodecUtil.maxH264DecodableFrameSize();
|
||||
if (!decoderCapable) {
|
||||
Log.d(TAG, "FalseCheck [legacyFrameSize, " + format.width + "x" + format.height + "] ["
|
||||
+ Util.DEVICE_DEBUG_INFO + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user