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

📄 dr_app.cpp

📁 这是DVD中伺服部分的核心代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if (DR_SUCCESS != status)
    {
        if (dr->eventCallback != NULL)
        {
            dr->eventCallback(dr->eventContext, DR_EVENT_COMMAND_ERROR, (PVOID)DR_SET_DVD_SPEED);
        }
    }

    OS_SemGive(dr->semDRMutex);

    /* Return status */
    return (status);
}



/**
 * DRBDROMStopAtPoint - Switch seamlessly to the new file
 *
 * @param handle        - Operating system handle for the DR object.
 * @param fAngle        - Should we stop at an angle change point or at any I-frame?
 * @param ulLastPTS     - the point at which the DR stops
 * @param pvContext     - a pointer to the context (which was passed in during PlayBDROM()) is returned
 *
 * @retval DR_ERROR
 *
 * @remarks none.
 */
DR_ERROR DRBDROMStopAtPoint(DR_HANDLE handle, BOOLEAN fAngle, ULONG *ulLastPTS, PVOID *pvContext)
{
    DRHANDLE *dr     = (DRHANDLE*)handle;
    DR_ERROR status  = DR_SUCCESS;

    /* validate */
    if (NULL == handle)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: NULL DR_HANDLE\n", __FUNCTION__));
        return (DR_FAILURE);
    }


    OS_SemTake(dr->semDRMutex, OS_WAIT_FOREVER);


    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    /* check state */
    if ( ( (dr->State & DR_STATE_PLAY_FIELD) == 0)                   ||
         ( (dr->State & DR_STATE_DISC_FIELD) != DR_STATE_BDROM )      )
    {
        status = DR_INVALID_STATE;
    }

    /* it's all good, send the angle change */
    if (status == DR_SUCCESS)
    {
        if (dr->prefetch[DR_STREAM_MAIN] != NULL)
        {
            status = dr->prefetch[DR_STREAM_MAIN]->StopAtChangePoint(fAngle, &(*ulLastPTS), &(*pvContext));
        }
    }

    OS_SemGive(dr->semDRMutex);

    return(status);
} /* end DRSetBDROMAngle() */




/**
 * Requests the DR to reset the Pre-Fetch buffers as well as clears the play
 * queue.
 *
 * @param handle - Operating system handle for the DR object.
 *
 * @retval DR_ERROR
 */
DR_ERROR DRStop(DR_HANDLE handle)
{
    DRHANDLE     *dr      = (DRHANDLE*)handle;
    DR_ERROR     status   = DR_SUCCESS;

    /* validate our input */
    if (NULL == handle)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: NULL DR_HANDLE\n", __FUNCTION__));
        return (DR_FAILURE);
    }

    OS_SemTake(dr->semDRMutex, OS_WAIT_FOREVER);

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    /* check state */
    if ( (dr->State & DR_STATE_PLAY_FIELD) == 0 )
    {
        status = DR_INVALID_STATE;
        goto errout;
    }

    if (status == DR_SUCCESS)
    {
        /* Stop all existing prefetch objects */
        for(int i=0; i<BDROM_NUM_MAX_PREFETCH; i++)
        {
            if (dr->prefetch[i] != NULL)
            {
                dr->prefetch[i]->Stop(TRUE);
            }
        }
    }

errout:
    /* If the command failed, signal the command error event */
    if (DR_SUCCESS != status)
    {
        if (dr->eventCallback != NULL)
        {
            dr->eventCallback(dr->eventContext, DR_EVENT_COMMAND_ERROR, (PVOID)DR_STOP);
        }
    }

    OS_SemGive(dr->semDRMutex);

    /* Return status */
    return (status);

} /* end DRStop() */




/**
 * DRStopStream - Stop one stream
 *
 * @param handle        - Operating system handle for the DR object.
 * @param strmType      - Which stream to stop.
 *
 * @retval DR_ERROR
 *
 * @remarks none.
 */
