14
14
import static org .webrtc .MediaCodecUtils .INTEL_PREFIX ;
15
15
import static org .webrtc .MediaCodecUtils .QCOM_PREFIX ;
16
16
import static org .webrtc .MediaCodecUtils .HISI_PREFIX ;
17
+ import static org .webrtc .MediaCodecUtils .IMG_PREFIX ;
17
18
18
19
import android .media .MediaCodecInfo ;
19
20
import android .media .MediaCodecList ;
@@ -42,6 +43,9 @@ public class HardwareVideoEncoderFactory implements VideoEncoderFactory {
42
43
@ Nullable private final EglBase14 .Context sharedContext ;
43
44
private final boolean enableIntelVp8Encoder ;
44
45
private final boolean enableH264HighProfile ;
46
+ private final String extraMediaCodecFile = "sdcard/mediaCodec.xml" ;
47
+ private final VideoCapabilityParser vcp = new VideoCapabilityParser ();
48
+
45
49
@ Nullable private final Predicate <MediaCodecInfo > codecAllowedPredicate ;
46
50
47
51
/**
@@ -216,16 +220,20 @@ private boolean isHardwareSupportedInCurrentSdkVp8(MediaCodecInfo info) {
216
220
return (name .startsWith (QCOM_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
217
221
// Hisi VP8 encoder seems to be supported. Needs more testing.
218
222
|| (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 )
219
224
// Exynos VP8 encoder is supported in M or later.
220
225
|| (name .startsWith (EXYNOS_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .M )
221
226
// Intel Vp8 encoder is supported in LOLLIPOP or later, with the intel encoder enabled.
222
227
|| (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" ));
224
230
}
225
231
226
232
private boolean isHardwareSupportedInCurrentSdkVp9 (MediaCodecInfo info ) {
227
233
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" )))
229
237
// Both QCOM and Exynos VP9 encoders are supported in N or later.
230
238
&& Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ;
231
239
}
@@ -240,7 +248,10 @@ private boolean isHardwareSupportedInCurrentSdkH264(MediaCodecInfo info) {
240
248
return (name .startsWith (QCOM_PREFIX ) && Build .VERSION .SDK_INT >= Build .VERSION_CODES .KITKAT )
241
249
// Exynos H264 encoder is supported in LOLLIPOP or later.
242
250
|| (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" ));;
244
255
}
245
256
246
257
private boolean isHardwareSupportedInCurrentSdkH265 (MediaCodecInfo info ) {
@@ -251,7 +262,9 @@ private boolean isHardwareSupportedInCurrentSdkH265(MediaCodecInfo info) {
251
262
|| (name .startsWith (EXYNOS_PREFIX )
252
263
&& Build .VERSION .SDK_INT >= Build .VERSION_CODES .LOLLIPOP )
253
264
// 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" ));
255
268
}
256
269
257
270
private boolean isMediaCodecAllowed (MediaCodecInfo info ) {
0 commit comments