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

📄 pbc_pbscenario.cpp

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

    /*
     * If a next entry mark exists, then start playback at the next mark.
     * Otherwise, ignore this operation.
     */
    if (fMarkFound == TRUE)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipNext: Mark Found!\n"));

        /* Get the playitem info for target playitem */
        if (MPLSGetPlayItem(pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id, &pPlayitem) != MPLS_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipNext: Failed to get playitem info\n"));
            return (PLAYCTRL_FAILURE);
        }

        /*
         * If the playitem's random access flag is set, then cannot allow access into
         * the playitem and must start from the beginning of the playitem.
         */
        if ( (pPlayitem->PlayItem_random_access_flag == 1) )
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipNext: Playitem Random Access flag is set, so playing from beginning of playitem!\n"));

            /*
             * Link to the beginning of the playitem
             */
            if (pbcpbscenarioLink(hPBC, pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id,
                                  pPlayitem->IN_time, ubRandomShuffleIndex) != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipNext: pbcpbscenarioLink() FAILED!\n"));
                return (PLAYCTRL_FAILURE);
            }
        }
        else
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipNext: NOT! Playitem Random Access flag!\n"));

            /*
             * Link to the specified time in the playitem that
             * the mark is located in.
             */
            if (pbcpbscenarioLink(hPBC, pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id,
                                  pPLMark->PL_mark[uiPlaymarkID].mark_time_stamp, ubRandomShuffleIndex) != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipNext: pbcpbscenarioLink() FAILED!\n"));
                return (PLAYCTRL_FAILURE);
            }
        }

        /* return the new mark number */
        if (pOutMarkNumber != NULL)
        {
            *pOutMarkNumber = uiTargetMarkID;
        }

        return (PLAYCTRL_SUCCESS);
    }

    /* Next mark does not exist */
    return (PLAYCTRL_FAILURE);
}

/**
 * PbcPbScenarioSkipPrev -- Start playback at previous skip point in the playlist.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      data1 -- not used
 *      data2 -- not used
 *      data3 -- not used
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcPbScenarioSkipPrev(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
    APPINFOPLAYLIST_TABLE   *pAppInfoPlayList       = NULL;
    PLAYLISTMARK_TABLE      *pPLMark                = NULL;
    BOOLEAN                 fMarkFound              = FALSE;
    USHORT                  usCount                 = 0;
    PLAYITEM                *pPlayitem              = NULL;
    UBYTE                   ubRandomShuffleIndex    = 0xff;
    TIME45k                 time45k_CurrPTS;
    uint32                  uiPlayitemID;
    uint16                  uiTargetMarkID          = 1;
    uint16                  uiCurMarkID;
    uint16                  uiPlaymarkID            = 0;
    uint32                  *pOutMarkNumber         = (uint32 *)data1;
    uint8                   uiMarkType              = (uint8)data2;
    uint16                  i;

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipPrev: ENTER\n"));

    /* check for valid handle */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipPrev: NULL handle!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    /* If playlist playback is not active this operation is not allowed */
    if (hPBC->tState == PLAYCTRL_STATE_STOP)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipPrev: not playing!\n"));
        return (PLAYCTRL_FAILURE);
    }

    OS_SemTake(hPBC->semRegisterMutex, OS_WAIT_FOREVER);

    /* Get the playitem and presentation time player registers */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemID);
    PbcRegGetPSR(PLAYCTRL_PSR_PRES_TIME, &time45k_CurrPTS);
    uiPlayitemID &= 0x0000ffff;

    OS_SemGive(hPBC->semRegisterMutex);

    /* get the playlist info */
    MPLSGetAppInfo(&pAppInfoPlayList);

    /* Get playlist mark from database */
    MPLSGetPlayMark(&pPLMark);

    /* calculate current entry mark */
    uiCurMarkID = (uint16)(PbcPLCtrlCalculatePLMark(pPLMark, (uint16)(uiPlayitemID), time45k_CurrPTS, uiMarkType));

    if ( (pAppInfoPlayList->PlayList_playback_type == MPLS_SEQUENTIAL_PLAYLIST) && (uiCurMarkID == 0) )
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipPrev: no previous mark!\n"));
        return (PLAYCTRL_FAILURE);
    }

    if (uiCurMarkID != 0)
    {
        /* Set target entry mark */
        uiTargetMarkID = uiCurMarkID - 1;

        /*
         * Look for appropriate mark.
         */
        for (i = 0; i < pPLMark->number_of_PlayList_marks; i++)
        {
            /*
             * If this mark has mark type we want, then increase count.
             */
            if (pPLMark->PL_mark[i].mark_type & uiMarkType)
            {
                usCount++;
            }

            /*
             * If this mark is the mark we are looking for, then
             * keep track of the mark ID, and finish search.
             */
            if (usCount == (uiTargetMarkID + 1)) // marks start from 0
            {
                fMarkFound = TRUE;
                uiPlaymarkID = i;
                break;
            }
        }
    }

    /*
     * If current playlist is random/shuffle, then we need to make sure that the playmark
     * found is in the current playitem.  If it is not in the current playitem, then we need
     * to transition to the previous playitem from the random/shuffle list.
     */
    if ( (pAppInfoPlayList->PlayList_playback_type == MPLS_RANDOM_PLAYLIST) ||
         (pAppInfoPlayList->PlayList_playback_type == MPLS_SHUFFLE_PLAYLIST) )
    {
        uint16 uiPrevPI;

        /* Get the previous playitem in random/shuffle list */
        uiPrevPI = PbcPLCtrlGetPrevPlayitem(hPBC, uiPlayitemID);

        /* get random/shuffle index for current playitem */
        ubRandomShuffleIndex = PbcPLCtrlGetRandomShuffleIndex(hPBC);

        if ( ( (uiPlayitemID != pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id) || (uiCurMarkID == 0) ) &&
             (ubRandomShuffleIndex > 0) )
        {
            /*
             * Playmark is not in current playitem or we're on the first mark, and
             * there is a previous playitem, so we need to transition to previous playitem.
             */

            /* Reset flag */
            fMarkFound = FALSE;

            /* Decrement random shuffle index */
            ubRandomShuffleIndex--;

            /*
             * Look for last mark in previous playitem.
             */
            for (i = pPLMark->number_of_PlayList_marks; i > 0; )
            {
                /* decrement first so that we can use the count to index our arrays */
                i--;

                /* If this is mark has mark type we want and it is in the desired playitem, we're done. */
                if ( (pPLMark->PL_mark[i].mark_type & uiMarkType) && (pPLMark->PL_mark[i].ref_to_PlayItem_id == uiPrevPI) )
                {
                    /* Mark found, set mark id */
                    fMarkFound = TRUE;
                    uiPlaymarkID = i;
                    break;
                }
            }
        }
        else if ( (uiPlayitemID != pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id) && (ubRandomShuffleIndex == 0) )
        {
            /*
             * Playmark is not in current playitem and we're on the first playitem of the random/shuffle
             * playlist, so we need to ignore this operation.
             */

            /* Reset flag */
            fMarkFound = FALSE;
        }
    }

    /*
     * If a previous entry mark exists, then start playback at the mark.
     * Otherwise, ignore this operation.
     */
    if (fMarkFound == TRUE)
    {
        /* Get the playitem info for target playitem */
        if (MPLSGetPlayItem(pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id, &pPlayitem) != MPLS_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipPrev: Failed to get playitem info\n"));
            return (PLAYCTRL_FAILURE);
        }

        /*
         * If the playitem's random access flag is set, then cannot allow access into
         * the playitem and must start from the beginning of the playitem.
         */
        if ( (pPlayitem->PlayItem_random_access_flag == 1) )
        {
            DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioSkipPrev: Playitem Random Access flag is set, so playing from beginning of playitem!\n"));

            /*
             * Link to the beginning of the playitem
             */
            if (pbcpbscenarioLink(hPBC, pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id,
                                  pPlayitem->IN_time, ubRandomShuffleIndex) != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipPrev: pbcpbscenarioLink() FAILED!\n"));
                return (PLAYCTRL_FAILURE);
            }
        }
        else
        {
            /*
             * Link to the specified time in the playitem that
             * the mark is located in.
             */
            if (pbcpbscenarioLink(hPBC, pPLMark->PL_mark[uiPlaymarkID].ref_to_PlayItem_id,
                                  pPLMark->PL_mark[uiPlaymarkID].mark_time_stamp, ubRandomShuffleIndex) != PLAYCTRL_SUCCESS)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioSkipPrev: pbcpbscenarioLink() FAILED!\n"));
                return (PLAYCTRL_FAILURE);
            }
        }

        /* return the new chapter number */
        if (pOutMarkNumber != NULL)
        {
            *pOutMarkNumber = uiTargetMarkID;
        }

        return (PLAYCTRL_SUCCESS);
    }

    /* Next mark does not exist */
    return (PLAYCTRL_FAILURE);
}

