Catch exceptions thrown by getCodecInfoAt() and getCapabilitiesForType().
BUG=b/30715199 R=jiayl@chromium.org Review URL: https://codereview.webrtc.org/2225073003 . Cr-Commit-Position: refs/heads/master@{#13678}
This commit is contained in:
@ -178,8 +178,13 @@ public class MediaCodecVideoDecoder {
|
|||||||
}
|
}
|
||||||
Logging.d(TAG, "Trying to find HW decoder for mime " + mime);
|
Logging.d(TAG, "Trying to find HW decoder for mime " + mime);
|
||||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
MediaCodecInfo info = null;
|
||||||
if (info.isEncoder()) {
|
try {
|
||||||
|
info = MediaCodecList.getCodecInfoAt(i);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Logging.e(TAG, "Cannot retrieve decoder codec info", e);
|
||||||
|
}
|
||||||
|
if (info == null || info.isEncoder()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = null;
|
String name = null;
|
||||||
@ -207,8 +212,13 @@ public class MediaCodecVideoDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if codec supports either yuv420 or nv12.
|
// Check if codec supports either yuv420 or nv12.
|
||||||
CodecCapabilities capabilities =
|
CodecCapabilities capabilities;
|
||||||
info.getCapabilitiesForType(mime);
|
try {
|
||||||
|
capabilities = info.getCapabilitiesForType(mime);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Logging.e(TAG, "Cannot retrieve decoder capabilities", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int colorFormat : capabilities.colorFormats) {
|
for (int colorFormat : capabilities.colorFormats) {
|
||||||
Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -242,8 +242,13 @@ public class MediaCodecVideoEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
|
||||||
MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
|
MediaCodecInfo info = null;
|
||||||
if (!info.isEncoder()) {
|
try {
|
||||||
|
info = MediaCodecList.getCodecInfoAt(i);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Logging.e(TAG, "Cannot retrieve encoder codec info", e);
|
||||||
|
}
|
||||||
|
if (info == null || !info.isEncoder()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String name = null;
|
String name = null;
|
||||||
@ -281,7 +286,13 @@ public class MediaCodecVideoEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if HW codec supports known color format.
|
// Check if HW codec supports known color format.
|
||||||
CodecCapabilities capabilities = info.getCapabilitiesForType(mime);
|
CodecCapabilities capabilities;
|
||||||
|
try {
|
||||||
|
capabilities = info.getCapabilitiesForType(mime);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Logging.e(TAG, "Cannot retrieve encoder capabilities", e);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (int colorFormat : capabilities.colorFormats) {
|
for (int colorFormat : capabilities.colorFormats) {
|
||||||
Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
Logging.v(TAG, " Color: 0x" + Integer.toHexString(colorFormat));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user