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

📄 mvplaylistdb.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetNumberOfSubPaths: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }

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

    return (MPLS_SUCCESS);
}

/**
 * MPLSGetSubPath -- Get the specified Subpath.
 *
 * @param
 *      uiSubPathNum -- which SubPath of the PlayList
 *      ppSubPath    -- pointer that gets set to the PlayItem
 *
 * @retval
 *      MPLS_STATUS
 */
MPLS_STATUS MPLSGetSubPath(uint8 uiSubPathNum, SUBPATH **ppSubPath)
{
    if (pMPLS_DB == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetSubPath: Database not created!\n"));
        return (MPLS_FAILURE);
    }
    if (ppSubPath == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetSubPath: NULL pointer!\n"));
        return (MPLS_NULL_PTR);
    }
    if (uiSubPathNum >= pMPLS_DB->tMovPlayListData.PlayList.number_of_SubPaths)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("MPLSGetSubPath: subpath %u doesn't exist!\n", uiSubPathNum));
        return (MPLS_FAILURE);
    }

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

    return (MPLS_SUCCESS);
}

/**
 * mplsLoadIndicator -- Read the type indicator and version number from the Movie Playlist Table.
 *
 * @param
 *      file          - handle to open file; this could be the main, or backup copy
 *
 * @retval
 *      MPLS_SUCCESS, MPLS_FILE_ERROR
 */
static MPLS_STATUS mplsLoadIndicator(LOADER_FILE_HANDLE file)
{
    MPLS_STATUS tStatus;
    uint8       pTmpBuf[8];

    /* Read up to the reserved field */
    if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 8, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("mplsLoadIndicator: Failed to read type indicator!\n"));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }

    /* store the type indicator */
    pMPLS_DB->tMovPlayListData.type_indicator[0] = pTmpBuf[0];
    pMPLS_DB->tMovPlayListData.type_indicator[1] = pTmpBuf[1];
    pMPLS_DB->tMovPlayListData.type_indicator[2] = pTmpBuf[2];
    pMPLS_DB->tMovPlayListData.type_indicator[3] = pTmpBuf[3];

    /* Check that type indicator is valid */
    if ( (pTmpBuf[0] != 'M') || (pTmpBuf[1] != 'P') || (pTmpBuf[2] != 'L') || (pTmpBuf[3] != 'S') )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("mplsLoadIndicator: Invalid type indicator!\n"));
        tStatus = MPLS_INVALID_FORMAT;
        goto errout;
    }

    /* store the version number */
    pMPLS_DB->tMovPlayListData.version_number[0] = pTmpBuf[4];
    pMPLS_DB->tMovPlayListData.version_number[1] = pTmpBuf[5];
    pMPLS_DB->tMovPlayListData.version_number[2] = pTmpBuf[6];
    pMPLS_DB->tMovPlayListData.version_number[3] = pTmpBuf[7];

    /* Check that version number is valid */
    if (GET_INT_FROM_ASCII4(pMPLS_DB->tMovPlayListData.version_number) < BDROM_SPEC_VERSION)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("mplsLoadIndicator: Version Number Invalid!\n"));
        tStatus = MPLS_INVALID_FORMAT;
        goto errout;
    }

    return (MPLS_SUCCESS);

errout:
    return (tStatus);
}

/**
 * mplsLoadAppInfoPlayList -- Parses the AppInfoPlayList portion of the Movie Playlist Table.
 *
 * @param
 *      file          - handle to open file; this could be the main, or backup copy
 *      start_address - offset to start of the AppInfoPlayList in the file
 *      pPlayListMark - pointer to record to receive the parsed data
 *
 * @retval
 *      MPLS_SUCCESS, MPLS_FILE_ERROR
 */
