在android stagefright Media Player中暂停和寻找

时间:2016-04-26 13:37:10

标签: android c++ stagefright

我有RK3288硬件板,我正在尝试使用软件解码器.. 我已经将我的软件解码器与android舞台惊吓播放器集成在一起.. 它完美集成,视频也完全运行..

但现在问题是当我暂停或寻找视频时,弹出窗口说

  

"无法播放此视频"

当我点击暂停按钮时,它再次调用了awesomeplayer的构造函数(我使用printf进行了检查。)

所以请问有人能指出我的代码中缺少的地方吗?或者是否需要进行任何其他更改?

My Onqueuefilled Function(类似于SoftAVC.cpp)

   void IntdecHEVC::onQueueFilled(OMX_U32 portIndex) {
        UNUSED(portIndex);
            if (checkp) {                          
            return;
        }

        IAccessUnit pic_val;
        DisplayPic Display_val;
        int32_t got_frame;
        int32_t timeDelay, timeTaken;
        unsigned int p;    
        if (mSignalledError) {
            return;
        }
        if (mOutputPortSettingsChange != NONE) {
            return;
        }


        List<BufferInfo *> &inQueue = getPortQueue(kInputPortIndex);
        List<BufferInfo *> &outQueue = getPortQueue(kOutputPortIndex);

             while (!outQueue.empty()) {
            BufferInfo *inInfo;
            OMX_BUFFERHEADERTYPE *inHeader = NULL;

        BufferInfo *outInfo;
            OMX_BUFFERHEADERTYPE *outHeader = NULL;
            uint8_t *pBuf;

            inInfo = NULL;
            inHeader = NULL;
            Display_val.eosFlag = false;

            if (!mIsInFlush) {
                    if (!inQueue.empty()) {
                    inInfo = *inQueue.begin();
                    inHeader = inInfo->mHeader;

                } else {
                    break;
                }
            }


        outInfo = *outQueue.begin();
                outHeader = outInfo->mHeader;
                outHeader->nFlags = 0;
                outHeader->nTimeStamp = 0;
                outHeader->nOffset = 0;


        if (inHeader != NULL && (inHeader->nFlags & OMX_BUFFERFLAG_EOS)) {

                mReceivedEOS = true;
                Display_val.eosFlag = true;
                if (inHeader->nFilledLen == 0) {

                    inQueue.erase(inQueue.begin());
                    inInfo->mOwnedByUs = false;
                    notifyEmptyBufferDone(inHeader);
                    inHeader = NULL;
                    setFlushMode();        
                }
            }    

            if (inHeader != NULL) {

                pic_val.bufferData = inHeader->pBuffer + inHeader->nOffset;
                pic_val.bufferLength = inHeader->nFilledLen;
                pic_val.pts = inHeader->nTimeStamp;

            }

       if (outHeader) 
                pBuf = outHeader->pBuffer;

                Display_val.pobLumaSl  = pBuf;
                Display_val.pobCromaCb = pBuf + (mWidth * mHeight);
                Display_val.pobCromaCr = //pBuf + (mWidth*mHeight) + (m_lOriginalWidthUV*m_lHeightUV);

                Display_val.pobCromaCb +(m_lOriginalWidthUV*m_lHeightUV);


            GETTIME(&mTimeStart, NULL);
            /* Compute time elapsed between end of previous decode()
             * to start of current decode() */
            TIME_DIFF(mTimeEnd, mTimeStart, timeDelay);



            // set the height and width of the picture */
            pic_val.width = mWidth;
            pic_val.height = mHeight;

           mInterface.api_inte265Decode(&pic_val); //decoding data

    handlePortSettingChangeEvent(&pic_val);                  
            GETTIME(&mTimeEnd, NULL);
            /* Compute time taken for decode() */
            TIME_DIFF(mTimeStart, mTimeEnd, timeTaken);
                  got_frame = mInterface.api_inte265GetPic(&Display_val);

    if (got_frame) {

                FormatIYUV(&Display_val);       //copy data to outputbuffer 1-4


                    /* added to check decoded data by pooja*/
                    if (1) {

                        unsigned int i;
                        unsigned int MAX_SIZE = Display_val.width * Display_val.height;

                        for (i = 0; i < MAX_SIZE; i++) {
                            fwrite(&Display_val.pobLumaSl[i], sizeof(uint8_t), 1, fb);
                        }

                        MAX_SIZE = (Display_val.width >> 1) * (Display_val.height >> 1);

                        for (i = 0; i < MAX_SIZE; i++) {
                            fwrite(&Display_val.pobCromaCb[i], sizeof(uint8_t), 1, fb);
                        }

                        for (i = 0; i < MAX_SIZE; i++) {
                            fwrite(&Display_val.pobCromaCr[i], sizeof(uint8_t), 1, fb);
                        }

                    }

                    if (outHeader != NULL) {

                        outHeader->nFilledLen = (Display_val.width * Display_val.height * 3) / 2;

                        outHeader->nTimeStamp = Display_val.pts;

                        outInfo->mOwnedByUs = false;
                        outQueue.erase(outQueue.begin());
                        outInfo = NULL;
                        notifyFillBufferDone(outHeader);
                        outHeader = NULL;
                    }
                } else if (mIsInFlush) {

                    /* If in flush mode and no output is returned by the codec,
                     * then come out of flush mode */
                    mIsInFlush = false;

                    /* If EOS was recieved on input port and there is no output
                     * from the codec, then signal EOS on output port */
                    if (mReceivedEOS) {

                        if (outHeader != NULL) {

                            outHeader->nFilledLen = 0;
                            outHeader->nFlags |= OMX_BUFFERFLAG_EOS;              // 12-4-2016                            
                            outInfo->mOwnedByUs = false;
                            outQueue.erase(outQueue.begin());
                            outInfo = NULL;
                            notifyFillBufferDone(outHeader);
                            outHeader = NULL;
                            resetPlugin();
                resetDecoder();     // added 
                checkp = true;               //15-4-2016
               // break;                        //13-4-2016
                return;                     //14-4-2016
                        }
           }
                  }


    /* If input EOS is seen and decoder is not in flush mode,
         * set the decoder in flush mode.
         * There can be a case where EOS is sent along with last picture data
         * In that case, only after decoding that input data, decoder has to be
         * put in flush. This case is handled here  */

        if (mReceivedEOS && !mIsInFlush) {

                 setFlushMode();
              }


            /* Notify to client that empty buffer is done - pooja*/
            if (inHeader != NULL) {
                //inHeader->nFilledLen = 0;

                inInfo->mOwnedByUs = false;
                inQueue.erase(inQueue.begin());
                inInfo = NULL;
                notifyEmptyBufferDone(inHeader);
                inHeader = NULL;
            }



        }       // end !outQueue.empty()) loop


    }

0 个答案:

没有答案