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

📄 playctrl.cpp

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

/**
 * PlayCtrlGetNumberOfPlayItemsInPL -- Get the number playitems in the specified playlist.
 *
 * @param
 *      uiPlaylist -- playlist number
 *
 * @retval
 *      The number playitems in the specified playlist.
 */
uint16  PlayCtrlGetNumberOfPlayItemsInPL(uint32 uiPlaylist)
{
    uint16 uiNumPlayItems;

    if (hPBC == NULL)
    {
        DbgPrint(("PlayCtrlGetNumberOfPlayItemsInPL: playback control engine not created!\n"));
        return (0);
    }

    /* Get number of playitems in specified playlist */
    if (MPLSGetNumberOfPlayItemsInPL(uiPlaylist, &uiNumPlayItems) != MPLS_SUCCESS)
    {
        DbgPrint(("PlayCtrlGetNumberOfPlayItemsInPL: Failed to get number of playitems!\n"));
        uiNumPlayItems = 0;
    }

    return (uiNumPlayItems);
}

/**
 * PlayCtrlGetNumberOfMarks -- Get the number of marks in current playlist.
 *
 * @param
 *      mark_type - type of marks to count
 *
 * @retval
 *      if (mark_type == 0x01) return (number entry marks)
 *      if (mark_type == 0x02) return (number link points)
 *      if (mark_type == 0x03) return (all marks)
 */
uint16 PlayCtrlGetNumberOfMarks(uint8 mark_type)
{
    PLAYLISTMARK_TABLE  *pPlayListMark  = NULL;
    uint16              num_marks       = 0;

    DbgAssert(mark_type != 0);
    DbgAssert(mark_type <  4);

    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfMarks: playback control engine not created!\n"));
        return (0);
    }

    /* Get current playlist mark info */
    if (MPLSGetPlayMark(&pPlayListMark) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfMarks: failed to get playlist mark info!\n"));
        return (0);
    }

    /* Count the number of chapters */
    for (int i = 0; i < pPlayListMark->number_of_PlayList_marks; i++)
    {
        /*
         * If this mark is an entry-mark, then increase chapter count.
         */
        if (pPlayListMark->PL_mark[i].mark_type & mark_type)
        {
            num_marks++;
        }
    }

    return (num_marks);
}

/**
 * PlayCtrlGetCurrentMark -- Get the current mark in current playlist.
 *
 * @param
 *      mark_type - type of marks to count
 *
 * @retval
 *      if (mark_type == 0x01) return (current entry mark)
 *      if (mark_type == 0x02) return (current link point)
 *      if (mark_type == 0x03) return (current mark including both entry-marks and link-points)
 */
uint16 PlayCtrlGetCurrentMark(uint8 mark_type)
{
    PLAYLISTMARK_TABLE  *pPlayListMark  = NULL;
    uint16              uiCurrentMark   = 0;
    uint32              uiPlayitemID;
    TIME45k             time45k_CurrPTS;

    DbgAssert(mark_type != 0);
    DbgAssert(mark_type <  4);

    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentMark: playback control engine not created!\n"));
        return (0);
    }

    /* Get current playlist mark info */
    if (MPLSGetPlayMark(&pPlayListMark) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentMark: failed to get playlist mark info!\n"));
        return (0);
    }

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

    /* get playmark table */
    MPLSGetPlayMark(&pPlayListMark);
    DbgAssert(pPlayListMark != NULL);

    /* calculate plmark based on current playitem and pts */
    uiCurrentMark = (uint16)(PbcPLCtrlCalculatePLMark(pPlayListMark, (uint16)(uiPlayitemID), time45k_CurrPTS, mark_type));

    return (uiCurrentMark);
}

/**
 * PlayCtrlGetNumberOfAngles -- Get the number of available angles.
 *
 * @param
 *      none
 *
 * @retval
 *      Number of available angles
 */
uint32 PlayCtrlGetNumberOfAngles(void)
{
    PLAYITEM    *pPlayitem = NULL;
    uint32      uiPlayitemId;
    int         angles;

    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfAngles: playback control engine not created!\n"));
        return (0);
    }

    /* Get current playitem register value */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);

    /* Pull out playitem id from register value */
    uiPlayitemId &= 0x0000ffff;

    /* Get current playitem info */
    if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfAngles: failed to get playitem info!\n"));
        return (0);
    }

    /* If playitem is multi angle, set number of angles.  O.w. only one angle */
    if (pPlayitem->is_multi_angle == 0)
    {
        angles = 1;
    }
    else
    {
        angles = (int)pPlayitem->number_of_angles;
    }

    return (angles);
}