/**
 * PbcPbScenarioRestartPoint -- Start playback at mark_time_stamp of the current Entry Point.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      data1 -- pointer to chapter number
 *      data2 -- not used
 *      data3 -- not used
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcPbScenarioRestartPoint(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
    APPINFOPLAYLIST_TABLE   *pAppInfoPlayList       = NULL;
    PLAYLISTMARK_TABLE      *pPLMark                = NULL;
    BOOLEAN                 fMarkFound              = FALSE;
    USHORT                  usCount                 = 0;
    PLAYITEM                *pPlayitem              = NULL;
    UBYTE                   ubRandomShuffleIndex    = 0xff;
    TIME45k                 time45k_CurrPTS;
    uint32                  uiPlayitemID;
    uint16                  uiCurMarkID;
    uint16                  uiPlaymarkID            = 0;
    uint32                  *pOutMarkNumber         = (uint32 *)data1;
    uint8                   uiMarkType              = (uint8)data2;
    uint16                  i;

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioRestartPoint: ENTER\n"));

    /* check for valid handle */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioRestartPoint: NULL handle!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    /* If playlist playback is not active this operation is not allowed */
    if (hPBC->tState == PLAYCTRL_STATE_STOP)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioRestartPoint: not playing!\n"));
        return (PLAYCTRL_FAILURE);
    }

    OS_SemTake(hPBC->semRegisterMutex, OS_WAIT_FOREVER);

    /* Get the playitem and presentation time player registers */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemID);
    PbcRegGetPSR(PLAYCTRL_PSR_PRES_TIME, &time45k_CurrPTS);
    uiPlayitemID &= 0x0000ffff;

    OS_SemGive(hPBC->semRegisterMutex);

    /* get the playlist info */
    MPLSGetAppInfo(&pAppInfoPlayList);

    /* Get playlist mark from database */
    MPLSGetPlayMark(&pPLMark);

    /* calculate current mark */
    uiCurMarkID = (uint16)(PbcPLCtrlCalculatePLMark(pPLMark, (uint16)(uiPlayitemID), time45k_CurrPTS, uiMarkType));

    /*
     * Look for appropriate mark.
     */
    for (i = 0; i < pPLMark->number_of_PlayList_marks; i++)
    {
        /*
         * I

⌨️ 快捷键说明

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