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

📄 pe_istreamctrl.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    {
        DbgPrint(("peiStrmSetGraphicsAspectRatio: Failed to get surface size\n"));
        status = PE_FAILURE;
        goto err_out;
    }

    /* Surface flipping done after SetSourceRectangle, Xavier mentioned SetSourceRectangle
       is not currently doing a flip */

    /* set the aspect ratio, note we are only setting up LUT8 surfaces (BDROM only) */
    if (LayerConfig.pixelformat != DSPF_LUT8)
    {
        return PE_SUCCESS;
    }

    if (SourceAspect == SOURCE_ASPECT_RATIO_16X9)
    {
        switch (ScreenAspect)
        {
        case ASPECT_RATIO_4X3_PANSCAN:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_16X9 -> ASPECT_RATIO_4X3_PANSCAN\n"));
            if ((VideoFormat == VIDEO_FORMAT_NTSC) || (VideoFormat == VIDEO_FORMAT_PAL) ||
                (VideoFormat == VIDEO_FORMAT_480P) || (VideoFormat == VIDEO_FORMAT_576P))
            {
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, (int)(width * 0.1111), 0, (int)(width * 0.7778), height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            }
            else
            {
                /* don't allow invalid config */
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            }
            break;

        case ASPECT_RATIO_4X3_LETTERBOX:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_16X9 -> ASPECT_RATIO_4X3_LETTERBOX\n"));
            if (VideoFormat == VIDEO_FORMAT_NTSC)
            {
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, (float)0.1225, 1, (float)0.7575);
            }
            else if ((VideoFormat == VIDEO_FORMAT_PAL) || (VideoFormat == VIDEO_FORMAT_480P) || (VideoFormat == VIDEO_FORMAT_576P))
            {
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, (float)0.1200, 1, (float)0.7620);
            }
            else
            {
                /* don't allow invalid config */
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            }
            break;

        case ASPECT_RATIO_4X3_LETTERBOX_REMOVED:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_16X9 -> ASPECT_RATIO_4X3_LETTERBOX_REMOVED\n"));
            if ((VideoFormat == VIDEO_FORMAT_NTSC) || (VideoFormat == VIDEO_FORMAT_PAL) ||
                (VideoFormat == VIDEO_FORMAT_480P) || (VideoFormat == VIDEO_FORMAT_576P))
            {
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, (float)(0.1111), 1, (float)(0.7778) );
            }
            else
            {
                /* don't allow invalid config */
                dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
                dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            }
            break;

        case ASPECT_RATIO_16X9_WINDOWBOX:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_16X9 -> ASPECT_RATIO_16x9_WINDOWBOX\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        case ASPECT_RATIO_16X9:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_16X9 -> ASPECT_RATIO_16x9\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        default:
            DBGPRINT(DBG_ON(DBG_ERROR), ("Unknown aspect ratio\n"));
            break;
        }
    }
    else if (SourceAspect == SOURCE_ASPECT_RATIO_4X3)
    {
        switch (ScreenAspect)
        {
        case ASPECT_RATIO_4X3_PANSCAN:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_4X3 -> ASPECT_RATIO_4X3_PANSCAN\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        case ASPECT_RATIO_4X3_LETTERBOX:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_4X3 -> ASPECT_RATIO_4X3_LETTERBOX\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        case ASPECT_RATIO_4X3_LETTERBOX_REMOVED:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_4X3 -> ASPECT_RATIO_4X3_LETTERBOX_REMOVED\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        case ASPECT_RATIO_16X9_WINDOWBOX:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_4X3 -> ASPECT_RATIO_16X9_WINDOWBOX\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, (float)(0.1111), 0, (float)(0.7778), 1.0);
            break;

        case ASPECT_RATIO_16X9:
            DBGPRINT(DBG_ON(DBG_TRACE), ("SOURCE_ASPECT_RATIO_4X3 -> ASPECT_RATIO_16X9\n"));
            dfbDispLayer->SetSourceRectangle(dfbDispLayer, 0, 0, width, height);
            dfbDispLayer->SetScreenLocation(dfbDispLayer, 0, 0, 1, 1);
            break;

        default:
            DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: Unknown aspect ratio\n"));
            break;
        }
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsAspectRatio: INVALID aspect ratio\n"));
    }

err_out:

    if (sfc)
    {
        sfc->Release(sfc);
    }

    if (dfbDispLayer != NULL)
    {
        dfbDispLayer->Release(dfbDispLayer);
    }

    return (status);
}

/**
 * Private function to execute the PE_RESET command.
 *
 * @param iStrmCtrl - iStrmCtrl handle
 * @param pPEConsumer - array of all consumers
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmReset(ISTREAMCTRLHANDLE *iStrmCtrl )
{
    PE_STATUS           status      = PE_SUCCESS;
    PEHANDLE*           pe          = NULL;
    ICONFIGUREHANDLE*   iConfigure  = NULL;
    int                 i           = 0;

    DbgAssert(iStrmCtrl != NULL);
    DbgAssert(iStrmCtrl->pPEConsumer != NULL);

    DbgAssert((iStrmCtrl->PEManager) != NULL);
    pe         = (PEHANDLE*)iStrmCtrl->PEManager;
    iConfigure = pe->iConfigure;
    DbgAssert(iConfigure != NULL);


    /* must be stopped before trying to detach */
    if (iStrmCtrl->SystemState == PE_ISTREAMCTRL_STATE_UNREALIZED)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmReset -- PE_INVALID_STATE\n"));
        status = PE_INVALID_STATE;
    }
    else
    {
        status = PE_SUCCESS;
    }

    if (status == PE_SUCCESS)
    {
        /* stop the Decode Done, PTS and Presentation Start callbacks */
        iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_TIMESTAMPS, DECODE_NOTIFY_CANCEL);
        iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_DECODE_DONE, DECODE_NOTIFY_CANCEL);
        iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_PRESENTATION_START, DECODE_NOTIFY_CANCEL);

        /* PEConsumer cleanup */
        for (i=0; i<MAX_PE_INPUTS; i++)
        {
            /* delete any PEConsumers that were created */
            if (iStrmCtrl->pPEConsumer[i] != NULL)
            {
                iStrmCtrl->pPEConsumer[i]->Reset();
                delete (iStrmCtrl->pPEConsumer[i]);
                iStrmCtrl->pPEConsumer[i] = NULL;
            }
            /* TODO-SDK - Delete any data channels that were created */
        }

        /* delete the spu decoder */
        if (iStrmCtrl->m_decoders.spu != NULL)
        {
            SPUDelete(iStrmCtrl->m_decoders.spu);
            iStrmCtrl->m_decoders.spu = NULL;
        }

#if BDROM_ENABLE
        /* delete the ig decoder */
        if (iStrmCtrl->m_decoders.ig_dec != NULL)
        {
            IGStop(iStrmCtrl->m_decoders.ig_dec);
            IGDetachEvent(iStrmCtrl->m_decoders.ig_dec);
            IGDelete(iStrmCtrl->m_decoders.ig_dec);
            iStrmCtrl->m_decoders.ig_dec = NULL;
        }

        /* delete the pg decoder */
        if (iStrmCtrl->m_decoders.pg_dec != NULL)
        {
            PGStop(iStrmCtrl->m_decoders.pg_dec);
            PGDelete(iStrmCtrl->m_decoders.pg_dec);
            iStrmCtrl->m_decoders.pg_dec = NULL;
        }

        /* delete the st decoder */
        if (iStrmCtrl->m_decoders.st_dec != NULL)
        {
            TextSTStop(iStrmCtrl->m_decoders.st_dec);
            TextSTDelete(iStrmCtrl->m_decoders.st_dec);
            iStrmCtrl->m_decoders.st_dec = NULL;
        }
