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

📄 pbc_avpres.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            {
                ubNextRandomShuffleIndex = PbcPLCtrlGetRandomShuffleIndex(hPBC);
            }
        }
        else
        {
            /* if we don't successfully find an angle point in the current playitem,
             * SEND THE NEXT play item, with the correct angle and with the play item's listed start and end times.
             */
            DBGPRINT(DBG_ON(DBG_TRACE), ("DID NOT find an angle change point in the clip - go to next clip\n"));
            DBGPRINT(DBG_ON(DBG_VERBOSE), ("play item id number: %u\n", pPIContext->uiPlayitemID));

            uiNextPlayitemID = PbcPLCtrlGetNextPlayitem(hPBC, pPIContext->uiPlayitemID);

            if (uiNextPlayitemID != INVALID_PLAYITEM)
            {
                /* Get pointer to the playitem from the movie playlist database */
                if (MPLSGetPlayItem(uiNextPlayitemID, &pPlayItem) != MPLS_SUCCESS)
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("%s: Failed to get playitem!\n", __FUNCTION__));
                    status = PLAYCTRL_FAILURE;
                    goto out;
                }

                ptsValue = (!hPBC->fReverse) ? pPlayItem->IN_time : pPlayItem->OUT_time;

                /*
                 * If playlist is random/shuffle, then set the random/shuffle index
                 * of the playitem to be played.
                 */
                if ( (pPLAppInfo->PlayList_playback_type == MPLS_RANDOM_PLAYLIST) ||
                    (pPLAppInfo->PlayList_playback_type == MPLS_SHUFFLE_PLAYLIST) )
                {
                    ubNextRandomShuffleIndex = PbcPLCtrlGetRandomShuffleIndex(hPBC) + (hPBC->fReverse ? -1 : 1);
                }
            }
        }

        if (uiNextPlayitemID != INVALID_PLAYITEM)
        {
            PbcPLCtrlPlayPlayitem(hPBC, pPIContext->uiPlayitemID, uiNextPlayitemID, ptsValue, hPBC->fReverse, hPBC->ulPlayRate, ubNextRandomShuffleIndex, FALSE, pwContext, connection, FALSE);
        }
    }
    else
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("angle didn't change (or the DR has passed that block) - nothing needed to happen\n"));
        status = PLAYCTRL_SUCCESS;
    }

out:

    if (fGiveSem)
    {
        /* Give register mutex semaphore */
        OS_SemGive(hPBC->semRegisterMutex);
    }

    /* Re-enable the DR */
    DRQueueControl(hPBC->hDR, DR_STREAM_MAIN, DR_QUEUE_CMD_ENABLE);

    /* send angle change event to the module manager if the angle change was successful*/
    if ( (status == PLAYCTRL_SUCCESS) && fSendNotification)
    {
        if (hPBC->pCallback != NULL)
        {
            uint32 tmp_uiNewAngle = uiNewAngle;
            hPBC->pCallback(hPBC->pvCallbackContext, PLAYCTRL_EVENT_ANGLECHANGE, &tmp_uiNewAngle);
        }
    }
    return (status);
}

