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

📄 indexdb.cpp

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

    /* Check that version number is valid */
    if (GET_INT_FROM_ASCII4( (&ubData[4]) ) < BDROM_SPEC_VERSION)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndicator: Version Number Invalid!\n"));
        DBGPRINT(DBG_ON(DBG_ERROR), ("version number: %s\n", &ubData[4]));
        tStatus = INDEX_INVALID_FORMAT;
        goto errout;
    }

    return (INDEX_SUCCESS);

errout:

    return (tStatus);
}

/**
 * indexLoadIndexes -- Load Indexes() from index file
 *
 * @param
 *      file -- file handle (could be main or backup file)
 *      ulStartAddress -- start address of file to read from
 *
 * @retval
 *      INDEX_STATUS
 */
static INDEX_STATUS  indexLoadIndexes(LOADER_FILE_HANDLE file, ULONG ulStartAddress)
{
    INDEX_STATUS    tStatus;
    UBYTE           ubData[8];
    USHORT          i;

    /* Seek To the Indexes() */
    if (LoaderFileSeek(hIndex->hLoader, file, LOADER_SEEK_SET, ulStartAddress) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes:  Failed to seek in file!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }

    /* Read the length of indexes() from the file */
    if (LoaderFileRead(hIndex->hLoader, file, (PVOID)ubData, 4, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Failed to read length!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }

    /* Load the First Playback object from the file */
    tStatus = indexLoadIndexes_FirstPlay(file, &hIndex->FirstPlayback);
    if (tStatus != INDEX_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes: Failed to load first play!\n"));
        goto errout;
    }

    /* Load the Top Menu object from the file */
    tStatus = indexLoadIndexes_TopMenu(file, &hIndex->TopMenu);
    if (tStatus != INDEX_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes: Failed to load top menu!\n"));
        goto errout;
    }

    /* Read the number of titles from the file */
    if (LoaderFileRead(hIndex->hLoader, file, (PVOID)ubData, 2, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Failed to read number of titles!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }

    /* Set number of titles */
    hIndex->usNumberOfTitles = MAKE_WORD(&ubData[0]);
    DbgAssert(hIndex->usNumberOfTitles <= INDEX_MAX_TITLES);

    /* Load all titles */
    for (i = 0; i < hIndex->usNumberOfTitles; i++)
    {
        /* Load the Title object from the file */
        tStatus = indexLoadIndexes_Title(file, &hIndex->Title[i]);
        if (tStatus != INDEX_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes: Failed to load title!\n"));
            goto errout;
        }
    }

    return (INDEX_SUCCESS);

errout:
    
    return (tStatus);
}

/**
 * indexLoadIndexes_FirstPlay -- Load first play object from Indexes() in index file
 *
 * @param
 *      file -- file handle (could be main or backup file)
 *      pFirstPlay -- pointer to first play object
 *
 * @retval
 *      INDEX_STATUS
 */
static INDEX_STATUS  indexLoadIndexes_FirstPlay(LOADER_FILE_HANDLE file, INDEX_OBJ_REF *pFirstPlay)
{
    INDEX_STATUS    tStatus;
    UBYTE           ubData[12];

    /* Read the first playback object from the file */
    if (LoaderFileRead(hIndex->hLoader, file, (PVOID)ubData, 12, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_FirstPlay: Failed to read first play obj type!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }

    /* 
     * Set first playback object type and object ID.  The object
     * ID format is different for an HDMV movie object and a BDJ object.
     */
    if ( (ubData[0] >> 6) == 1)
    {
        /* First playback object is an HDMV movie object */
        pFirstPlay->tObjType = INDEX_OBJ_HDMV;

        /* Set movie object id */
        pFirstPlay->tObjectId.ulHdmvMobjID = MAKE_WORD(&ubData[6]);

        if (pFirstPlay->tObjectId.ulHdmvMobjID != 0xffff)
        {
        /* Set title playback type */
        if ( (ubData[4] >> 6) == 0)
        {
            /* title is a HDMV movie title */
            pFirstPlay->tPlaybackType = INDEX_TITLE_PB_MOVIE;
        }
        else if ( (ubData[4] >> 6) == 1)
        {
            /* title is a HDMV interactive title */
            pFirstPlay->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_FirstPlay: Invalid HDMV title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }
        }
    }
    else if ( (ubData[0] >> 6) == 2)
    {
        /* First playback object is a BDJ object */
        pFirstPlay->tObjType = INDEX_OBJ_BDJ;

        /* Set title playback type */
        if ( (ubData[4] >> 6) == 2)
        {
            /* title is a BDJ movie title */
            pFirstPlay->tPlaybackType = INDEX_TITLE_PB_MOVIE;
        }
        else if ( (ubData[4] >> 6) == 3)
        {
            /* title is a BDJ interactive title */
            pFirstPlay->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_FirstPlay: Invalid BDJ title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }

        /* Copy BDJ file id into database */
        memcpy( (void *)pFirstPlay->tObjectId.ubBdjFileTag, &ubData[6], 5);
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_FirstPlay: Invalid first play obj type!\n"));
        tStatus = INDEX_INVALID_FORMAT;
        goto errout;
    }

    return (INDEX_SUCCESS);

errout:
    
    return (tStatus);
}

/**
 * indexLoadIndexes_TopMenu -- Load top menu object from Indexes() in index file
 *
 * @param
 *      file -- file handle (could be main or backup file)
 *      pTopMenu -- pointer to top menu object
 *
 * @retval
 *      INDEX_STATUS
 */
static INDEX_STATUS  indexLoadIndexes_TopMenu(LOADER_FILE_HANDLE file, INDEX_OBJ_REF *pTopMenu)
{
    INDEX_STATUS    tStatus;
    UBYTE           ubData[12];

    /* Read the top menu object from the file */
    if (LoaderFileRead(hIndex->hLoader, file, (PVOID)ubData, 12, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_TopMenu: Failed to read top menu obj type!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }   

    /* 
     * Set top menu object type and object ID.  The object
     * ID format is different for an HDMV movie object and a BDJ object.
     */
    if ( (ubData[0] >> 6) == 1)
    {
        /* top menu object is an HDMV movie object */
        pTopMenu->tObjType = INDEX_OBJ_HDMV;

        /* Set movie object id */
        pTopMenu->tObjectId.ulHdmvMobjID = MAKE_WORD(&ubData[6]);

        if (pTopMenu->tObjectId.ulHdmvMobjID != 0xffff)
        {
        /* Set title playback type.  It should be interactive */
        if ( (ubData[4] >> 6) == 1)
        {
            /* title is a HDMV interactive title */
            pTopMenu->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_TopMenu: Invalid HDMV title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }
        }
    }
    else if ( (ubData[0] >> 6) == 2)
    {
        /* top menu object is a BDJ object */
        pTopMenu->tObjType = INDEX_OBJ_BDJ;

        /* Set title playback type.  It should be interactive */
        if ( (ubData[4] >> 6) == 3)
        {
            /* title is a BDJ interactive title */
            pTopMenu->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_TopMenu: Invalid BDJ title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }

        /* Copy BDJ file id into database */
        memcpy( (void *)pTopMenu->tObjectId.ubBdjFileTag, &ubData[6], 5);
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("indexLoadIndexes_TopMenu: Invalid top menu obj type!\n"));
        tStatus = INDEX_INVALID_FORMAT;
        goto errout;
    }

    return (INDEX_SUCCESS);

errout:
    
    return (tStatus);
}

/**
 * indexLoadIndexes_Title -- Load title object from Indexes() in index file
 *
 * @param
 *      file -- file handle (could be main or backup file)
 *      pTitle -- pointer to title object
 *
 * @retval
 *      INDEX_STATUS
 */
static INDEX_STATUS  indexLoadIndexes_Title(LOADER_FILE_HANDLE file, INDEX_OBJ_REF *pTitle)
{
    INDEX_STATUS    tStatus;
    UBYTE           ubData[12];

    /* Read the title object from the file */
    if (LoaderFileRead(hIndex->hLoader, file, (PVOID)ubData, 12, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Failed to read title obj type!\n"));
        tStatus = INDEX_FILE_ERROR;
        goto errout;
    }   

    /* 
     * Set title access type.
     */
    if ( ( (ubData[0] >> 4) & 0x03) == 0)
    {
        /* title search into this title is permitted */
        pTitle->tAccessType = INDEX_TITLE_ACCESS_PERMIT;
    }
    else if ( ( (ubData[0] >> 4) & 0x03) == 2)
    {
        /* title search into this title is probited */
        pTitle->tAccessType = INDEX_TITLE_ACCESS_PROHIBIT;
    }
    else if ( ( (ubData[0] >> 4) & 0x03) == 3)
    {
        /* 
         * Title search into this title is prohibited and the title
         * number shall not be displayed on the osd. 
         */
        pTitle->tAccessType = INDEX_TITLE_ACCESS_PROHIBIT_NO_OSD;
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Invalid title acess type!\n"));
        tStatus = INDEX_INVALID_FORMAT;
        goto errout;
    }

    /* 
     * Set title object type, object ID, and title playback type.  The object
     * ID and playback formats are different for an HDMV movie object and a BDJ object.
     */
    if ( (ubData[0] >> 6) == 1)
    {
        /* title object is an HDMV movie object */
        pTitle->tObjType = INDEX_OBJ_HDMV;

        /* Set title playback type */
        if ( (ubData[4] >> 6) == 0)
        {
            /* title is a HDMV movie title */
            pTitle->tPlaybackType = INDEX_TITLE_PB_MOVIE;
        }
        else if ( (ubData[4] >> 6) == 1)
        {
            /* title is a HDMV interactive title */
            pTitle->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Invalid HDMV title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }

        /* Set movie object id */
        pTitle->tObjectId.ulHdmvMobjID = MAKE_WORD(&ubData[6]);
    }
    else if ( (ubData[0] >> 6) == 2)
    {
        /* title object is a BDJ object */
        pTitle->tObjType = INDEX_OBJ_BDJ;

        /* Set title playback type */
        if ( (ubData[4] >> 6) == 2)
        {
            /* title is a BDJ movie title */
            pTitle->tPlaybackType = INDEX_TITLE_PB_MOVIE;
        }
        else if ( (ubData[4] >> 6) == 3)
        {
            /* title is a BDJ interactive title */
            pTitle->tPlaybackType = INDEX_TITLE_PB_INTERACTIVE;
        }   
        else
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Invalid BDJ title playback type!\n"));
            tStatus = INDEX_INVALID_FORMAT;
            goto errout;
        }

        /* Copy BDJ file id into database */
        memcpy( (void *)pTitle->tObjectId.ubBdjFileTag, &ubData[6], 5);
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("IndexLoad: Invalid title obj type!\n"));
        tStatus = INDEX_INVALID_FORMAT; 
        goto errout;
    }

    return (INDEX_SUCCESS);

errout:
    
    return (tStatus);
}

⌨️ 快捷键说明

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