Add checks to HW codecs to ensure unsupported features are not used.
Add checks to ensure encoder is not used below API level 19. Removes global @TargetApi from MediaCodecUtils since it is also used by the decoder. Ensures that texture mode is never enabled below API level 18. Bug: webrtc:9821 Change-Id: I2ca1014bf8995719c970eb1449b0acbf7b3c883e Reviewed-on: https://webrtc-review.googlesource.com/c/103701 Reviewed-by: Paulina Hensman <phensman@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24990}
This commit is contained in:
committed by
Commit Bot
parent
24ee167a3d
commit
d5806b289f
@ -14,12 +14,12 @@ import android.annotation.TargetApi;
|
||||
import android.media.MediaCodec;
|
||||
import android.media.MediaCodecInfo;
|
||||
import android.media.MediaCodecInfo.CodecCapabilities;
|
||||
import android.os.Build;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Container class for static constants and helpers used with MediaCodec. */
|
||||
@TargetApi(18)
|
||||
// We are forced to use the old API because we want to support API level < 21.
|
||||
@SuppressWarnings("deprecation")
|
||||
class MediaCodecUtils {
|
||||
@ -56,7 +56,15 @@ class MediaCodecUtils {
|
||||
MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m};
|
||||
|
||||
// Color formats supported by texture mode encoding - in order of preference.
|
||||
static final int[] TEXTURE_COLOR_FORMATS = {MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface};
|
||||
static final int[] TEXTURE_COLOR_FORMATS = getTextureColorFormats();
|
||||
|
||||
private static int[] getTextureColorFormats() {
|
||||
if (Build.VERSION.SDK_INT >= 18) {
|
||||
return new int[] {MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface};
|
||||
} else {
|
||||
return new int[] {};
|
||||
}
|
||||
}
|
||||
|
||||
static @Nullable Integer selectColorFormat(
|
||||
int[] supportedColorFormats, CodecCapabilities capabilities) {
|
||||
|
||||
Reference in New Issue
Block a user