📄 exolmpegts.c
字号:
UInt32 flags,
ptsaErrorArgs_t args );
static tmErrorCode_t lFreadProgFunc( Int inst,
UInt32 flags,
ptsaProgressArgs_t args );
static void openFreadInstance( void );
static void setupFreadComponent( pFreadInst_s pInstance );
static tmErrorCode_t startFreadComponent( void );
static tmErrorCode_t stopFreadComponent( void );
// MPEG Video Decoder component functions
static tmErrorCode_t closeVdecMpegComponent( void );
static void createVdecMpegComponentControlDescriptor( void );
static void createVdecMpegComponentSemaphores( void );
static void destroyVdecMpegComponentControlDescriptor( void );
static void destroyVdecMpegComponentSemaphores( void );
static void getVdecMpegCapabilities( void );
static tmErrorCode_t lVdecMpegCompFunc( Int inst,
UInt32 flags,
ptsaCompletionArgs_t args );
static tmErrorCode_t lVdecMpegErrorFunc( Int inst,
UInt32 flags,
ptsaErrorArgs_t args );
static tmErrorCode_t lVdecMpegProgFunc( Int inst,
UInt32 flags,
ptsaProgressArgs_t args );
static void openVdecMpegInstance( void );
static void setupVdecMpegComponent( pVdecMpegInst_s pInstance );
static tmErrorCode_t startVdecMpegComponent( void );
static tmErrorCode_t stopVdecMpegComponent( void );
// Video Renderer component functions
static tmErrorCode_t closeVrendGfxVoComponent( void );
static void createVrendGfxVoComponentControlDescriptor( void );
static void createVrendGfxVoComponentSemaphores( void );
static void destroyVrendGfxVoComponentControlDescriptor( void );
static void destroyVrendGfxVoComponentSemaphores( void );
static void getVrendGfxVoCapabilities( void );
static tmErrorCode_t lVrendGfxVoCompFunc( Int inst,
UInt32 flags,
ptsaCompletionArgs_t args );
static tmErrorCode_t lVrendGfxVoErrorFunc( Int inst,
UInt32 flags,
ptsaErrorArgs_t args );
static tmErrorCode_t lVrendGfxVoProgFunc( Int inst,
UInt32 flags,
ptsaProgressArgs_t args );
static void openVrendGfxVoInstance( void );
static void setupVrendGfxVoComponent( pVrendGfxVoInst_s pInstance );
static tmErrorCode_t startVrendGfxVoComponent( void );
static tmErrorCode_t stopVrendGfxVoComponent( void );
// Analog Video Encoder component functions
static tmErrorCode_t closeVencAnaComponent( void );
static void createVencAnaComponentSemaphores( void );
static void destroyVencAnaComponentSemaphores( void );
static void openVencAnaInstance( void );
static tmErrorCode_t setupVencAnaComponent( void );
#if TMFL_NEED_TIME_DOCTOR
// TimeDoctor functions
static void enableTimeDoctor( void );
#endif
//---------------------------------------------------------------------------
// Functions
//---------------------------------------------------------------------------
#undef tmMain_DBG_BUFF_SIZE
#define tmMain_DBG_BUFF_SIZE (1 * MB)
//---------------------------------------------------------------------------
tmMain()
{
Int size = 0;
Int menuResult = 0;
Bool bQuit = False;
Bool bUseMenu = True;
tmErrorCode_t rval = TM_OK;
Bool bFirstTime = True;
// Debug system initialization
DBG_REGISTER_MODULE (dbgTsDemux, "TsDemux");
DBG_ISR_PRINT ((dbgTsDemux, DBG_INTERNAL_ENTER, "tmMain"))
// Initialize the global pid structure
gPids.videoPid = DEMUXMPEGTS_NO_PID;
gPids.mainAudioPid = DEMUXMPEGTS_NO_PID;
gPids.pcrPid = DEMUXMPEGTS_NO_PID;
#if TMFL_NEED_TIME_DOCTOR
enableTimeDoctor();
#endif
printf ("\n-------------------------------------------------------------------------------\n");
printf ("\n\t\t\t\t\tDemuxMpegTS test application\n");
printf ("\n-------------------------------------------------------------------------------\n");
#if TMFL_NEED_TIME_DOCTOR
gUserTdId = tmtdUserBlockCreate ("VDMP");
tmtdUserBlockEnter (gUserTdId);
#endif
psiInit();
// Check command line arguments (always returns TM_OK)
checkArgCv (__argc, __argv);
// Take care of some unallowed combinations
if ((gDeinterlaceMode == tmolVrendGfxVo_DeinterlaceModeNone) &&
(gEddiLevel != tmolVrendGfxVo_EddiOff))
{
printf ("Warning: Deinterlacing is set to 'none', eddiLevel other than "
"'off' not allowed. Will switch it 'off'.\n");
gEddiLevel = tmolVrendGfxVo_EddiOff;
}
if ((gDeinterlaceMode != tmolVrendGfxVo_DeinterlaceModeNone) &&
!bEddiLevelSet)
{
printf ("Warning: Deinterlacing required, eddi level not explicitely "
"set. Switching eddi level to 'NMcSafe'!\n");
gEddiLevel = tmolVrendGfxVo_EddiNMcSafe;
}
// Set the video output mode
ERRCHK (setVideoOutMode (gMode))
if ((bVideoOutInterlaced == True) &&
(gDeinterlaceMode != tmolVrendGfxVo_DeinterlaceModeNone))
{
printf ("Warning: Deinterlacing not allowed in case of an interlaced "
"video out mode. Switching deinterlacing off.\n");
gDeinterlaceMode = tmolVrendGfxVo_DeinterlaceModeNone;
}
// Initialize the Video Router
ERRCHK (setVideoRouter())
// Create a memspace for this application
/* NOTE: The size only has to be large enough to accomodate all calls to
tmmlMalloc that we are using (approx 5 KB) plus 0.5 MB for VdecMpeg
normalMmsp */
ERRCHK (tmmlCreate (&gAppInstanceMmsp, (1*MB), tmmlMmspNormal))
if (gUseFgpi)
{
// Setup the frequency of the clocks
setClockFrequency( CLOCK_FREQUENCY );
// Setup Data/Video Input Router for 8-bit raw data capture, 32-bit storage
MMIO( VDI_MODE ) = 0x00000001;
// Enable GPIO pins VDI_D[33:32] to functional mode
MMIO( GPIO_MODE_CONTROL3 ) = (1 << 8) | (1 << 6);
}
// Get the capabilities of the component instances
getComponentCapabilities();
// Open the component instances
openComponentInstances();
// Allocate memory for the largest I/O descriptor setup structure we need
/* NOTE: In our case that would be the TsDemuxToVdecIoDescriptor since it
has the most numberOfBuffers */
size = sizeof (tsaInOutDescriptorSetup_t) +
((NROF_DEMUX_TO_VDEC_BUFFERS - 1) * sizeof( UInt32 ));
ERRCHK( tmmlMalloc( gAppInstanceMmsp, size, (pVoid *)&(gIoSetupPtr),
tmmlMallocCleared))
// Initialize the I/O descriptor setup memory
memset ((Char *)gIoSetupPtr, 0x0, size);
// Create the descriptors for I/O between component instances
createComponentIoDescriptors();
// Free the I/O descriptor setup memory
ERRCHK( tmmlFree( gIoSetupPtr ) )
// Create the control descriptors for component instances
createComponentControlDescriptors();
// Create semaphores for the component instances
createComponentSemaphores();
// Set up the component instances
setupComponentInstances();
// Start the component instances
ERRCHK( startComponentInstances() )
// Start the tasks
ERRCHK( startTasks() )
// Perform a consistency check on the internal state of the memory manager
tmmlCheck();
// Print a list of all guarded blocks in the application memory space
tmmlPrintGuarded (gAppInstanceMmsp);
/* Main loop. Sets up pids and starts streaming the video, waits for any
channel changes */
do
{
menuResult = displayCommandMenu( bUseMenu );
if ( bFirstTime && menuResult != 4 )
{
if (gUseFgpi)
{
// Start the Fast General Purpose Input (FGPI) instance
ERRCHK( startFgpiComponent() )
}
}
rval = verifyProgramNumber_GetPids( menuResult );
if ( rval == TM_OK)
{
// Sets up and redirects pids according to what was specified by the user
bQuit = commandControl( menuResult, bUseMenu );
if ( bFirstTime && !bQuit )
{
// Setup the Analog Video Encoder
ERRCHK( setupVencAnaComponent() )
bFirstTime = False;
}
}
else if ( rval != TM_ERR_BAD_INDEX )
{
DBG_ISR_PRINT( (dbgTsDemux, DBG_LEVEL_1,
"tmMain: Error in call to verifyProgramNumber_GetPids(): "
"err=0x%x\n", rval) )
bQuit = True;
}
} while( !bQuit );
// If we returned from the command menu loop then we want to quit
if (gUseFgpi)
{
// Stop the Fast General Purpose Input (FGPI) instance
ERRCHK( stopFgpiComponent() )
}
/* Since the PSI Data task is a non-TSSA component, we set the receiverState
to stopped ourselves. This would normally be done by tsaDefaultStop(). */
gIoDescripts.TsDemuxPsiDataIoDescriptor->receiverState = tsaIODescFlagSTOPPED;
/* Since the Private Data task is a non-TSSA component, we set the
receiverState to stopped ourselves. This would normally be done by
tsaDefaultStop(). */
gIoDescripts.TsDemuxPrivateDataIoDescriptor->receiverState = tsaIODescFlagSTOPPED;
/* Since the User Data task is a non-TSSA component, we set the
receiverState to stopped ourselves. This would normally be done by
tsaDefaultStop(). */
gIoDescripts.VdecUserDataIoDescriptor->receiverState = tsaIODescFlagSTOPPED;
/* Since the TS Demux talks to these non-tssa components, we stop the pins
explicitly */
ERRCHK( tsaDefaultStopPin( gDemuxMpegTsInst.DemuxMpegTsInst, tsaOutputPin,
gIoDescripts.TsDemuxPsiDataIoDescriptor->senderIndex ) )
ERRCHK( tsaDefaultStopPin( gDemuxMpegTsInst.DemuxMpegTsInst, tsaOutputPin,
gIoDescripts.TsDemuxPrivateDataIoDescriptor->senderIndex ) )
ERRCHK( tsaDefaultStopPin( gVdecMpegInst.VdecMpegInst, tsaOutputPin,
gIoDescripts.VdecUserDataIoDescriptor->senderIndex ) )
// Signal the PSI Data task to kill itself
bKillPsiDataTask = True;
// Signal the Private Data task to kill itself
bKillPrivateDataTask = True;
// Signal the User Data task to kill itself
bKilluserDataTask = True;
// Signal the Watchdog Timer task to kill itself
bKillWatchDogTask = True;
// Put this task to sleep for a bit to allow the other tasks to run
tmosalTaskSleep( TASK_SMALL_SLEEP_MS );
// Stop the component instances
ERRCHK( stopComponentInstances() )
// Check that the I/O between components has stopped
checkComponentIoQueues();
// Close the component instances
ERRCHK( closeComponentInstances() )
// Destroy the semaphores associated with the component instances
destroyComponentSemaphores();
// Deallocate the imageInfo user pointer
detachPictureInfo (gIoDescripts.VdecToVrendGfxVoIoDescriptor);
// Destroy the descriptors for I/O between component instances
destroyComponentIoDescriptors();
// Destroy the control descriptors associated with the component instances
destroyComponentControlDescriptors();
// Delete the memspace for this application
ERRCHK( tmmlDelete( gAppInstanceMmsp ) )
// EXIT
printf ("exolMpegTs test application exiting\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -