Chapter 4-android MediaCodec: Determine whether hard decoding code is supported.-androidmediacodec
Public boolean issuppmedimediacodecharddecoder () {boolean isHardcode = false; // read the system configuration File/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 ;}