Handle reported camera sizes array is null
The array of sizes may be null. Handle this case gracefully. Fixes #4852 <https://github.com/Genymobile/scrcpy/issues/4852>
This commit is contained in:
parent
9aa6cc71be
commit
bcb8503b26
@ -127,6 +127,10 @@ public class CameraCapture extends SurfaceCapture {
|
|||||||
|
|
||||||
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
||||||
android.util.Size[] sizes = highSpeed ? configs.getHighSpeedVideoSizes() : configs.getOutputSizes(MediaCodec.class);
|
android.util.Size[] sizes = highSpeed ? configs.getHighSpeedVideoSizes() : configs.getOutputSizes(MediaCodec.class);
|
||||||
|
if (sizes == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Stream<android.util.Size> stream = Arrays.stream(sizes);
|
Stream<android.util.Size> stream = Arrays.stream(sizes);
|
||||||
if (maxSize > 0) {
|
if (maxSize > 0) {
|
||||||
stream = stream.filter(it -> it.getWidth() <= maxSize && it.getHeight() <= maxSize);
|
stream = stream.filter(it -> it.getWidth() <= maxSize && it.getHeight() <= maxSize);
|
||||||
|
@ -118,12 +118,16 @@ public final class LogUtils {
|
|||||||
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
|
||||||
|
|
||||||
android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
|
android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
|
||||||
for (android.util.Size size : sizes) {
|
if (sizes == null || sizes.length == 0) {
|
||||||
builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
|
builder.append("\n (none)");
|
||||||
|
} else {
|
||||||
|
for (android.util.Size size : sizes) {
|
||||||
|
builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes();
|
android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes();
|
||||||
if (highSpeedSizes.length > 0) {
|
if (highSpeedSizes != null && highSpeedSizes.length > 0) {
|
||||||
builder.append("\n High speed capture (--camera-high-speed):");
|
builder.append("\n High speed capture (--camera-high-speed):");
|
||||||
for (android.util.Size size : highSpeedSizes) {
|
for (android.util.Size size : highSpeedSizes) {
|
||||||
Range<Integer>[] highFpsRanges = configs.getHighSpeedVideoFpsRanges();
|
Range<Integer>[] highFpsRanges = configs.getHighSpeedVideoFpsRanges();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user