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

📄 bdrom_app.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
 *      none.
 */
void BDROMAppSetCountryCode(UCHAR ucCountryCode)
{
    int iso_country;

    /* Map country code to code defined in ISO 3166 */
    switch (ucCountryCode)
    {
    case 1:
        iso_country = 0x00005553;   /* US */
        break;
    default:
        iso_country = 0xffffffff;
        break;
    }

    /* Set country code */
    if (ModMgrConfigCountryCode(iso_country) != MODMGR_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetCountryCode: failed to set country code\n"));
    }
}

/**
 * BDROMAppSetVideoFormat -- Set the video format
 *
 * @param
 *      ucVideoFormat - video format
 *
 * @retval
 *      none.
 */
void BDROMAppSetVideoFormat(VDVD_VIDEO_FORMAT video_format)
{
    if (ModMgrSetVideoFormat(video_format) != MODMGR_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetVideoFormat: FAILED\n"));
    }
}

/**
 * BDROMAppSetAspectRatio -- Set the aspect ratio
 *
 * @param
 *      ucAspectRatio - aspect ratio
 *
 * @retval
 *      none.
 */
void BDROMAppSetAspectRatio(VDVD_ASPECT_RATIO aspect_ratio)
{
    if (ModMgrSetAspectRatio(aspect_ratio) != MODMGR_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetAspectRatio: FAILED\n"));
    }
}

/**
 * BDROMAppSetDigitalAudioOutput -- Set the digital audio output
 *
 * @param
 *      ucDigOut - digital output
 *
 * @retval
 *      none.
 */
void BDROMAppSetDigitalAudioOutput(UCHAR ucDigOut)
{
    DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppSetDigitalAudioOutput: stubbed\n"));
}

/**
 * BDROMAppGetLocationHandleSize -- Get size of the location handle passed into BDROMAppGetLocation().
 *
 * @param
 *      none
 *
 * @retval
 *      size of location handle
 */
ULONG BDROMAppGetLocationHandleSize(void)
{
    return (ModMgrGetLocationHandleSize());
}

/*
 * This API is used to set the player region code.
 *
 * The players default region is configurable by defining the following variable in
 * the make file or build environment. If not defined the player is hard coded
 * to be Region 1.
 *
 * Environment settings to override the hard coded region:
 *   add -D "BDROM_PSR_REGION_DEFAULT=Y"  - where Y is the desired region for Blu-Ray
 */
void BDROMAppSetPlayerRegionCode(UCHAR ucRegionCode)
{
    PbcRegSetPSR(PLAYCTRL_PSR_REGION, (uint32)ucRegionCode);
}

/**
 * BDROMAppGetLocation -- Get current play location
 *
 * @param
 *      pvLocation -- location handle
 *      ulSize -- size of buffer pointed to by location handle
 *
 * @retval
 *      BDAPP_STATUS
 */
BDAPP_STATUS   BDROMAppGetLocation(PVOID pvLocation, ULONG ulSize)
{
    if (pvLocation == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetLocation: NULL pointer!\n"));
        return (BDAPP_NULL_PTR);
    }

    if (fBDROMAppInit == TRUE)
    {
        MODMGR_STATUS status;

        /* get location from module manager */
        status = ModMgrGetLocation(pvLocation, ulSize);
        if (status == MODMGR_UOP_PROHIBITED)
        {
            return (BDAPP_PROHIBITED);
        }
        else if (status != MODMGR_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetLocation: failed to get location!\n"));
            return (BDAPP_FAILURE);
        }
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetLocation: BD-ROM App not initialized!\n"));
    }

    return (BDAPP_SUCCESS);
}

/**
 * BDROMAppGetPlayRate -- Get play rate of the nav
 *
 * @param
 *      none
 *
 * @retval
 *      play rate
 */
int32 BDROMAppGetPlayRate(void)
{
    if (fBDROMAppInit == FALSE)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetPlayRate: BDROM App not initialized!\n"));
        return (0);
    }

    return (MogMgrGetPlayRate());
}

/**
 * BDROMAppGetPlayState -- Get play state of the nav
 *
 * @param
 *      none
 *
 * @retval
 *      play state
 */
