⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 play_psfdemux_multicast.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2002. All rights reserved. * *//**   @file play_psfdemux.c   @brief sample application for hardware demux of EM86xx	   @author Aurelia Popa-Radu   @ingroup dccsamplecode*/#include "../samples/sample_os.h"#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../samples/common.h"#include "command_ids.h"#include "play_psfdemux_helper.h"#include "../rmlibcw/include/rmsocket.h"// this will add a field to the context, see psfdemux_common.h#define MULTICAST 1 #define MAX_MULTICAST_STREAMS 10#include "psfdemux_common.h"/**************************** macros ******************************/#define KEYFLAGS (SET_KEY_DISPLAY | SET_KEY_PLAYBACK | SET_KEY_AUDIO | SET_KEY_DEBUG | SET_KEY_SPI)#define DMA_BUFFER_SIZE_LOG2	15	// 32k buffer#define DMA_BUFFER_COUNT	32	// 32 * 32k = 0x200000 = 1M #define DEMUX_FIFO_SIZE		(1 << DMA_BUFFER_SIZE_LOG2) * DMA_BUFFER_COUNT	// match the dma pool for standalone#define DEMUX_XFER_FIFO_COUNT	DMA_BUFFER_COUNT	// same as dma pool buffers - this application sends complete buffer every time. #define VIDEO_FIFO_SIZE		( 1792*1024) /* "-vfifo 1792", default same value as in play_demux and play_hwdemux */#define AUDIO_FIFO_SIZE		(  128*1024)#define SPU_FIFO_SIZE		(  104*1024)#define DUMP_SOCKET_DATA	1#define	FORCE_DECRYPTION	1#define SOCKET_BLOCKING_READ_SLEEP 3000//#define AUTO_CHANGE_CHANNEL#ifdef WITH_MONO#define MAX_TASK_COUNT		1#else#define MAX_TASK_COUNT		3#endif#define MAX_EVENT_COUNT_PER_TASK     5 /* 4 events (demux, video, display, audio) for file playback and 1 receive event per task */#define CPU_ERROR_EVENT_MASK        (1<<0)#define DEMUX_RECEIVE_EVENT_MASK(i) (1<<(1+0+i*MAX_EVENT_COUNT_PER_TASK))#define DEMUX_SEND_EVENT_MASK(i)    (1<<(1+1+i*MAX_EVENT_COUNT_PER_TASK))#define DEMUX_EOS_EVENT_MASK(i)     (1<<(1+1+i*MAX_EVENT_COUNT_PER_TASK))#define VIDEO_EOS_EVENT_MASK(i)     (1<<(1+2+i*MAX_EVENT_COUNT_PER_TASK))#define DISPLAY_EOS_EVENT_MASK(i)   (1<<(1+3+i*MAX_EVENT_COUNT_PER_TASK))#define AUDIO_EOS_EVENT_MASK(i)     (1<<(1+4+i*MAX_EVENT_COUNT_PER_TASK))#define VIDEO_PID_FROM_CMDLINE    1#define PCR_PID_FROM_CMDLINE      2#define AUDIO_PID_FROM_CMDLINE    4#define AV_PIDS_ENABLE_FIRST_TIME 8#define LOOP_KEY_TABLE /* Allow the Key table to loop when it reaches the end */#if defined(WITH_AACS)#define MAX_SP			6#define PACKET_SIZE		192#define AACS_IBC_CMD_MT		2#define AACS_IBC_CMD_PLAY_ITEM  4#endif/* to enable or disable the debug messages of this source file, put 1 or 0 below */#if 0#define LOCALDBG ENABLE#else#define LOCALDBG DISABLE#endif#if 0#define CALLDBG ENABLE#else#define CALLDBG DISABLE#endifstruct dvb_csa_key arte_dvb_key_table[] = {	{ TRUE, 0, EMhwlibScramblingBits_10, { 0xfc, 0x32, 0x54, 0x76, 0x94, 0xba, 0xdc, 0xfe },	 { 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00},	  ECM0_SECTION_ENTRY }, /* arte key starts from LSB (byte 0) */};struct dvb_csa_key cweven_dvb_key_table[] = {	{ FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0x34, 0x18, 0x3c, 0xe0, 0x41, 0xc2, 0x03, 0x7c },	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x14, 0x00, 0x6E, 0x26}, },};struct dvb_csa_key cwodd_dvb_key_table[] = {	{ FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0x7e, 0x7e, 0x00, 0x00, 0xc8, 0x03, 0xc6, 0xff },	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x15, 0x00, 0x8F, 0x26}, },};	struct dvb_csa_key ecm1_dvb_key_table[] = {	{ TRUE, 0, EMhwlibScramblingBits_11, { 0x8b, 0xbe, 0xba, 0x13, 0x69, 0xb2, 0xfb, 0xbc },	 { 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00},	  ECM0_SECTION_ENTRY }, /* 1ECM key starts from LSB (byte 0) */};struct dvb_csa_key ecm4_dvb_key_table[] = {	/* to prove that ECM parsing is Ok invalidate key_byte_counter and scrambling settings */	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, /*0x00000000, EMhwlibScramblingBits_10,*/ { 0x5e, 0x2d, 0x29, 0x08, 0xbd, 0x2d, 0x61, 0x2f },	 { 0x00, 0x02, 0x2D, 0x5E, 0xE4, 0x00, 0x49, 0x15, 0x09, 0x04, 0x00, 0x00, 0x01, 0x4D, 0x04, 0x4E}, }, /* 4ECM key starts from LSB (byte 0) */	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, /*0x00E3F3F0, EMhwlibScramblingBits_11,*/ { 0x5c, 0x2c, 0x28, 0x08, 0xba, 0x2c, 0x60, 0x2e },	 { 0x00, 0x02, 0x2C, 0x5C, 0xE4, 0x00, 0x45, 0x15, 0x09, 0x04, 0x00, 0x00, 0x01, 0x4D, 0x04, 0x4E}, },	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, /*0x01E61c00, EMhwlibScramblingBits_10,*/ { 0x62, 0x2f, 0x2b, 0x08, 0xbf, 0x2f, 0x63, 0x2d },	 { 0x00, 0x02, 0x2F, 0x62, 0xE4, 0x00, 0x51, 0x15, 0x09, 0x04, 0x00, 0x00, 0x01, 0x4D, 0x04, 0x4E}, },	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, /*0x02e56880, EMhwlibScramblingBits_11,*/ { 0x60, 0x2e, 0x2a, 0x08, 0xbc, 0x2e, 0x62, 0x2c },	 { 0x00, 0x02, 0x2E, 0x60, 0xE4, 0x00, 0x4D, 0x15, 0x09, 0x04, 0x00, 0x00, 0x01, 0x4D, 0x04, 0x4E}, },};struct dvb_csa_key vgs3_key_table[] = {	/* to prove that ECM parsing is Ok invalidate key_byte_counter and scrambling settings */	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0x7A, 0x03, 0xFF, 0x78, 0x74, 0x80, 0x01, 0xF3},	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x64, 0x00, 0xBA, 0x26}, }, /* vgs3 key starts from LSB (byte 0) */	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0x8B, 0x3F, 0x0E, 0x3E, 0x7E, 0x00, 0x78, 0x06},	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x65, 0x00, 0xC0, 0x26}, },	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0x20, 0x60, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00},	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x66, 0x00, 0xC6, 0x26}, },	{  FALSE, 0xffffffff, EMhwlibScramblingBits_None, { 0xAF, 0x00, 0xE0, 0xCF, 0xF8, 0x00, 0x00, 0xF8},	 { 0x00, 0x00, 0x00, 0x00, 0x91, 0x01, 0x02, 0x05, 0xFF, 0x02, 0x00, 0x17, 0x67, 0x00, 0xCC, 0x26}, },};static RMstatus HwPlay(struct context_per_task *context);static RMstatus HwStop(struct context_per_task *context);static void printTimeOfDay(struct timeval now){	RMuint64 secondsPerMinute = 60;	RMuint64 secondsPerHour = 60 * secondsPerMinute;	RMuint64 secondsPerDay = 24 * secondsPerHour;	RMuint64 today, h, m;	today = (now.tv_sec - ((now.tv_sec / secondsPerDay) * secondsPerDay));	h = today / secondsPerHour;	today -= h * secondsPerHour;	m = today / secondsPerMinute;	today -= m * secondsPerMinute;		fprintf(stderr, "time is %02llu:%02llu:%02llu.%llu\n", h, m, today, (RMuint64)now.tv_usec);}#define GET_DATA_FIFO_INFO(pRUA, ModuleId, checkStarvation)		\	{								\		struct DataFIFOInfo DataFIFOInfo;			\		RMuint32 fullness;					\		RUAGetProperty(pRUA, ModuleId, RMGenericPropertyID_DataFIFOInfo, &DataFIFOInfo, sizeof(DataFIFOInfo)); \		if(DataFIFOInfo.Size > 0) {				\			fullness = (100*DataFIFOInfo.Readable)/DataFIFOInfo.Size; \			fprintf(stderr, "Data %lx: st=%08lx sz=%ld wr=%ld rd=%ld --> fullness : %lu/100\n", ModuleId, DataFIFOInfo.StartAddress, \				DataFIFOInfo.Size, DataFIFOInfo.Writable,  DataFIFOInfo.Readable, fullness); \			if ((fullness < 2) && checkStarvation) {	\				struct timeval now;			\									\				gettimeofday(&now, NULL);		\				RMDBGLOG((ENABLE, "close to starvation at\n")); \				printTimeOfDay(now);			\			}						\		}							\	}								\#define GET_XFER_FIFO_INFO(pRUA, ModuleId, checkStarvation)		\	{								\		struct XferFIFOInfo_type XferFIFOInfo;			\		RMuint32 fullness;					\		RMstatus err;						\		err = RUAGetProperty(pRUA, ModuleId, RMGenericPropertyID_XferFIFOInfo, &XferFIFOInfo, sizeof(XferFIFOInfo)); \		if ( RMFAILED(err) ) {					\			fprintf(stderr, "XFER %lx: ERROR\n", ModuleId);	\		}							\		else {							\			fullness = (100*XferFIFOInfo.Readable)/XferFIFOInfo.Size; \			fprintf(stderr, "XFER %lx: st=%08lx sz=%ld wr=%ld rd=%ld er=%lx --> fullness : %lu/100\n", ModuleId, XferFIFOInfo.StartAddress, \				XferFIFOInfo.Size, XferFIFOInfo.Writable,  XferFIFOInfo.Readable, XferFIFOInfo.Erasable, fullness); \			if ((fullness < 2) && checkStarvation) {	\				struct timeval now;			\									\				gettimeofday(&now, NULL);		\				RMDBGLOG((ENABLE, "close to starvation at\n")); \				printTimeOfDay(now);			\			}						\		}							\	}								\#define MONITOR_INTERVAL_US 250000static void monitor(struct context_per_task *context, RMbool alwaysShow){		/* the bitrate reading of this probe is accurate only if the blocking call is RUASendData */	struct timeval now;		RMuint64 elapsed; 		RMuint64 ptime; 		struct dcc_context *dcc_info = context->dcc_info;	struct EMhwlibDemuxErrorInfo dmxErrorInfos;	gettimeofday(&now, NULL);	elapsed = (now.tv_sec - context->last.tv_sec) * 1000000;			elapsed += (now.tv_usec - context->last.tv_usec);	if (elapsed > MONITOR_INTERVAL_US || alwaysShow){		RMstatus st;		RMuint64 bitrate = (RMuint64)context->bitrate * 1000000;		bitrate /= elapsed;		context->meanBitrate += bitrate;		context->meanCount++;		DCCSTCGetTime(dcc_info->pStcSource, &ptime, 90000);					fprintf(stderr, "\n*****************************\n");		fprintf(stderr, "timeofday %llu.%llu secs since epoch\n", (RMuint64)now.tv_sec, (RMuint64)now.tv_usec);		printTimeOfDay(now);		fprintf(stderr, "STC = %llu (%llu secs) bytes sent %lu\n", ptime, (ptime/90000), context->file_byte_counter);		/* sample code to get fifo info */		if (dcc_info->pDemuxTask) {			fprintf(stderr, "Demux :\n");						GET_DATA_FIFO_INFO(dcc_info->pRUA, context->demux_task, FALSE);			if (!context->play_opt->spi) {				GET_XFER_FIFO_INFO(dcc_info->pRUA, context->demux_task, FALSE);				fprintf(stderr, "bitrate: mean %llu bit/sec, pseudo-instantaneus %llu bit/sec (%lu bytes/%llu us)\n", 					context->meanBitrate / context->meanCount,					bitrate, 					context->bitrate >> 3, 					elapsed);			}			else				fprintf(stderr, "No fifo, playing from SPI\n");					st = RUAGetProperty(dcc_info->pRUA, context->demux_task, RMDemuxTaskPropertyID_ErrorInfo, &dmxErrorInfos, sizeof(dmxErrorInfos));			if(RMFAILED(st)){				fprintf(stderr, "Cannot get error infos from Demux task %lu\n", context->demux_task);			}			else				fprintf(stderr, "Demux task error infos : EngineError = %lu, TaskError = %lu, InputDiscontinuityCounter = %lu, InputSyncLossCounter = %lu, OutputOverflowCounter = %lu, PTSOutputOverflowCounter = %lu\n", 					dmxErrorInfos.EngineError,					dmxErrorInfos.TaskError,					dmxErrorInfos.InputDiscontinuityCounter, 					dmxErrorInfos.InputSyncLossCounter, 					dmxErrorInfos.OutputOverflowCounter, 					dmxErrorInfos.PTSOutputOverflowCounter);		}		if (dcc_info->pVideoSource) {			RMuint32 vidError;			fprintf(stderr, "Video (pid is %u=0x%x) :\n", context->video_pid, context->video_pid);			GET_DATA_FIFO_INFO(dcc_info->pRUA, dcc_info->video_decoder, TRUE);			st = RUAGetProperty(dcc_info->pRUA, dcc_info->video_decoder, RMVideoDecoderPropertyID_Error, &vidError, sizeof(vidError));			if(RMFAILED(st)){				fprintf(stderr, "Cannot get error infos from video decoder %lu\n", dcc_info->video_decoder);			}			else				fprintf(stderr, "Video decoder error info : 0x%lX\n", vidError);		}		if (dcc_info->pMultipleAudioSource) {			struct DCCAudioSourceHandle audioHandle;			RMuint32 i;			for (i = 0; i < context->audioInstances; i++) {				fprintf(stderr, "Audio[%lu] (pid is %u=0x%x, subid %u=0x%x)):\n", 					i, 					context->audio_pid, context->audio_pid,					context->audio_subid, context->audio_subid);								DCCMultipleAudioSourceGetSingleDecoderHandleForInstance(dcc_info->pMultipleAudioSource, i, &audioHandle);										GET_DATA_FIFO_INFO(dcc_info->pRUA, audioHandle.moduleID, TRUE);			}		}		else {			fprintf(stderr, "Audio pid is %u=0x%x, subid %u=0x%x:\n", 				context->audio_pid, context->audio_pid,				context->audio_subid, context->audio_subid);			GET_DATA_FIFO_INFO(dcc_info->pRUA, dcc_info->audio_decoder, TRUE);		}		fprintf(stderr, "*****************************\n");					gettimeofday(&context->last, NULL);		context->bitrate = 0;		fflush(stderr);			}					        	return;}/****************************** global variables ******************************//* these should be made local */static RMuint32			task_count = 0;static struct dcc_context       *pdcc_info[MAX_TASK_COUNT];static struct context_per_task	Tasks[MAX_TASK_COUNT] = {{0,},}; static struct RM_PSM_Context    PSMcontext;static RMuint32			output_count_per_task;static RMuint32			idle_port = 0xff;static RMbool			timedbg = FALSE;enum AudioDecoder_Codec_type    stream_type_6 = AudioDecoder_Codec_DTS;#ifndef WITH_MONO/* these can stay global as they are only used by the standalone play_psfdemux app */static RMbool			load_ucode = TRUE;static struct playback_cmdline  playback_options[MAX_TASK_COUNT]; static struct display_cmdline   display_options[MAX_TASK_COUNT]; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -