1414import static org .webrtc .MediaCodecUtils .INTEL_PREFIX ;
1515import static org .webrtc .MediaCodecUtils .QCOM_PREFIX ;
1616import static org .webrtc .MediaCodecUtils .HISI_PREFIX ;
17+ import static org .webrtc .MediaCodecUtils .IMG_PREFIX ;
1718
1819import android .media .MediaCodecInfo ;
1920import android .media .MediaCodecList ;
@@ -42,6 +43,9 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
4243 @ Nullable private final EglBase14 .Context sharedContext ;
4344 private final boolean enableIntelVp8Encoder ;
4445 private final boolean enableH264HighProfile ;
46+ private final String extraMediaCodecFile = "sdcard/mediaCodec.xml" ;
47+ private final VideoCapabilityParser vcp = new VideoCapabilityParser ();
48+
4549 @ Nullable private final Predicate <MediaCodecInfo > codecAllowedPredicate ;
4650
4751 /**
@@ -216,16 +220,20 @@ private boolean isHardwareSupportedInCurrentSdkVp8(MediaCodecInfo info) {
216220 return (name .startsWith (QCOM_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
217221 // Hisi VP8 encoder seems to be supported. Needs more testing.
218222 || (name .startsWith (HISI_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
223+ || (name .startsWith (IMG_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
219224 // Exynos VP8 encoder is supported in M or later.
220225 || (name .startsWith (EXYNOS_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .M )
221226 // Intel Vp8 encoder is supported in LOLLIPOP or later, with the intel encoder enabled.
222227 || (name .startsWith (INTEL_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP
223- && enableIntelVp8Encoder );
228+ && enableIntelVp8Encoder )
229+ || vcp .isExtraHardwareSupported (name , "video/x-vnd.on2.vp8" , vcp .parseWithTag (vcp .loadWithDom (extraMediaCodecFile ), "Decoders" ));
224230 }
225231
226232 private boolean isHardwareSupportedInCurrentSdkVp9 (MediaCodecInfo info ) {
227233 String name = info .getName ();
228- return (name .startsWith (QCOM_PREFIX ) || name .startsWith (EXYNOS_PREFIX ) || name .startsWith (HISI_PREFIX ))
234+ return (name .startsWith (QCOM_PREFIX ) || name .startsWith (EXYNOS_PREFIX ) || name .startsWith (HISI_PREFIX )
235+ || name .startsWith (IMG_PREFIX )
236+ || vcp .isExtraHardwareSupported (name , "video/x-vnd.on2.vp9" , vcp .parseWithTag (vcp .loadWithDom (extraMediaCodecFile ), "Decoders" )))
229237 // Both QCOM and Exynos VP9 encoders are supported in N or later.
230238 && Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ;
231239 }
@@ -240,7 +248,10 @@ private boolean isHardwareSupportedInCurrentSdkH264(MediaCodecInfo info) {
240248 return (name .startsWith (QCOM_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
241249 // Exynos H264 encoder is supported in LOLLIPOP or later.
242250 || (name .startsWith (EXYNOS_PREFIX )
243- && Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP );
251+ && Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP )
252+ || (name .startsWith (HISI_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
253+ || (name .startsWith (IMG_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
254+ || vcp .isExtraHardwareSupported (name , "video/avc" , vcp .parseWithTag (vcp .loadWithDom (extraMediaCodecFile ), "Decoders" ));;
244255 }
245256
246257 private boolean isHardwareSupportedInCurrentSdkH265 (MediaCodecInfo info ) {
@@ -251,7 +262,9 @@ private boolean isHardwareSupportedInCurrentSdkH265(MediaCodecInfo info) {
251262 || (name .startsWith (EXYNOS_PREFIX )
252263 && Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP )
253264 // Hisi VP8 encoder seems to be supported. Needs more testing.
254- || (name .startsWith (HISI_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT );
265+ || (name .startsWith (HISI_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
266+ || (name .startsWith (IMG_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
267+ || vcp .isExtraHardwareSupported (name , "video/hevc" , vcp .parseWithTag (vcp .loadWithDom (extraMediaCodecFile ), "Decoders" ));
255268 }
256269
257270 private boolean isMediaCodecAllowed (MediaCodecInfo info ) {
0 commit comments