📄 console_player.cpp
字号:
/*****************************************************************************
******************************************************************************
** **
** Copyright (c) 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 console_player.cpp
*
* $Revision: 1.9 $
*
* SDK console_player sample
*
*/
#include "file_capture_decoder.h"
#include "vdvd_types.h"
#include "osapi.h"
#include "psl_interface.h"
#include "dbgprint.h"
#include "cStream.h"
/* this has to be the last file included */
#ifdef DMALLOC
#include "dmalloc.h"
#endif
#define DBG_MAIN DBG_ERROR
#define DBG_ON(x) (DBG_MAIN >= x)
/*
* NOTE: PAYLOAD_SIZE needs to be set by the project or an environment variable
*/
#define NAV_PAYLOAD_SIZE (PAYLOAD_SIZE * 1024) /* recommended size is 32K buffers */
/* The DR creates payloads and all other modules just reference
* them so we should need the same number of payloads as there
* are DR messages. Add a couple for getting title keys etc. */
#if BDROM_ENABLE
#define NAV_PAYLOAD_COUNT (100)
#else
#define NAV_PAYLOAD_COUNT (24)
#endif
/********************************************************************************
GLOBAL VARIABLES
********************************************************************************/
FileCaptureDecoder g_primaryDecoder;
#if BDROM_ENABLE
FileCaptureDecoder g_secondaryDecoder;
#endif
static OS_SEM_ID sem_player_exit = 0;
int main(int argc, char *argv[])
{
PVOID pvPayloadBuffer;
/************************************************************************
* Create the primary decoder
*/
#if BDROM_ENABLE
if ( g_primaryDecoder.Create("1_") != VDVD_SUCCESS )
#else
if ( g_primaryDecoder.Create(NULL) != VDVD_SUCCESS )
#endif
{
DbgPrint(("main: Could not initialize primary file capture decoder\n"));
return (OS_FAILURE);
}
#if BDROM_ENABLE
/************************************************************************
* Create the secondary decoder
*/
if ( g_secondaryDecoder.Create("2_") != VDVD_SUCCESS )
{
DbgPrint(("main: Could not initialize secondary file capture decoder\n"));
return (OS_FAILURE);
}
#endif
/************************************************************************
* Create the global payload manager
*/
/* allocate the payload buffer from the settops memory pool instead of
* system memory so that we can perform DMA operations */
pvPayloadBuffer = OS_MemAlloc( NAV_PAYLOAD_COUNT * NAV_PAYLOAD_SIZE );
if (NULL == pvPayloadBuffer)
{
DbgPrint(("main: Could not allocate payload buffer!\n"));
return (OS_FAILURE);
}
/* create and initialize the global playload manager */
DBGPRINT(DBG_ON(DBG_TRACE), ("main: CreatePayloadMgr\n"));
globalPayloadManager = (cPayloadManager *)CreatePayloadMgr(pvPayloadBuffer, NAV_PAYLOAD_COUNT, NAV_PAYLOAD_SIZE);
if (NULL == globalPayloadManager)
{
DbgPrint(("main: Could not allocate globalPayloadManager!\n"));
OS_MemFree(pvPayloadBuffer);
return (OS_FAILURE);
}
/* create semaphore used to block until player exits */
sem_player_exit = OS_SemBCreate(OS_SEM_Q_FIFO, OS_SEM_EMPTY);
if (sem_player_exit == 0)
{
DbgPrint(("main: Could not create semaphore\n"));
OS_MemFree(pvPayloadBuffer);
return (OS_FAILURE);
}
/************************************************************************
* Create the PSL
*/
if (PslCreate() != PSL_SUCCESS)
{
/* TODO: Handle error */
DBGPRINT(DBG_ON(DBG_ERROR), ("main: -- Failed to create PSL layer\n"));
OS_MemFree(pvPayloadBuffer);
return (OS_FAILURE);
}
DBGPRINT(DBG_ON(DBG_TRACE), ("%s %d\n", __FUNCTION__, __LINE__));
/* send initialize message to psl thread */
if (PslSendInitialize(sem_player_exit) != PSL_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("main: -- Failed to send initialize to PSL\n"));
OS_MemFree(pvPayloadBuffer);
return (OS_FAILURE);
}
/************************************************************************
* Block until player exits.
*/
OS_SemTake(sem_player_exit, OS_WAIT_FOREVER);
/************************************************************************
* Delete the PSL.
*/
DBGPRINT(DBG_ON(DBG_TRACE), ("main: -- PslDelete\n"));
PslDelete();
/* delete player exit sem */
OS_SemDelete(sem_player_exit);
sem_player_exit = 0;
/************************************************************************
* Release payload manager
*/
if (NULL != globalPayloadManager)
{
DeletePayloadMgr(globalPayloadManager);
globalPayloadManager = NULL;
}
if (NULL != pvPayloadBuffer)
{
OS_MemFree(pvPayloadBuffer);
}
/************************************************************************
* Destroy the primary decoder file capture decoder
*/
if ( g_primaryDecoder.Destroy() != VDVD_SUCCESS )
{
DbgPrint(("main: Could not destroy primary file capture decoder\n"));
return (OS_FAILURE);
}
#if BDROM_ENABLE
/************************************************************************
* Destroy the secondary decoder file capture decoder
*/
if ( g_secondaryDecoder.Destroy() != VDVD_SUCCESS )
{
DbgPrint(("main: Could not destroy secondary file capture decoder\n"));
return (OS_FAILURE);
}
#endif
#ifdef DMALLOC
dmalloc_shutdown();
#endif
return (OS_OK);
}
/**
*******************************************************************************
* GetDecoder returns pointer to request decoder
*
* @param DecoderIdType requested decoder's id
* @param ppDecoder variable to store decoder pointer
*
* @return VDVD_SUCCESS if the function is successful
*******************************************************************************/
VDVD_ERROR GetDecoder( DECODER_ID_TYPE decoderId, Decoder** ppDecoder )
{
VDVD_ERROR error = VDVD_SUCCESS;
VDVD_ASSERT_ERROR( (ppDecoder==NULL), VDVD_ERROR_INVALID_PARAMETER );
switch ( decoderId )
{
case DECODER_ID_PRIMARY: *ppDecoder = &g_primaryDecoder; break;
#if BDROM_ENABLE
case DECODER_ID_SECONDARY: *ppDecoder = &g_secondaryDecoder; break;
#endif
default:
*ppDecoder = NULL;
error = VDVD_ERROR_INVALID_PARAMETER;
break;
}
return ( error );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -