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

📄 play_psfdemux.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error video RMDemuxTaskPropertyID_PidEntryDisable", context->id));			return err;		}	}		if (context->audio_pid != 0x1fff) {		/* set the audio pid */		entry.index = context->audio_pidentry;		entry.PidEntry.pid = context->audio_pid;		if(context->demux_opt->send_scrambled_packets_for_invalid_key)			entry.PidEntry.input_type = EMhwlibPid_Ts1;		else			entry.PidEntry.input_type = EMhwlibPid_Ts;		entry.PidEntry.flags = TS_FLAGS;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error audio RMDemuxTaskPropertyID_PidEntry", context->id));			return err;		}		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error audio RMDemuxTaskPropertyID_PidEntryEnable", context->id));			return err;		}	}	else {		/* disable the audio pid */		entry.index = context->audio_pidentry;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error audio RMDemuxTaskPropertyID_PidEntryDisable", context->id));			return err;		}	}		if (context->teletext_pid != 0x1fff  && context->video_opt->display_ttx) {		/* set the audio pid */		RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback SET TTX PID TO 0x%lX\n", context->id, context->teletext_pid));		entry.index = context->teletext_pidentry;		entry.PidEntry.pid = context->teletext_pid;		entry.PidEntry.input_type = EMhwlibPid_Ts;		entry.PidEntry.flags = TS_FLAGS;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error teletext RMDemuxTaskPropertyID_PidEntry", context->id));			return err;		}			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error teletext RMDemuxTaskPropertyID_PidEntryEnable", context->id));			return err;		}	}	else {		/* disable the teletext pid */		RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback : DISABLE TTX PID", context->id));		entry.index = context->teletext_pidentry;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error teletext RMDemuxTaskPropertyID_PidEntryDisable", context->id));			return err;		}	}		/* set the pcr pid */#ifdef USE_HW_PCR_PID_ENTRY	/* EM8634 has three hardware PCR filters but only two clock recovery blocks,	 limiting us to only two hardware PCR filters. For the third task we have to use PCR extraction from PidBank.	 For task 0 and 1 I will use the hardware PCR pids and for task 2 the PidBank pcr pid. */	if(context->id < 2) {		/* Set and enable the pcr extraction from special hardware pcr pid. We don't need any output connected. */		if ( context->pcr_pid != 0x1fff ) {			RMuint32 dummy;			struct EMhwlibPCRPidEntry_type hwpcr;			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback USE_HW_PCR_PID_ENTRY\n", context->id));			hwpcr.pid = context->pcr_pid;			hwpcr.clock_recovery_id = context->id; /* 0 or 1 for EM8634. Next chips will have a clock recovery for every PCR: 0, 1, 2. */			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PCRPidEntry, &hwpcr, sizeof(hwpcr), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PCRPidEntry", context->id));				return err;			}			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PCRPidEntryEnable, &dummy, sizeof(dummy), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PCRPidEntryEnable", context->id));				return err;			}		}		else {			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PCRPidEntryDisable, &dummy, sizeof(dummy), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PCRPidEntryDisable", context->id));				return err;			}		}	}	else /* third task will use PCR extraction from PidBank. */#endif	{		/* select the pcr extraction from pid bank. we need to have an output associated and enabled. */		if ( (context->pcr_pid != context->video_pid) && (context->pcr_pid != context->audio_pid) && (context->pcr_pid != 0x1fff) ) {			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidBankPCRPid, &context->pcr_pid, sizeof(context->pcr_pid), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidBankPCRPid", context->id));				return err;			}			/* set and enable the pcr in pid bank */			entry.index = context->pcr_pidentry;			entry.PidEntry.pid = context->pcr_pid;			entry.PidEntry.input_type = EMhwlibPid_Ts;			entry.PidEntry.flags = TS_FLAGS;			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidEntry", context->id));				return err;			}				err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidEntryEnable", context->id));				return err;			}		}		else if  ((context->pcr_pid  == context->video_pid) || (context->pcr_pid == context->audio_pid)) {			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidBankPCRPid, &context->pcr_pid, sizeof(context->pcr_pid), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidBankPCRPid", context->id));				return err;			}		}		else {			/* disable the pcr pid */			entry.index = context->pcr_pidentry;			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidEntryDisable", context->id));				return err;			}			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidBankPCRPid, &context->pcr_pid, sizeof(context->pcr_pid), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error pcr RMDemuxTaskPropertyID_PidBankPCRPid", context->id));				return err;			}		}	}	/* Set the ECM pid */	if (context->ecm_pid[0] != 0x1FFF) {		// Apply cipher to pid of video		cipher.index = context->video_pidentry;		/* pid index */		cipher.pid_cipher_index = 0;			/* first and only cipher per pid in current implementation */		cipher.cipher_index = context->cipher_index[0];	/* 1st cipher index of this task */		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "InitPidTablePerTask Error RMDemuxTaskPropertyID_PidEntryAddCipher"));			return err;		}		// Apply cipher to pid of audio		if (context->ecm_pid[0] == context->ecm_pid[1]) {			cipher.index = context->audio_pidentry;		/* pid index */			cipher.pid_cipher_index = 0;			/* first and only cipher per pid in current implementation */			cipher.cipher_index = context->cipher_index[0];	/* 1st cipher index of this task */			err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "InitPidTablePerTask Error RMDemuxTaskPropertyID_PidEntryAddCipher"));				return err;			}		}		fprintf(stderr, "   m>   ecm_pid[0]=0x%04X pidentry[0]=0x%02x\n", (RMuint16)(context->ecm_pid[0]), (RMuint16)(context->ecm_pidentry[0]));		entry.index = context->ecm_pidentry[0];		entry.PidEntry.pid = context->ecm_pid[0];		entry.PidEntry.input_type = EMhwlibPid_Ts;		entry.PidEntry.flags = TS_FLAGS;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM RMDemuxTaskPropertyID_PidEntry", context->id));			return err;		}		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM RMDemuxTaskPropertyID_PidEntryEnable", context->id));			return err;		}	}	else {		/* disable the ecm video pid */		entry.index = context->ecm_pidentry[0];		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM0 RMDemuxTaskPropertyID_PidEntryDisable", context->id));			return err;		}	}	if ((context->ecm_pid[1] != 0x1FFF) && (context->ecm_pid[1] != context->ecm_pid[0])) {		// Apply cipher to pid of audio		cipher.index = context->audio_pidentry;		/* pid index */		cipher.pid_cipher_index = 0;			/* first and only cipher per pid in current implementation */#if defined(MULTI2_ARIB_STREAM_1_TO_7) || defined(MULTI2_TR26_ECM_X2)		cipher.cipher_index = context->cipher_index[0];	/* Quick test: force video and audio share the same cipher index */#else		cipher.cipher_index = context->cipher_index[1];	/* 2nd cipher index of this task */#endif		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "InitPidTablePerTask Error RMDemuxTaskPropertyID_PidEntryAddCipher"));			return err;		}		fprintf(stderr, "   m>   ecm_pid[1]=0x%04X pidentry[1]=0x%02x\n", (RMuint16)(context->ecm_pid[1]), (RMuint16)(context->ecm_pidentry[1]));		entry.index = context->ecm_pidentry[1];		entry.PidEntry.pid = context->ecm_pid[1];		entry.PidEntry.input_type = EMhwlibPid_Ts;		entry.PidEntry.flags = TS_FLAGS;		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntry, &entry, sizeof(entry), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM RMDemuxTaskPropertyID_PidEntry", context->id));			return err;		}		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryEnable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM RMDemuxTaskPropertyID_PidEntryEnable", context->id));			return err;		}	}	else {		/* disable the ecm audio pid */		entry.index = context->ecm_pidentry[1];		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryDisable, &entry.index, sizeof(entry.index), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "%ld_SetHwAVPlayback Error ECM1 RMDemuxTaskPropertyID_PidEntryDisable", context->id));			return err;		}	}#if (FORCE_DECRYPTION)	if ( (  (context->app_type == aes_cbc_decryption) 		|| (context->app_type == aes_ecb_decryption)		|| (context->app_type == aes_ofb_decryption)		|| (context->app_type == aes_nsa_decryption)		|| (context->app_type == multi2_decryption)		|| (context->app_type == dvbcsa_decryption) ) && 	    ((context->ecm_pid[0] == 0x1FFF) && (context->ecm_pid[1] = 0x1FFF))) {		// Apply cipher to pid of video		cipher.index = context->video_pidentry;		/* pid index */		cipher.pid_cipher_index = 0;			/* first and only cipher per pid in current implementation */		cipher.cipher_index = context->cipher_index[0];	/* 1st cipher index of this task */		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "InitPidTablePerTask Error RMDemuxTaskPropertyID_PidEntryAddCipher"));			return err;		}		// Apply cipher to pid of audio		cipher.index = context->audio_pidentry;		/* pid index */		cipher.pid_cipher_index = 0;			/* first and only cipher per pid in current implementation */		cipher.cipher_index = context->cipher_index[0];	/* 1st cipher index of this task */		err = RUASetProperty(context->pRUA, context->demux_task, RMDemuxTaskPropertyID_PidEntryAddCipher, &cipher, sizeof(cipher), 0);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "InitPidTablePerTask Error RMDemuxTaskPropertyID_PidEntryAddCipher"));			return err;		}	}#endif	return RM_OK;}static RMstatus SwitchAudioDecoder(struct context_per_task *context, enum AudioDecoder_Codec_type ACodec){	RMstatus err = RM_OK;	if (context->audio_opt->Codec == ACodec) return err;	RMDBGLOG((ENABLE, "%lx_SwitchAudioDecoder: from %u to %u SPDIF[%u]\n",		context->id, context->audio_opt->Codec, ACodec, context->audio_opt->Spdif));	context->audio_opt->Codec = ACodec;	if (ACodec == AudioDecoder_Codec_AC3) {		context->audio_opt->Ac3Params.OutputChannels = Ac3_LR;					if (!context->audio_opt->OutputChannelsExplicitAssign)			context->audio_opt->OutputChannels = Audio_Out_Ch_LR;	}	/* apply the audio format - uninit, set codec, set specific parameters, init */	err = apply_audio_decoder_options(context->dcc_info, context->audio_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "%lx_Error applying audio_decoder_options err=%d\n", context->id, err));		return RM_ERROR;	}	apply_dvi_hdmi_audio_options(context->dcc_info, context->audio_opt, 0, FALSE, FALSE, FALSE);	err = Play(context, RM_DEVICES_AUDIO, VideoDecoder_Command_PlayFwd);	return err;}static RMstatus SwitchVideoDecoder(struct context_per_task *context, enum VideoDecoder_Codec_type VCodec, enum MPEG_Profile MPEGProfile){	RMstatus err = RM_OK;	RMuint32 dummy;	struct ReceiveThreshold_type rec_thr;	struct DemuxOutput_Connect_type	connect;	RMuint32 demux_output;	if ((context->video_opt->MPEGProfile == MPEGProfile) && (context->video_opt->Codec == VCodec))		return err;	fprintf(stderr, "\nSwitch Video Codec from %u to %u Profile from %u to %u\n", context->video_opt->Codec, VCodec, context->video_opt->MPEGProfile, MPEGProfile);	demux_output = EMHWLIB_MODULE(DemuxOutput, context->videoDemuxOutputIndex + output_count_per_task * context->id); 	err = RUASetProperty(context->pRUA, demux_output, RMDemuxOutputPropertyID_Close, &dummy, sizeof(dummy), 0);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "SwitchVideoDecoder cannot close DemuxOutput %lu err=%d\n", demux_output, err));		return err;	}	RMDBGLOG((LOCALDBG, "SwitchVideoDecoder: CloseVideoSource %p\n", context->dcc_info->pVideoSource));	err = DCCCloseVideoSource(context->dcc_info->pVideoSource);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "%lx_Error cannot close vid

⌨️ 快捷键说明

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