iframe.c
上传用户:fy98168
上传日期:2015-06-26
资源大小:13771k
文件大小:20k
源码类别:

DVD

开发平台:

C/C++

  1. /* Includes ---------------------------------------------------------------- */
  2. #include <time.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <task.h>
  7. /* STAPI header------------------------------------------------------------- */
  8. #include "stddefs.h"
  9. #include "stlite.h"
  10. #include "stcommon.h"
  11. #include "stdevice.h"
  12. #include "sttbx.h"
  13. #include "testtool.h"
  14. #include "section.h"
  15. #include "errors.h"
  16. #include "vid.h"
  17. #include "vtg.h"
  18. #include "avslot.h"
  19. #include "stpti_hal.h"
  20. #include "debug.h"
  21. //#include "viddbg.h"
  22. #include "regevent.h"   /* SLSL */
  23. #define I_FRAME_DATA 0
  24. #if (I_FRAME_DATA == 1)
  25. #include "mwaudio.h"
  26. #define I_FRAME_DATA_POINTER (unsigned char*)MPEG1_DATA
  27. #define I_FRAME_DATA_SIZE    sizeof(MPEG1_DATA)
  28. #endif
  29. #if (I_FRAME_DATA == 2)
  30. #include "test.h"
  31. #define I_FRAME_DATA_POINTER (unsigned char*)ucBitMap
  32. #define I_FRAME_DATA_SIZE    sizeof(ucBitMap)
  33. #endif
  34. #if (I_FRAME_DATA == 3)
  35. #include "ggbmpeg.h"
  36. #define I_FRAME_DATA_POINTER (unsigned char*)GoldenGateBridge
  37. #define I_FRAME_DATA_SIZE    sizeof(GoldenGateBridge)
  38. #endif
  39. #define VD_FEED_SIZE (1024*5)
  40. #define DUMMY_BUF_SIZE  (4096)
  41. static  U8     *VID_Mem_p, *VID_Buffer_p;
  42. static  U32     VID_BufferSize;
  43. /* Parameters required for video injection */
  44. static  void *UserBufferStart_p;
  45. static  void *UserBufferStop_p;
  46. static  void *UserBufferCurrent_P;
  47. static  void *VideoInputBuffWptr;
  48. static  void *VideoInputBuffRptr;
  49. static  void *VideoInputBuffStart;
  50. static  void *VideoInputBuffStop;
  51. static semaphore_t * iframeStopDecodeLock ;
  52. static semaphore_t * iframePicDecodeLock ;
  53. /*-------------------------------------------------------------------------
  54. * Function : BackGround_VID_StartDecode
  55. Start the video decoding for the input parameters passed by the user.
  56. * Input    :
  57. * Output   :
  58. * Return   : TRUE if fails, else FALSE.
  59. * ----------------------------------------------------------------------*/
  60. ST_ErrorCode_t BackGround_VID_StartDecode( void )
  61. {
  62.     ST_ErrorCode_t          ErrCode = ST_NO_ERROR;
  63.     STVID_Freeze_t          Freeze;
  64.     STVID_StartParams_t     VIDStartParams;
  65.     STVID_Stop_t    VID_StopMode = STVID_STOP_NOW;
  66.     STVID_WindowParams_t    WinParams = { STVID_WIN_ALIGN_VCENTRE_HCENTRE, STVID_WIN_SIZE_DONT_CARE };
  67.     S32 InputWinPositionX;
  68.     S32 InputWinPositionY;
  69.     U32 InputWinWidth;
  70.     U32 InputWinHeight;
  71.     S32 OutputWinPositionX;
  72.     S32 OutputWinPositionY;
  73.     U32 OutputWinWidth;
  74.     U32 OutputWinHeight;
  75.     
  76.     /*Primary decode is in auto mode whereas secondary decode is in manual mode which is required for resizing*/
  77.     ErrCode = STVID_SetDisplayAspectRatioConversion(VID_ViewPortHandle_Multiple[0], STVID_DISPLAY_AR_CONVERSION_LETTER_BOX/*STVID_DISPLAY_AR_CONVERSION_LETTER_BOX STVID_DISPLAY_AR_CONVERSION_IGNORE*/);
  78.     if ( ErrCode != ST_NO_ERROR )
  79.     {
  80.         STTBX_Print(("STVID_SetDisplayAspectRatioConversion()Failed 0x%08Xn", ErrCode ));
  81.         //return ErrCode;
  82.     }
  83.     ErrCode = STVID_GetIOWindows( VID_ViewPortHandle_Multiple[0],
  84.         &InputWinPositionX,  &InputWinPositionY,
  85.         &InputWinWidth,      &InputWinHeight,
  86.         &OutputWinPositionX, &OutputWinPositionY,
  87.         &OutputWinWidth,     &OutputWinHeight );
  88.     
  89.     if ( ErrCode != ST_NO_ERROR )
  90.     {
  91.         STTBX_Print(("GetIOWindows=%sn", KB_ErrorGetText(ErrCode)));
  92.         STTBX_Print(("Input %d,%d,%d,%dnOutput %d,%d,%d,%dn",
  93.             InputWinPositionX, InputWinPositionY, InputWinWidth, InputWinHeight,
  94.             OutputWinPositionX, OutputWinPositionY, OutputWinWidth, OutputWinHeight ));
  95.     }
  96.     ErrCode = STVID_SetOutputWindowMode(VID_ViewPortHandle_Multiple[0], FALSE, &WinParams);
  97.     if ( ErrCode != ST_NO_ERROR )
  98.     {
  99.         STTBX_Print(("STVID_SetOutputWindowMode()Failed 0x%08Xn", ErrCode ));
  100.     }
  101.     ErrCode = STVID_SetIOWindows(VID_ViewPortHandle_Multiple[0], InputWinPositionX,  InputWinPositionY,
  102.         InputWinWidth,      InputWinHeight,
  103.         OutputWinPositionX, OutputWinPositionY,
  104.         OutputWinWidth,     OutputWinHeight );
  105.     
  106.     if ( ErrCode != ST_NO_ERROR )
  107.     {
  108.         STTBX_Print(("STVID_SetIOWindows()Failed 0x%08Xn", ErrCode ));
  109.         //return ErrCode;
  110.     }
  111.     
  112.     /* stop video */
  113.     Freeze.Field = STVID_FREEZE_FIELD_TOP;
  114.     Freeze.Mode = STVID_FREEZE_MODE_NO_FLICKER;
  115.     ErrCode = STVID_Stop(VID_Handle_Multiple[0], VID_StopMode, &Freeze);
  116.     STTBX_Print(("IFRAME_BackGround_VID_StartDecode:: STVID_STOPn"));
  117.     
  118.     if ( ErrCode != ST_NO_ERROR )
  119.     {
  120.         STTBX_Print(("BackGround: STVID_Stop()=%sn", KB_ErrorGetText(ErrCode) ));
  121.     }
  122.             
  123.     /* start video */
  124.     VIDStartParams.StreamType    = STVID_STREAM_TYPE_ES;
  125.     VIDStartParams.BrdCstProfile = STVID_BROADCAST_DVB;
  126.     VIDStartParams.RealTime      = FALSE;//TRUE;
  127.     VIDStartParams.UpdateDisplay = TRUE;
  128.     VIDStartParams.StreamID      = STVID_IGNORE_ID;
  129.     VIDStartParams.DecodeOnce    = FALSE;
  130.     
  131.     ErrCode = STVID_Start(VID_Handle_Multiple[0], &VIDStartParams);
  132.     STTBX_Print(("IFRAME:: STVID_STARTn"));
  133.     if ( ErrCode != ST_NO_ERROR )
  134.     {
  135.         STTBX_Print(("BackGround: STVID_Start()=%sn", KB_ErrorGetText(ErrCode) ));
  136.         
  137.        Freeze.Field = STVID_FREEZE_FIELD_TOP;
  138.             Freeze.Mode = STVID_FREEZE_MODE_NO_FLICKER;
  139.             ErrCode = STVID_Stop(VID_Handle_Multiple[0], VID_StopMode, &Freeze);  /*Stop again*/
  140.             STTBX_Print(("IFRAME_BackGround_VID_StartDecode:: STVID_STOPn"));
  141.             
  142.             ErrCode = STVID_Start(VID_Handle_Multiple[0], &VIDStartParams); /*Restart*/
  143.             STTBX_Print(("IFRAME:: STVID_STARTn"));
  144.             if ( ErrCode != ST_NO_ERROR )
  145.                 STTBX_Print(("BackGround: STVID_Start()=%sn", KB_ErrorGetText(ErrCode) ));
  146.     }
  147.     
  148.     ErrCode = STVID_DisableSynchronisation(VID_Handle_Multiple[0]);
  149.     if ( ErrCode != ST_NO_ERROR )
  150.     {
  151.         STTBX_Print(("STVID_DisableSyncronisation()=%sn", KB_ErrorGetText(ErrCode) ));
  152.     }
  153.     
  154.     
  155.     return ErrCode;
  156. }
  157. static ST_ErrorCode_t GetWritePtrPTIFctLive(void * const Handle_p, void ** const Address_p)
  158. {
  159.     ST_ErrorCode_t          ErrCode = ST_NO_ERROR;
  160.     ErrCode = STPTI_BufferGetWritePointer((STPTI_Buffer_t)Handle_p,Address_p);
  161.     if ( ErrCode != ST_NO_ERROR )
  162.     {
  163.         STTBX_Print(("GetWritePtrPTIFctLive()=%sn", KB_ErrorGetText(ErrCode) ));
  164.     }
  165.     return ErrCode;
  166. }
  167. static void SetReadPtrPTIFctLive(void * const Handle_p, void * const Address_p)
  168. {
  169.     ST_ErrorCode_t          ErrCode = ST_NO_ERROR;
  170.     ErrCode = STPTI_BufferSetReadPointer((STPTI_Buffer_t)Handle_p,Address_p);
  171.     if ( ErrCode != ST_NO_ERROR )
  172.     {
  173.         STTBX_Print(("SetReadPtrPTIFctLive()=%sn", KB_ErrorGetText(ErrCode) ));
  174.     }
  175. }
  176. static ST_ErrorCode_t GetWritePtrFctIframe(void * const Handle_p, void ** const Address_p)
  177. {
  178.     *Address_p = VideoInputBuffWptr;
  179.     return(0);
  180. }
  181. static void SetReadPtrFctIframe(void * const Handle_p, void * const Address_p)
  182. {
  183.     VideoInputBuffRptr = Address_p;
  184.     return;
  185. }
  186. /* Start I frame decode */
  187. ST_ErrorCode_t IFrameDecodeStart(void)
  188. {
  189.     ST_ErrorCode_t ErrCode = ST_NO_ERROR;
  190.     STVID_StartParams_t VIDStartParams;
  191.     //STVID_DecodedPictures_t DecodedPictures;
  192.     
  193.     VIDStartParams.StreamType    = STVID_STREAM_TYPE_ES;
  194.     VIDStartParams.BrdCstProfile = STVID_BROADCAST_DVB;
  195.     VIDStartParams.RealTime = FALSE;
  196.     VIDStartParams.DecodeOnce =TRUE;
  197.     VIDStartParams.StreamID = STVID_IGNORE_ID; 
  198.     
  199.     VIDStartParams.UpdateDisplay = TRUE;  /* SLSL */
  200.     
  201.     ErrCode = STVID_Start(VID_Handle, &VIDStartParams);    
  202.     if (ErrCode != ST_NO_ERROR)
  203.     {
  204.         STTBX_Print(("vid start=%sn", KB_ErrorGetText(ErrCode) ));
  205.     }
  206.     
  207.     
  208.     return ErrCode;
  209. }
  210. ST_ErrorCode_t testvideo(void)
  211. {
  212.     STVID_Freeze_t Freeparam;
  213.     ST_ErrorCode_t ErrCode = ST_NO_ERROR;
  214.     
  215.     Freeparam.Mode = STVID_FREEZE_MODE_NO_FLICKER ;
  216.     Freeparam.Field = STVID_FREEZE_FIELD_CURRENT;
  217.     ErrCode=STVID_Freeze(VID_Handle_Multiple[0],&Freeparam);
  218.     if ( ErrCode != ST_NO_ERROR )
  219.     {
  220.         STTBX_Print(("STVID_Freeze()=%sn", KB_ErrorGetText(ErrCode) ));
  221.     }
  222.     
  223.     return ErrCode;
  224. }
  225. /* Stop I frame decode */
  226. ST_ErrorCode_t IFrameStop( void )
  227. {
  228.     ST_ErrorCode_t ErrCode = ST_NO_ERROR;
  229.     STVID_Stop_t    VID_StopMode = STVID_STOP_NOW;
  230.     STVID_Freeze_t  VID_Freeze;
  231.     STVID_ClearParams_t ClearParams;
  232.     
  233.     VID_Freeze.Field    = STVID_FREEZE_FIELD_TOP;
  234.     VID_Freeze.Mode     = STVID_FREEZE_MODE_NO_FLICKER;
  235.     
  236. #if 1
  237.     ErrCode = STVID_Stop(VID_Handle, VID_StopMode, &VID_Freeze);
  238.     //STTBX_Print(("IFRAME_IFrameStop:: STVID_STOPn"));    
  239. #else
  240.     ErrCode = STVID_Freeze(VID_Handle_Multiple[0], &VID_Freeze);
  241. #endif
  242.     if (ErrCode != ST_NO_ERROR)
  243.     {
  244.         STTBX_Print(("vid stop1=%sn", KB_ErrorGetText(ErrCode) ));
  245.     }
  246.     ErrCode = STVID_DisableOutputWindow(VID_ViewPortHandle);
  247.     if (ErrCode != ST_NO_ERROR)
  248.     {
  249.         STTBX_Print(("STVID_DisableOutputWindow()=%sn", KB_ErrorGetText(ErrCode) ));
  250.     }
  251.     
  252.     return ErrCode;
  253. }
  254. static BOOL LiveVideoStart( void )
  255. {
  256.     STVID_StartParams_t VIDStartParams;
  257.     STVID_DecodedPictures_t DecodedPictures;
  258.     #if 1
  259.     STVID_SetDataInputInterface( VID_Handle,
  260.         GetWritePtrPTIFctLive, SetReadPtrPTIFctLive,
  261.         (void * const)PTI_VideoBufferHandle_Multiple[0]);
  262.     #endif
  263.     STVID_EnableSynchronisation(VID_Handle);  
  264. #if 1
  265.     DecodedPictures = STVID_DECODED_PICTURES_ALL;
  266.     STVID_SetDecodedPictures(VID_Handle, DecodedPictures);
  267. #endif
  268.     VIDStartParams.StreamType    = STVID_STREAM_TYPE_ES;
  269.     VIDStartParams.BrdCstProfile = STVID_BROADCAST_DVB;
  270.     VIDStartParams.RealTime = (BOOL)FALSE;
  271.     VIDStartParams.UpdateDisplay = (BOOL)TRUE;
  272.     VIDStartParams.DecodeOnce = (BOOL)FALSE;
  273.     VIDStartParams.StreamID = STVID_IGNORE_ID;
  274.     
  275.     STVID_EnableSynchronisation(VID_Handle_Multiple[0]);
  276.     return TRUE;
  277. }
  278. ST_ErrorCode_t LiveVideoStop( void )
  279. {
  280.     /*STVID_Stop_t    VID_StopMode = STVID_STOP_WHEN_END_OF_DATA; */
  281.     STVID_Stop_t    VID_StopMode = STVID_STOP_NOW; 
  282.     STVID_Freeze_t  VID_Freeze;
  283.     //STVID_ClearParams_t ClearParams;
  284.     ST_ErrorCode_t ErrCode = ST_NO_ERROR;
  285.     VID_Freeze.Field    = STVID_FREEZE_FIELD_TOP;
  286.     VID_Freeze.Mode     = STVID_FREEZE_MODE_NO_FLICKER;
  287.     ErrCode=STVID_Stop(VID_Handle, VID_StopMode, &VID_Freeze);
  288.     if (ErrCode != ST_NO_ERROR)
  289.     {
  290.         STTBX_Print(("vid stop2=%sn", KB_ErrorGetText(ErrCode) ));
  291.     }
  292.     
  293.     ErrCode = STVID_DisableOutputWindow(VID_ViewPortHandle);
  294.     if (ErrCode != ST_NO_ERROR)
  295.     {
  296.         STTBX_Print(("STVID_DisableOutputWindow()=%sn", KB_ErrorGetText(ErrCode) ));
  297.     }
  298.     
  299.     return ErrCode;
  300. }
  301. static BOOL LoadIframe(unsigned char *buffer,int number )
  302. {   
  303.     VID_BufferSize = number;
  304.     VID_Mem_p = buffer;
  305.     VID_Buffer_p = buffer;
  306.     return 0;
  307. } /* end VID_MemLoad */
  308. /* why can not 100% display I frame with 1 time injection?? */
  309. static void InjectIframe(int loop)
  310. {
  311.     U32     MaxDmaTransferSize = 128*1024;
  312.     U32     DmaTransferSize = 0,
  313.         InputBufferFreeSize,
  314.         RemainingSourceDataSize,
  315.         BitBufferThreshold,
  316.         BitBufferFreeSize,
  317.         /*BitBufferSize = 370 * 1024;*//*378800*/
  318.         BitBufferSize = 380928;/*CHENG modify-05/20/2006*/
  319.     U32     SnapInputRead = 0,
  320.         SnapInputWrite = 0;
  321.     BOOL    OneRound = FALSE;
  322.     
  323.     STVID_GetDataInputBufferParams(VID_Handle, &VideoInputBuffStart, &InputBufferFreeSize);
  324.     VideoInputBuffWptr = VideoInputBuffStart;
  325.     VideoInputBuffRptr = VideoInputBuffStart;
  326.     VideoInputBuffStop = (void*)((U32)VideoInputBuffStart+InputBufferFreeSize-1);
  327.     STVID_SetDataInputInterface(VID_Handle,GetWritePtrFctIframe,SetReadPtrFctIframe,(void*)1);
  328.     UserBufferStart_p       = (void*)VID_Buffer_p;
  329.     UserBufferCurrent_P     = UserBufferStart_p;
  330.     UserBufferStop_p        = (void*)((U32)UserBufferStart_p+VID_BufferSize-1);
  331.     
  332. #if 1 /*LYNN COMMENT OFF*/
  333.     /*STVID_GetBitBufferFreeSize(VID_Handle_Multiple[0], &BitBufferSize);*/
  334. #endif
  335.     
  336.     for( ; (loop > 0) ; loop-- )
  337.     {
  338.         while(OneRound == FALSE)
  339.         {
  340.             STVID_GetBitBufferFreeSize(VID_Handle, &BitBufferFreeSize);
  341.             DmaTransferSize = BitBufferFreeSize;
  342.             /* Compute threshold to avoid an overflow */
  343.             BitBufferThreshold = (3*BitBufferSize/4) & (~3);/*284160*/
  344.             
  345.             /* prevent for data pending in input-buffer */
  346.             if(BitBufferThreshold > ((U32)VideoInputBuffStop - (U32)VideoInputBuffStart + 1))
  347.             {
  348.                 BitBufferThreshold = BitBufferThreshold - ((U32)VideoInputBuffStop - (U32)VideoInputBuffStart + 1);
  349.             }
  350.             
  351.             if (BitBufferSize-BitBufferFreeSize > BitBufferThreshold)
  352.             {
  353.                 DmaTransferSize = 0;
  354.                 task_reschedule();
  355.             }
  356.             else
  357.             {
  358.                 DmaTransferSize = BitBufferThreshold-(BitBufferSize-BitBufferFreeSize);
  359.             }
  360.             
  361.             /* Control data size to be injected */
  362.             /* - enough data to fill the bit buffer until Threshold limit */
  363.             /* - 128k bytes maximum */
  364.             /* - remaining source data maximum */
  365.             RemainingSourceDataSize = (U32)VID_BufferSize - (U32)((U32)UserBufferCurrent_P - (U32)UserBufferStart_p);
  366.             
  367.             if (DmaTransferSize > MaxDmaTransferSize)
  368.                 DmaTransferSize = MaxDmaTransferSize;
  369. /*cheng delete-05/20/2006*/            
  370. #if 0 
  371.                 if (DmaTransferSize >= RemainingSourceDataSize)
  372.                 {
  373.                     DmaTransferSize = RemainingSourceDataSize;
  374.                     OneRound = TRUE; /* completed the first round of injection */
  375.                 }
  376. #endif  
  377. /*cheng delete-05/20/2006*/
  378.             
  379.             if (DmaTransferSize > 0)
  380.             {
  381.                 /* store shared pointers in private values */
  382.                 SnapInputRead  = (U32)VideoInputBuffRptr;
  383.                 SnapInputWrite = (U32)VideoInputBuffWptr;
  384.                 
  385.                 if( SnapInputWrite < SnapInputRead )
  386.                 {
  387.                     InputBufferFreeSize = SnapInputRead - SnapInputWrite - 10;
  388.                 }
  389.                 else
  390.                 {
  391.                     InputBufferFreeSize = (U32)VideoInputBuffStop - SnapInputWrite + 1;
  392.                 }
  393.                 
  394.                 if(DmaTransferSize > InputBufferFreeSize)
  395.                 {
  396.                     DmaTransferSize = InputBufferFreeSize;
  397.                 }
  398.                 if(DmaTransferSize > 0x4000)
  399.                 {
  400.                     DmaTransferSize=0x4000;
  401.                 }
  402.                 
  403.                 /*cheng add for right DmaTransferSize-05/20/2006*/
  404.                 if (DmaTransferSize >= RemainingSourceDataSize)
  405.                 {
  406.                     DmaTransferSize = RemainingSourceDataSize;
  407.                     OneRound = TRUE; /* completed the first round of injection */
  408.                 }
  409.                 /*cheng add end*/
  410.                 
  411.                 /* INJECTION BY CPU */
  412.                 memcpy(/* dest */ (void*)SnapInputWrite,
  413.                     /* src  */ UserBufferCurrent_P,
  414.                     DmaTransferSize);
  415.                 /* INJECTION DONE */
  416.                 
  417.                 /* Push the W pointer in video input */
  418.                 if(( SnapInputWrite+ DmaTransferSize) > (U32)VideoInputBuffStop)
  419.                 {
  420.                     SnapInputWrite= (U32)VideoInputBuffStart;
  421.                 }
  422.                 else
  423.                 {
  424.                     SnapInputWrite=  SnapInputWrite + DmaTransferSize;
  425.                 }
  426.                 /* Share the new input ptr */
  427.                 VideoInputBuffWptr = (void*)SnapInputWrite;
  428. #if 1
  429.                 task_delay((30*DmaTransferSize/1024)/8/*(30*DmaTransferSize/1024)/8*/);
  430.                 
  431.                 task_delay(15625); /* temp delay, to be removed*/
  432. #endif
  433.                 
  434.                 /* push our injection ptr */
  435.                 UserBufferCurrent_P = (void*)((U32)UserBufferCurrent_P + DmaTransferSize);
  436.                 if((U32)UserBufferCurrent_P > (U32)UserBufferStop_p)
  437.                 {
  438.                     /*STTBX_Print(("injection loops the streamn"));*/
  439.                     UserBufferCurrent_P = UserBufferStart_p;
  440.                 }
  441.             }
  442. #if 1 /*LYNN COMMENT OFF*/
  443.                 }
  444.                 OneRound = FALSE; /* initialise for the next round of injection */
  445.             }
  446. #endif
  447. }
  448.         
  449.         
  450. /**************************
  451. * ST_ErrorCode_t Switch2Iframe
  452. *
  453. *
  454. *
  455. *
  456. ***************************/
  457. ST_ErrorCode_t Switch2Iframe(unsigned char *buffer,int number)
  458. {  
  459.     ST_ErrorCode_t ErrCode;
  460.     
  461.     
  462.     //STTBX_Print(("nnn ======== Switch2Iframe ( ) =========n"));
  463.     
  464.     /*IFrameStop();*/
  465.     
  466.     /*ErrCode = IFrameDecodeStart();
  467.     if(ErrCode != ST_NO_ERROR)
  468.     {
  469.     STTBX_Print((" Switch2Iframe ( ) -> IFrameDecodeStart() Err = %sn", KB_ErrorGetText(ErrCode)));
  470. } */
  471.     
  472.     ErrCode = BackGround_VID_StartDecode();
  473.     if(ErrCode != ST_NO_ERROR)
  474.     {
  475.         STTBX_Print((" Switch2Iframe ( ) -> BackGround_VID_StartDecode() Err = %sn", KB_ErrorGetText(ErrCode)));
  476.     }
  477.     
  478.     LoadIframe(buffer,number);
  479.     InjectIframe(4);
  480.     //STTBX_Print(("zxqCHK ---------> InjectIframe success; InjectIframe successnn"));  
  481.     
  482. #if 1
  483.     //STVID_DisableOutputWindow(VID_ViewPortHandle_Multiple[0]);
  484.     //ErrCode = STVID_EnableOutputWindow(VID_ViewPortHandle_Multiple[0]);
  485. #else
  486.     STVID_DisableOutputWindow(VID_ViewPortHandle);
  487. #endif
  488.     
  489.     if(ErrCode != ST_NO_ERROR)
  490.     {
  491.         STTBX_Print((" Switch2Iframe ( ) -> STVID_EnableOutputWindow() Err = %sn", KB_ErrorGetText(ErrCode)));
  492.     }
  493.     #if 0
  494.     gnAvVideoEnabled = FALSE;
  495.     gnAvVideoIframeEnabled = TRUE;
  496.     #endif
  497.     
  498.     //STTBX_Print(("n ==========================nnn"));
  499.     return ErrCode;
  500. }
  501.         
  502.         
  503. /**************************
  504. * ST_ErrorCode_t Switch2Live
  505. *
  506. *
  507. *
  508. *
  509. ***************************/
  510. ST_ErrorCode_t Switch2Live(void)
  511. {
  512.     ST_ErrorCode_t ErrCode;
  513.     //STVID_ClearParams_t  ClearParams;
  514.     
  515.     //STTBX_Print(("nnn ======== Switch2Live ( ) =========n"));
  516.     
  517.     
  518.     IFrameStop();
  519.     
  520.     ErrCode = LiveVideoStart();
  521.     if(ErrCode != TRUE)
  522.     {
  523.         STTBX_Print((" Switch2Live ( ) -> LiveVideoStart() Err = %sn", KB_ErrorGetText(ErrCode)));
  524.     }           
  525.     
  526.     //STTBX_Print(("n ==========================nnn"));
  527.     return ErrCode;
  528. }
  529. static void NewVideoFrameEvent(STEVT_CallReason_t Reason, const ST_DeviceName_t RegistrantName, STEVT_EventConstant_t Event, const void *EventData, const void *SubscriberData_p )
  530. {
  531.     ST_ErrorCode_t ErrCode;
  532.     ErrCode = ST_NO_ERROR;
  533.     
  534.     switch (Event)
  535.     {
  536.     case STVID_NEW_PICTURE_DECODED_EVT:
  537.         semaphore_signal(iframePicDecodeLock);
  538. #if 1
  539.         STVID_EnableOutputWindow(VID_ViewPortHandle_Multiple[0]);
  540. #endif
  541.         break;
  542.     case STVID_DISPLAY_NEW_FRAME_EVT:
  543.         STVID_EnableOutputWindow(VID_ViewPortHandle_Multiple[0]);  
  544.         break;
  545.     case STVID_STOPPED_EVT:
  546.         semaphore_signal(iframeStopDecodeLock);
  547.         break;
  548.     }
  549.     return;
  550. }
  551. extern ST_DeviceName_t g_KB_EVTDeviceName[];
  552. extern STEVT_Handle_t  g_KB_EVTHandle[1];
  553. void NewFrameEventSubsvribe( void )
  554. {
  555.     STEVT_DeviceSubscribeParams_t SubscribeParams;
  556.     memset(&SubscribeParams, 0, sizeof(STEVT_DeviceSubscribeParams_t));
  557.     SubscribeParams.NotifyCallback = NewVideoFrameEvent;
  558. STEVT_SubscribeDeviceEvent(g_KB_EVTHandle[0],  VID_DeviceName_Multiple[0], (U32)STVID_NEW_PICTURE_TO_BE_DISPLAYED_EVT, &SubscribeParams);
  559. }
  560. void NewFrameEventSubscribe( void )
  561. {
  562.     STEVT_DeviceSubscribeParams_t SubscribeParams;
  563.     
  564.     iframePicDecodeLock = semaphore_create_fifo_timeout(0);
  565.     iframeStopDecodeLock = semaphore_create_fifo_timeout(0);
  566.     
  567.     memset(&SubscribeParams, 0, sizeof(STEVT_DeviceSubscribeParams_t));
  568.     SubscribeParams.NotifyCallback = NewVideoFrameEvent;
  569.     STEVT_SubscribeDeviceEvent(g_KB_EVTHandle[0],  VID_DeviceName_Multiple[0], (U32)STVID_NEW_PICTURE_DECODED_EVT, &SubscribeParams);
  570. #if 1
  571.     STEVT_SubscribeDeviceEvent(g_KB_EVTHandle[0],  VID_DeviceName_Multiple[0], (U32)STVID_STOPPED_EVT, &SubscribeParams);
  572. #endif
  573.     
  574. }
  575. /* EOF */