📄 pbc_stnselect.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_stnselect.cpp
*
* Stream Selection module of the Playback Control Engine.
* The Stream Selection module is responsible for selecting an appropriate stream
* number for audio, presentation graphics and text subtitle, and interactive graphics streams.
* This API is intended to be private and used by other Playback
* Control Engine modules only.
*
* $Id: pbc_stnselect.cpp,v 1.23 2006/10/25 23:50:09 rbehe Exp $
*/
#include "vdvd_types.h"
#include "playctrl.h"
#include "pbc_stnselect.h"
#include "pbc_register.h"
#include "../mvplaylistdb.h"
#ifdef DMALLOC
#include "dmalloc.h"
#endif
/* Debug macros */
#define DBG_STNSELECT DBG_ERROR
#define DBG_ON(x) (DBG_STNSELECT >= x)
/**
* Local constants
*/
#define TEXTST_LANG_BASE_REG (48)
#define TEXTST_LANG_NUMBER_OF_REGS (14)
/* Text Subtitle Language Table */
static const ULONG TEXTST_LANG_TABLE[][32] =
{
{0x0061626b, 0x00616365, 0x00616368, 0x00616461, 0x00616172, 0x00616668, 0x00616672, 0x00616661,
0x00616b61, 0x00616b6b, 0x00737169, 0x00616c65, 0x00616c67, 0x00747574, 0x00616d68, 0x00617061,
0x00617261, 0x00617263, 0x00617270, 0x0061726e, 0x00617277, 0x00687965, 0x00617274, 0x0061736d,
0x00617468, 0x00617573, 0x006d6170, 0x00617661, 0x00617665, 0x00617761, 0x0061796d, 0x00617a65},
{0x0062616e, 0x00626174, 0x0062616c, 0x0062616d, 0x00626169, 0x00626164, 0x00626e74, 0x00626173,
0x0062616b, 0x00657573, 0x0062746b, 0x0062656a, 0x0062656c, 0x0062656d, 0x0062656e, 0x00626572,
0x0062686f, 0x00626968, 0x0062696b, 0x0062696e, 0x00626973, 0x00627261, 0x00627265, 0x00627567,
0x0062756c, 0x00627561, 0x006d7961, 0x00636164, 0x00636172, 0x00636174, 0x00636175, 0x00636562},
{0x0063656c, 0x00636169, 0x00636867, 0x00636d63, 0x00636861, 0x00636865, 0x00636872, 0x00636879,
0x00636862, 0x007a686f, 0x0063686e, 0x00636870, 0x0063686f, 0x00636875, 0x0063686b, 0x00636876,
0x00636f70, 0x00636f72, 0x00636f73, 0x00637265, 0x006d7573, 0x00637270, 0x00637065, 0x00637066,
0x00637070, 0x00687276, 0x00637573, 0x00636573, 0x0064616b, 0x0064616e, 0x00646179, 0x0064656c},
{0x0064696e, 0x00646976, 0x00646f69, 0x00646772, 0x00647261, 0x00647561, 0x006e6c64, 0x0064756d,
0x00647975, 0x00647a6f, 0x00656669, 0x00656779, 0x00656b61, 0x00656c78, 0x00656e67, 0x00656e6d,
0x00616e67, 0x0065706f, 0x00657374, 0x00657765, 0x0065776f, 0x0066616e, 0x00666174, 0x0066616f,
0x0066696a, 0x0066696e, 0x00666975, 0x00666f6e, 0x00667261, 0x0066726d, 0x0066726f, 0x00667279},
{0x00667572, 0x0066756c, 0x00676161, 0x00676c61, 0x00676c67, 0x006c7567, 0x00676179, 0x00676261,
0x0067657a, 0x006b6174, 0x00646575, 0x00676d68, 0x00676f68, 0x0067656d, 0x0067696c, 0x00676f6e,
0x00676f72, 0x00676f74, 0x00677262, 0x00677263, 0x00656c6c, 0x0067726e, 0x0067756a, 0x00677769,
0x00686169, 0x00686175, 0x00686177, 0x00686562, 0x00686572, 0x0068696c, 0x0068696d, 0x0068696e},
{0x00686d6f, 0x00686974, 0x00686d6e, 0x0068756e, 0x00687570, 0x00696261, 0x0069736c, 0x0069626f,
0x00696a6f, 0x00696c6f, 0x00696e63, 0x00696e65, 0x00696e64, 0x00696e61, 0x00696c65, 0x00696b75,
0x0069706b, 0x00697261, 0x00676c65, 0x006d6761, 0x00736761, 0x0069726f, 0x00697461, 0x006a706e,
0x006a6177, 0x006a7262, 0x006a7072, 0x006b6162, 0x006b6163, 0x006b616c, 0x006b616d, 0x006b616e},
{0x006b6175, 0x006b6161, 0x006b6172, 0x006b6173, 0x006b6177, 0x006b617a, 0x006b6861, 0x006b686d,
0x006b6869, 0x006b686f, 0x006b696b, 0x006b6d62, 0x006b696e, 0x006b6972, 0x006b6f6d, 0x006b6f6e,
0x006b6f6b, 0x006b6f72, 0x006b6f73, 0x006b7065, 0x006b726f, 0x006b7561, 0x006b756d, 0x006b7572,
0x006b7275, 0x006b7574, 0x006c6164, 0x006c6168, 0x006c616d, 0x006c616f, 0x006c6174, 0x006c6176},
{0x006c747a, 0x006c657a, 0x006c696e, 0x006c6974, 0x006c6f7a, 0x006c7562, 0x006c7561, 0x006c7569,
0x006c756e, 0x006c756f, 0x006c7573, 0x006d6b64, 0x006d6164, 0x006d6167, 0x006d6169, 0x006d616b,
0x006d6c67, 0x006d7361, 0x006d616c, 0x006d6c74, 0x006d6472, 0x006d616e, 0x006d6e69, 0x006d6e6f,
0x00676c76, 0x006d7269, 0x006d6172, 0x0063686d, 0x006d6168, 0x006d7772, 0x006d6173, 0x006d796e},
{0x006d656e, 0x006d6963, 0x006d696e, 0x006d6973, 0x006d6f68, 0x006d6f6c, 0x006d6b68, 0x006c6f6c,
0x006d6f6e, 0x006d6f73, 0x006d756c, 0x006d756e, 0x006e6168, 0x006e6175, 0x006e6176, 0x006e6465,
0x006e626c, 0x006e646f, 0x006e6570, 0x006e6577, 0x006e6961, 0x006e6963, 0x00737361, 0x006e6975,
0x006e6f6e, 0x006e6169, 0x006e6f72, 0x006e7562, 0x006e796d, 0x006e7961, 0x006e796e, 0x006e796f},
{0x006e7a69, 0x006f6369, 0x006f6a69, 0x006f7269, 0x006f726d, 0x006f7361, 0x006f7373, 0x006f746f,
0x0070616c, 0x00706175, 0x00706c69, 0x0070616d, 0x00706167, 0x0070616e, 0x00706170, 0x00706161,
0x00666173, 0x0070656f, 0x00706869, 0x0070686e, 0x00706f6e, 0x00706f6c, 0x00706f72, 0x00707261,
0x0070726f, 0x00707573, 0x00717565, 0x00726f68, 0x0072616a, 0x00726170, 0x00726172, 0x00726f61},
{0x00726f6e, 0x00726f6d, 0x0072756e, 0x00727573, 0x0073616c, 0x0073616d, 0x00736d69, 0x00736d6f,
0x00736164, 0x00736167, 0x0073616e, 0x00736174, 0x00737264, 0x00736173, 0x0073636f, 0x0073656c,
0x0073656d, 0x00737270, 0x00737272, 0x0073686e, 0x00736e61, 0x00736964, 0x00626c61, 0x00736e64,
0x0073696e, 0x00736974, 0x0073696f, 0x0064656e, 0x00736c61, 0x00736c6b, 0x00736c76, 0x00736f67},
{0x00736f6d, 0x00736f6e, 0x00736e6b, 0x0077656e, 0x006e736f, 0x00736f74, 0x00736169, 0x00737061,
0x0073756b, 0x00737578, 0x0073756e, 0x00737573, 0x00737761, 0x00737377, 0x00737765, 0x00737972,
0x0074676c, 0x00746168, 0x00746169, 0x0074676b, 0x00746d68, 0x0074616d, 0x00746174, 0x0074656c,
0x00746572, 0x00746574, 0x00746861, 0x00626f64, 0x00746967, 0x00746972, 0x0074656d, 0x00746976},
{0x00746c69, 0x00747069, 0x00746b6c, 0x00746f67, 0x00746f6e, 0x00747369, 0x0074736f, 0x0074736e,
0x0074756d, 0x00747572, 0x006f7461, 0x0074756b, 0x0074766c, 0x00747976, 0x00747769, 0x00756761,
0x00756967, 0x00756b72, 0x00756d62, 0x00756e64, 0x00757264, 0x00757a62, 0x00766169, 0x0076656e,
0x00766965, 0x00766f6c, 0x00766f74, 0x0077616b, 0x0077616c, 0x00776172, 0x00776173, 0x0063796d},
{0x00776f6c, 0x0078686f, 0x00736168, 0x0079616f, 0x00796170, 0x00796964, 0x00796f72, 0x0079706b,
0x007a6e64, 0x007a6170, 0x007a656e, 0x007a6861, 0x007a756c, 0x007a756e, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff}
};
/**
* Local functions.
*/
static BOOLEAN pbcstnselectCheckAudioCapability(uint32 uiStreamNumber, STN_TABLE *pStnTable, BOOLEAN fSurround);
static BOOLEAN pbcstnselectCheckLanguageCapability(UBYTE *pubLangCode);
static BOOLEAN pbcstnselectCheckTextSTCapability(uint32 uiStreamNumber, STN_TABLE *pStnTable);
/**
* PbcStnSelectAudio -- Set the audio stream player register. Set it to the specified
* audio stream number as long as the player is capable
* of playing the specified audio stream. If the player is not
* capable of playing the specified audio stream, then select an
* audio stream it is capable of playing from the stn table.
* If there are no audio streams that the player is capable of playing,
* then set the audio stream player register to its initial value (0xff).
*
* @param
* uiStreamNumber -- audio stream number
* pStnTable -- pointer to stn table from current playitem being played
* pSelectedStn - pointer that gets set to seleted stream number
*
* @retval
* PLAYCTRL_STATUS
*/
PLAYCTRL_STATUS PbcStnSelectAudio(uint32 uiStreamNumber, STN_TABLE *pStnTable, uint32 *pSelectedStn)
{
BOOLEAN fAudioCapability = FALSE;
/* Check that stn table is valid */
if ( (pStnTable == NULL) || (pSelectedStn == NULL) )
{
DBGPRINT(DBG_ON(DBG_ERROR), ("PbcStnSelectAudio: NULL pointer!\n"));
return (PLAYCTRL_NULL_POINTER);
}
if (pStnTable->number_of_primary_audio_stream_entries == 0)
{
/* No streams exist in this playitem, don't change anything */
fAudioCapability = TRUE;
}
/*
* Check if player is capable of playing specified audio stream.
*/
else if ( (uiStreamNumber > 0) && (uiStreamNumber <= pStnTable->number_of_primary_audio_stream_entries) )
{
fAudioCapability = pbcstnselectCheckAudioCapability(uiStreamNumber, pStnTable, FALSE);
}
/*
* If player is capable of playing specified audio stream, then select the specified audio stream.
* Otherwise, do further processing to determine what audio stream to select.
*/
if (fAudioCapability == TRUE)
{
/* Set selected stream number */
*pSelectedStn = uiStreamNumber;
}
else
{
UBYTE i;
uint32 uiAudioLang;
BOOLEAN fCondA = FALSE;
BOOLEAN fCondAB = FALSE;
BOOLEAN fCondAC = FALSE;
BOOLEAN fCondABC = FALSE;
uint32 stream = 0;
/* Get the value of the user configuration setting for default audio language */
PbcRegGetPSR(PLAYCTRL_PSR_AUDIO_LANG, &uiAudioLang);
/*
* Check all audio streams in the stn table for the following three conditions:
* a) Check if player is capable of playing audio stream.
* b) Check correspondence between language code of audio stream and the
* user configuration setting for default audio language.
* c) Check surround capability.
*
* The first stream that satisfies a, b, and c should be used.
* If no stream satisfies a, b, and c then the first stream that satisfies
* a and b should be used. If no stream satisfies a and b, then the first stream
* that satisfies a and c should be used. If no stream satisfies a and c, then
* the first stream that satisfies a should be used. If no stream satisfies a, then
* no stream is used.
*/
for (i = 0; i < pStnTable->number_of_primary_audio_stream_entries; i++)
{
/*
* Check if player is capable of playing audio stream.
*/
if (pbcstnselectCheckAudioCapability( (i + 1), pStnTable, FALSE) == TRUE)
{
/*
* Check correspondence between language code of audio stream and the
* user configuration setting for default audio language.
*/
if ( (pStnTable->primary_audio_stream[i].stream_attributes.audio_language_code[0] == (UBYTE)( (uiAudioLang & 0x00ff0000) >> 16) ) &&
(pStnTable->primary_audio_stream[i].stream_attributes.audio_language_code[1] == (UBYTE)( (uiAudioLang & 0x0000ff00) >> 8) ) &&
(pStnTable->primary_audio_stream[i].stream_attributes.audio_language_code[2] == (UBYTE)(uiAudioLang & 0x000000ff) ) )
{
/*
* Check surround capability.
*/
if (pbcstnselectCheckAudioCapability( (i + 1), pStnTable, TRUE) == TRUE)
{
/*
* If there is not already a stream that satisfies all three conditions,
* then keep track of this stream number.
*/
if (fCondABC == FALSE)
{
fCondABC = TRUE;
stream = i + 1;
}
}
else
{
/*
* If there is not already a stream that satisfies conditions a and b,
* nor conditions a, b and c, then keep track of this stream number.
*/
if ( (fCondAB == FALSE) && (fCondABC == FALSE) )
{
fCondAB = TRUE;
stream = i + 1;
}
}
}
else
{
/*
* Check surround capability.
*/
if (pbcstnselectCheckAudioCapability( (i + 1), pStnTable, TRUE) == TRUE)
{
/*
* If there is not already a stream that satisfies conditions a and c,
* conditions a and b, nor conditions a, b and c, then keep track of this
* stream number.
*/
if ( (fCondAC == FALSE) && (fCondAB == FALSE) && (fCondABC == FALSE) )
{
fCondAC = TRUE;
stream = i + 1;
}
}
else
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -