📄 pe_consumer_bdrom.cpp
字号:
/*
* Delay so that all data has time to be passed on to the ig decoder.
* @todo: We may want to find a nicer way of doing this.
*/
OS_TaskDelayMsec(100);
if (m_fPrefill == TRUE)
{
if (m_fSyncPrefill == TRUE)
{
/* clear the prefill flag */
m_fPrefill = FALSE;
}
else
{
/* clear the prefill flag */
m_fPrefill = FALSE;
/* send the event */
PE_PREFILL_EVENT_INFO prefill_info = {m_ConsumerInput};
SendEvent(PE_EVENT_ASYNC_PREFILL, &prefill_info);
}
}
}
/* If this is a textst input, send prefill event before end of stream */
if (m_ConsumerInput == INPUT_BDROM_SUBPATH_TEXT_SUBTITLE)
{
/*
* Delay so that all data has time to be passed on to the textst decoder.
* @todo: We may want to find a nicer way of doing this.
*/
OS_TaskDelayMsec(100);
/* Tell TextST decoder to load data */
if (TextSTLoad(m_st_dec) != TEXTST_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("cPEConsumer_BDROM::ProcessEndOfStream() - TextSTLoad() Failed!\n"));
}
/* If pe is already in run state, start the textst decoder */
if (PE_CONSUMER_STATE_RUN == m_ConsumerState)
{
if (TextSTRun(m_st_dec) != TEXTST_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("cPEConsumer_BDROM::ProcessEndOfStream() - Failed to start textst decoder!\n"));
}
}
if (m_fPrefill == TRUE)
{
if (m_fSyncPrefill == TRUE)
{
/* clear the prefill flag */
m_fPrefill = FALSE;
}
else
{
/* clear the prefill flag */
m_fPrefill = FALSE;
/* send the event */
PE_PREFILL_EVENT_INFO prefill_info = {m_ConsumerInput};
SendEvent(PE_EVENT_ASYNC_PREFILL, &prefill_info);
}
}
}
status = cPEConsumer::ProcessEndOfStream(StreamContext);
/* check for an error */
if (PE_STATUS_FAILED(status) == FALSE)
{
/* there was no error so it is safe to check the event status */
if ( (status & PE_EVNT_WAIT_FOR_DONE) == PE_EVNT_WAIT_FOR_DONE)
{
IGSynchronize(m_ig_dec, IG_DECODE_ASYNC);
}
}
return (status);
}
/**
* If active start consuming and presenting AV data.
*
* @return PE_STATUS
*/
PE_STATUS cPEConsumer_BDROM::processData(PEINPUTMESSAGE *pInMessage)
{
PE_STATUS status = PE_SUCCESS;
#ifdef DRM_SUPPORT
if (AES_ECB == pInMessage->Encryption)
{
cPayload *pDecPayload = NULL;
BYTE *pDec;
ULONG ulNumAu;
/* the offset of the desired data from the base data */
ULONG offset = (BYTE*)pInMessage->payload->get_rd_ptr() - (BYTE*)pInMessage->payload->get_base_ptr();
/* pointer to the base data */
BYTE *pbData = (BYTE*)pInMessage->payload->get_base_ptr();
/* the size of the base data */
ULONG ulSize = (ULONG)pInMessage->payload->get_size() + offset;
#if DBG_ON(DBG_VERBOSE)
DbgPrint(("processData -- offset=%u, ulDataSize=%u, pbData=%p, ulSize=%u\n",
offset, pInMessage->payload->get_size(), pbData, ulSize));
#endif
/* get a payload for decryption */
while (1)
{
pDecPayload = NEW_PAYLOAD;
if (pDecPayload != NULL)
{
break;
}
OS_TaskYield();
}
pDec = (BYTE *)pDecPayload->get_wr_ptr();
/*
* Calculate number of aligned units this data consumes, and handle the case
* where data is not aligned to AU's.
*/
ulNumAu = ( (ulSize % AU_SIZE) == 0) ? ulSize / AU_SIZE : (ulSize / AU_SIZE) + 1;
/*
* TODO-SDK - Decrypt data from original payload into new payload (pDecPayload).
*/
/* add *all* of the decryped data to the payload*/
pDecPayload->add_data(ulSize);
/* set the read pointer to the correct offset point */
pDecPayload->set_rd_ptr((BYTE*)pDecPayload->get_rd_ptr() + offset);
/* swap out the message's encrypted payload for the newly decrypted one */
delete (pInMessage->payload);
pInMessage->payload = pDecPayload;
}
#endif
#ifdef DRM_BDPLUS_SUPPORT
/*
* TODO-SDK - If BD+ DRM is applied, transform the payload here.
*/
DbgPrint(("%s:%d - NO DRM_BDPLUS_SUPPORT\n", __FILE__, __LINE__));
#endif
if (status == PE_SUCCESS)
{
switch ( m_ConsumerInput )
{
case INPUT_MAIN:
status = SendPayloadToDecoder(m_videoDecode[0], pInMessage->payload);
break;
case INPUT_SECONDARY:
status = SendPayloadToDecoder(m_videoDecode[1], pInMessage->payload);
break;
case INPUT_BDROM_SUBPATH_INTERACTIVE_GRAPHICS:
status = SendPayloadToInputInteractiveGraphics(pInMessage->payload);
break;
case INPUT_BDROM_SUBPATH_TEXT_SUBTITLE:
status = SendPayloadToInputTextSubtitle(pInMessage->payload);
break;
}
if (pInMessage->SequenceEnd == TRUE)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("cPEConsumer_BDROM::processData() - Received Sequence End!!\n"));
ForceLastPictureDecode();
}
}
return(status);
}
/**
* Process an info payload.
*
* @return PE_STATUS
*/
PE_STATUS cPEConsumer_BDROM::processInfo(PEINPUTMESSAGE *pInMessage)
{
PE_STATUS status = PE_SUCCESS;
INFOPAYLOAD *infoPayload;
BYTE* base_ptr;
TCH_PAYLOAD(pInMessage->payload);
infoPayload = (INFOPAYLOAD*)pInMessage->payload->get_base_ptr();
/* Check for encryption key */
if (infoPayload->bType == INFOTYPE_FONTLIST)
{
base_ptr = infoPayload->data_packet.data;
/* load fonts */
if (TextSTLoadFonts(m_st_dec, (PVOID)base_ptr) != TEXTST_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("cPEConsumer_BDROM::processInfo() - Failed to load textst fonts!\n"));
status = PE_FAILURE;
}
/* set textst system base time */
if (TextSTSetTimeBase(m_st_dec, MAKE_DWORD(&base_ptr[(base_ptr[0] * 5) + 1]) ) != TEXTST_SUCCESS)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("cPEConsumer_BDROM::processInfo() - Failed to set textst time base!\n"));
status = PE_FAILURE;
}
}
#ifdef DRM_SUPPORT
if (infoPayload->bType == INFOTYPE_CRYPTKEY)
{
/* get payload info */
base_ptr = infoPayload->data_packet.data;
/* TODO-SDK - This key can be either a cleartext key, handle, or pointer. Adjust the storage
* according to current DRM library. */
/* The payload is an encryption key, we need to save this */
m_key = 0;
m_key = base_ptr[0];
m_key |= base_ptr[1]<<8;
m_key |= base_ptr[2]<<16;
m_key |= base_ptr[3]<<24;
DBGPRINT(DBG_ON(DBG_TRACE), ("processInfo m_key = 0x%x\n", m_key));
}
#endif
#ifdef DRM_BDPLUS_SUPPORT
/* TODO-SDK - If BD+ is active for current, apply fixup to the data packet */
#endif
/* check for time message */
if (infoPayload->bType == INFOTYPE_TIMEPACK)
{
/* TODO-SDK - The following section uses information gathered in the DR to adapt the synchronization
* algorithm for certain discontinuities and stream modes. These conditions may not be necessary for
* all decoders to check and apply changes. */
/* if this is a non-seamless connection then we check the application
* type to determine the correct synchronization model */
if ( ( (infoPayload->time.bTransCond == VDVD_CONNECTION_1) || (infoPayload->time.bTransCond == VDVD_CONNECTION_ABORT) ) && (m_playrate.rate == PLAY_RATE_NORMAL) )
{
if (infoPayload->time.bAppType == 2)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("\n>>>>> %u TIMEBASED SLIDESHOW <<<<<\n", m_ConsumerInput));
/* for a timebased slideshow turn synchronization on and put in discontinuous mode */
if (m_videoDecode[0] != NULL)
{
DBGPRINT(DBG_ON(DBG_TRACE), (">>>>> ENABLE synchronization <<<<<\n\n"));
// set a/v sync mode
}
}
else if (infoPayload->time.bAppType == 3)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("\n>>>>> %u BROWSABLE SLIDESHOW <<<<<\n", m_ConsumerInput));
/* for a browsable slideshow turn off synchronization */
if (m_videoDecode[0] != NULL)
{
DBGPRINT(DBG_ON(DBG_TRACE), (">>>>> DISABLE synchronization <<<<<\n\n"));
// set a/v sync mode
}
}
else if (infoPayload->time.bAppType == 4)
{
while ( (fMainStarted == FALSE) && (m_fStop == FALSE) && (m_fAbort == FALSE) )
{
OS_TaskDelayMsec(10);
}
}
else if (infoPayload->time.bAppType == 1)
{
DBGPRINT(DBG_ON(DBG_TRACE), ("\n>>>>> %u STANDARD MOVIE <<<<<\n", m_ConsumerInput));
/* for a movie turn synchronization on and discontinuous mode off */
if (m_videoDecode[0] != NULL)
{
// set a/v sync mode
}
}
}
if (m_videoDecode[0] != NULL)
{
/* validate the start/stop pts values before we use them */
if (infoPayload->time.ulStartTime < infoPayload->time.ulStopTime)
{
// infoPayload->time.ulStartTime;
// infoPayload->time.ulStopTime;
}
else
{
// ignore start time
// ignore stop time
}
// SDK PRECI
}
}
return (status);
} /* end cPEConsumer_BDROM::processInfo() */
PE_STATUS cPEConsumer_BDROM::SendPayloadToInputInteractiveGraphics(cPayload* pPayload)
{
VDVD_ERROR error = VDVD_SUCCESS;
PE_STATUS status = PE_FAILURE;
unsigned char* payload_buffer = 0;
size_t payload_buffer_size = 0;
if (NULL == pPayload)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s(%d): NULL pPayload\n", __FUNCTION__, __LINE__));
return (PE_NULL_POINTER);
}
payload_buffer = (unsigned char *)pPayload->get_rd_ptr();
payload_buffer_size = pPayload->get_size();
do {
// send data to ig decoder
if ( !VDVD_IS_ERROR(error))
{
return (PE_SUCCESS);
}
// Yeild the processor, try again to send the data
OS_TaskYield();
} while ( (m_fStop == FALSE) && (m_fAbort == FALSE) && (error == VDVD_ERROR_TIMEOUT) );
return (status);
}
PE_STATUS cPEConsumer_BDROM::SendPayloadToInputTextSubtitle(cPayload* pPayload)
{
VDVD_ERROR error = VDVD_SUCCESS;
PE_STATUS status = PE_FAILURE;
unsigned char* payload_buffer = 0;
size_t payload_buffer_size = 0;
if (NULL == pPayload)
{
DBGPRINT(DBG_ON(DBG_ERROR), ("%s(%d): NULL pPayload\n", __FUNCTION__, __LINE__));
return (PE_NULL_POINTER);
}
payload_buffer = (unsigned char *)pPayload->get_rd_ptr();
payload_buffer_size = pPayload->get_size();
do {
// send data to st decoder
if ( !VDVD_IS_ERROR(error))
{
return (PE_SUCCESS);
}
// Yeild the processor, try again to send the data
OS_TaskYield();
} while ( (m_fStop == FALSE) && (m_fAbort == FALSE) && (error == VDVD_ERROR_TIMEOUT) );
return (status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -