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

📄 pe_istreamctrl.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        {
            /** Configuration for HD DVD (Advanced Content) **/

            /* Create the consumers for HD DVD (Advanced Content) */
            iStrmCtrl->pPEConsumer[INPUT_MAIN] = new cPEConsumer_HDDVD_ADV;
            iStrmCtrl->pPEConsumer[INPUT_SECONDARY] = new cPEConsumer_HDDVD_ADV;
            iStrmCtrl->pPEConsumer[INPUT_SUBSTITUTE_AUDIO] = new cPEConsumer_HDDVD_ADV;

            /* Proceed only of the consumer was created successfully */
            if (
                 (iStrmCtrl->pPEConsumer[INPUT_MAIN] == NULL)             ||
                 (iStrmCtrl->pPEConsumer[INPUT_SECONDARY] == NULL)        ||
                 (iStrmCtrl->pPEConsumer[INPUT_SUBSTITUTE_AUDIO] == NULL)
               )
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfig(STREAM_TYPE_MPEG2_EVOB_ADV) - Could not create consumer!\n"));
                status = PE_MEM_ALLOCATION;
            }
            else
            {
                /** Create the resources for the main and substitute audio inputs **/

                /* Attach the decode playback for the main input */
                config_info.input     = INPUT_MAIN;
                config_info.fPlaybackStarted = FALSE;
                iStrmCtrl->pPEConsumer[INPUT_MAIN]->Configure(&config_info);

                /* Attach callback to receive events from this PEConsumer */
                iStrmCtrl->pPEConsumer[INPUT_MAIN]->AttachEvent(peiStrmConsumerCallback, iStrmCtrl->PEManager);

                /* Attach the decode playback for the substitute audio input, which uses many of the same configuration resources as the main input */
                config_info.input     = INPUT_SUBSTITUTE_AUDIO;
                config_info.fPlaybackStarted = TRUE;
                iStrmCtrl->pPEConsumer[INPUT_SUBSTITUTE_AUDIO]->Configure(&config_info);

                /* Attach callback to receive events from this PEConsumer */
                iStrmCtrl->pPEConsumer[INPUT_SUBSTITUTE_AUDIO]->AttachEvent(peiStrmConsumerCallback, iStrmCtrl->PEManager);

                /** Create the resources for the secondary input **/


                /* Attach the decode playback for the secondary input */
                config_info.input     = INPUT_SECONDARY;
                config_info.fPlaybackStarted = FALSE;
                iStrmCtrl->pPEConsumer[INPUT_SECONDARY]->Configure(&config_info);

                /* Attach callback to receive events from this PEConsumer */
                iStrmCtrl->pPEConsumer[INPUT_SECONDARY]->AttachEvent(peiStrmConsumerCallback, iStrmCtrl->PEManager);
            }

            /* Attach presentation start callback */
            iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_PRESENTATION_START, DECODE_NOTIFY_ALWAYS);
        }
#endif
        else if ( StreamType == STREAM_TYPE_AUDIO )
        {
            /* TODO-SDK - Configure playback for CDDA streams */


            /* here we only need the MAIN PEConsumer */
            iStrmCtrl->pPEConsumer[INPUT_MAIN] = new cPEConsumer_CDDA;
            if (iStrmCtrl->pPEConsumer[INPUT_MAIN] == NULL)
            {
                status = PE_MEM_ALLOCATION;
            }
            else
            {
                /* Configure the consumer */
                config_info.input       = INPUT_MAIN;
                config_info.fPlaybackStarted = FALSE;
                iStrmCtrl->pPEConsumer[INPUT_MAIN]->Configure(&config_info);

                /* Attach callback to receive events from this PEConsumer */
                iStrmCtrl->pPEConsumer[INPUT_MAIN]->AttachEvent(peiStrmConsumerCallback, iStrmCtrl->PEManager);
            }

            iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_PRESENTATION_START, DECODE_NOTIFY_ALWAYS);
        }
        else if ( (StreamType == STREAM_TYPE_MPEG1_SS) || (StreamType == STREAM_TYPE_MPEG2_PS) )
        {
            /* TODO-SDK - configure playback for SVCD/VCD/CDDA  streams */

            switch (StreamType)
            {
                case STREAM_TYPE_MPEG2_PS:
                    /* TODO-SDK - configure playback for [SVCD] streams */

                case STREAM_TYPE_MPEG1_SS:
                    /* TODO-SDK - Configure data channel for [VCD] streams */
                    break;

                case STREAM_TYPE_AUDIO :
                    /* TODO-SDK - Configure data channel for audio streams */
                    break;

                default:
                    status = PE_NOT_IMPLEMENTED;
            }

            if (status == PE_SUCCESS)
            {
                /* here we only need the MAIN PEConsumer
                 * generic consumer for VCD, CDDA, etc
                 */
                iStrmCtrl->pPEConsumer[INPUT_MAIN] = new cPEConsumer_VCD(StreamType);
                if (iStrmCtrl->pPEConsumer[INPUT_MAIN] == NULL)
                {
                    status = PE_MEM_ALLOCATION;
                }
                else
                {
                    /* Configure the consumer */
                    config_info.input            = INPUT_MAIN;
                    config_info.fPlaybackStarted = FALSE;
                    iStrmCtrl->pPEConsumer[INPUT_MAIN]->Configure(&config_info);

                    /* Attach callback to receive events from this PEConsumer */
                    iStrmCtrl->pPEConsumer[INPUT_MAIN]->AttachEvent(peiStrmConsumerCallback, iStrmCtrl->PEManager);
                }
            }

            iConfigure->primaryDecoder->RequestNotification( DECODE_EVENT_PRESENTATION_START, DECODE_NOTIFY_ALWAYS);
        }
        else
        {
            status = PE_NOT_IMPLEMENTED;
        }
    }

    /* cleanup after a failure */
    if (status != PE_SUCCESS)
    {
        /* 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 channel resources that were created. */
        }
    }

    return (status);
}

/**
 * Private function to execute the PE_SET_GRAPHICS_MODE command.
 *
 * @param iStrmCtrl - istrmctrl handle
 * @param Mode - identifies the graphics mode
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmSetGraphicsMode(ISTREAMCTRLHANDLE *iStrmCtrl, PE_ISTEAMCTRL_GRAPHICS_MODE Mode)
{
    PEHANDLE *pe = (PEHANDLE *)iStrmCtrl->PEManager;

    DbgAssert(iStrmCtrl != NULL);

    /* verify state */
    if (iStrmCtrl->SystemState < PE_ISTREAMCTRL_STATE_REALIZING)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- PE_INVALID_STATE\n"));
        return (PE_INVALID_STATE);
    }

    /* validate input mode */
    if (Mode >= GRAPHICS_MODE_NOT_SET)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- invalid graphics mode!\n"));
        return (PE_INVALID_PARAM);
    }

    /* Only configure graphics if the graphics mode is changing */
    if (Mode == DVD_GRAPHICS_MODE)
    {
        if (iStrmCtrl->GraphicsMode != DVD_GRAPHICS_MODE)
        {
            /* Create the subpicture decoder */
            if (SPUCreate(&iStrmCtrl->m_decoders.spu) != SPU_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to create spu decoder!\n"));
                goto err_out;
            }
        }
    }
#if BDROM_ENABLE
    else
    {
        if (iStrmCtrl->GraphicsMode == GRAPHICS_MODE_NOT_SET)
        {
            /*
             * If going from no graphics to HDMV graphics, configure ig, pg, and textst.
             * If going from no graphics to BDJ graphics, configure just ig.
             */

            if (Mode == HDMV_GRAPHICS_MODE)
            {
                /* configure graphics for ig graphics layer */
                if (peiStrmConfigGraphics(&pe->dfb_ig_graphics_layer, 1920, 1080, &iStrmCtrl->ig_dfb_disp_layer) != PE_SUCCESS)
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to config ig graphics!\n"));
                    goto err_out;
                }

                /* create the IG decoder */
                if (IGCreate(&iStrmCtrl->m_decoders.ig_dec, 1920, 1080, pDfb, iStrmCtrl->ig_dfb_disp_layer) != IG_STATUS_SUCCESS)
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to create ig decoder!\n"));
                    goto err_out;
                }

                /* register for IG events */
                IGAttachEvent(iStrmCtrl->m_decoders.ig_dec, iStrmCtrl->PEManager, peiStrmIGCallback);
            }

            /* configure graphics for pg and textst presentation layer */
            if (peiStrmConfigGraphics(&pe->dfb_pg_graphics_layer, 1920, 1080, &iStrmCtrl->pg_dfb_disp_layer) != PE_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to config pg/textst graphics!\n"));
                goto err_out;
            }

            /* create the PG decoder */
            if (PGCreate(&iStrmCtrl->m_decoders.pg_dec, 1920, 1080, pDfb, iStrmCtrl->pg_dfb_disp_layer) != PG_STATUS_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to create pg decoder!\n"));
                goto err_out;
            }

            /* create the ST decoder */
            if (TextSTCreate(&iStrmCtrl->m_decoders.st_dec, 1920, 1080, pDfb, iStrmCtrl->pg_dfb_disp_layer) != TEXTST_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to create textst decoder!\n"));
                goto err_out;
            }
        }
        else if ( (Mode == HDMV_GRAPHICS_MODE) && (iStrmCtrl->GraphicsMode == BDJ_GRAPHICS_MODE) )
        {
            /* Going from BD-J to HDMV, need to configure IG graphics */
            if (peiStrmConfigGraphics(&pe->dfb_ig_graphics_layer, 1920, 1080, &iStrmCtrl->ig_dfb_disp_layer) != PE_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to config ig graphics!\n"));
                goto err_out;
            }

            /* create the IG decoder */
            if (IGCreate(&iStrmCtrl->m_decoders.ig_dec, 1920, 1080, pDfb, iStrmCtrl->ig_dfb_disp_layer) != IG_STATUS_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmSetGraphicsMode -- failed to create ig decoder!\n"));
                goto err_out;
            }

            /* register for IG events */
            IGAttachEvent(iStrmCtrl->m_decoders.ig_dec, iStrmCtrl->PEManager, peiStrmIGCallback);
        }
        else if ( (Mode == BDJ_GRAPHICS_MODE) && (iStrmCtrl->GraphicsMode == HDMV_GRAPHICS_MODE) )
        {
            /* Going from HDMV to BDJ, need to delete IG graphics */
            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;
            }

            /* reset IG graphics configurations */
            peiStrmResetGraphics(&iStrmCtrl->ig_dfb_disp_layer);
        }
    }
#endif

    /* store graphics mode */
    iStrmCtrl->GraphicsMode = Mode;

    return (PE_SUCCESS);

err_out:

    /* 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 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;
    }

    /* 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 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;
    }
#endif

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

    return (PE_FAILURE);
}

/**
 * Private function to configure graphics for pg, ig, and textst.
 *
 * @param disp_layer - directfb display layer used for graphics
 * @param layer_type - graphics layer type (should be presentation for pg/textst and graphics for ig)
 *
 * @return PE_STATUS.
 */
static PE_STATUS peiStrmConfigGraphics(DfbExtHandle *layer, int screen_width, int screen_height, IDirectFBDisplayLayer **disp_layer)
{
    IDirectFBSurface                *sfc;
    DFBDisplayLayerConfig           LayerConfig;
    DfbExtLayerSettingsType   settings;
    DFBDisplayLayerID               layer_id;
    IDirectFBPalette                *pal = NULL;
    DFBColor                        clr_transp = {0,0,0,0};
    PE_STATUS                       status = PE_SUCCESS;

    if (DfbExtLayerGet(*layer, &settings) != 0)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("peiStrmConfigGraphics: Failed call to DfbExtLayerGet\n"));
        return (PE_FAILURE);
    }

    layer_id = (DFBDisplayLayerID)settings.id;

    /* get the directfb display layer for specified graphics layer */
    if (pDfb->GetDisplayLayer(pDfb, layer_id, disp_layer) != DFB_OK)
    {
        DbgPrint(("Failed to set GetDisplayLayer\n"));
        status = PE_FAILURE;
        goto err_out;
    }

    /* set display layer coop. level */
    if ((*disp_layer)->SetCooperativeLevel((*disp_layer), DLSCL_ADMINISTRATIVE) != DFB_OK)
    {
        DbgPrint(("peiStrmConfigGraphics: Failed to set coop level\n"));

⌨️ 快捷键说明

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