/**
 * PlayCtrlGetNumberOfAudio -- Get the number of available audio streams.
 *
 * @param
 *      none
 *
 * @retval
 *      Number of available audio streams
 */
uint32 PlayCtrlGetNumberOfAudio(void)
{
    PLAYITEM    *pPlayitem = NULL;
    uint32      uiPlayitemId;

    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfAudio: playback control engine not created!\n"));
        return (0);
    }

    /* Get current playitem register value */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);

    /* Pull out playitem id from register value */
    uiPlayitemId &= 0x0000ffff;

    /* Get current playitem info */
    if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfAudio: failed to get playitem info!\n"));
        return (0);
    }

    return (pPlayitem->STN_table.number_of_primary_audio_stream_entries);
}

/**
 * PlayCtrlGetNumberOfPGTextST -- Get the number of available PG/ST streams.
 *
 * @param
 *      none
 *
 * @retval
 *      Number of available PG/ST streams
 */
uint32 PlayCtrlGetNumberOfPGTextST(void)
{
    PLAYITEM    *pPlayitem = NULL;
    uint32      uiPlayitemId;

    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfPGTextST: playback control engine not created!\n"));
        return (0);
    }

    /* Get current playitem register value */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);

    /* Pull out playitem id from register value */
    uiPlayitemId &= 0x0000ffff;

    /* Get current playitem info */
    if (MPLSGetPlayItem( (uint16)(uiPlayitemId), &pPlayitem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetNumberOfPGTextST: failed to get playitem info!\n"));
        return (0);
    }

    return (pPlayitem->STN_table.number_of_PG_textST_stream_entries);
}

/**
 * PlayCtrlGetNumberOfPGTextST -- Get the number of available text subtitle user styles.
 *
 * @param
 *      none
 *
 * @retval
 *      Number of available user styles
 */
uint16 PlayCtrlGetNumberOfTextSubtitleStyles(void)
{
    ULONG user_styles;

    if (hPBC == NULL)
    {
        DbgPrint(("PlayCtrlGetNumberOfTextSubtitleStyles: playback control engine not created!\n"));
        return ( (uint16) PLAYCTRL_FAILURE);
    }

    /* make sure the subtitle info has finished loading */
    while (hPBC->fWaitingPrefill[INPUT_BDROM_SUBPATH_TEXT_SUBTITLE] == TRUE)
    {
        OS_TaskDelayMsec(100);
    }

    /*
     * Process the command in the pbc engine task.
     * This MUST be a synchronous operation.
     */
    if (PbcEngineProcessCmd(hPBC, PLAYCTRL_GETNUMTEXTSUBTITLESTYLES, (ULONG)&user_styles, 0, 0, TRUE) != PLAYCTRL_SUCCESS)
    {
        return (0);
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("PlayCtrlGetNumberOfTextSubtitleStyles: NumStyles = %d\n", user_styles));

    return ( (uint16)(user_styles) );
}

/**
 * PlayCtrlIsPlaylistAcessRestricted -- Return current playlist access restriction.
 *
 * @param
 *      none
 *
 * @retval
 *      TRUE - current playlist is access restricted
 *      FALSE - current playlist is not access restricted
 */
BOOLEAN PlayCtrlIsPlaylistAcessRestricted(void)
{
    APPINFOPLAYLIST_TABLE *pAppInfoPL = NULL;

    /* check that pbc engine has been created */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlIsPlaylistAcessRestricted: playback control engine not created!\n"));
        return (FALSE);
    }

    /* check that pbc engine is running */
    if (hPBC->tState == PLAYCTRL_STATE_STOP)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlIsPlaylistAcessRestricted: playback control engine is stopped!\n"));
        return (FALSE);
    }

    /* Get playlist info */
    if (MPLSGetAppInfo(&pAppInfoPL) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlIsPlaylistAcessRestricted: failed to get playlist info!\n"));
        return (FALSE);
    }

    return (pAppInfoPL->PlayList_random_access_flag == 1);
}

/**
 * PlayCtrlGetCurrentApplicationType -- Get application type of current playlist
 *
 * @param
 *      none
 *
 * @retval
 *      Application type
 */
