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

📄 mvplaylistdb.cpp

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

    /* close the movie play list file */
    LoaderFileClose(pMPLS_DB->hLoader, mpls_file);

    /* close the backup */
    if (mpls_backup != 0)
    {
        LoaderFileClose(pMPLS_DB->hLoader, mpls_backup);
    }

    /* take mutex while we load the movie playlist file */
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);

errout_2:
    /* close the movie play list file */
    LoaderFileClose(pMPLS_DB->hLoader, mpls_file);

    /* close the backup */
    if (mpls_backup != 0)
    {
        LoaderFileClose(pMPLS_DB->hLoader, mpls_backup);
    }

errout_1:

    /* take mutex while we load the movie playlist file */
    OS_SemGive(pMPLS_DB->semMutex);

    return (tStatus);
}

/**
 * MPLSGetVersion -- Get the bd spec revision for this playlist.
 *
 * @param
 *      pVersion -- receives the version number
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetVersion(uint32 *pVersion)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetVersion: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (pVersion == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetVersion: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

    /* return the version number */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);
    *pVersion = GET_INT_FROM_ASCII4(pMPLS_DB->tMovPlayListData.version_number);
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetAppInfo -- Get a pointer to the AppInfoPlaylist for the current movie playlist.
 *
 * @param
 *      pAppInfoPlayList -- pointer that gets the AppInfoPlayList
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetAppInfo(APPINFOPLAYLIST_TABLE **ppAppInfoPlayList)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetAppInfo: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (ppAppInfoPlayList == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetAppInfo: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

    /* return a pointer to the AppInfoPlaylist */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);
    *ppAppInfoPlayList = &(pMPLS_DB->tMovPlayListData.AppInfoPlayList);
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetPlayMark -- Get the PlayListMark of the current playlist.
 *
 * @param
 *      pPlayListMark -- pointer that gets the PlayListMark
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetPlayMark(PLAYLISTMARK_TABLE **ppPlayListMark)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetPlayMark: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (ppPlayListMark == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetPlayMark: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

    /* return a pointer to the PlayListMark */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);
    *ppPlayListMark = &(pMPLS_DB->tMovPlayListData.PlayListMark);
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetNumberOfPlayItems -- Get the number of PlayItems in the Playlist.
 *
 * @param
 *      pNumSubPath -- pointer that gets set to the count
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetNumberOfPlayItems(uint16 *pNumPlayItem)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItems: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (pNumPlayItem == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItems: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

    /* return number of playitems */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);
    *pNumPlayItem = pMPLS_DB->tMovPlayListData.PlayList.number_of_PlayItems;
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetNumberOfPlayItemsInPL -- Get the number of PlayItems in the given Playlist.
 *
 * @param
 *      mpls_number -- playlist number
 *      pNumSubPath -- pointer that gets set to the count
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetNumberOfPlayItemsInPL(uint32 mpls_number, uint16 *pNumPlayItem)
{
    LOADER_FILE_HANDLE  mpls_file   = 0;
    LOADER_FILE_HANDLE  mpls_backup = 0;
    UBYTE               pTmpBuf[12];
    MPLS_STATUS         tStatus     = MPLS_SUCCESS;
    char                filename[64];
    ULONG               ulPlaylistStartAddr;

    if (pNumPlayItem == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

    /* take mutex */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);

    /* Open the movie playlist */
    snprintf(filename, 64, "/mnt/cdrom/BDMV/PLAYLIST/%.5lu.mpls", mpls_number);
    if (LoaderFileOpen(pMPLS_DB->hLoader, filename, &mpls_file) != LOADER_SUCCESS)
    {
        mpls_file = 0;
    }

    /* Open the backup copy */
    snprintf(filename, 64, "/mnt/cdrom/BDMV/BACKUP/PLAYLIST/%.5lu.mpls", mpls_number);
    if (LoaderFileOpen(pMPLS_DB->hLoader, filename, &mpls_backup) != LOADER_SUCCESS)
    {
        mpls_backup = 0;
    }

    /* make sure at least one of the playlist files opened successfuly */
    if (mpls_file == 0)
    {
        if (mpls_backup == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Could not open movie playlist file!\n"));
            tStatus = MPLS_FAILURE;
            goto errout;
        }
        else
        {
            /* use the backup copy */
            mpls_file   = mpls_backup;
            mpls_backup = 0;
        }
    }

    /* Read up to the end of the playlist start address */
    if (LoaderFileRead(pMPLS_DB->hLoader, mpls_file, (PVOID)pTmpBuf, 12, NULL) != LOADER_SUCCESS)
    {
        if (mpls_backup == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to read type indicator!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }

        /* try again with backup */
        if (LoaderFileRead(pMPLS_DB->hLoader, mpls_backup, (PVOID)pTmpBuf, 12, NULL) != LOADER_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to read type indicator!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }
    }

    /* Read the PlayList Start Address */
    ulPlaylistStartAddr = MAKE_DWORD(&pTmpBuf[8]);

    /* Seek To the PlayList() */
    if (LoaderFileSeek(pMPLS_DB->hLoader, mpls_file, LOADER_SEEK_SET, ulPlaylistStartAddr) != LOADER_SUCCESS)
    {
        if (mpls_backup == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to seek to playlist()!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }

        /* try again with backup */
        if (LoaderFileSeek(pMPLS_DB->hLoader, mpls_backup, LOADER_SEEK_SET, ulPlaylistStartAddr) != LOADER_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to seek to playlist()!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }
    }

    /* Read up to the end of the number of playitems */
    if (LoaderFileRead(pMPLS_DB->hLoader, mpls_file, (PVOID)pTmpBuf, 8, NULL) != LOADER_SUCCESS)
    {
        if (mpls_backup == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to read type indicator!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }

        /* try again with backup */
        if (LoaderFileRead(pMPLS_DB->hLoader, mpls_backup, (PVOID)pTmpBuf, 8, NULL) != LOADER_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfPlayItemsInPL: Failed to read type indicator!\n"));
            tStatus = MPLS_FILE_ERROR;
            goto errout;
        }
    }

    /* Read the number of playitems */
    *pNumPlayItem = MAKE_WORD(&pTmpBuf[6]);

errout:

    /* close the movie play list file */
    if (mpls_file != 0)
    {
        LoaderFileClose(pMPLS_DB->hLoader, mpls_file);
    }

    /* close the backup */
    if (mpls_backup != 0)
    {
        LoaderFileClose(pMPLS_DB->hLoader, mpls_backup);
    }

    /* give mutex */
    OS_SemGive(pMPLS_DB->semMutex);

    return (tStatus);
}
/**
 * MPLSGetPlayItem -- Get the specified PlayItem.
 *
 * @param
 *      usPlayItemNum -- which PlayItem of the PlayList
 *      pPlayItem     -- pointer that gets set to the PlayItem
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetPlayItem(uint16 uiPlayItemNum, PLAYITEM **ppPlayItem)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetPlayItem: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (ppPlayItem == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetPlayItem: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }
    if (uiPlayItemNum >= pMPLS_DB->tMovPlayListData.PlayList.number_of_PlayItems)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetPlayItem: play item %u doesn't exist!\n", uiPlayItemNum));
        return (MPLS_FAILURE);
    }

    /* return a pointer to the specified PlayItem */
    OS_SemTake(pMPLS_DB->semMutex, OS_WAIT_FOREVER);
    if (pMPLS_DB->tMovPlayListData.PlayList.PlayItem != NULL)
    {
        *ppPlayItem = &(pMPLS_DB->tMovPlayListData.PlayList.PlayItem[uiPlayItemNum]);
    }
    OS_SemGive(pMPLS_DB->semMutex);

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetNumberOfSubPaths -- Get the number of SubPaths in the Playlist.
 *
 * @param
 *      pNumSubPath -- pointer that gets set to the count
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetNumberOfSubPaths(uint16 *pNumSubPath)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfSubPaths: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (pNumSubPath == NULL)
    {

⌨️ 快捷键说明

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