Improve Java video codec error handling.

FALLBACK_SOFTWARE is now treated as a critical error and results in
immediate fallback to software coding if available. If ERROR is
returned, codec reset is attempted. If that fails, software fallback
is used.

Bug: b/73498933
Change-Id: I7fe163efd09e6f27c72491e9595954ddc59b1448
Reviewed-on: https://webrtc-review.googlesource.com/54901
Reviewed-by: Alex Glaznev <glaznev@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22169}
This commit is contained in:
Sami Kalliomäki
2018-02-20 11:35:53 +01:00
committed by Commit Bot
parent 99f52f83e4
commit d60d5c4479
6 changed files with 78 additions and 52 deletions

View File

@ -163,7 +163,7 @@ class HardwareVideoDecoder
Logging.d(TAG, "initDecodeInternal");
if (outputThread != null) {
Logging.e(TAG, "initDecodeInternal called while the codec is already running");
return VideoCodecStatus.ERROR;
return VideoCodecStatus.FALLBACK_SOFTWARE;
}
// Note: it is not necessary to initialize dimensions under the lock, since the output thread
@ -180,7 +180,7 @@ class HardwareVideoDecoder
codec = MediaCodec.createByCodecName(codecName);
} catch (IOException | IllegalArgumentException e) {
Logging.e(TAG, "Cannot create media decoder " + codecName);
return VideoCodecStatus.ERROR;
return VideoCodecStatus.FALLBACK_SOFTWARE;
}
try {
MediaFormat format = MediaFormat.createVideoFormat(codecType.mimeType(), width, height);
@ -192,7 +192,7 @@ class HardwareVideoDecoder
} catch (IllegalStateException e) {
Logging.e(TAG, "initDecode failed", e);
release();
return VideoCodecStatus.ERROR;
return VideoCodecStatus.FALLBACK_SOFTWARE;
}
running = true;
outputThread = createOutputThread();
@ -241,11 +241,11 @@ class HardwareVideoDecoder
// Need to process a key frame first.
if (frame.frameType != EncodedImage.FrameType.VideoFrameKey) {
Logging.e(TAG, "decode() - key frame required first");
return VideoCodecStatus.ERROR;
return VideoCodecStatus.NO_OUTPUT;
}
if (!frame.completeFrame) {
Logging.e(TAG, "decode() - complete frame required first");
return VideoCodecStatus.ERROR;
return VideoCodecStatus.NO_OUTPUT;
}
}

View File

@ -176,7 +176,7 @@ class HardwareVideoEncoder implements VideoEncoder {
codec = MediaCodec.createByCodecName(codecName);
} catch (IOException | IllegalArgumentException e) {
Logging.e(TAG, "Cannot create media encoder " + codecName);
return VideoCodecStatus.ERROR;
return VideoCodecStatus.FALLBACK_SOFTWARE;
}
final int colorFormat = useSurfaceMode ? surfaceColorFormat : yuvColorFormat;
@ -218,7 +218,7 @@ class HardwareVideoEncoder implements VideoEncoder {
} catch (IllegalStateException e) {
Logging.e(TAG, "initEncodeInternal failed", e);
release();
return VideoCodecStatus.ERROR;
return VideoCodecStatus.FALLBACK_SOFTWARE;
}
running = true;