/**
 * PbcAvPresIGChange -- Change presentation of interactive graphics to
 *                      specified interactive graphics stream number.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      data1 -- IG stream number
 *      data2 -- not used
 *      data3 -- not used
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcAvPresIGChange(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
    uint32          uiPlayItemID    = 0;
    PLAYITEM        *pPlayItem      = NULL;
    uint32          uiIGStnCurrent;
    uint32          uiIGStnNew;
    uint32          uiIGStnNext;
    PLAYCTRL_STATUS status          = PLAYCTRL_SUCCESS;

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcAvPresIGChange: ig stream = %d\n", data1));

    /* check for valid handle */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresIGChange: NULL handle!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    /* if we're currently stopped then just update the PSR */
    if (hPBC->tState == PLAYCTRL_STATE_STOP)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcAvPresIGChange: JUST UPDATE PSR\n"));

        /* update the current stream selection */
        OS_SemTake(hPBC->semRegisterMutex, OS_WAIT_FOREVER);
        PbcRegGetPSR(PLAYCTRL_PSR_IG_STN, &uiIGStnCurrent);

        /* check if the requested IG stream is different than the current IG stream */
        if (data1 != (uiIGStnCurrent & 0x000000ff) )
        {
            /*
             * Set flag to indicate that IG stream change needs to happen when a
             * playlist is started again.
             */
            hPBC->fIGChangePending = TRUE;
        }

        /* Set the PSR to the requested stream number */
        uiIGStnCurrent &= 0xffffff00;
        uiIGStnCurrent |= (data1 & 0x000000ff);
        PbcRegSetPSR(PLAYCTRL_PSR_IG_STN, uiIGStnCurrent);
        OS_SemGive(hPBC->semRegisterMutex);

        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcAvPresIGChange: PSR = 0x%lx\n", uiIGStnCurrent));

        return (PLAYCTRL_SUCCESS);
    }

    /* Get the current playitem id */
    PlayCtrlGetPSR(PLAYCTRL_PSR_PLAYITEM, &uiPlayItemID);
    uiPlayItemID &= 0x0000ffff;

    /* Get the playitem from the movie playlist database */
    if (MPLSGetPlayItem( (uint16)(uiPlayItemID), &pPlayItem) != MPLS_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresIGChange: Failed to get playitem!\n"));
        return (PLAYCTRL_FAILURE);
    }

    /*
     * If specified IG stream number is valid, then select
     * the IG stream number.
     */
    if (data1 <= pPlayItem->STN_table.number_of_IG_stream_entries)
    {
        DR_STREAM dr_stream;

        /* Get the current IG stream number */
        PbcRegGetPSR(PLAYCTRL_PSR_IG_STN, &uiIGStnCurrent);

        /* select IG stream number */
        PbcStnSelectIG(data1, &pPlayItem->STN_table, &uiIGStnNew);
        uiIGStnNew = uiIGStnNew | (uiIGStnCurrent & 0xffffff00);

        dr_stream = PbcPLCtrlGetDRStreamType(hPBC, PBC_STREAM_ENTRY_IG, (uint16)(uiPlayItemID), (uiIGStnNew & 0x000000ff) );

        /* Halt the DR play queue so the DR status can't change */
        DRQueueControl(hPBC->hDR, DR_STREAM_MAIN, DR_QUEUE_CMD_DISABLE);
        DRQueueControl(hPBC->hDR, dr_stream, DR_QUEUE_CMD_DISABLE);

        /* If IG stream number has been changed, then switch to new IG stream */
        if ( (uiIGStnCurrent & 0x000000ff) != (uiIGStnNew & 0x000000ff) )
        {
            uint32                   uiPlaylistID;
            PE_ISTREAMCTRL_PLAYRATE  PlayRate;
            PBC_PLAYITEM_CONTEXT     *pPIContext = NULL;
            PBC_PLAYITEM_CONTEXT     *CurrentContext = NULL;

            /* Configure IG */
            PbcRegGetPSR(PLAYCTRL_PSR_PLAYLIST, &uiPlaylistID);

            /*
             *  CHANGE CURRENT      (check that we're not in discrete mode)
             */
            PEiStreamCtrlGetRate(hPBC->hPE, &PlayRate);
            if (PlayRate.discontiguous == 0)
            {
                /* If desired IG is on a subpath */
                if (dr_stream != DR_STREAM_MAIN)
                {
                    /* Play the subplayitem */
                    if (PbcPLCtrlPlaySubPlayitem(hPBC, (uint16)(uiPlayItemID), PBC_STREAM_ENTRY_IG, (uiIGStnNew & 0x000000ff), FALSE) != PLAYCTRL_SUCCESS)
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresIGChange: Failed to play subplayitem!\n"));
                        status = PLAYCTRL_FAILURE;
                        goto out;
                    }
                }

                DRGetStatus(hPBC->hDR, DR_STREAM_MAIN, DR_STATCMD_CONTEXT, (uint32 *)&CurrentContext);

                if (CurrentContext != NULL)
                {
                    /*
                     * Check to make sure that the playitem context returned from the DR is actually
                     * the current playitem's context, and not the next.
                     */
                    if (CurrentContext->uiPlayitemID != uiPlayItemID)
                    {
                        /*
                         * The DR is on the NEXT playitem, so need to run the stream selection
                         * algorithm for that playitem to determine the stream number to set
                         * in the context.
                         */

                        /* Get the playitem struct for what's currently playing in the DR */
                        if (MPLSGetPlayItem(CurrentContext->uiPlayitemID, &pPlayItem) != MPLS_SUCCESS)
                        {
                            DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresSubtitleChange: Failed to get playitem!\n"));
                            status = PLAYCTRL_FAILURE;
                            goto out;
                        }

                        /* select subtitle stream number MUST BE BASED ON NEXT PLAYITEM! */
                        PbcStnSelectIG( (uiIGStnNew & 0x00000fff), &pPlayItem->STN_table, &uiIGStnNext);
                        uiIGStnNext = uiIGStnNext | (uiIGStnNew & 0xffffff00);

                        /* change the stream info of what's currently playing in the DR */
                        CurrentContext->StreamInfo.uiIGStn = uiIGStnNext & 0x000000ff;
                    }
                    else
                    {
                        /* change the stream info of what's currently playing in the DR */
                        CurrentContext->StreamInfo.uiIGStn = uiIGStnNew & 0x000000ff;
                    }
                }

                PbcPLCtrlConfigIG(hPBC, uiPlaylistID, (uint16)(uiPlayItemID), (uiIGStnNew & 0x000000ff) );
            }

            /*
             *  SET THE PSR
             */
            OS_SemTake(hPBC->semRegisterMutex, OS_WAIT_FOREVER);

            PbcRegSetPSR(PLAYCTRL_PSR_IG_STN, uiIGStnNew);

            OS_SemGive(hPBC->semRegisterMutex);


            /*
             *  SET UP NEXT (On the MAIN)
             */
            DRGetStatus(hPBC->hDR, DR_STREAM_MAIN, DR_STATCMD_NEXT_CONTEXT, (uint32 *)&pPIContext);

            /* if there is something in the queue, we need to update it too */
            if (pPIContext != NULL)
            {
                /* Get the playitem struct for the queued playitem */
                if (MPLSGetPlayItem(pPIContext->uiPlayitemID, &pPlayItem) != MPLS_SUCCESS)
                {
                    DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresIGChange: Failed to get playitem!\n"));
                    status = PLAYCTRL_FAILURE;
                    goto out;
                }

                /* select subtitle stream number MUST BE BASED ON NEXT PLAYITEM! */
                PbcStnSelectIG( (uiIGStnNew & 0x00000fff), &pPlayItem->STN_table, &uiIGStnNext);
                uiIGStnNext = uiIGStnNext | (uiIGStnNew & 0xffffff00);

                /* modify the context */
                pPIContext->StreamInfo.uiIGStn = uiIGStnNext & 0x000000ff;
            }
        }
out:
        DRQueueControl(hPBC->hDR, dr_stream, DR_QUEUE_CMD_ENABLE);
        DRQueueControl(hPBC->hDR, DR_STREAM_MAIN, DR_QUEUE_CMD_ENABLE);
    }

    return (status);
}

/**
 * PbcAvPresTextSTStyleChange -- Changle a text subtitle style to specified style.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      data1 -- style id
 *      data2 -- not used
 *      data3 -- not used
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcAvPresTextSTStyleChange(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcAvPresTextSTStyleChange: user style id = %d\n", data1));

    /* check for valid handle */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresTextSTStyleChange: NULL handle!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    /* set user style through pe iConfigure */
    if (PEiConfigureSetTextSTUserStyle(hPBC->hPE, data1) != PE_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresTextSTStyleChange: Failed to set user style!\n"));
        return (PLAYCTRL_FAILURE);
    }

    /* update the PSR */
    OS_SemTake(hPBC->semRegisterMutex, OS_WAIT_FOREVER);
    PbcRegSetPSR(PLAYCTRL_PSR_SEL_STYLE, data1);
    OS_SemGive(hPBC->semRegisterMutex);

    return (PLAYCTRL_SUCCESS);
}

/**
 * PbcAvPresGetNumTextSTStyles -- Get the number of currently available text subtitle styles.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      data1 -- buffer to receive number of styles
 *      data2 -- not used
 *      data3 -- not used
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcAvPresGetNumTextSTStyles(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
    /* check for valid handle */
    if (hPBC == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcAvPresGetNumTextSTStyles: NULL handle!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    if (PEiConfigureGetTextSTNumberOfUserStyles(hPBC->hPE, (ULONG *)data1) != PE_SUCCESS)
    {
        *((ULONG *)data1) = 0;
    }

    return (PLAYCTRL_SUCCESS);
}

⌨️ 快捷键说明

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