static MPLS_STATUS mplsLoadAppInfoPlayList(LOADER_FILE_HANDLE file, uint32 start_address, APPINFOPLAYLIST_TABLE *pAppInfoPlayList)
{
    MPLS_STATUS tStatus;
    uint8       pTmpBuf[10];
    uint32      length;

    /* Seek To the AppInfoPlayList() */
    if (LoaderFileSeek(pMPLS_DB->hLoader, file, LOADER_SEEK_SET, start_address) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s: %u:  Failed to seek in file!\n", __FILE__, __LINE__));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }

    /* Read length, PlayList_playback_type, and playback_count
     * note: playback_count is only valid for type 2 || 3, but we need to seek past it anyway */
    if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 8, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u  Read Failed!\n", __FUNCTION__, __LINE__));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }
    length = MAKE_DWORD(&pTmpBuf[0]);
    pAppInfoPlayList->PlayList_playback_type = pTmpBuf[5];
    pAppInfoPlayList->playback_count = MAKE_WORD(&pTmpBuf[6]);

    DBGPRINT((length != 14), ("MPLSLoad: INVALID AppInfoPlayList Length!\n"));

    /* read UO_mask_table and PlayList_random_access_flag */
    if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 10, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u  Read Failed!\n", __FUNCTION__, __LINE__));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }

    /* store the UO mask table */
#if VDVD_PLATFORM_ENDIANESS == VDVD_BIG_ENDIAN
    memcpy(&(pAppInfoPlayList->UO_mask_table), pTmpBuf, 8);
#else
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[0] = pTmpBuf[7];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[1] = pTmpBuf[6];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[2] = pTmpBuf[5];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[3] = pTmpBuf[4];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[4] = pTmpBuf[3];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[5] = pTmpBuf[2];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[6] = pTmpBuf[1];
    ((BYTE *)(&(pAppInfoPlayList->UO_mask_table)))[7] = pTmpBuf[0];
#endif

    /* store the random access flag */
    pAppInfoPlayList->PlayList_random_access_flag = ( (pTmpBuf[8] & 0x80) != 0 );

    /* store the audio mix flag */
    pAppInfoPlayList->audio_mix_app_flag = ( (pTmpBuf[8] & 0x40) != 0 );

    /* store the mixer bypass flag */
    pAppInfoPlayList->lossless_may_bypass_mixer_flag = ( (pTmpBuf[8] & 0x20) != 0 );

    return (MPLS_SUCCESS);

errout:
    return (tStatus);
}

/**
 * mplsLoadPlayList -- Parses the PlayList portion of the Movie Playlist Table.
 *
 * @param
 *      file          - handle to open file; this could be the main, or backup copy
 *      start_address - offset to start of the PlayList in the file
 *      pPlayListMark - pointer to record to receive the parsed data
 *
 * @retval
 *      MPLS_SUCCESS, MPLS_FILE_ERROR
 */
static MPLS_STATUS mplsLoadPlayList(LOADER_FILE_HANDLE file, uint32 start_address, PLAYLIST_TABLE *pPlayList)
{
    MPLS_STATUS tStatus;
    uint8       pTmpBuf[10];
    uint32      length;

#if DBG_ON(DBG_TRACE)
    gMPLSMemUsage = 0;
#endif

    /* release old allocations */
    mplsUnLoadPlayList(pPlayList);

    /* Seek To the PlayList() */
    if (LoaderFileSeek(pMPLS_DB->hLoader, file, LOADER_SEEK_SET, start_address) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s: %u:  Failed to seek in file!\n", __FILE__, __LINE__));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }

    /* Read PlayList length, number of PlayItems, and number of SubPaths */
    if (LoaderFileRead(pMPLS_DB->hLoader, file, (PVOID)pTmpBuf, 10, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u  Read Failed!\n", __FUNCTION__, __LINE__));
        tStatus = MPLS_FILE_ERROR;
        goto errout;
    }

    length = MAKE_DWORD(&pTmpBuf[0]);
    pPlayList->number_of_PlayItems = MAKE_WORD(&pTmpBuf[6]);
    pPlayList->number_of_SubPaths  = MAKE_WORD(&pTmpBuf[8]);
    DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList: length              = %lu\n", length));
    DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList: number of playitems = %u\n", pPlayList->number_of_PlayItems));
    DBGPRINT(DBG_ON(DBG_VERBOSE), ("mplsLoadPlayList: number of subpaths  = %u\n", pPlayList->number_of_SubPaths));

    /*
     * PlayItem()
     ************************************************************************/
    if (pPlayList->number_of_PlayItems > 0)
    {
#if DBG_ON(DBG_TRACE)
        gMPLSMemUsage += sizeof(PLAYITEM) * pPlayList->number_of_PlayItems;
#endif

        pPlayList->PlayItem = (PLAYITEM *)OS_MemAlloc(sizeof(PLAYITEM) * pPlayList->number_of_PlayItems);
        if (pPlayList->PlayItem == NULL)
        {
            tStatus = MPLS_NO_MEMORY;
            goto errout;
        }

        /* intialize playitem data */
        memset(pPlayList->PlayItem , 0, (sizeof(PLAYITEM) * pPlayList->number_of_PlayItems) );

        for (int playitem=0; playitem<pPlayList->number_of_PlayItems; playitem++)
        {
            tStatus = mplsLoadPlayList_PlayItem(file, &pPlayList->PlayItem[playitem]);
            if (tStatus != MPLS_SUCCESS)
            {
                goto errout;
            }
        }
    }

    /*
     * SubPath()
     ************************************************************************/
    if (pPlayList->number_of_SubPaths > 0)
    {
#if DBG_ON(DBG_TRACE)
        gMPLSMemUsage += sizeof(SUBPATH) * pPlayList->number_of_SubPaths;
#endif

        pPlayList->SubPath = (SUBPATH *)OS_MemAlloc(sizeof(SUBPATH) * pPlayList->number_of_SubPaths);
        if (pPlayList->SubPath == NULL)
        {
            tStatus = MPLS_NO_MEMORY;
            goto errout;
        }

        /* intialize subpath data */
        memset(pPlayList->SubPath , 0, (sizeof(SUBPATH) * pPlayList->number_of_SubPaths) );

        for (int subpath=0; subpath<pPlayList->number_of_SubPaths; subpath++)
        {
            tStatus = mplsLoadPlayList_SubPath(file, &pPlayList->SubPath[subpath]);
            if (tStatus != MPLS_SUCCESS)
            {
                goto errout;
            }
        }
    }

#if DBG_ON(DBG_TRACE)
    DbgPrint(("\n>>>>>>>>>> MPLSMemUsage = %d <<<<<<<<<<<\n\n", gMPLSMemUsage + sizeof(MPLS_DB_HANDLE)));
#endif

    return (MPLS_SUCCESS);

errout:
    mplsUnLoadPlayList(pPlayList);
    return (tStatus);
}

/**
 * mplsUnLoadPlayList -- Dealloc any playlist allocations.
 *
 * @param
 *      pPlayListMark - pointer to record to receive the parsed data
 *
 * @retval
 *      MPLS_SUCCESS, MPLS_FILE_ERROR
 */
static MPLS_STATUS mplsUnLoadPlayList(PLAYLIST_TABLE *pPlayList)
{
    /*
     * PlayItem()
     ************************************************************************/
    if ( (pPlayList->number_of_PlayItems > 0) && (pPlayList->PlayItem != NULL) )
    {
        for (int playitem=0; playitem<pPlayList->number_of_PlayItems; playitem++)
        {
            mplsUnLoadPlayList_PlayItem(&pPlayList->PlayItem[playitem]);
        }
        pPlayList->number_of_PlayItems = 0;
        OS_MemFree(pPlayList->PlayItem);
        pPlayList->PlayItem = NULL;
    }

    /*
     * SubPath()
     ************************************************************************/
    if ( (pPlayList->number_of_SubPaths > 0) && (pPlayList->SubPath != NULL) )
    {
        for (int subpath=0; subpath<pPlayList->number_of_SubPaths; subpath++)
        {
            mplsUnLoadPlayList_SubPath(&pPlayList->SubPath[subpath]);
        }
        pPlayList->number_of_SubPaths = 0;
        OS_MemFree(pPlayList->SubPath);
        pPlayList->SubPath = NULL;
    }

    return (MPLS_SUCCESS);
}

/**
 * mplsLoadPlayList_PlayItem -- Parses the Playitem portion of the current Playlist.
 *
 * @param
 *      file      - handle to open file; this could be the main, or backup copy
 *      pPlayItem - pointer to record to receive the parsed data
 *
 * @retval
 *      MPLS_SUCCESS, MPLS_FILE_ERROR
 */
static MPLS_STATUS mplsLoadPlayList_PlayItem(LOADER_FILE_HANDLE file, PLAYITEM *pPlayItem)
{
    MPLS_STATUS tStatus;

⌨️ 快捷键说明

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