tci1.c
上传用户:chenpengke
上传日期:2018-03-28
资源大小:44995k
文件大小:15k
- /******************************************************************************
- * File Name : tci.c
- *
- * Description :
- *
- * Author : Marino Congiu, Alessandro Innocenti - Dec 1999
- *
- * (c) Copyright STMicroelectronics - 1999
- ******************************************************************************/
- #define INFO_REPORTING 1
-
- #include <stdio.h>
- #include <stddef.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #include <debug.h>
- #include <stddefs.h>
- #include <stlite.h>
- #include <stevt.h>
- #include <stsubt.h>
- #include <common.h>
- #include <apdu.h>
- #include <setup.h>
- #define GLOBAL_DATA
- #include "app_data.h"
- #define NUMTC 5
- #define VIDEO_PID 0 /* No Video stream */
- #define AUDIO_PID 0 /* No Audio stream */
- #define PCR_PID 0 /* No Sincronization */
- #define GET_MESSAGE_DELAY CLOCKS_PER_SEC / 10
- #define PAUSE_BASE CLOCKS_PER_SEC / 10
- #define CACHE_SIZE (20 * 1024)
- #ifdef RDE_DISPLAY_SERVICE
- #define USING_RDE_DISPLAY 1
- #else
- #define USING_OSD_DISPLAY 1
- #endif
-
- #ifdef USING_OSD_DISPLAY
- #define DISPLAY_SERVICE STSUBT_OSD_DisplayService
- #define DISPLAY_REPORT
- #define NUM_LOOP 2
- #elif defined USING_RDE_DISPLAY
- extern void STSUBT_TEST_Report (void);
- #define DISPLAY_SERVICE STSUBT_RDE_DisplayService
- #define DISPLAY_REPORT
- #define NUM_LOOP 2
- #elif defined USING_TEST_DISPLAY
- extern void STSUBT_TEST_Report (void);
- #define DISPLAY_SERVICE STSUBT_TEST_DisplayService
- #define DISPLAY_REPORT STSUBT_TEST_Report()
- #define NUM_LOOP 2
- #else
- #define DISPLAY_SERVICE STSUBT_NULL_DisplayService
- #define DISPLAY_REPORT
- #define NUM_LOOP 2
- #endif
- #define exit_failure(tcnum)
- {
- ERROR_MSG(("TC_%u: ^^^Failedn",tcnum));
- INFO_MSG(("============================================================="));
- return(EXIT_FAILURE);
- }
- /* ----------------------------------------------------------------------- */
- /* ------------------------ define subtitling demo ----------------------- */
- /* ----------------------------------------------------------------------- */
- int main (void)
- {
- ST_DeviceName_t DeviceName="SUBT0";
- STSUBT_Handle_t SubtHandle;
- STSUBT_InitParams_t InitParams;
- STSUBT_OpenParams_t OpenParams;
- STSUBT_ShowParams_t ShowParams;
- STSUBT_TermParams_t TermParams;
- ST_ErrorCode_t ST_ErrorCode;
-
- APDU_t *APDU_List;
- SegmentBuffer_t SegmentBuffer;
- U32 NumAPDU = 0;
- U32 ContAPDU = 0;
- U32 ContLoop = 0;
- U32 SegmentMore = 0;
- U32 APDUPacketLength =0;
- U32 APDUPacketTag =0;
- U8 APDUReplyData[3] ;
- STSUBT_CallingMode_t CallingMode;
- char *TXTFileName[NUMTC];
- char *APDFileName[NUMTC];
- char *SEGFileName[NUMTC];
- char *TCName[NUMTC];
- TXTFileName[0]="../../ci/tci1a.txt";
- APDFileName[0]="../../ci/tci1a.apd";
- SEGFileName[0]="../../ci/tci1.seg";
- TXTFileName[1]="../../ci/tci1b.txt";
- APDFileName[1]="../../ci/tci1b.apd";
- SEGFileName[1]="../../ci/tci1.seg";
- TXTFileName[2]="../../ci/tci1c.txt";
- APDFileName[2]="../../ci/tci1c.apd";
- SEGFileName[2]="../../ci/tci1.seg";
- TXTFileName[3]="../../ci/tci1d.txt";
- APDFileName[3]="../../ci/tci1d.apd";
- SEGFileName[3]="../../ci/tci1.seg";
- TXTFileName[4]="../../ci/insect.txt";
- APDFileName[4]="../../ci/insect.apd";
- SEGFileName[4]="../../ci/insect.seg";
- TCName[0]="TC_01: Showing subtitles displays by using scene_end_mark()";
- TCName[1]="TC_02: Deferring displays using scene_done_message() and scene_control()";
- TCName[2]="TC_03: Pausing and resuming decoder using decoder_continue_flag";
- TCName[3]="TC_04: Pausing and resuming decoder using decoder_pause() and decoder_resume()";
- TCName[4]="TC_05: Showing stored displays using scene_control() APDUs";
- TermParams.ForceTerminate = FALSE;
- /* Init ST20 core */
- if ( BOOT_Init() != ST_NO_ERROR)
- {
- return ( EXIT_FAILURE );
- }
- /* Init of required driver */
- if ( STAPISupportDriverSetup() != ST_NO_ERROR)
- {
- return ( EXIT_FAILURE );
- }
- if (STAPISubscribeEvents (DeviceName)!= ST_NO_ERROR)
- {
- return ( EXIT_FAILURE );
- }
- strcpy(OpenParams.stevt_name, EVTDeviceName);
- strcpy(OpenParams.stclkrv_name, CLKRVDeviceName);
- /* Init of all driver */
- if (STAPIDriverSetup() != 0)
- {
- FATAL_MSG(("Main: Failed hardware initialization!n"));
- return(EXIT_FAILURE);
- }
- InitParams.MemoryPartition = SystemPartition;
- InitParams.FullScreenDisplayEnabled = FALSE;
- InitParams.CommonInterfaceEnabled = TRUE;
- InitParams.ObjectCacheSize = CACHE_SIZE;
- if ((ST_ErrorCode = STSUBT_Init(DeviceName, &InitParams)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Initializing the drivern"));
- exit_failure(0);
- }
- OpenParams.WorkingMode = STSUBT_OverlayMode;
- if ((ST_ErrorCode = STSUBT_Open(DeviceName,
- &OpenParams,&SubtHandle)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Opening the drivern"));
- exit_failure(0);
- }
- if ((ST_ErrorCode = STSUBT_Start(SubtHandle)) !=ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Starting the drivern"));
- exit_failure(0);
- }
-
- ShowParams.DisplayServiceName = DISPLAY_SERVICE;
- ShowParams.RDEBuffer_p = Setup_RDEBuffer_p;
- ShowParams.RDEBufferSize = RDE_BUFFER_SIZE;
- if ((ST_ErrorCode = STSUBT_OutStart(SubtHandle, ShowParams)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Enabling Displayn"));
- exit_failure(0);
- }
- for (ContLoop = 0 ; ContLoop < NUMTC; ContLoop++)
- {
- INFO_MSG(("============================================================="));
- INFO_MSG((TCName[ContLoop]));
- if ((NumAPDU =DecodeAPDUFile(TXTFileName[ContLoop],APDFileName[ContLoop]))==0)
- {
- ERROR_MSG(("ERROR Decoding TXT APDU File"));
- exit_failure((ContLoop+1));
- }
- DEBUG_MSG(("** Main: ----- APDUFile Decoded ------ **n"));
- if ((NumAPDU = LoadAPDUFile(APDFileName[ContLoop], &APDU_List)) == 0)
- {
- ERROR_MSG(("ERROR Loading APDU File"));
- exit_failure((ContLoop+1));
- }
- DEBUG_MSG(("** Main: ----- APDUFile Loaded ------ **n"));
- if (LoadSegmentFile(SEGFileName[ContLoop], &SegmentBuffer) == EXIT_FAILURE)
- {
- ERROR_MSG(("ERROR Loading Segment File"));
- exit_failure((ContLoop+1));
- }
- DEBUG_MSG(("Segment Buffer Size = %d",SegmentBuffer.SegmentBufferLength));
- for (ContAPDU = 0 ; ContAPDU < NumAPDU ; ContAPDU++)
- {
- APDUReplyData[0] = 0;
- APDUReplyData[1] = 0;
- APDUReplyData[2] = 0;
- APDUPacketLength = 0;
- APDUPacketTag = 0;
- CallingMode = 0;
- switch (APDU_List[ContAPDU].APDU_Tag)
- {
- case STSUBT_SUBTITLE_SEGMENT_LAST_TAG :
- case STSUBT_SUBTITLE_DOWNLOAD_LAST_TAG :
- if (SegmentMore == 0)
- {
- PeekNextSegment (&SegmentBuffer);
- }
- if (STSUBT_InsertPacket(SubtHandle,
- APDU_List[ContAPDU].APDU_Tag,
- (SegmentBuffer.SegmentLength - SegmentMore),
- (U8*)(SegmentBuffer.PointerToSegment) + SegmentMore) !=
- ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Inserting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- SegmentMore = 0;
- task_delay(APDU_List[ContAPDU].Pause * PAUSE_BASE);
- break;
- case STSUBT_SUBTITLE_SEGMENT_MORE_TAG :
- case STSUBT_SUBTITLE_DOWNLOAD_MORE_TAG :
- if (SegmentMore == 0)
- {
- PeekNextSegment (&SegmentBuffer);
- }
- if (STSUBT_InsertPacket(SubtHandle,
- APDU_List[ContAPDU].APDU_Tag,
- APDU_List[ContAPDU].ObjectId,
- (U8*)(SegmentBuffer.PointerToSegment) + SegmentMore) !=
- ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Inserting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- SegmentMore += APDU_List[ContAPDU].ObjectId;
- break;
- case STSUBT_SCENE_END_MARK_TAG :
- case STSUBT_SCENE_CONTROL_TAG :
- if (STSUBT_InsertPacket(SubtHandle,
- APDU_List[ContAPDU].APDU_Tag,
- 1,
- &(APDU_List[ContAPDU].Data)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Inserting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- task_delay(APDU_List[ContAPDU].Pause * PAUSE_BASE);
- break;
- case STSUBT_FLUSH_DOWNLOAD_TAG :
- case STSUBT_DECODER_PAUSE_TAG :
- case STSUBT_DECODER_RESUME_TAG :
- if (STSUBT_InsertPacket(SubtHandle,
- APDU_List[ContAPDU].APDU_Tag,
- 0,
- NULL) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Inserting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- task_delay(APDU_List[ContAPDU].Pause * PAUSE_BASE);
- break;
- case STSUBT_DISPLAY_MESSAGE_TAG :
- ST_ErrorCode = STSUBT_GetMessagePacket(SubtHandle,
- &APDUPacketTag,
- &APDUPacketLength,
- (void*)APDUReplyData);
- while(ST_ErrorCode == STSUBT_ERROR_NO_PACKET_AVAILABLE)
- {
- ST_ErrorCode = STSUBT_GetMessagePacket(SubtHandle,
- &APDUPacketTag,
- &APDUPacketLength,
- (void*)APDUReplyData);
- task_delay(GET_MESSAGE_DELAY);
- }
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: Error Getting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- if (APDUReplyData[0] != APDU_List[ContAPDU].Data)
- {
- ERROR_MSG(("ERROR: Wrong Error Expected = %x Returned = %x",
- APDU_List[ContAPDU].Data,
- APDUReplyData[0]));
- exit_failure((ContLoop+1));
- }
- break;
- case STSUBT_SCENE_DONE_MESSAGE_TAG :
- CallingMode = STSUBT_Blocking;
- ST_ErrorCode = STSUBT_GetReplyPacket(SubtHandle,
- &APDUPacketTag,
- &APDUPacketLength,
- (void*)APDUReplyData,
- CallingMode);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: Error Getting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- if (APDUPacketTag != APDU_List[ContAPDU].APDU_Tag)
- {
- ERROR_MSG(("ERROR: Wrong Tag Expected = %x Returned = %x",
- APDU_List[ContAPDU].APDU_Tag,
- APDUPacketTag));
- exit_failure((ContLoop+1));
- }
- if (APDUPacketLength != 1)
- {
- ERROR_MSG(("ERROR: Wrong Length Expected = %d Returned = %d",
- 1,APDUPacketLength));
- exit_failure((ContLoop+1));
- }
- if (APDUReplyData[0] != APDU_List[ContAPDU].Data)
- {
- ERROR_MSG(("ERROR: Wrong Data Expected = %x Returned = %x",
- APDU_List[ContAPDU].Data,
- APDUReplyData[0]));
- exit_failure((ContLoop+1));
- }
- break;
- case STSUBT_DOWNLOAD_REPLY_TAG :
- CallingMode = STSUBT_Blocking;
- ST_ErrorCode = STSUBT_GetReplyPacket(SubtHandle,
- &APDUPacketTag,
- &APDUPacketLength,
- (void*)APDUReplyData,
- CallingMode);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: Error Getting APDU Packetn"));
- exit_failure((ContLoop+1));
- }
- if (APDUPacketTag != APDU_List[ContAPDU].APDU_Tag)
- {
- ERROR_MSG(("ERROR: Wrong Tag Expected = %x Returned = %x",
- APDU_List[ContAPDU].APDU_Tag,
- APDUPacketTag));
- exit_failure((ContLoop+1));
- }
- if (APDUPacketLength != 3)
- {
- ERROR_MSG(("ERROR: Wrong Length Expected = %d Returned = %d",
- 3,APDUPacketLength));
- exit_failure((ContLoop+1));
- }
- if (APDUReplyData[2] != APDU_List[ContAPDU].Data)
- {
- ERROR_MSG(("ERROR: Wrong Data Expected = %x Returned = %x",
- APDU_List[ContAPDU].Data,
- APDUReplyData[2]));
- exit_failure((ContLoop+1));
- }
- if ( ((APDUReplyData[0] << 8) + APDUReplyData[1]) !=
- APDU_List[ContAPDU].ObjectId)
- {
- ERROR_MSG(("ERROR: Wrong ObjectId Expected = %d Returned = %d",
- APDU_List[ContAPDU].ObjectId,
- ((APDUReplyData[0] << 8) + APDUReplyData[1]) ));
- exit_failure((ContLoop+1));
- }
- break;
- default :
- ERROR_MSG(("Main: INVALID APDU TAG - APDU n = %d APDUTAG = %x",
- ContAPDU,
- APDU_List[ContAPDU].APDU_Tag));
- exit_failure((ContLoop+1));
- break;
- }
- }
- FreeSegmentBuffer(&SegmentBuffer);
- FreeAPDUList(&APDU_List);
- INFO_MSG(("TC_0%d: ^^^Passed",(ContLoop+1)));
- }
- INFO_MSG(("============================================================="));
- if ((ST_ErrorCode = STSUBT_Hide(SubtHandle)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Disabling Displayn"));
- exit_failure(1);
- }
- if ((ST_ErrorCode = STSUBT_Stop(SubtHandle)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Stopping the drivern"));
- exit_failure(1);
- }
- if ((ST_ErrorCode = STSUBT_Close(SubtHandle)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Closing the drivern"));
- exit_failure(1);
- }
- if ((ST_ErrorCode = STSUBT_Term(DeviceName,&TermParams)) != ST_NO_ERROR)
- {
- FATAL_MSG(("Main: error Terminating the drivern"));
- exit_failure(1);
- }
- DISPLAY_REPORT;
- STAPIDriverTerminate();
- STAPIUnsubscribeEvents (DeviceName);
- STAPISupportDriverTerminate();
- /* --- terminate hardware system --- */
-
- return (EXIT_SUCCESS);
- }