📄 pbc_pbscenario.cpp
字号:
/*****************************************************************************
******************************************************************************
** **
** Copyright (c) 2005-2006 Videon Central, Inc. **
** All rights reserved. **
** **
** The computer program contained herein contains proprietary information **
** which is the property of Videon Central, Inc. The program may be used **
** and/or copied only with the written permission of Videon Central, Inc. **
** or in accordance with the terms and conditions stipulated in the **
** agreement/contract under which the programs have been supplied. **
** **
******************************************************************************
*****************************************************************************/
/**
* @file pbc_pbscenario.cpp
*
* Playback scenario module of the playback control engine.
* This API is intended to be private and used by other Playback
* Control Engine modules only.
*
* $Id: pbc_pbscenario.cpp,v 1.62 2007/01/26 22:30:21 rbehe Exp $
*/
#include "vdvd_types.h"
#include "pbc_pbscenario.h"
#include "playctrl.h"
#include "pbc_types.h"
#include "pbc_engine.h"
#include "pbc_register.h"
#include "pbc_plcontrol.h"
#include "pbc_avpres.h"
#include "../mvplaylistdb.h"
#include "dr_app.h"
#include "pe_app.h"
#include "usrapi.h"
#include "dbgprint.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* Debug macros */
#define DBG_PBCPBSCENARIO DBG_ERROR
#define DBG_ON(x) (DBG_PBCPBSCENARIO >= x)
/* Local functions */
PLAYCTRL_STATUS pbcpbscenarioLink(PBC_HANDLE *hPBC, uint32 uiPlayitemID, TIME45k time45k_StartTime, UBYTE ubRandomShuffleIndex, BOOLEAN fRepeat = FALSE);
/**
* PbcPbScenarioPlayPLPI -- Start playback of playlist at specified playitem.
*
* @param
* hPBC -- handle to playback control engine private data
* data1 -- playlist number
* data2 -- playitem number
* data3 -- not used
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PbcPbScenarioPlayPLPI(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
uint32 uiPlaylistID = data1;
uint32 uiPlayitemID = data2;
APPINFOPLAYLIST_TABLE *pAppInfoPL = NULL;
PLAYITEM *pPlayitem = NULL;
UBYTE ubRandomShuffle = 0xff;
uint32 uiLastPlaylistID;
BOOLEAN fNewPlaylist;
PE_ISTREAMCTRL_STATE tPEState;
DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioPlayPLPI: playlist %lu, playitem %lu\n", uiPlaylistID, uiPlayitemID));
/* check for valid handle */
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: NULL handle!\n"));
return (PLAYCTRL_NULL_POINTER);
}
/* If playlist playback is active, stop playback */
if (hPBC->tState != PLAYCTRL_STATE_STOP)
{
/* stop the playlist */
if (PbcPLCtrlStopPL(hPBC, TRUE) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: Failed to stop playlist\n"));
return (PLAYCTRL_FAILURE);
}
/* enter stop state */
hPBC->tState = PLAYCTRL_STATE_STOP;
/* flush the input queue to remove any PE/DR events from the previous playback */
PbcEngineClearCmdQueue(hPBC);
}
/* Load the Movie Playlist Database */
if (MPLSLoad(uiPlaylistID) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: Could not parse playlist\n"));
return (PLAYCTRL_FAILURE);
}
/* Get playlist info */
if (MPLSGetAppInfo(&pAppInfoPL) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: Failed to get playlist info!\n"));
return (PLAYCTRL_FAILURE);
}
/* If playlist is random/shuffle playback type, then initialize random/shuffle status */
if ( (pAppInfoPL->PlayList_playback_type == MPLS_RANDOM_PLAYLIST) ||
(pAppInfoPL->PlayList_playback_type == MPLS_SHUFFLE_PLAYLIST) )
{
/* If playback count is 0, no playitems should be played */
if (pAppInfoPL->playback_count == 0)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioPlayPLPI: Random/shuffle playback count is 0!\n"));
return (PLAYCTRL_SUCCESS);
}
else
{
uiPlayitemID = PbcPLCtrlInitRandomShuffle();
ubRandomShuffle = 0;
}
}
/* Get the playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemID), &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: Failed to get playitem info\n"));
return (PLAYCTRL_FAILURE);
}
/* Get ID of last playlist to be played */
PbcRegGetPSR(PLAYCTRL_PSR_PLAYLIST, &uiLastPlaylistID);
/* Get the PE run state */
PEiStreamCtrlGetState(hPBC->hPE, &tPEState);
/* Determine if this is a new playlist */
fNewPlaylist = (uiLastPlaylistID != uiPlaylistID) || (tPEState != PE_ISTREAMCTRL_STATE_RUN);
/* start the playlist at the in time of the specified playitem */
if (PbcPLCtrlStartPL(hPBC, uiPlaylistID, (uint16)(uiPlayitemID), pPlayitem->IN_time, ubRandomShuffle, fNewPlaylist) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLPI: pbcpbscenarioPlayPL() FAILED!\n"));
return (PLAYCTRL_FAILURE);
}
/* Update Playback Control Engine State */
hPBC->tState = PLAYCTRL_STATE_PLAY;
hPBC->ulPlayRate = 1000;
/* Notify if playrate has changed */
PbcPLCtrlNotifyPlayRateChange(hPBC->ulPlayRate);
return (PLAYCTRL_SUCCESS);
}
/**
* PbcPbScenarioLinkPI -- Change playback position to the specified playitem.
*
* @param
* hPBC -- handle to playback control engine private data
* data1 -- playitem number
* data2 -- not used
* data3 -- not used
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PbcPbScenarioLinkPI(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
uint32 uiPlayitemID = data1;
PLAYITEM *pPlayitem = NULL;
uint32 ptsValue;
DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioLinkPI: playitem %lu\n", uiPlayitemID));
/* check for valid handle */
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioLinkPI: NULL handle!\n"));
return (PLAYCTRL_NULL_POINTER);
}
/* Check that playback is active */
if (hPBC->tState == PLAYCTRL_STATE_STOP)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioLinkPI: Playback is stopped!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get the playitem info */
if (MPLSGetPlayItem( (uint16)(uiPlayitemID), &pPlayitem) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioLinkPI: Failed to get playitem info\n"));
return (PLAYCTRL_FAILURE);
}
/* set start pts value of playitem */
ptsValue = pPlayitem->IN_time;
/* Link to new playback position */
if (pbcpbscenarioLink(hPBC, uiPlayitemID, ptsValue, 0) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioLinkPI: pbcpbscenarioLink() FAILED!\n"));
return (PLAYCTRL_FAILURE);
}
return (PLAYCTRL_SUCCESS);
}
/**
* PbcPbScenarioPlayPLMark -- Start playback of playlist at specified mark
*
* @param
* hPBC -- handle to playback control engine private data
* data1 -- playlist number
* data2 -- playmark id
* data3 -- indicates user op or navigation command
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PbcPbScenarioPlayPLMark(PBC_HANDLE *hPBC, ULONG data1, ULONG data2, ULONG data3)
{
PLAYLISTMARK_TABLE *pPLMark = NULL;
APPINFOPLAYLIST_TABLE *pAppInfoPL = NULL;
uint32 uiPlaylistID = data1;
uint32 uiPlaymarkID = data2;
BOOLEAN fIsUserOp = (BOOLEAN)(data3);
BOOLEAN fMarkFound = FALSE;
PLAYITEM *pPlayitem = NULL;
uint32 uiCount = 0;
uint32 uiTargetPM = 0;
UBYTE ubRandomShuffle = 0xff;
uint32 uiPlayitemID;
uint32 uiLastPlaylistID;
BOOLEAN fNewPlaylist;
PE_ISTREAMCTRL_STATE tPEState;
DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioPlayPLMark: playlist %ld, playmark %ld\n", uiPlaylistID, uiPlaymarkID));
/* check for valid handle */
if (hPBC == NULL)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLMark: NULL handle!\n"));
return (PLAYCTRL_NULL_POINTER);
}
/* If playlist playback is active, stop playback */
if (hPBC->tState != PLAYCTRL_STATE_STOP)
{
/* stop the playlist */
if (PbcPLCtrlStopPL(hPBC, TRUE) != PLAYCTRL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLMark: Failed to stop playlist\n"));
return (PLAYCTRL_FAILURE);
}
/* enter stop state */
hPBC->tState = PLAYCTRL_STATE_STOP;
}
/* Load the Movie Playlist Database */
if (MPLSLoad(uiPlaylistID) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLMark: Could not parse playlist\n"));
return (PLAYCTRL_FAILURE);
}
/* Get playlist info */
if (MPLSGetAppInfo(&pAppInfoPL) != MPLS_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLMark: Failed to get playlist info!\n"));
return (PLAYCTRL_FAILURE);
}
/* Get playlist mark from database */
MPLSGetPlayMark(&pPLMark);
/*
* If this is a user operation and playback type is random/shuffle, then
* the operation is invalid.
*/
if ( (pAppInfoPL->PlayList_playback_type == MPLS_SEQUENTIAL_PLAYLIST) || (fIsUserOp == FALSE) )
{
/*
* Look for appropriate entry mark.
*/
for (uint16 i = 0; i < pPLMark->number_of_PlayList_marks; i++)
{
/*
* If this mark is an entry-mark, then increase count.
*/
if (pPLMark->PL_mark[i].mark_type == ENTRY_MARK)
{
uiCount++;
}
else
{
/* if this is a navigation command and an link point, then increase count */
if ( (fIsUserOp == FALSE) && (pPLMark->PL_mark[i].mark_type == LINK_POINT) )
{
uiCount++;
}
}
/*
* If this mark is the entry mark we are looking for, then
* keep track of the mark ID, and finish search.
*/
if (fIsUserOp == TRUE)
{
if (uiCount == uiPlaymarkID)
{
fMarkFound = TRUE;
uiTargetPM = i;
break;
}
}
else if (i == uiPlaymarkID)
{
fMarkFound = TRUE;
uiTargetPM = i;
break;
}
}
}
else
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcPbScenarioPlayPLMark: Operation invalid!\n"));
return (PLAYCTRL_FAILURE);
}
/*
* If a specified mark exists, then start playback at the mark.
* Otherwise, fail this operations.
*/
if (fMarkFound == TRUE)
{
/* If playlist is random/shuffle playback type, then initialize random/shuffle status */
if ( (pAppInfoPL->PlayList_playback_type == MPLS_RANDOM_PLAYLIST) ||
(pAppInfoPL->PlayList_playback_type == MPLS_SHUFFLE_PLAYLIST) )
{
/* If playback count is 0, no playitems should be played */
if (pAppInfoPL->playback_count == 0)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("PbcPbScenarioPlayPLMark: Random/shuffle playback count is 0!\n"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -