⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pe_consumer_bdrom.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:

    *pfIsActive = FALSE;

    return (PE_SUCCESS);
}

/**
 * Return status of IG demux for this consumer
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::DemuxGetIGTS(LONG *pPID, BOOLEAN *pfIsActive)
{
    // SDK: if we are demuxing then *pPID = m_ig_pid;

    *pfIsActive = FALSE;

    return (PE_SUCCESS);
}

/**
 * Return status of TextST demux for this consumer
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::DemuxGetSubTextTS(LONG *pPID, BOOLEAN *pfIsActive)
{
    // SDK: if we are demuxing then *pPID = m_st_pid;

    *pfIsActive = FALSE;

    return (PE_SUCCESS);
}

/**
 * If active start consuming and presenting AV data.  Wakes up dataProc.
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::Run(void)
{
    VDVD_ERROR  error = VDVD_SUCCESS;
    PE_STATUS   status = PE_SUCCESS;

    DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Run()\n"));

    if (IS_PECONSUMER_STATE_RUNNING(m_ConsumerState) == FALSE)
    {
        if (INPUT_MAIN == m_ConsumerInput)
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Run() - decode setup\n"));

            if (m_videoDecode[0] != NULL)
            {
                DECODER_SETTINGS_TYPE settings;
                settings.streamType = DECODER_STREAM_TYPE_MPEG2;
  
                error = m_videoDecode[0]->Setup(&settings);
                if (VDVD_IS_ERROR(error))
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("cPEConsumer_BDROM::Run() - decode setup FAILED!\n"));
                    status = PE_FAILURE;
                }
            }
        }

        /* if we have the PG decoder then start it */
        if (m_pg_dec != NULL)
        {
            PGRun(m_pg_dec);
        }

        /* if we have the IG decoder then start it */
        if (m_ig_dec != NULL)
        {
            IGRun(m_ig_dec);
        }

        /* if we have the ST decoder then start it */
        if (m_st_dec != NULL)
        {
            TextSTRun(m_st_dec);
        }

        if (status == PE_SUCCESS)
        {
            /* update state info */
            m_fPrefill      = FALSE;
            m_fSuspend      = FALSE;
            m_ConsumerState = PE_CONSUMER_STATE_RUN;
            m_fStillOn      = FALSE;
        }
    }

    return (status);

} /* end cPEConsumer_BDROM::Run() */

/**
 * If active start consuming and presenting AV data.
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::Stop(BOOLEAN fHoldPicture)
{
    VDVD_ERROR  error = VDVD_SUCCESS;

    DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - input = %d\n", m_ConsumerInput));

    /* clear prefill since we are going to stop state */
    BOOLEAN fWasPrefilling = m_fPrefill;
    m_fPrefill = FALSE;
    m_fSuspend = FALSE;

    /* @todo Examine what decode/channel stops need to be called and if teardown
     * of dataProc for this BDROM consumer and its information should be done. */

    if ( (IS_PECONSUMER_STATE_RUNNING(m_ConsumerState) == TRUE) && (m_fStop == FALSE) )
    {
        PEINPUTMESSAGE* pMessage = NULL;

        /* tell the consumer data task it should stop */
        m_fStop  = TRUE;
        m_fAbort = TRUE;


        /* kick the dataProc so it won't wait */
        pMessage = (PEINPUTMESSAGE*)m_InputStream->GetMsg((ULONG)OS_NO_WAIT);
        if (pMessage != NULL)
        {
            m_InputStream->Write((PVOID)pMessage, OS_NO_WAIT);
        }

        /* wait for transition to stopped state */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - wait for transition to stopped (%d)\n", m_ConsumerInput));
        while (m_fStop == TRUE)
        {
            OS_TaskYield();
        }

        /* if we have the IG decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - IGStop (%d)\n", m_ConsumerInput));
        if (m_ig_dec != NULL)
        {
            IGStop(m_ig_dec);
            m_ig_pid = -1;
        }

        /* if we have the PG decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - PGStop (%d)\n", m_ConsumerInput));
        if (m_pg_dec != NULL)
        {
            PGStop(m_pg_dec);
            m_pg_pid = -1;
        }

        /* if we have the ST decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - STStop (%d)\n", m_ConsumerInput));
        if (m_st_dec != NULL)
        {
            TextSTStop(m_st_dec);
        }

        /* stop the decoder */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - stop the decoder (%d)\n", m_ConsumerInput));
        if (INPUT_MAIN == m_ConsumerInput)
        {
            if (m_videoDecode[0] != NULL)
            {
                error = m_videoDecode[0]->Stop(fHoldPicture);
            }
        }

        m_fAbort = FALSE;
    }
    else if (fWasPrefilling == TRUE)
    {
        /* if we have the IG decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - IGStop (%d)\n", m_ConsumerInput));
        if (m_ig_dec != NULL)
        {
            IGStop(m_ig_dec);
            m_ig_pid = -1;
        }

        /* if we have the PG decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - PGStop (%d)\n", m_ConsumerInput));
        if (m_pg_dec != NULL)
        {
            PGStop(m_pg_dec);
            m_pg_pid = -1;
        }

        /* if we have the ST decoder then stop it */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - STStop (%d)\n", m_ConsumerInput));
        if (m_st_dec != NULL)
        {
            TextSTStop(m_st_dec);
        }
    }

    /* The state is set in the base consumer! */
    DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Stop() - DONE (%d)\n", m_ConsumerInput));
    return (PE_SUCCESS);

} /* end cPEConsumer_BDROM::Stop() */

