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

📄 asfdemux_callback.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * * Copyright (c) Sigma Designs, Inc. 2006. All rights reserved. * *//**   @file asfdemux_callback.c   @brief common callbacks of play_asf and play_asf_streaming applications	   @author Laurent Crinon   @ingroup dccsamplecode*/#include "../samples/sample_os.h"#define ALLOW_OS_CODE 1#include "../dcc/include/dcc.h"#include "../rmasfdemux/include/rmasfdemuxapi.h"#include "../rmasfdemux/include/wmdrm.h"#include "../rmasfdemux/include/wmdrmopl.h"#include "common.h"#include "../rmwmaprodecoder/include/rmwmaprodefine.h"#include "../rmwmaprodecoder/include/rmwmaprodecoderapi.h"/* #### Begin CARDEA code #### */#include "rmupnp/rmlibwmdrmnd/include/ms_cardea.h"/* #### End CARDEA code #### *//* ################## Begin DTCP code ################### */#if (EM86XX_CHIP == EM86XX_CHIPID_TANGO15)#include "../rmdtcp/include/dtcp_session.h"#else#include "../rmdtcpapi/include/dtcp_session.h"#endif/* ############### End DTCP code ####################### */#include "bcc.h"#include "asfdemux_common.h"#if 0#define PAYLOADDBG ENABLE#else#define PAYLOADDBG DISABLE#endif#if 0#define SENDDBG ENABLE#else#define SENDDBG DISABLE#endif#if 0#define IFRAMEDBG ENABLE#else#define IFRAMEDBG DISABLE#endif#if 0#define VC1_STARTCODE_DBG ENABLE#else#define VC1_STARTCODE_DBG DISABLE#endifstatic RMuint32 RMSupported_codec_list[] = {0x161,0x7A21,0x7A21,0x162,0x163,0x1};/* static functions *//* #### Begin CARDEA code #### */#if (EM86XX_CHIP == EM86XX_CHIPID_TANGO2)static void test_cci( void *cardea_context ) {	struct rmcci	cci_info;	RMstatus	status;	memset( &cci_info, 0xff, sizeof(cci_info) );	status = get_cardea_cci( cardea_context, &cci_info );	if ( status == RM_OK ) {		fprintf(stderr, "----   CCI information   ----\n");		fprintf(stderr, "Dirty                   : %d\n", cci_info.DirtyBit);		fprintf(stderr, "Audio disable\n");		fprintf(stderr, " Analog                 : %d\n", cci_info.AnalogAudio_disable);		fprintf(stderr, " Digital Compressed     : %d\n", cci_info.DigitalCompressedAudio_disable);		fprintf(stderr, " Digital Uncompressed   : %d\n", cci_info.DigitalUncompressedAudio_disable);		fprintf(stderr, "SPDIF PCM limit         : %d\n", cci_info.SPDIF_PCMLimit);		fprintf(stderr, "SPDIF Cp Bit            : %d\n", cci_info.SPDIF_CpBit);		fprintf(stderr, "SPDIF L Bit             : %d\n", cci_info.SPDIF_LBit);		fprintf(stderr, "Analog Video disable    : %d\n", cci_info.AnalogVideo_disable);		fprintf(stderr, "Video AGC               : %lu\n", cci_info.Video_agc);		fprintf(stderr, "Video CGMSA             : %lu\n", cci_info.Video_CGMSA);		fprintf(stderr, "Digital Video disable   : %d\n", cci_info.DigitalVideo_disable);		fprintf(stderr, "Analog Video Constraint : %d\n", cci_info.AnalogVideo_imageConstraint);		fprintf(stderr, "HDCP Enable             : %d\n", cci_info.HDCP_Enable);	}}#endif/* #### End CARDEA code #### */static RMbool parseVC1SeqHeader(struct asf_context *pSendContext, RMuint8 *buffer, RMuint32 size){	RMuint32 i;	RMuint32 entryHeaderFound = 0;	RMuint32 entryHeaderSize = 0;	if (size < 3)		return FALSE;	for (i = 3; i < size; i++) {		if ((entryHeaderFound) && (buffer[i-2] != 0) && (buffer[i-1] != 0) && (buffer[i] != 1))			entryHeaderSize++;				if ((buffer[i-3] == 0) && (buffer[i-2] == 0) && (buffer[i-1] == 1) && (buffer[i] == 0xe)) {			pSendContext->entryHeader = (buffer + i - 3);			entryHeaderFound = i;		}	}	pSendContext->entryHeaderSize = entryHeaderSize + 4;	if (entryHeaderFound) {		RMDBGLOG((ENABLE, "entryHeader found at i=%lu, size %lu\n", entryHeaderFound - 3, pSendContext->entryHeaderSize));#if 0		RMDBGLOG((ENABLE, "hacking it by clearing Broken_link and setting Closed_entry\n"));		*(pSendContext->entryHeader + 4) = *(pSendContext->entryHeader + 4) | 0xC;#endif		for (i = 0; i < pSendContext->entryHeaderSize; i++)			fprintf(stderr, "0x%02X ", *(pSendContext->entryHeader + i));		fprintf(stderr, "\n");		return TRUE;	}	return FALSE;}/** * Setup the video decoder, according to the given context * * @param pSendContext - context to use for the setup * @return RM_OK on sucess */static RMstatus setup_video_decoder(struct asf_context *pSendContext){	struct DCCVideoSource *pVideoSource = NULL;	RMuint32 surfaceID;	RMstatus err;		if (pSendContext == NULL)		return RM_ERROR;	{		struct DCCXVideoProfile video_profile;		enum EMhwlibVideoCodec vcodec;		RMDBGLOG((ENABLE, "*** setup_video_decoder ***\n"));		video_profile.ProtectedFlags = 0;		video_profile.BitstreamFIFOSize = pSendContext->video_opt->fifo_size;		video_profile.XferFIFOCount = pSendContext->video_opt->xfer_count;		RMDBGLOG((ENABLE, "bitstream fifo %ld, count %ld\n", pSendContext->video_opt->fifo_size, pSendContext->video_opt->xfer_count));		video_profile.MpegEngineID = pSendContext->video_opt->MpegEngineID;		video_profile.VideoDecoderID = pSendContext->video_opt->VideoDecoderID;		video_profile.PtsFIFOCount = 180;		video_profile.InbandFIFOCount = 16;		video_profile.XtaskInbandFIFOCount = 0;		video_profile.SPUBitstreamFIFOSize = 0;		video_profile.SPUXferFIFOCount = 0;		video_profile.STCID = pSendContext->play_opt->STCid;			/* set codec based on command line options either "-pv" or "-vcodec" */		if (pSendContext->video_opt->vcodec_max_width) {			video_profile.Codec = pSendContext->video_opt->vcodec;			video_profile.Profile = pSendContext->video_opt->vcodec_profile;			video_profile.Level = pSendContext->video_opt->vcodec_level;			video_profile.MaxWidth = pSendContext->video_opt->vcodec_max_width;			video_profile.MaxHeight = pSendContext->video_opt->vcodec_max_height;		}		else {			err = video_profile_to_codec(pSendContext->video_opt->Codec, 						     &video_profile.Codec,						     &video_profile.Profile, 						     &video_profile.Level, 						     &video_profile.ExtraPictureBufferCount,						     &video_profile.MaxWidth, 						     &video_profile.MaxHeight);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Unknown video decoder codec \n"));				return err;			}		}		/* set the extra pictures after the profile to codec conversion */		video_profile.ExtraPictureBufferCount = pSendContext->video_opt->vcodec_extra_pictures;		err = DCCXOpenVideoDecoderSource(pSendContext->dcc_info->pDCC, &video_profile, &pVideoSource);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot open video decoder %d\n", err));			return err;		}				vcodec = video_profile.Codec;		err = DCCXSetVideoDecoderSourceCodec(pVideoSource, vcodec);		if (RMFAILED(err)) {			RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err));			return err;		}	}	pSendContext->dcc_info->pVideoSource = pVideoSource;#if 0	// test for uninit/init problem seen when we set 816P then DIVX3 codec	err = DCCSetVideoDecoderSourceCodec(pVideoSource, VideoDecoder_Codec_DIVX3_SD);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot set video decoder codec %d\n", err));		goto exit_with_error;	}#endif	RMDBGLOG((ENABLE, "get scaler module\n"));	err = DCCGetScalerModuleID(pSendContext->dcc_info->pDCC, pSendContext->dcc_info->route , DCCSurface_Video, pSendContext->videoscaler_id, &surfaceID);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot get surface to display video source %d\n", err));		return RM_ERROR;	}	pSendContext->dcc_info->SurfaceID = surfaceID;	RMDBGLOG((ENABLE, "set surface\n"));	err = DCCSetSurfaceSource(pSendContext->dcc_info->pDCC, surfaceID, pVideoSource);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot set the surface source %d\n", err));		return err;	}	RMDBGLOG((ENABLE, "get video decoder info\n"));	err = DCCGetVideoDecoderSourceInfo(pVideoSource, 			&(pSendContext->dcc_info->video_decoder), 			&(pSendContext->dcc_info->spu_decoder), 			&(pSendContext->dcc_info->video_timer));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error getting video decoder source information %d\n", err));		return err;	}#ifndef WITH_MONO	pSendContext->dcc_info->disp_info = &pSendContext->disp_info;	set_default_out_window(&(pSendContext->dcc_info->disp_info->out_window));	set_default_out_window(&(pSendContext->dcc_info->disp_info->osd_window[0]));	set_default_out_window(&(pSendContext->dcc_info->disp_info->osd_window[1]));	pSendContext->dcc_info->disp_info->active_window = &(pSendContext->dcc_info->disp_info->out_window);	pSendContext->dcc_info->disp_info->video_enable = TRUE;	RMDBGLOG((ENABLE, "apply display options\n"));	err = apply_display_options(pSendContext->dcc_info, pSendContext->disp_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot set display opions %d\n", err));		return err;	}#endif /*WITH_MONO*/	// apply the fixed vop rate if required	RMDBGLOG((ENABLE, "apply video decoder options\n"));	err = apply_video_decoder_options(pSendContext->dcc_info, pSendContext->video_opt);	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Error applying video_decoder_options %d\n", err));		return err;	}#if 0	{		struct DisplayBlock_SurfaceAspectRatio_type param;				param.type = EMhwlibAspectRatio_Display;		param.ar.Y = pSendContext->wmv9_prop.Image_Height;		param.ar.X = pSendContext->wmv9_prop.Image_Width;		RMDBGLOG((ENABLE, "******************set aspect ratio\n"));		if (pSendContext->pRUA) {			err = RUASetProperty(pSendContext->pRUA, DisplayBlock, RMDisplayBlockPropertyID_SurfaceAspectRatio, &param, sizeof(param), 0);			if (err != RM_OK) {				RMDBGLOG((ENABLE, "errrrrrrrrrrrrrrrrrrrrroooooooooooor!\n"));			}		}	}#endif	return RM_OK;}/** * Setup the audio decoder, according to the given context * * @param pSendContext - context to use for the setup * @return RM_OK on sucess */static RMstatus setup_audio_decoder(struct asf_context *pSendContext){	struct dcc_context *dcc_info = pSendContext->dcc_info;	struct DCCAudioProfile audio_profiles[MAX_AUDIO_DECODER_INSTANCES];	//struct RUABufferPool *pDMAuncompressed;	RMstatus err;	RMuint32 i;	if (!pSendContext->audio_parameters[pSendContext->audio_stream_index].enabled)		return RM_ERROR;	RMDBGLOG((ENABLE, "*** setup_audio_decoder ***\n"));	for (i = 0 ; i < pSendContext->audioInstances; i++) {		audio_profiles[i].BitstreamFIFOSize = pSendContext->audio_opt[i].fifo_size;		audio_profiles[i].XferFIFOCount = pSendContext->audio_opt[i].xfer_count;		audio_profiles[i].DemuxProgramID = pSendContext->audio_opt[i].AudioEngineID * 2;		audio_profiles[i].AudioEngineID = pSendContext->audio_opt[i].AudioEngineID;		audio_profiles[i].AudioDecoderID = pSendContext->audio_opt[i].AudioDecoderID;		audio_profiles[i].STCID = pSendContext->play_opt->STCid;	}		err = DCCOpenMultipleAudioDecoderSource(dcc_info->pDCC, audio_profiles, pSendContext->audioInstances, &(dcc_info->pMultipleAudioSource));		if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot open multiple audio decoder %d\n", err));		return err;	}			return RM_OK;}static RMstatus initVideoDecoder(struct asf_context * context){	if(context->video_decoder_initialized == FALSE) {		RMstatus err = RM_ERROR;		RMDBGLOG((ENABLE, "initVideoDecoder\n"));		switch(context->Compression_ID) {		case 0x3334504D: // MP43			err = RUASetProperty(context->pRUA, 					     context->dcc_info->video_decoder, 					     RMVideoDecoderPropertyID_DIVX3VSProp, 					     &context->divx3_prop, sizeof(context->divx3_prop), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE,"Error setting DIVX3 video info : %d !\n", err));				return err;			}			break;		case 0x33564D57: //WMV3			RMDBGLOG((ENABLE, "video prop : seq 0x%08lx, %ld x %ld\n", 				  context->wmv9_prop.Sequence, 				  context->wmv9_prop.Image_Width,			          context->wmv9_prop.Image_Height));						err = RUASetProperty(context->pRUA, 					     context->dcc_info->video_decoder,					     RMVideoDecoderPropertyID_WMV9VSProp, 					     &context->wmv9_prop, sizeof(context->wmv9_prop), 0);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE,"Error setting WMV9 video info : %d !\n", err));				return RM_ERROR;			}			break;		case 0x41564D57: //WMVA - Windows Media Video 9 Advanced Profile		case 0x31435657: //WVC1			RMDBGLOG((ENABLE, "VC1 Advanced Profile\n"));

⌨️ 快捷键说明

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