uint8 PlayCtrlGetCurrentApplicationType(void)
{
    uint8       app_type        = 0;
    uint32      uiPlayitemId    = 0;
    PLAYITEM    *pPlayitem      = NULL;

    /* check that pbc engine has been created */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentApplicationType: playback control engine not created!\n"));
        return (0);
    }

    /* check that pbc engine is running */
    if (hPBC->tState == PLAYCTRL_STATE_STOP)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentApplicationType: playback control engine is stopped!\n"));
        return (0);
    }

    /* Get current playitem register value */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayitemId);

    /* Pull out playitem id from register value */
    uiPlayitemId &= 0x0000ffff;

    /* Get current playitem info */
    if (MPLSGetPlayItem((uint16)(uiPlayitemId), &pPlayitem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentApplicationType: Failed to get playitem!\n"));
    }
    else
    {
        /* take clip info mutex */
        OS_SemTake(hPBC->semClipInfo, OS_WAIT_FOREVER);

        /*
         * First load the clip information for the current playitem's default clip from the
         * preloaded clipinfo database.
         */
        if (hPBC->hClipInfo->ClpInfoLoad(GET_INT_FROM_ASCII5(pPlayitem->Clip_Information_file_name) ) != CLPINFO_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlGetCurrentApplicationType: Failed to load clip info!\n"));
        }
        else
        {
            /* Now, get the application type for the clip */
            app_type = hPBC->hClipInfo->ClpInfoGet_ubAppType();
        }

        /* give clip info mutex */
        OS_SemGive(hPBC->semClipInfo);
    }

    return (app_type);
}

/**
 * PlayCtrlIsPlayitemAcessRestricted -- Return playitem access restriction.
 *
 * @param
 *      uiPlayitem -- playitem to check access restriction for
 *
 * @retval
 *      TRUE - specified playitem is access restricted
 *      FALSE - specified playitem is not access restricted
 */
BOOLEAN PlayCtrlIsPlayitemAcessRestricted(uint16 uiPlayitem)
{
    PLAYITEM *pPlayitem  = NULL;

    /* check that pbc engine has been created */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlIsPlayitemAcessRestricted: playback control engine not created!\n"));
        return (FALSE);
    }

    /* Get playitem info */
    if (MPLSGetPlayItem(uiPlayitem, &pPlayitem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PlayCtrlIsPlayitemAcessRestricted: failed to get playitem info!\n"));
        return (FALSE);
    }

    return (pPlayitem->PlayItem_random_access_flag == 1);
}

/**
 * PlayCtrlGetMarkInfo -- Return the PLAYLISTMARK info for the specified playmark.
 *
 * @param
 *      usStreamNum - video stream number
 *      pAttributes - pointer to stream attributes struct that will receive the info
 *
 * @retval
 *      audio language code
 */
PLAYCTRL_STATUS PlayCtrlGetMarkInfo(uint16 uiMarkNum, uint8 mark_type, PLAYLISTMARK *pMark)
{
    PLAYLISTMARK_TABLE *pPlayListMark = NULL;
    uint16             uiNumMarks     = 0;

    DbgAssert(mark_type != 0);
    DbgAssert(mark_type <  4);

    if (hPBC == NULL)
    {
        DbgPrint(("PlayCtrlGetMarkInfo: playback control engine not created!\n"));
        return (PLAYCTRL_FAILURE);
    }
    if (pMark == NULL)
    {
        DbgPrint(("PlayCtrlGetMarkInfo: NULL POINTER!\n"));
        return (PLAYCTRL_FAILURE);
    }

    /* Get current playlist mark info */
    if (MPLSGetPlayMark(&pPlayListMark) != MPLS_SUCCESS)
    {
        DbgPrint(("PlayCtrlGetMarkInfo: failed to get playlist mark info!\n"));
        return (PLAYCTRL_FAILURE);
    }

    /* scan for the requested mark */
    for (uint16 count=0; count < pPlayListMark->number_of_PlayList_marks; count++)
    {
        if (pPlayListMark->PL_mark[count].mark_type & mark_type)
        {
            /* check for a match */
            if (uiNumMarks == uiMarkNum)
            {
                /* copy the mark info to the output buffer */
                memcpy( pMark, &pPlayListMark->PL_mark[count], sizeof(PLAYLISTMARK) );
                return (PLAYCTRL_SUCCESS);
            }
            uiNumMarks++;

⌨️ 快捷键说明

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