USHORT BDROMAppGetPlayState(void)
{
    MODMGR_PLAYSTATE    tPlayState;
    USHORT              usNavState = VDVD_STATUS_UNKNOWN;

    if (fBDROMAppInit == TRUE)
    {
        /* Get BD-ROM navigator play state from module manager */
        tPlayState = MogMgrGetPlayState();

        switch (tPlayState)
        {
        case MODMGR_PLAYSTATE_STOP:
            usNavState = VDVD_STATUS_STOP;
            break;
        case MODMGR_PLAYSTATE_FULLSTOP:
            usNavState = VDVD_STATUS_FULLSTOP;
            break;
        case MODMGR_PLAYSTATE_PLAY:
            usNavState = VDVD_STATUS_PLAY;
            break;
        case MODMGR_PLAYSTATE_PAUSE:
            usNavState = VDVD_STATUS_PAUSE;
            break;
        case MODMGR_PLAYSTATE_STILL:
            usNavState = VDVD_STATUS_STILL;
            break;
        case MODMGR_PLAYSTATE_FAST_F:
            usNavState = VDVD_STATUS_FAST_F;
            break;
        case MODMGR_PLAYSTATE_FAST_R:
            usNavState = VDVD_STATUS_FAST_B;
            break;
        case MODMGR_PLAYSTATE_SLOW_F:
            usNavState = VDVD_STATUS_SLOW_F;
            break;
        case MODMGR_PLAYSTATE_SLOW_R:
            usNavState = VDVD_STATUS_SLOW_B;
            break;
        default:
            break;
        }
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetPlayState: BD-ROM App not initialized!\n"));
    }

    return (usNavState);
}

/**
 * BDROMAppGetNumberOfTitles -- Get number of titles on the disc
 *
 * @param
 *      none
 *
 * @retval
 *      Number of titles
 */
USHORT BDROMAppGetNumberOfTitles(void)
{
    USHORT *numTitles;
    numTitles = IndexGetNumberOfTitles();
    return *numTitles;
}

/**
 * BDROMAppGetNumberOfChapters -- Get number of chapters on the current title
 *
 * @param
 *      none
 *
 * @retval
 *      Number of chapters
 */
USHORT BDROMAppGetNumberOfChapters(void)
{
    USHORT usNumChapters = 0;

    if (fBDROMAppInit == TRUE)
    {
        /* Get current title from module manager */
        usNumChapters = ModMgrGetNumberOfChapters();
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetNumberOfChapters: BD-ROM App not initialized!\n"));
    }

    return (usNumChapters);
}

/**
 * BDROMAppGetCurrentTitle -- Get the current title number
 *
 * @param
 *      none
 *
 * @retval
 *      Current title number
 */
USHORT BDROMAppGetCurrentTitle(void)
{
    USHORT usTitle = 0;

    if (fBDROMAppInit == TRUE)
    {
        /* Get current title from module manager */
        usTitle = (USHORT)ModMgrGetTitle();
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetCurrentTitle: BD-ROM App not initialized!\n"));
    }

    return (usTitle);
}

/**
 * BDROMAppGetTitleInfo -- Get the current title information
 *
 * @param
 *      none
 *
 * @retval
 *      VDVD_TITLE_INFO bit-mask
 */
ULONG BDROMAppGetTitleInfo(void)
{
    ULONG ulTitleInfo = VDVD_TITLE_UNKNOWN;

    if (fBDROMAppInit == TRUE)
    {
        /* Get current title info from module manager */
        ulTitleInfo = ModMgrGetTitleInfo();
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetTitleInfo: BD-ROM App not initialized!\n"));
    }

    return (ulTitleInfo);
}

/**
 * BDROMAppGetCurrentChapter -- Get current chapter number
 *
 * @param
 *      none
 *
 * @retval
 *      Current chapter number
 */
USHORT BDROMAppGetCurrentChapter(void)
{
    USHORT usChapter = 0;

    if (fBDROMAppInit == TRUE)
    {
        /* Get current chapter from module manager */
        usChapter = (USHORT)ModMgrGetChapter();
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetCurrentChapter: BD-ROM App not initialized!\n"));
    }

    return (usChapter);
}

/**
 * BDROMAppGetPlayTime -- Get current play time
 *
 * @param
 *      bTimeMode - time mode (0 = Chapter, 1 = Chapter remain, 2 = Title, 3 = Title Remain)
 *
 * @retval
 *      Play time in seconds
 */
