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

@ -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;