/**
 * If active start consuming and presenting AV data.
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::Flush(void)
{
    VDVD_ERROR   error = VDVD_SUCCESS;

    DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Flush -- input = %d\n", m_ConsumerInput));

    if (IS_PECONSUMER_STATE_RUNNING(m_ConsumerState) == TRUE)
    {
        if (m_fSuspend == FALSE)
        {
            PEINPUTMESSAGE* pMessage = NULL;

            /* tell the consumer data task it should stop */
            m_fPrefill = FALSE;
            m_fStop    = TRUE;
            m_fAbort   = TRUE;

            /* kick the dataProc so it won't wait */
            pMessage = (PEINPUTMESSAGE*)m_InputStream->GetMsg((ULONG)OS_NO_WAIT);
            if (pMessage != NULL)
            {
                m_InputStream->Write((PVOID)pMessage, OS_NO_WAIT);
            }

            /* wait for transition to stopped state */
            DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Flush() - wait for transition to stopped\n"));
            while (m_fStop == TRUE)
            {
                OS_TaskYield();
            }
            m_fAbort = FALSE;
            m_ConsumerState = PE_CONSUMER_STATE_RUN;
        }

        /* flush the playback and the decoders */
        DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Flush() - flush the decoder\n"));
        if (m_videoDecode[0] != NULL)
        {
            error = m_videoDecode[0]->Flush(DECODER_TYPE_VIDEO, DECODE_FLUSH_MODE_DISCARD);
        }
        if (m_audioDecode[0] != NULL)
        {
            error = m_audioDecode[0]->Flush(DECODER_TYPE_AUDIO, DECODE_FLUSH_MODE_DISCARD);
        }
        if (m_videoDecode[1] != NULL)
        {
            error = m_videoDecode[1]->Flush(DECODER_TYPE_VIDEO, DECODE_FLUSH_MODE_DISCARD);
        }
        if (m_audioDecode[1] != NULL)
        {
            error = m_audioDecode[1]->Flush(DECODER_TYPE_AUDIO, DECODE_FLUSH_MODE_DISCARD);
        }

        /* Restart Text decoder, this does not actually flush the buffers;
         * just tells it to resync */
        if (m_st_dec != NULL)
        {
            TextSTStop(m_st_dec);
            TextSTRun(m_st_dec);
        }

        /* Flush PG decoder */
        if (m_pg_dec != NULL)
        {
            PGStop(m_pg_dec);
            PGRun(m_pg_dec);
        }

        /* we never flush out-of-mux IG */
        if (m_ConsumerInput != INPUT_BDROM_SUBPATH_INTERACTIVE_GRAPHICS)
        {
            /* Flush IG decoder */
            if (m_ig_dec != NULL)
            {
                IGStop(m_ig_dec);
                IGRun(m_ig_dec);
            }
        }
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::Flush - END\n" ));
    return (PE_SUCCESS);

} /* end cPEConsumer_BDROM::Flush() */