ULONG  BDROMAppGetPlayTime(BYTE bTimeMode)
{
    PLAYLISTMARK_TABLE *pPLMark     = NULL;
    USHORT             usMarkID     = 0;
    USHORT             usCount      = 0;
    USHORT             usChapter;
    ULONG              ulPlayitemID;
    ULONG              secOutTime;

    if (fBDROMAppInit == FALSE)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("BDROMAppGetPlayTime: BDROM App not initialized!\n"));
        return (0);
    }

    switch (bTimeMode)
    {
    /* Chapter Time */
    case 0:
        /* get current playitem and chapter index */
        ulPlayitemID = ModMgrGetPlayItem();
        usChapter    = (USHORT)(ModMgrGetChapter());

        /* Get current playlist mark info */
        if (MPLSGetPlayMark(&pPLMark) == MPLS_SUCCESS)
        {
            /*
             * Map entry mark (chapter) to a mark id.
             */
            for (USHORT i = 0; i < pPLMark->number_of_PlayList_marks; i++)
            {
                /*
                 * If this mark is an entry-mark, then increase count.
                 */
                if (pPLMark->PL_mark[i].mark_type == ENTRY_MARK)
                {
                    usCount++;
                }

                /*
                 * If this mark is the entry mark we are looking for, then we're done.
                 */
                if (usCount == usChapter)
                {
                    usMarkID = i;
                    break;
                }
            }

            if (pPLMark->PL_mark[usMarkID].ref_to_PlayItem_id == ulPlayitemID)
            {
                /* subtract time of the current chapter (pts) from the current time (pts) */
                secOutTime = (ModMgrGetRawPTS() - pPLMark->PL_mark[usMarkID].mark_time_stamp);
            }
            else
            {
                PLAYITEM *pLastPlayItem  = NULL;
                PLAYITEM *pPlayItem      = NULL;

                /* Get current playitem */
                if (MPLSGetPlayItem( (uint16)(ulPlayitemID), &pPlayItem) == MPLS_SUCCESS)
                {
                    /* Get the previous playitem */
                    if (MPLSGetPlayItem( (uint16)(ulPlayitemID-1), &pLastPlayItem) == MPLS_SUCCESS)
                    {
                        /* (current time - this playitem's in_time) + (this playitem's out_time - the chapter time) */
                        secOutTime = ( (ModMgrGetRawPTS() - pPlayItem->IN_time) +
                            (pLastPlayItem->OUT_time - pPLMark->PL_mark[usMarkID].mark_time_stamp));
                    }
                    else
                    {
                        secOutTime = 0;
                    }
                }
                else
                {
                    secOutTime = 0;
                }
            }
        }
        else
        {
            secOutTime = 0;
        }
        break;

    /* Chapter Time Remaining */
    case 1:
        /* get current playitem and chapter index */
        ulPlayitemID = ModMgrGetPlayItem();
        usChapter    = (USHORT)(ModMgrGetChapter());

        if (usChapter >= BDROMAppGetNumberOfChapters() )
        {
            /* if it's the last chapter, the chapter remaining time is the same as the title time remaining */
            secOutTime = ModMgrGetTitleDuration() - ModMgrGetPlayTime();
        }
        else
        {
            /* Get current playlist mark info */
            if (MPLSGetPlayMark(&pPLMark) == MPLS_SUCCESS)
            {
                /*
                 * Map entry mark (for next chapter) to a mark id.
                 */
                for (USHORT i = 0; i < pPLMark->number_of_PlayList_marks; i++)
                {
                    /*
                     * If this mark is an entry-mark, then increase count.
                     */
                    if (pPLMark->PL_mark[i].mark_type == ENTRY_MARK)
                    {
                        usCount++;
                    }

                    /*
                     * If this mark is the entry mark we are looking for, then we're done.
                     */
                    if (usCount == (usChapter + 1) )
                    {
                        usMarkID = i;
                        break;
                    }
                }

                if (pPLMark->PL_mark[usMarkID].ref_to_PlayItem_id == ulPlayitemID)
                {
                    /* subtract time of the next chapter (pts) from the current time (pts) */
                    secOutTime = (pPLMark->PL_mark[usMarkID].mark_time_stamp - ModMgrGetRawPTS());
                }
                else
                {
                    PLAYITEM *pNextPlayItem  = NULL;
                    PLAYITEM *pPlayItem      = NULL;

                    /* Get current playitem */
                    if (MPLSGetPlayItem( (uint16)(ulPlayitemID), &pPlayItem) == MPLS_SUCCESS)
                    {
                        if (MPLSGetPlayItem( (uint16)(ulPlayitemID+1), &pNextPlayItem) == MPLS_SUCCESS)
                        {
                            /* (next chapter time - next playitem's in_time) + (this playitem's out_time - current time) */
                            secOutTime = ( (pPLMark->PL_mark[usMarkID].mark_time_stamp - pNextPlayItem->IN_time) +
                                (pPlayItem->OUT_time - ModMgrGetRawPTS()));
                        }
                        else
                        {
                            secOutTime = 0;
                        }
                    }
                    else
                    {
                        secOutTime = 0;
                    }
                }
            }
            else
            {
                secOutTime = 0;
            }
        }
        break;

    /* Title Time */
    case 2:
        /* get the current title time from module manager */
        secOutTime = ModMgrGetPlayTime();
        break;

    /* Title Time Remaining */
    case 3:
        /* subtract the title time from the total title time (in seconds) */
        secOutTime = ModMgrGetTitleDuration() - ModMgrGetPlayTime();
        break;

    default:
        /* invalid case */
        secOutTime = 0;
        break;
    }

⌨️ 快捷键说明

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