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

📄 pbc_plcontrol.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                ubNextRandomShuffle = PbcPLCtrlGetRandomShuffleIndex(hPBC) + (hPBC->fReverse ? -1 : 1);
            }

            if (pNextPlayItem->PlayItem_random_access_flag)
            {
                DBGPRINT(DBG_ON(DBG_ERROR), ("Entering a random_access_flag restricted area!\n"));

                if (fReverse)
                {
                    /* Get the next playitem id */
                    uiNextPlayitemID = PbcPLCtrlGetPrevPlayitem(hPBC, uiNextPlayitemID);

                    /* get the playitem info */
                    if (MPLSGetPlayItem(uiNextPlayitemID, &pNextPlayItem) != MPLS_SUCCESS)
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlBegStream: Failed to get playitem!\n"));
                        status = PLAYCTRL_FAILURE;
                        goto errout;
                    }
                }

                fReverse   = 0;
                uiPlayRate = 1000;

                /* Notify if the playrate has changed */
                PbcPLCtrlNotifyPlayRateChange(uiPlayRate);

                time45k_StartTime = pNextPlayItem->IN_time;
            }

            if ( (pCurrentPlayItem->still_mode == 0x01) || (pCurrentPlayItem->still_mode == 0x02) )
            {
                connection = VDVD_CONNECTION_ABORT;
            }
            else
            {
                connection = VDVD_CONNECTION_UNDEF;
            }

            PbcPLCtrlPlayPlayitem(hPBC, pPIContext->uiPlayitemID, uiNextPlayitemID, time45k_StartTime, fReverse,
                    uiPlayRate, ubNextRandomShuffle, FALSE, PBC_NEXT, connection, FALSE);
        }

        /* @todo - temp solution to make sure video is displayed */
        PEiConfigureSetVideoMute(hPBC->hPE, VIDEO_MUTE_OFF);
    }
    else
    {
        SUBPATH *pSubpath = NULL;

        /* get the playitem info */
        if (MPLSGetPlayItem(pPIContext->uiSyncPlayitemID, &pCurrentPlayItem) != MPLS_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("%s:%u - PbcPLCtrlBegStream: Failed to get playitem!\n", __FILE__, __LINE__));
            goto errout;
        }

        /* TODO: need to work on subpaths for subpath types 5, 6, and 7. */

        if (tInput == INPUT_SECONDARY)
        {
            if ( (VDVD_CONNECTION_1     == pPIContext->connection) ||
                 (VDVD_CONNECTION_ABORT == pPIContext->connection)  )
            {
                ULONG ulAudioEntry = pPIContext->StreamInfo.uiPrimaryAudioStn - 1;

                /* Only configure primary audio if it is on this sub-path */
                if ( (pCurrentPlayItem->STN_table.number_of_primary_audio_stream_entries > 0) &&
                     (pCurrentPlayItem->STN_table.primary_audio_stream[ulAudioEntry].stream_entry.type == 2) )
                {
                    /* Get subpath for Audio stream */
                    if (MPLSGetSubPath(pCurrentPlayItem->STN_table.primary_audio_stream[ulAudioEntry].stream_entry.ref_to_SubPath_id,
                        &pSubpath) != MPLS_SUCCESS)
                    {
                        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlBegStream: MPLSGetSubPath() FAILED!\n"));
                        goto errout;
                    }

                    /*
                     * Subpath is either for browsable audio or additional
                     * content for audio stream.
                     */
                    if (pSubpath->SubPath_type == MPLS_SUBPATH_BROWSABLE_SLIDESHOW_AUDIO)
                    {
                        /*
                         * If this is a repeat subpath, then play the subplayitem again.
                         */
                        if (pSubpath->is_repeat_SubPath == 1)
                        {
                            /* Play the subplayitem */
                            if (PbcPLCtrlPlaySubPlayitem(hPBC, pPIContext->uiSyncPlayitemID, PBC_STREAM_ENTRY_PAUDIO,
                                pPIContext->StreamInfo.uiPrimaryAudioStn, FALSE) != PLAYCTRL_SUCCESS)
                            {
                                DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlBegStream: Failed to play subplayitem!\n"));
                                return (PLAYCTRL_FAILURE);
                            }
                        }
                    }
                }
            }
        }
    }

out:

    /* Tell the PE to resume from being idle, now that it is re-configured */
    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlBegStream: PEiStreamCtrlResumeFromIdle()\n"));
    if (PEiStreamCtrlResumeFromIdle(hPBC->hPE, tInput) != PE_SUCCESS)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlBegStream: PEiStreamCtrlResumeFromIdle() FAILED!\n"));
        goto errout;
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlBegStream: EXIT()\n"));
    return (status);

errout:

    /* playlist complete */
    PbcPLCtrlPlaylistComplete(hPBC, TRUE);

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlBegStream: EXIT() with error\n"));
    return (status);
}

/**
 * PbcPLCtrlNotifyPlayRateChange
 *
 * Send Play status event in the case of automatic transition
 * from trickplay to standard play between playitems.
 *
 * @param
 *      ulSpeed -- The new playrate
 *
 * @retval
 *      None.
 */
void PbcPLCtrlNotifyPlayRateChange(ULONG ulSpeed)
{
    ULONG out_msg[4];

    if (ulSpeed != prevPlayitemPlayRate)
    {
        out_msg[0] = VDVD_STATUS_PLAY;
        UsrEventHandler(out_msg);
        prevPlayitemPlayRate = 1000; /*Reset to normal playrate*/
    }
}

/**
 * PbcPLCtrlEndStream -- Handle the end of a playitem.
 *
 * @param
 *      hPBC -- handle to playback control engine private data
 *      pPIContext -- pointer to playitem context of playitem that has ended
 *      tInput -- PE Input pin that is at the end of stream
 *
 * @retval
 *      PLAYCTRL_STATUS
 */
PLAYCTRL_STATUS PbcPLCtrlEndStream(PBC_HANDLE *hPBC, PBC_PLAYITEM_CONTEXT *pPIContext, PE_ISTREAMCTRL_INPUT tInput,
    BOOLEAN fRepeatCall)
{
    uint32                  uiPlaylistID;
    uint16                  uiNumPlayitems;
    PLAYITEM                *pPlayItem  = NULL;
    APPINFOPLAYLIST_TABLE   *pPLAppInfo = NULL;
    uint16                  uiNextPlayitemID;

    /* verify input */
    if ( (hPBC == NULL) || (pPIContext == NULL) )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlEndStream: NULL pointer!\n"));
        return (PLAYCTRL_NULL_POINTER);
    }

    /* make sure the playlist hasn't changed */
    PbcRegGetPSR(PLAYCTRL_PSR_PLAYLIST, &uiPlaylistID);
    if (pPIContext->uiPlaylistID != uiPlaylistID)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlEndStream: WRONG PLAYLIST!\n"));
        return (PLAYCTRL_FAILURE);
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream: %u\n", pPIContext->uiPlayitemID));

    if (tInput == INPUT_BDROM_SUBPATH_INTERACTIVE_GRAPHICS)
    {
        /* @todo: Disable the DR  (test this)*/
        //DRQueueControl(hPBC->hDR, DR_STREAM_BDROM_SUBPATH_INTERACTIVE_GRAPHICS, DR_QUEUE_CMD_DISABLE);
    }

    if (tInput != INPUT_MAIN)
    {
        return(PLAYCTRL_SUCCESS);
    }

    /*
     * BELOW HERE, IT'S ONLY THE MAIN
     */

    /* Save the playrate */
    prevPlayitemPlayRate = hPBC->ulPlayRate;

    /* first call */
    if (!fRepeatCall)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream %u: First Call\n", pPIContext->uiPlayitemID));

        /* @todo; if it's the first call to EOS, disable the DR (test this) */
        //DRQueueControl(hPBC->hDR, DR_STREAM_MAIN, DR_QUEUE_CMD_DISABLE);

        /* then determine if we need to wait for the Decoder EOS */

        if (MPLSGetPlayItem(pPIContext->uiPlayitemID, &pPlayItem) != MPLS_SUCCESS)
        {
            return (PLAYCTRL_FAILURE);
        }

        if (MPLSGetAppInfo(&pPLAppInfo) != MPLS_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlEndStream: MPLSGetAppInfo() Failed!\n"));
            return (PLAYCTRL_FAILURE);
        }

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

        /* If still mode is set for this playitem */
        if ( ( (pPlayItem->still_mode == 0x01) || (pPlayItem->still_mode == 0x02) ) ||

            /* Or if we've reversed to the start of the playlist */
            ( (pPIContext->PlayRate.direction == PE_ISTREAMCTRL_DIRECTION_BACKWARD) &&
            ( ( (pPLAppInfo->PlayList_playback_type == MPLS_SEQUENTIAL_PLAYLIST) && (pPIContext->uiPlayitemID == 0 ) ) ||
            ( (pPLAppInfo->PlayList_playback_type != MPLS_SEQUENTIAL_PLAYLIST) && (pPIContext->ubRandomShuffleIndex == 0) ) ) ) ||

            /* Or if we've played forward to the end of the playlist */
            ( (pPIContext->PlayRate.direction == PE_ISTREAMCTRL_DIRECTION_FORWARD) && (uiNextPlayitemID == INVALID_PLAYITEM) ) )
        {
            /* then we want to loop around and wait for the decoder to reach EOS */
            /* first time in and we're going to wait for data to run out */

            if (hPBC->newpi.doneState == PBC_DECDONE_STATE_ACTIVE)
            {
                hPBC->newpi.doneState = PBC_DECDONE_STATE_INACTIVE;
            }
            else
            {
                SET_BIT(hPBC->newpi.doneState, PBC_DECDONE_STATE_WAITING_EOS);
            }
            return (PLAYCTRL_RETRY);
        }
        else
        {
            /* otherwise, we're done */
            DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream: DONE\n"));
            return(PLAYCTRL_SUCCESS);
        }
    }

    /* below this point... THIS IS A REPEAT CALL OF THE MAIN */

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream: Repeat Call\n"));

    if (hPBC->newpi.abort == TRUE)
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream PI %u: ABORTED\n", pPIContext->uiPlayitemID));
        return(PLAYCTRL_SUCCESS);
    }

    /* if decoder isn't finished  */
    if ( GET_BIT(hPBC->newpi.doneState, PBC_DECDONE_STATE_WAITING_EOS) )
    {
        DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream: rejected.  haven't actually reached EOS\n"));
        OS_TaskDelayMsec(100);
        return (PLAYCTRL_RETRY);
    }

    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream: accepted for playitem %u.  do EOS processing\n", pPIContext->uiPlayitemID));
    DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream for PI: %u\n", pPIContext->uiPlayitemID));

    /* Get the number of playitems in the playlist. */
    if (MPLSGetNumberOfPlayItems(&uiNumPlayitems) != MPLS_SUCCESS)
    {
        return (PLAYCTRL_FAILURE);
    }

    if (tInput == INPUT_MAIN)
    {
        /* Get playitem information */
        MPLSGetPlayItem(pPIContext->uiPlayitemID, &pPlayItem);

        /* If still mode is set for this playitem, then set still time */
        if (pPlayItem->still_mode == 0x01)
        {
            /* Still is finite, so set timer to still time in seconds */
            hPBC->ulStillTime = pPlayItem->still_time;
        }
        else if (pPlayItem->still_mode == 0x02)
        {
            /* Still is infinite, so set timer to indicate infinite time */
            hPBC->ulStillTime = 0xffffffff;
        }

        /* Get playlist info */
        if (MPLSGetAppInfo(&pPLAppInfo) != MPLS_SUCCESS)
        {
            DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPLCtrlEndStream: MPLSGetAppInfo() Failed!\n"));
            return (PLAYCTRL_FAILURE);
        }

        if (pPIContext->PlayRate.direction == PE_ISTREAMCTRL_DIRECTION_BACKWARD)
        {
            /* Reversed to beginning of Playlist */
            if ( ( (pPLAppInfo->PlayList_playback_type == MPLS_SEQUENTIAL_PLAYLIST) && (pPIContext->uiPlayitemID == 0) ) ||
                ( (pPLAppInfo->PlayList_playback_type != MPLS_SEQUENTIAL_PLAYLIST) && (pPIContext->ubRandomShuffleIndex == 0) )  )
            {
                DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPLCtrlEndStream for PI: %u - reversed to beg of playlist\n", pPIContext->uiPlayitemID));

                /*
                 * If repeat mode is on then link to the repeat start point, rather than
                 * restarting the playlist.
                 */
                if ( (hPBC->RepeatBlock.repeat_mode != VDVD_INFO_REPEAT_OFF) && (hPBC->RepeatBlock.fRepeatInProgress == FALSE) )
                {

⌨️ 快捷键说明

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