当前位置: 萬仟网 > IT编程>移动开发>Android > android7.1 MediaCodec到OMX流程

android7.1 MediaCodec到OMX流程

2018年11月04日 05:15  | 萬仟网IT编程  | 我要评论
0.frameworks/base/media/java/android/media/mediacodec.java
<1>.public static mediacodec createdecoderbytype(@nonnull string type) {
    eturn new mediacodec(type, true /* nameistype */, false /* encoder */); 
  }

<2>.public static mediacodec createencoderbytype(@nonnull string type){
    return new mediacodec(type, true /* nameistype */, true /* encoder */);
}

<3>.public static mediacodec createbycodecname(@nonnull string name){
    new mediacodec(name, false /* nameistype */, false /* unused */);
}

<4>.private mediacodec( @nonnull string name, boolean nameistype, boolean encoder) {
   native_setup(name, nameistype, encoder);
}


1.frameworks/base/media/jni/android_media_mediacodec.cpp
<1>.static void android_media_mediacodec_native_setup(){
    sp codec = new jmediacodec(env, thiz, tmp, nameistype, encoder);
 }

<2>.jmediacodec::jmediacodec(const char *name, bool nameistype, bool encoder){
    if(nameistype) { 
      mcodec = mediacodec::createbytype(mlooper, name, encoder, &minitstatus);
    }else{
      mcodec = mediacodec::createbycomponentname(mlooper, name, &minitstatus); 
    }
  }

2.frameworks/av/media/libstagefright/mediacodec.cpp
<1>sp mediacodec::createbycomponentname(){
   sp codec = new mediacodec(looper, pid);
   const status_t ret = codec->init(name, false /* nameistype */, false /* encoder */); 
}

sp mediacodec::createbytype(){
   sp codec = new mediacodec(looper, pid); 
   const status_t ret = codec->init(mime, true /* nameistype */, encoder);
}

<2>. status_t mediacodec::init(const astring &name, bool nameistype, bool encoder){
  sp msg = new amessage(kwhatinit, this);
}
<3>.case kwhatinit:{ 
  mcodec->initiateallocatecomponent(format); 
  break;
}
3.frameworks/av/media/libstagefright/acodec.cpp 
<1>.void acodec::initiateallocatecomponent(const sp &msg) {
     msg->setwhat(kwhatallocatecomponent); 
     msg->settarget(this); 
     msg->post();
}

<2>.bool acidic::uninitializedstate::onmessagereceived(const sp &msg) {
     case acodec::kwhatallocatecomponent: 
          onallocatecomponent(msg);
          handled = true;
          break;
}

<3>.bool acodec::uninitializedstate::onallocatecomponent(const sp &msg) {
   astring componentname;//就是codec编解码器的name
   err = omx->allocatenode(componentname.c_str(), observer, &mcodec->mnodebinder, &node);
}
4.frameworks/av/media/libstagefright/omx/omx.cpp
status_t omx::allocatenode(const char *name,…){
  omx_errortype err = mmaster->makecomponentinstance(name,…)
}

5.frameworks/av/media/libstagefright/omx/omxmaster.cpp
omx_errortype omxmaster::makecomponentinstance(const char* name,…){
   aloge("----omxmaster----------> %s(), line = %d, name = %s", __function__, __line__,name);
}

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

◎已有 0 人评论

Copyright © 2019  萬仟网 保留所有权利. 粤ICP备17035492号-1
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com