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

📄 clpinfodb.cpp

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

        if (fBackupLoaded == FALSE)
        {
            fBackupLoaded = TRUE;

            /* Open the Clip Info BACKUP file */
            snprintf(bkup_filename, 64, "/mnt/cdrom/BDMV/BACKUP/CLIPINF/%.5u.clpi", ulClipnum);
            DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: Open ClpInfoBkupFile: %s\n", bkup_filename));
            if (LoaderFileOpen(hClpInfo->hLoader, bkup_filename, &ClpInfoBkupFile) != LOADER_SUCCESS)
            {
                ClpInfoBkupFile = 0;
            }
        }

        if (ClpInfoBkupFile == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoad:  No BACKUP!\n"));
            tStatus = CLPINFO_FILE_ERROR;
            goto errout;
        }

        if (CLPINFO_SUCCESS != clpinfoLoadProgramInfo(hClpInfo->ClpInfo_Entry[ulClipInfoIndex], ClpInfoBkupFile, hClpInfo->ClpInfo_Entry[ulClipInfoIndex]->tClpInfoData.ProgramInfo_start_address))
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoadProgramInfo BACKUP Failed!\n"));
            tStatus = CLPINFO_FILE_ERROR;
            goto errout;
        }
    }

    /* Read the Clip Info CPI() Table */
    DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: Read Clip Info CPI()\n"));
    if (CLPINFO_SUCCESS != clpinfoLoadCPI(hClpInfo->ClpInfo_Entry[ulClipInfoIndex], ClpInfoFile, hClpInfo->ClpInfo_Entry[ulClipInfoIndex]->tClpInfoData.CPI_start_address))
    {
        if (fBackupLoaded == FALSE)
        {
            fBackupLoaded = TRUE;

            /* Open the Clip Info BACKUP file */
            snprintf(bkup_filename, 64, "/mnt/cdrom/BDMV/BACKUP/CLIPINF/%.5u.clpi", ulClipnum);
            DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: Open ClpInfoBkupFile: %s\n", bkup_filename));
            if (LoaderFileOpen(hClpInfo->hLoader, bkup_filename, &ClpInfoBkupFile) != LOADER_SUCCESS)
            {
                ClpInfoBkupFile = 0;
            }
        }

        if (ClpInfoBkupFile == 0)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoad:  No BACKUP!\n"));
            tStatus = CLPINFO_FILE_ERROR;
            goto errout;
        }

        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoadCPI Failed!\n"));
        if (CLPINFO_SUCCESS != clpinfoLoadCPI(hClpInfo->ClpInfo_Entry[ulClipInfoIndex], ClpInfoBkupFile, hClpInfo->ClpInfo_Entry[ulClipInfoIndex]->tClpInfoData.CPI_start_address))
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoadCPI BACKUP Failed!\n"));
            tStatus = CLPINFO_FILE_ERROR;
            goto errout;
        }
    }


#if 0
    /**************************/
    /* Seek to the ClipMark() */
    /**************************/
    if (LoaderFileSeek(hClpInfo->hLoader, ClpInfoFile, LOADER_SEEK_SET, hClpInfo->ClpInfo_Entry[ulClipInfoIndex]->tClpInfoData.CPI_start_address) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s: %u:  Failed to seek in file!\n", __FILE__, __LINE__));
        tStatus = CLPINFO_FILE_ERROR;
        goto errout;
    }

    /* Read the ClipMark length */
    if (LoaderFileRead(hClpInfo->hLoader, ClpInfoFile, (PVOID)&(ubData), 4, NULL) != LOADER_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoad: Failed to read CPI length!\n"));
        tStatus = CLPINFO_FILE_ERROR;
        goto errout;
    }
#endif

    /* increment number of clip info entries loaded */
    hClpInfo->ulNumClipsLoaded++;

    DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: After Load, Buffer Level = %u\n", hClpInfo->ulDataPosition));

errout:

    /* Close the ClpInfo file */
    DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: Close ClpInfoFile\n"));
    if (ClpInfoFile != 0)
    {
        if (LoaderFileClose(hClpInfo->hLoader, ClpInfoFile) != LOADER_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoad: Failed to close file!\n"));
            tStatus = CLPINFO_FILE_ERROR;
        }
    }

    /* Close the ClpInfo BACKUP file */
    DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrLoad: Close ClpInfoBKUPFile\n"));
    if (ClpInfoBkupFile != 0)
    {
        if (LoaderFileClose(hClpInfo->hLoader, ClpInfoBkupFile) != LOADER_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrLoad: Failed to close BACKUP file!\n"));
            tStatus = CLPINFO_FILE_ERROR;
        }
    }

    return (tStatus);
}


/**
 * ClpInfoMgrUnload -- Unload all loaded clip info entries
 *
 * @param
 *      none
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS  ClpInfoMgrUnload(void)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("ClpInfoMgrUnload()\n"));

    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoMgrUnload: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    /* reset clip info entry list */
    hClpInfo->ulNumClipsLoaded = 0;
    memset(hClpInfo->ClpInfo_Entry, 0, sizeof(CLPINFO_ENTRY *) * CLPINFO_MAX_ENTRIES);
    
    /* reset our buffer */
    hClpInfo->ulDataPosition = 0;

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoLoad -- Reference a clip info entry from the database.
 *
 * @param
 *      ulClipnum -- clip number
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS ClpInfo::ClpInfoLoad(ULONG ulClipnum)
{
    CLPINFO_STATUS tStatus = CLPINFO_NOT_LOADED;

    for (ULONG i = 0; i < CLPINFO_MAX_ENTRIES; i++)
    {
        if ( (hClpInfo->ClpInfo_Entry[i] != NULL) && (hClpInfo->ClpInfo_Entry[i]->ulClipnum == ulClipnum) )
        {
            m_ulClipnum = ulClipnum;
            m_tClpInfoData = &hClpInfo->ClpInfo_Entry[i]->tClpInfoData;
            
            /* found the clip info entry, so this is a success */
            tStatus = CLPINFO_SUCCESS;
        }
    }

    return (tStatus);
}