/**
 * cPEConsumer_BDROM::SetRate
 *
 * @param PE_ISTREAMCTRL_PLAYRATE *pPlayRate
 *
 * @return PE_STATUS
 */
PE_STATUS cPEConsumer_BDROM::SetRate(PE_ISTREAMCTRL_PLAYRATE *pPlayRate)
{
    PE_STATUS status = PE_SUCCESS;

    /*
     * If setting rate for textst consumer, then possibly start or stop
     * the textst decoder, depending on the rate change.
     * Otherwise, call the base consumer to set the rate.
     */
    if (INPUT_BDROM_SUBPATH_TEXT_SUBTITLE == m_ConsumerInput)
    {
        /*
         * Setting rate for textst consumer.  If we are going into a trick mode and
         * the textst decoder is running, then stop the textst decoder.  If we are going into
         * normal mode and the textst decoder is stopped, then re-start the textst decoder.
         */
        if (pPlayRate->rate == PLAY_RATE_NORMAL)
        {
            /* if we have the ST decoder then start it */
            if (m_st_dec != NULL)
            {
                /*
                 * If the textst decoder is stopped, then start the textst decoder, but
                 * only if the pe is not stopped.
                 */
                if ( (m_ConsumerState != PE_CONSUMER_STATE_STOP) && (TextSTGetState(m_st_dec) != TEXTST_STATE_RUNNING) )
                {
                    TextSTRun(m_st_dec);
                }
            }
        }
        else if ( (pPlayRate->rate != PLAY_RATE_PAUSE) && (pPlayRate->rate != PLAY_RATE_STEP) )
        {
            /* if we have the ST decoder then stop it */
            if (m_st_dec != NULL)
            {
                /* stop the textst decoder */
                if (TextSTGetState(m_st_dec) != TEXTST_STATE_STOPPED)
                {
                    TextSTStop(m_st_dec);
                }
            }
        }
    }
    else
    {
        /* call base consumer */
        status = cPEConsumer::SetRate(pPlayRate);
    }

    return (status);

} /* end cPEConsumer_BDROM::SetRate() */

PE_STATUS cPEConsumer_BDROM::ProcessBegOfStream(PVOID StreamContext)
{
    /*
     * If this is a textst input, then flush the textst decoder so
     * the preloading buffer does not fill up.
     */
    if (m_ConsumerInput == INPUT_BDROM_SUBPATH_TEXT_SUBTITLE)
    {
        /* if we have the ST decoder then flush it (but stop it first!) */
        if (m_st_dec != NULL)
        {
            if (TextSTGetState(m_st_dec) != TEXTST_STATE_STOPPED)
            {
                TextSTStop(m_st_dec);
            }
            TextSTFlush(m_st_dec);
        }
    }

    /*
     * If this is an IG subpath input, then flush the IG decoder so
     * the preloading buffer has correct clip loaded into it.
     */
    if (m_ConsumerInput == INPUT_BDROM_SUBPATH_INTERACTIVE_GRAPHICS)
    {
        /* if we have the IG decoder then stop it so that it gets flushed */
        if (m_ig_dec != NULL)
        {
            IGStop(m_ig_dec);
            IGRun(m_ig_dec);
        }
    }

    if (m_ConsumerInput == INPUT_MAIN)
    {
        IGSynchronize(m_ig_dec, IG_DECODE_SYNC);
    }

    return (cPEConsumer::ProcessBegOfStream(StreamContext));
}

PE_STATUS cPEConsumer_BDROM::ProcessEndOfStream(PVOID StreamContext)
{
    PE_STATUS status = PE_SUCCESS;

    /* If this is a ig secondary input, send prefill event before end of stream */
    if (m_ConsumerInput == INPUT_BDROM_SUBPATH_INTERACTIVE_GRAPHICS)
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -