I am trying to understand how MediaCodec is used for hardware decoding.
My knowledge of Android is very limited.
Here are my findings:
There is an XML file that represents the details of the codec in the Android system.
device/ti/omap3evm/media_codecs.xml for an example.
This means that if we create a codec from a Java application with Media Codec
MediaCodec codec = MediaCodec.createDecoderByType(type);
It should find the appropriate encoder using the xml file.
What am I doing?
I am trying to figure out which part of the code is reading xml and finding a codec based on this type.
1) Application Level:
MediaCodec codec = MediaCodec.createDecoderByType(type);
2) MediaCodec.java β [ frameworks / base / media / java / android / media / MediaCodec.java ]
public static MediaCodec createDecoderByType(String type) { return new MediaCodec(type, true , false ); }
3)
private MediaCodec( String name, boolean nameIsType, boolean encoder) { native_setup(name, nameIsType, encoder); --> JNI Call. }
4) JNI implementation β [ frameworks / base / media / jni / android_media_MediaCodec.cpp ]
static void android_media_MediaCodec_native_setup (..) { ....... const char *tmp = env->GetStringUTFChars(name, NULL); sp<JMediaCodec> codec = new JMediaCodec(env, thiz, tmp, nameIsType, encoder); ---> Here }
from frameworks / base / media / jni / android _media_MediaCodec.cpp
JMediaCodec::JMediaCodec( ..) { .... mCodec = MediaCodec::CreateByType(mLooper, name, encoder); //Call goes to libstagefright .... } sp<MediaCodec> MediaCodec::CreateByType( const sp<ALooper> &looper, const char *mime, bool encoder) { sp<MediaCodec> codec = new MediaCodec(looper); if (codec->init(mime, true /* nameIsType */, encoder) != OK) { --> HERE. return NULL; } return codec; } status_t MediaCodec::init(const char *name, bool nameIsType, bool encoder) { // MediaCodec }
This stream amazes me. If someone points out how to do this, that will help a lot.
thanks.