播放媒体文件找到对应解码器组件的过程

以下代码流程为一个媒体文件解码时找到对应插件的流程:


函数 status_t NuPlayer::instantiateDecoder(boolaudio, sp<DecoderBase> *decoder) 函数初始化创建解码器

 

status_t NuPlayer::instantiateDecoder(boolaudio, sp<DecoderBase> *decoder) {

   if (*decoder != NULL) {

       return OK;

    }

……

   if (audio) {

       sp<AMessage> notify = new AMessage(kWhatAudioNotify, id());

       ++mAudioDecoderGeneration;

       notify->setInt32("generation", mAudioDecoderGeneration);

 

       if (mOffloadAudio) {

           *decoder = new DecoderPassThrough(notify, mSource, mRenderer);

       } else {

           *decoder = new Decoder(notify, mSource, mRenderer);

       }

    }else {

       sp<AMessage> notify = new AMessage(kWhatVideoNotify, id());

       ++mVideoDecoderGeneration;

       notify->setInt32("generation", mVideoDecoderGeneration);

 

       *decoder = new Decoder(

                notify, mSource, mRenderer,mNativeWindow, mCCDecoder);

 

        // enable FRC if high-quality AV sync isrequested, even if not

       // queuing to native window, as this will even improve textureview

       // playback.

       {

           char value[PROPERTY_VALUE_MAX];

           if (property_get("persist.sys.media.avsync", value, NULL)&&

                    (!strcmp("1",value) || !strcasecmp("true", value))) {

               format->setInt32("auto-frc", 1);

           }

       }

    }

 

   if (mPlayerExtendedStats != NULL) {

       format->setObject(MEDIA_EXTENDED_STATS, mPlayerExtendedStats);

    }

 

    (*decoder)->init();

(*decoder)->configure(format, mIsStreaming);

……
……

}

 

 

 

 

void NuPlayer::DecoderBase::configure(constsp<AMessage> &format, bool isStreaming) {

   sp<AMessage> msg = new AMessage(kWhatConfigure, id());

   msg->setMessage("format", format);

   msg->setInt32("isStreaming", isStreaming);

 

   sp<AMessage> response;

   PostAndAwaitResponse(msg, &response);

}

 

 

voidNuPlayer::DecoderBase::onMessageReceived(const sp<AMessage> &msg) {

 

   switch (msg->what()) {

       case kWhatConfigure:

       {

           uint32_t replyID;

           CHECK(msg->senderAwaitsResponse(&replyID));

 

           sp<AMessage> format;

           uint32_t isStreaming;

           CHECK(msg->findMessage("format", &format));

           CHECK(msg->findInt32("isStreaming", (int32_t*)&isStreaming));

           onConfigure(format

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值