DR_ERROR DRStopStream(DR_HANDLE handle, DR_STREAM strmType)
{
    DRHANDLE     *dr             = (DRHANDLE*)handle;
    DR_ERROR     status          = DR_SUCCESS;
    UBYTE        ubStreamIndex;

    /* validate our input */
    if (NULL == handle)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: NULL DR_HANDLE\n", __FUNCTION__));
        return (DR_FAILURE);
    }

    OS_SemTake(dr->semDRMutex, OS_WAIT_FOREVER);

    ubStreamIndex = (UBYTE)strmType;

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    /* check state */
    if ( (dr->State & DR_STATE_PLAY_FIELD) == 0 )
    {
        status = DR_INVALID_STATE;
        goto errout;
    }

    if (status == DR_SUCCESS)
    {
        /* Stop one prefetch object */
        if (dr->prefetch[ubStreamIndex] != NULL)
        {
            dr->prefetch[ubStreamIndex]->Stop(TRUE);
        }
        else
        {
            status = DR_INVALID_PARAM;
        }
    }

errout:
    /* If the command failed, signal the command error event */
    if (DR_SUCCESS != status)
    {
        if (dr->eventCallback != NULL)
        {
            dr->eventCallback(dr->eventContext, DR_EVENT_COMMAND_ERROR, (PVOID)DR_STOP_STREAM);
        }
    }

    OS_SemGive(dr->semDRMutex);

    /* Return status */
    return (status);

} /* end DRStopStream() */




/**
 * DRQueueControl - control a stream's playqueue
 *
 * @param handle        - Operating system handle for the DR object.
 * @param strmType      - Which stream to control.
 * @param command       - command for that stream's playqueue.
 *
 * @retval DR_ERROR
 *
 * @remarks none.
 */
DR_ERROR DRQueueControl(DR_HANDLE handle, DR_STREAM strmType, DR_QUEUE_CMD command)
{
    DRHANDLE     *dr             = (DRHANDLE*)handle;
    DR_ERROR     status          = DR_SUCCESS;
    UBYTE        ubStreamIndex;

    /* validate our input */
    if (NULL == handle)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: NULL DR_HANDLE\n", __FUNCTION__));
        return (DR_FAILURE);
    }
    if (strmType == DR_STREAM_NONE)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: INCORRECT STREAM\n", __FUNCTION__));
        return (DR_FAILURE);
    }

    OS_SemTake(dr->semDRMutex, OS_WAIT_FOREVER);

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    ubStreamIndex = (UBYTE)strmType;

    /* check state */
    if ( (dr->State & DR_STATE_PLAY_FIELD) == 0 )
    {
        status = DR_INVALID_STATE;
        goto errout;
    }

    /* check that prefetch object exists */
    if (dr->prefetch[ubStreamIndex] == NULL)
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s: queue control: specified prefetch doesn't exist\n", __FUNCTION__));
        status = DR_INVALID_PARAM;
        goto errout;
    }

    /* it's all good - tell the prefetch object to do the command */
    if (status == DR_SUCCESS)
    {
        status = dr->prefetch[ubStreamIndex]->QueueControl(command);
    }


errout:

    OS_SemGive(dr->semDRMutex);

    /* Return status */
    return (status);
}


/**
 * Resets the DR without de-attaching the event handler, loader, and POS.
 *
 * @param handle - Operating system handle for the DR object.
 *
 * @retval DR_ERROR
 */
DR_ERROR DRReset(DR_HANDLE handle)
{
    DRHANDLE     *dr        = (DRHANDLE*)handle;
    DR_ERROR     status     = DR_SUCCESS;

    /* validate our input */
    if (NULL == handle)
    {
        DBGPRINT(DEBUG_DR_APP, ("%s: NULL DR_HANDLE\n", __FUNCTION__));
        return (DR_FAILURE);
    }

    OS_SemTake(dr->semDRMutex, OS_WAIT_FOREVER);

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    /* check state */
    if ((dr->State != DR_STATE_CD_ATTACH_STREAM) &&
        (dr->State != DR_STATE_VCD_ATTACH_STREAM) &&
        (dr->State != DR_STATE_DVD_ATTACH_STREAM) &&
        (dr->State != DR_STATE_HDDVD_STD_ATTACH_STREAM) &&
        (dr->State != DR_STATE_HDDVD_ADV_ATTACH_STREAM) &&
        (dr->State != DR_STATE_BDROM_ATTACH_STREAM) )
    {
        DBGPRINT(DBG_ON(DBG_ERROR), ("%s: DR_RESET: Invalid State\n", __FUNCTION__));
        status = DR_INVALID_STATE;
        goto errout;
    }

    if (status == DR_SUCCESS)
    {
        dr->State = DR_STATE_DISCID;
        DBGPRINT(DBG_ON(DBG_TRACE), ("dr->State: DR_STATE_DISCID\n"));
    }

errout:
    /* If the command failed, signal the command error event */
    if (DR_SUCCESS != status)
    {
        if (dr->eventCallback != NULL)
        {
            dr->eventCallback(dr->eventContext, DR_EVENT_COMMAND_ERROR, (PVOID)DR_RESET);
        }
    }

    OS_SemGive(dr->semDRMutex);

    /* Return status */
    return (status);

} /* end DRReset() */


/**
 * DRGetStatus - Get status information from the DR
 *
 * @param handle   - Operating system handle for the DR object.
 * @param stream   - the stream from which to get Status information.
 * @param cmd      - the status command (what sort of status is desired).
 * @param pStatus  - the status information.
 *
 * @retval DR_ERROR
 *
 * @remarks none.
 */
DR_ERROR DRGetStatus(DR_HANDLE handle, DR_STREAM stream, DR_STATCMD cmd, uint32 *pStatus)
{
    DRHANDLE *dr = (DRHANDLE*)handle;
    DR_ERROR status = DR_SUCCESS;

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    if (handle == NULL)
    {
        return (DR_FAILURE);
    }
    if (pStatus == NULL)
    {
        return (DR_FAILURE);
    }

    /* intialize the return variable */
    *pStatus = 0;


    if (stream == DR_STREAM_NONE)
    {
        /* General Status - currently unused */
    }
    else
    {
        if (dr->prefetch[stream] != NULL)
        {
            status = dr->prefetch[stream]->GetStatus(cmd, &(*pStatus));
        }
        else
        {
            /* specified stream doesn't exist, return a failure */
            status = DR_INVALID_PARAM;
        }
    }

    return (status);
}



/**
 * DRGetEncryptionType - Get the Encryption type of the disk
 *
 * @param handle   - Operating system handle for the DR object.
 * @param type     - The encryption type detected by the loader
 * @retval DR_ERROR
 *
 * @remarks this function will return type=NONE if the loader has not had a
 * chance to detect the disk.
 */
DR_ERROR DRGetEncryptionType(DR_HANDLE handle, ENCRYPTION_TYPE *type)
{
    DRHANDLE *dr = (DRHANDLE*)handle;

    DBGPRINT(DBG_ON(DBG_TRACE), ("%s\n", __FUNCTION__));

    if ((handle == NULL) || (type == NULL))
    {
        return (DR_FAILURE);
    }

    *type = dr->EncryptionType;
    return DR_SUCCESS;
}




/**************************************************************
 **                                                          **
 ******             PRIVATE FUNCTIONS                    ******
 **                                                          **
 *************************************************************/

/**
 * Scan the disc content to verify if all the files needed to decrypt AACS content are
 * present on the disc
 *
 * @param dr    - Operating system handle for the DR object.
 * @param bAacs - pointer to the AACS compliance status.
 *                0 means the content is not AACS;
 *                1 means the content is AACS.
 *

⌨️ 快捷键说明

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