资讯详情

MyHandler.h对消息"accu"的处理

以下是安卓N版MyHandler.h对消息”accu处理原文

            //收到'accu新闻,解释AAVCAssembler成功将多个NAL单元组合成一帧完整的数据,并存储帧数据buffer添加引用buffer里了。             case 'accu':             {                 if (mSeekPending) {                     ALOGV("Stale access unit.");                     break;                 }                  int32_t timeUpdate;                 if (msg->findInt32("time-update", &timeUpdate) && timeUpdate) {                     如果在消息中msg里设置了"time-update"字段信息,并获得timeUpdate非零值需要处理                     //从消息msg里设置的"track-index"获取字段信息trackIndex的值                     //从消息msg里设置的"rtp-time"获取字段信息rtpTime的值                     //从消息msg里设置的"ntp-time"获取字段信息ntpTime的值                     //调用onTimeUpdate(trackIndex, rtpTime, ntpTime)进行处理                     //break跳出该case处理分支                     size_t trackIndex;                     CHECK(msg->findSize("track-index", &trackIndex));                      uint32_t rtpTime;                     uint64_t ntpTime;                     CHECK(msg->findInt32("rtp-time", (int32_t *)&rtpTime));                     CHECK(msg->findInt64("ntp-time", (int64_t *)&ntpTime));                      onTimeUpdate(trackIndex, rtpTime, ntpTime);                     break;                 }                  int32_t first;                 if (msg->findInt32("first-rtcp", &first)) {                     //如果消息msg里设置了"first-rtcp"将字段信息mReceivedFirstRTCPPacket的值设置为true                     //break跳出该case语句处理分支                     mReceivedFirstRTCPPacket = true;                     break;                 }                  if (msg->findInt32("first-rtp", &first)) {                     //如果消息msg里设置了"first-rtp"字段信息,将mReceivedFirstRTPPacket的值设置为true                     //break跳出该case语句处理分支                     mReceivedFirstRTPPacket = true;                     break;                 }                  ///代码执行到此表明收到的是正常的一帧数据                 //将mNumAccessUnitsReceived自增1计数已收到的帧数                 //调用postAccessUnitTimeoutCheck超时检查                   mNumAccessUnitsReceived;                 postAccessUnitTimeoutCheck();                   //从消息msg的字段信息"track-index"得到trackIndex的值                 size_t trackIndex;                 CHECK(msg->findSize("track-index", &trackIndex));                  if (trackIndex >= mTracks.size()) {                     //mTracks.size()表示支持的最大轨道数,trackIndex超过这个值的差异                     //trackIndex在0~mTracks.size()-1内                     ALOGV("late packets ignored.");                     break;                 }                  //由trackIndex获得相应的轨道TrackInfo信息结构体的指针                 TrackInfo *track = &mTracks.editItemAt(trackIndex);                  int32_t eos;                 if (msg->findInt32("eos", &eos)) {                     //如果消息msg设置了"eos"字段信息显示帧位结尾的帧                     ///当收到的帧是结尾帧时,应相应处理                     ///这里具体处理先不介绍,先放一边,抓住主要矛盾先                     ALOGI("received BYE on track index %zu", trackIndex);                    char value[PROPERTY_VALUE_MAX] = {
    
      0};
                    if (property_get("rtcp.bye.notify", value, "false")
                            && !strcasecmp(value, "true")) {
                        sp<AMessage> msg = mNotify->dup();
                        msg->setInt32("what", kWhatByeReceived);
                        msg->post();
                    }
                    if (!mAllTracksHaveTime && dataReceivedOnAllChannels()) {
                        ALOGI("No time established => fake existing data");

                        track->mEOSReceived = true;
                        mTryFakeRTCP = true;
                        mReceivedFirstRTCPPacket = true;
                        fakeTimestamps();
                    } else {
                        postQueueEOS(trackIndex, ERROR_END_OF_STREAM);
                    }
                    return;
                }

                if (mSeekPending) {
                    ALOGV("we're seeking, dropping stale packet.");
                    break;
                }

                /从消息msg里的"access-unit"字段信息得到存放数据帧buffer的引用
                //调用onAccessUnitComplete(trackIndex, accessUnit)对该buffer进行处理
                sp<ABuffer> accessUnit;
                CHECK(msg->findBuffer("access-unit", &accessUnit));
                onAccessUnitComplete(trackIndex, accessUnit);
                break;
            }

  小结:MyHandler对消息”accu”的处理是:收到正常的数据帧的做法从消息msg里的”access-unit”字段信息得到存放数据帧buffer的引用,然后调用onAccessUnitComplete(trackIndex, accessUnit)进行处理

标签: 300kg传感器accu

锐单商城拥有海量元器件数据手册IC替代型号,打造 电子元器件IC百科大全!

锐单商城 - 一站式电子元器件采购平台