/**
 * ClpInfoGet_ClipNum -- Get the clip number of the currently loaded clip
 *
 * @param
 *      ulClipnum        -- the clip number
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS ClpInfo::ClpInfoGet_ClipNum(ULONG *ulClipnum)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipNum: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipNum: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    *ulClipnum = m_ulClipnum;

    return (CLPINFO_SUCCESS);
}


/**
 * ClpInfoGet_ClipSize -- Get the clip size of the currently loaded clip
 *
 * @param
 *      spnSize        -- the clip size in number of source packets
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS ClpInfo::ClpInfoGet_ClipSize(ULONG *spnSize)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipSize: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ClipSize: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    *spnSize = m_tClpInfoData->ClipInfo.number_of_source_packets;

    return (CLPINFO_SUCCESS);
}


/**
 * ClpInfoGet_FontInfo -- Get the clip font information of the currently loaded clip
 *
 * @param
 *      numFiles          -- the number of font files
 *      font_names        -- a set of font names
 *
 * @retval
 *      CLPINFO_STATUS
 */
CLPINFO_STATUS ClpInfo::ClpInfoGet_FontInfo(UBYTE *numFiles, UBYTE **font_names)
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_FontInfo: Database not created!\n"));
        return (CLPINFO_FAILURE);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_FontInfo: Clip not loaded!\n"));
        return(CLPINFO_FAILURE);
    }

    *numFiles   = m_tClpInfoData->ClipInfo.number_of_font_files;
    *font_names = (UBYTE *)m_tClpInfoData->ClipInfo.font_file_name;

    return (CLPINFO_SUCCESS);
}

/**
 * ClpInfoGet_ptsFirst -- Get the first pts of the currently loaded clip (based on the in and out times set)
 *
 * @retval
 *      This will give the PTS value of the actual read point calculated in Set_InOut.
 */
ULONG ClpInfo::ClpInfoGet_ptsFirst()
{
    COARSEINFO *pClpInfoEpMapCoarse;
    FINEINFO   *pClpInfoEpMapFine;

    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ptsFirst: Database not created!\n"));
        return (0);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ptsFirst: Clip not loaded!\n"));
        return(0);
    }

    pClpInfoEpMapCoarse = m_tClpInfoData->CPI.EP_map.stream_pid_entry[EPMAP_STREAMINDEX].EP_map_for_one_stream_PID.coarse;
    pClpInfoEpMapFine   = m_tClpInfoData->CPI.EP_map.stream_pid_entry[EPMAP_STREAMINDEX].EP_map_for_one_stream_PID.fine;

    return  ( ( (pClpInfoEpMapCoarse[m_ciStart].PTS_EP_coarse & 0xfffe) << 18) | (pClpInfoEpMapFine[m_fiStart].PTS_EP_fine << 8) );
}

/**
 * ClpInfoGet_ptsLast -- Get the last pts of the currently loaded clip (based on the in and out times set)
 *
 * @retval
 *      This will give the PTS value of the actual read point calculated in Set_InOut.
 */
ULONG ClpInfo::ClpInfoGet_ptsLast()
{
    COARSEINFO *pClpInfoEpMapCoarse;
    FINEINFO   *pClpInfoEpMapFine;

    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ptsLast: Database not created!\n"));
        return (0);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ptsLast: Clip not loaded!\n"));
        return(0);
    }

    pClpInfoEpMapCoarse = m_tClpInfoData->CPI.EP_map.stream_pid_entry[EPMAP_STREAMINDEX].EP_map_for_one_stream_PID.coarse;
    pClpInfoEpMapFine   = m_tClpInfoData->CPI.EP_map.stream_pid_entry[EPMAP_STREAMINDEX].EP_map_for_one_stream_PID.fine;

    return  ( ( (pClpInfoEpMapCoarse[m_ciEnd].PTS_EP_coarse & 0xfffe) << 18) | (pClpInfoEpMapFine[m_fiEnd].PTS_EP_fine << 8) );
}

/**
 * ClpInfoGet_spnFirst -- Get the first spn of the currently loaded clip (based on the in and out times set)
 *
 * @retval
 *      m_spnFirst
 */
ULONG ClpInfo::ClpInfoGet_spnFirst()
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_spnFirst: Database not created!\n"));
        return (0);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_spnFirst: Clip not loaded!\n"));
        return(0);
    }

    return (m_spnFirst);
}

/**
 * ClpInfoGet_spnLast -- Get the last spn of the currently loaded clip (based on the in and out times set)
 *
 * @retval
 *      m_spnLast
 */
ULONG ClpInfo::ClpInfoGet_spnLast()
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_spnLast: Database not created!\n"));
        return (0);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_spnLast: Clip not loaded!\n"));
        return(0);
    }

    return (m_spnLast);
}

/**
 * ClpInfoGet_ciStart -- Get the first coarse index of the currently loaded clip (based on the in and out times set)
 *
 * @retval
 *      m_ciStart
 */
ULONG ClpInfo::ClpInfoGet_ciStart()
{
    if (hClpInfo == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ciStart: Database not created!\n"));
        return (0);
    }

    if (m_tClpInfoData == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("ClpInfoGet_ciStart: Clip not loaded!\n"));

⌨️ 快捷键说明

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