標籤:android平台 mediacodec 判斷硬解碼
public boolean isSupportMediaCodecHardDecoder(){ boolean isHardcode = false; //讀取系統設定檔/system/etc/media_codecc.xml File file = new File("/system/etc/media_codecs.xml"); InputStream inFile = null; try { in = new FileInputStream(file); } catch (Exception e) { // TODO: handle exception } if(inFile != null) { XmlPullParserFactory pullFactory; try { pullFactory = XmlPullParserFactory.newInstance(); XmlPullParser xmlPullParser = pullFactory.newPullParser(); xmlPullParser.setInput(in, "UTF-8"); int eventType = xmlPullParser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { String tagName = xmlPullParser.getName(); switch (eventType) { case XmlPullParser.START_TAG: if ("MediaCodec".equals(tagName)) { String componentName = xmlPullParser.getAttributeValue(0); if(componentName.startsWith("OMX.")) { if(!componentName.startsWith("OMX.google.")) { isHardcode = true; } } } } eventType = xmlPullParser.next(); } } catch (Exception e) { // TODO: handle exception } } return isHardcode;}
著作權聲明:本文為博主原創文章,未經博主允許不得轉載。
【第四篇章-android平台MediaCodec】判斷是否支援硬解碼代碼