#endif

        /* reset graphics configureations */
        peiStrmResetGraphics(&iStrmCtrl->pg_dfb_disp_layer);
        peiStrmResetGraphics(&iStrmCtrl->ig_dfb_disp_layer);

        /* reset graphics mode */
        iStrmCtrl->GraphicsMode = GRAPHICS_MODE_NOT_SET;
    }

    return (status);
}

/**
 * Private function to reset graphics for pg, ig, and textst.
 *
 * @param disp_layer -- display layer to release
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmResetGraphics(IDirectFBDisplayLayer **disp_layer)
{
    DbgAssert(disp_layer != NULL);

    /* release display layer */
    if (*disp_layer)
    {
        (*disp_layer)->Release(*disp_layer);
        *disp_layer = NULL;
    }

    return (PE_SUCCESS);
}

/**
 * Private function to execute the PE_ATTACH_INPUT_STREAM command.
 *
 * @param SystemState - the current state of iStreamCtrl
 * @param StreamType - identifies iStreamCtrls mode of operation
 * @param input - which input is being attached
 * @param pStream - the cStream to attach for the specified input
 * @param pPEConsumer - array of all consumers
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmAttachInputStream(const PE_ISTREAMCTRL_STATE SystemState, const PE_ISTREAMCTRL_STREAM_TYPE StreamType,
    const PE_ISTREAMCTRL_INPUT input, cStream *pStream, cPEConsumer **pPEConsumer)
{
    PE_STATUS status;

    DbgAssert(pPEConsumer != NULL);
    DbgAssert(pStream != NULL);

    if (SystemState != PE_ISTREAMCTRL_STATE_REALIZING)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmAttachInputStream -- PE_INVALID_STATE\n"));
        status = PE_INVALID_STATE;
    }
    else
    {
        status = PE_SUCCESS;
    }

    if (status == PE_SUCCESS)
    {
        /* check that the input number is valid for the current stream type
         * Note that in BDROM mode we support 5 inputs */
        if (StreamType == STREAM_TYPE_MPEG2_BDTS)
        {
            if (input >= MAX_PE_INPUTS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmAttachInputStream -- PE_INVALID_PARAM\n"));
                status = PE_INVALID_PARAM;
            }
        }
        /* Validate the input number for HD DVD (Advanced Content) */
        else if (StreamType == STREAM_TYPE_MPEG2_EVOB_ADV)
        {
            if (input >= MAX_INPUTS_HDDVD_ADV)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmAttachInputStream -- PE_INVALID_PARAM %d\n", input));
                status = PE_INVALID_PARAM;
            }
        }
        else
        {
            if (input != INPUT_MAIN)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmAttachInputStream -- PE_INVALID_PARAM\n"));
                status = PE_INVALID_PARAM;
            }
        }
    }

    /* attach the stream to the indicated PEConsumer */
    if (status == PE_SUCCESS)
    {
        status = pPEConsumer[input]->AttachInputStream(pStream, input);
    }

    return (status);
}

/**
 * Private function to execute the PE_PREFILL command.
 *
 * @param SystemState - the current state of iStreamCtrl
 * @param StreamType - identifies iStreamCtrls mode of operation
 * @param input - which input is being attached
 * @param fBlocking - used to request synchronous or asynchronous prefill completion
 * @param pPEConsumer - array of all consumers
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmPrefill(const PE_ISTREAMCTRL_STATE SystemState, const PE_ISTREAMCTRL_STREAM_TYPE StreamType,
    const PE_ISTREAMCTRL_INPUT input, BOOLEAN fBlocking, cPEConsumer **pPEConsumer)
{
    PE_STATUS status = PE_SUCCESS;

    /* verify current state */
    if (SystemState < PE_ISTREAMCTRL_STATE_STOPPED)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmPrefill -- PE_INVALID_STATE\n"));
        status = PE_INVALID_STATE;
    }

    /* verify the request is valid for the current stream type */
    if ( ( (StreamType != STREAM_TYPE_MPEG2_BDTS) && (i

⌨️ 快捷键说明

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