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

📄 mono.c

📁 1. 8623L平台
💻 C
📖 第 1 页 / 共 3 页
字号:
}RMbool RMPlayNonInterleavedAVI(void){	RMascii key;	RMbool confirm = FALSE;	RtkRect rect;	RtkPoint point;	RtkProp prop;	if (!mono_opt.use_gui){		return TRUE;	}	/* erase whatever there was on the osd (except the logo) */	prop.lineWidth = 0;	prop.fgColor = MONO_DEFAULT_RECT_FORGROUND_COLOR;	RMFRTKDrawRect(mono_opt.rtk, &mono_opt.osd_rect, &prop);	point.x = 64;	point.y = 200;	RMFRTKDrawString(mono_opt.rtk , "Warning: non-interleaved AVI file. Play anyways?", &point,  &info_face, &rect);	gui_enable_osd(TRUE);	 get_key:	key = RMGetKey();			switch(key){	case KEY_CMD_QUIT:	case KEY_CMD_NEXT_TRACK:		confirm = FALSE;		break;	case KEY_CMD_PLAY:	case KEY_CMD_PAUSE:		confirm = TRUE;		break;	default:		RMDBGLOG((ENABLE, "Unknown command %c (%d), try again\n", key, key));		goto get_key;		break;		}	gui_enable_osd(FALSE);	return confirm;}static struct playback_cmdline local_play_opt;static struct video_cmdline local_video_opt;static struct display_cmdline local_disp_opt;static struct demux_cmdline local_demux_opt;static struct mono_context local_mono_opt;static struct dcc_context local_dcc_info;static RMbool open_path() {	RMbool is_directory = FALSE;	directory[0] = open_directory(filename); 	if(directory[0] != NULL) {		RMDBGLOG((MONODBG, "%s is a directory\n", filename));		is_directory = TRUE;		RMCopyAscii (path, filename);		if(path[RMasciiLength(path)-1] != '/')			RMAppendAscii (path, "/");		path_index[0] = RMasciiLength(path);		play_opt.filename = get_next_filename();	}	else		play_opt.filename = filename;	return is_directory;}static RMstatus play_file_app(	struct mono_info *app_params, 	enum rfp_application app){	RMuint32 i;		RMDBGLOG((ENABLE, "instances %lu\n", mono_opt.audio_instances));	app_params->audio_opt[0].audioInstances = mono_opt.audio_instances;	/* 	   replicate audio_opt[0] which was filled by rfp_detect to the rest of the audio instances;	   setup engineID and decoderID accordingly, and restore data lost during replication	*/	for (i = 1; i < mono_opt.audio_instances; i++) {		RMMemcpy(&(app_params->audio_opt[i]), &(app_params->audio_opt[0]), sizeof(struct audio_cmdline));		// we have to restore these settings according to set_audio_options		app_params->audio_opt[i].thisAudioInstance = i; 		app_params->audio_opt[i].audioInstances = mono_opt.audio_instances;		//app_params->audio_opt[i].dh_info = &dh_info;		// setup engineID and decoderID		switch (i) {		case 1:			// this is the second instance, assign it to engine 1, decoder 0 (the first instance is default engine=0 decoder=0)			app_params->audio_opt[i].AudioEngineID = 1;			app_params->audio_opt[i].AudioDecoderID = 0;			break;		case 2:			// this is the third instance, assign it to engine 0, decoder 1			app_params->audio_opt[i].AudioEngineID = 0;			app_params->audio_opt[i].AudioDecoderID = 1;			break;		case 3:			// this is the fourth instance, assign it to engine 1, decoder 1			app_params->audio_opt[i].AudioEngineID = 1;			app_params->audio_opt[i].AudioDecoderID = 1;			break;		default:			fprintf(stderr, "error when replicating %lu audio instances\n", mono_opt.audio_instances);			break;		}	}	print_parsed_audio_options(app_params->audio_opt);	/* in case we use psfdemux, force some STC/PTS delay */	if ((app == APP_DEMUX) && (app_params->play_opt->video_delay_ms == 0)) {		app_params->play_opt->video_delay_ms = 500;		app_params->play_opt->audio_delay_ms = 500;	}	return rfp_play(app_params, app);}static void init_globals(){	/* Init static global variables in case we are used in a library, and	 * it is not the first call */	filename = NULL;	remote_dev = NULL;	rh = (RMremoteHandle) NULL;	RMMemset(&dcc_info, 0, sizeof(dcc_info));	RMMemset(&play_opt, 0, sizeof(play_opt));	RMMemset(&video_opt, 0, sizeof(video_opt));	RMMemset(&disp_opt, 0, sizeof(disp_opt));	RMMemset(&mono_opt, 0, sizeof(mono_opt));	RMMemset(&demux_opt, 0, sizeof(demux_opt));	init_playback_options(&play_opt);	init_video_options(&video_opt);	init_display_options(&disp_opt);	mono_opt.recurse_dirs = FALSE;	mono_opt.use_gui = TRUE;	mono_opt.demux_decode = mono_decode_auto;	mono_opt.jpeg_decode = mono_decode_auto;	mono_opt.force_sd = FALSE;	mono_opt.display_cc = TRUE;	mono_opt.cc_select = EMhwlibCCSelect_CC1;	mono_opt.use_soft_cc_decoder = 0;	mono_opt.audio_instances = 1;	mono_opt.display_error_threshold = 0;	mono_opt.AnchorErrPropagationThreshold = 500;	mono_opt.AnchorErrPropagationLength = 13;}int main(int argc, char **argv){	RMstatus err;	remoteHandleType *handle = (remoteHandleType *) NULL;	RMbool is_directory = FALSE;	int error = 0;	struct rfp_detect_options detect_opt;	enum rfp_application app = NOT_SUPPORTED;	struct mono_info app_params;	struct rfp_stream_info stream_info;	RMuint32 SRM_Size;	RMuint8 SRM[SRM_SIZE];	// comment the following line to compile this file under em8620branch	struct dh_context dh_info;		struct audio_cmdline audio_options[MAX_AUDIO_DECODER_INSTANCES]; /*access through audio_opt*/	RMuint32 i;		init_globals();	// Initialize the HTTP stream options data structure	init_stream_options(&app_params.stream_opts);	app_params.play_opt = &play_opt;	app_params.video_opt = &video_opt;	app_params.demux_opt = &demux_opt;	app_params.disp_opt = &disp_opt;	app_params.audio_opt = audio_options;		// comment the following lines to compile this file under em8620branch	RMMemset(&dh_info, 0, sizeof(dh_info));	disp_opt.dh_info = &dh_info;	for (i = 0; i < MAX_AUDIO_DECODER_INSTANCES; i++)		audio_options[i].dh_info = &dh_info;		dh_info.pSRM = SRM;	SRM_Size = SRM_SIZE;	err = Read_SRM(dh_info.pSRM, &SRM_Size);	parse_cmdline(argc, argv, &app_params);	RMDBGLOG((ENABLE, ">>> Mono will be using %lu audio instances\n", mono_opt.audio_instances));	app_params.osd_scaler = 0;	app_params.video_scaler = disp_opt.video_scaler;	err = init_dcc_info();	if (RMFAILED(err)) {		RMDBGLOG((MONODBG, "Could not create RUA and DCC handles %d\n", err));		return -1;	}	dcc_info.dh_info = &dh_info;	err = apply_playback_options(&dcc_info, &play_opt);	if (RMFAILED(err)) {		RMDBGLOG((MONODBG, "Cannot set playback options %d\n", err));		ERROR_CLEANUP(-1);	}		if (remote_dev != NULL) {		if (RMlocalRemoteOpen(remote_dev,&handle) != RM_OK) {			RMDBGLOG((MONODBG,"Cannot open remote control \"%s\"\n",remote_dev));			ERROR_CLEANUP(-1);		}		rh = RMFremoteOpenEx((void *)handle, PseudoFileReadWithTimeout, RMFlushCallback, RMSleepCallback, PseudoFileAvailable);		if (rh != 0){			printf("remote device %s successfully opened\n", remote_dev);		}		else {			RMDBGLOG((MONODBG,"Cannot open remote control \"%s\"\n",remote_dev));			RMlocalRemoteClose(&handle);			ERROR_CLEANUP(-1);		}	}	err = DCCGetScalerModuleID(dcc_info.pDCC, dcc_info.route, DCCSurface_Video, app_params.video_scaler, &(dcc_info.SurfaceID));	if (RMFAILED(err)) {		RMDBGLOG((ENABLE, "Cannot get surface to display video source %d\n", err));		ERROR_CLEANUP(-1);	}	err = apply_display_options(&dcc_info, &disp_opt);	if (RMFAILED(err)) {		RMDBGLOG((MONODBG, "Cannot set display options %d\n", err));		ERROR_CLEANUP(-1);	}		if (mono_opt.use_gui){		err = gui_init_osd();		if (RMFAILED(err)) {			fprintf(stderr, "Cannot init osd\n");			ERROR_CLEANUP(-1);		}	} else {		// Give HDMI sink 1/2 Sec to set up		RMuint32 i;		for (i = 0; i < 25; i++) {			RMMicroSecondSleep(20 * 1000);			update_hdmi(&dcc_info, app_params.disp_opt, app_params.audio_opt);		}	}		//init_doubleBuffer_OSD();	app_params.pRUA = dcc_info.pRUA;	app_params.pDCC = dcc_info.pDCC;	// Check for HDCP.SRM file in root of medium	dh_info.pSRM = SRM;	Update_SRM(filename, dh_info.pDH, dh_info.pSRM);		is_directory = open_path();	if (play_opt.filename == NULL) {		RMDBGLOG((MONODBG, "No files found on directory\n"));		ERROR_CLEANUP(-1);	}	RMMemcpy(&local_dcc_info, &dcc_info, sizeof(dcc_info));	RMMemcpy(&local_play_opt, &play_opt, sizeof(play_opt));	RMMemcpy(&local_video_opt, &video_opt, sizeof(video_opt));	RMMemcpy(&local_disp_opt, &disp_opt, sizeof(disp_opt));	RMMemcpy(&local_mono_opt, &mono_opt, sizeof(mono_opt));	RMMemcpy(&local_demux_opt, &demux_opt, sizeof(demux_opt)); new_filename:	 fprintf(stderr, "------------------------------------------ %s ----------------------\n", play_opt.filename);		RMMemcpy(&video_opt, &local_video_opt, sizeof(video_opt));	init_audio_options2(app_params.audio_opt, MAX_AUDIO_DECODER_INSTANCES);	if (video_opt.UseAFD) {		apply_active_format(dcc_info.pRUA, &disp_opt, video_opt.afd, dcc_info.SurfaceID);	}		/* set cc options after video init */	{		video_opt.display_cc = mono_opt.display_cc;		video_opt.use_soft_cc_decoder = mono_opt.use_soft_cc_decoder;		video_opt.cc_select = mono_opt.cc_select;		video_opt.display_error_threshold = mono_opt.display_error_threshold;		video_opt.anchor_error_parms.AnchorErrPropagationThreshold = mono_opt.AnchorErrPropagationThreshold;		video_opt.anchor_error_parms.AnchorErrPropagationLength = mono_opt.AnchorErrPropagationLength;	}	RMTermInit(TRUE);	RMSignalInit(NULL, NULL);	if (mono_opt.use_gui){		RMascii key = 0;		gui_show_filename();		gui_enable_osd(TRUE);		get_key:		while (! RMKeyAvailable()) {			update_hdmi(&dcc_info, app_params.disp_opt, app_params.audio_opt);		}		key = RMGetKey();				switch(key){		case KEY_CMD_QUIT:			RMTermExit();			goto cleanup;			break;		case KEY_CMD_NEXT_TRACK:			goto next_file;			break;		case KEY_CMD_PLAY:		case KEY_CMD_PAUSE:			RMremoteResetState();			break;		default:			RMDBGLOG((ENABLE, "Unknown command, try again\n"));			goto get_key;			break;		}		}	/* keep compatibility with deprecated player_conf struct */	detect_opt.force_sd = mono_opt.force_sd;	/* #### Begin DTCP code #### */	// Parse the URL searching for DTCP parameters.	// If found, initialize the DTCP subsystem.	err = init_DTCP_session(((struct dtcp_cookie**)(&app_params.dtcpCookieHandle)),				&app_params.stream_opts,				app_params.pRUA,				play_opt.filename,				FALSE);	if (RMFAILED(err)) {		fprintf(stderr, "Cannot initialize or check for DTCP-IP session correctly !!!\n");		goto cleanup;	}	/* #### End DTCP code #### */	err = rfp_detect(&app_params, &detect_opt, &app, &stream_info);	if(RMFAILED(err)){		RMDBGLOG((ENABLE, "Detection failed\n"));		if (!mono_opt.recurse_dirs) {			RMTermExit();			ERROR_CLEANUP(-1);		}		else {			RMDBGLOG((MONODBG, "skip file %s\n", play_opt.filename));			goto next_file;		}	}	/* it's up to mono (not rfp) to decide which app to use for each format */	app = get_app(&stream_info); 	if(app == NOT_SUPPORTED){		RMDBGLOG((MONODBG, "Could not play file, error %d\n", err));		if (!mono_opt.recurse_dirs) {			RMTermExit();			ERROR_CLEANUP(-1);		}		else {			RMDBGLOG((MONODBG, "skip file %s\n", play_opt.filename));			goto next_file;		}	}		if (mono_opt.use_gui) {		if(app == APP_AUDIO){			gui_show_stream_info(play_opt.filename, &stream_info);		} else {			gui_enable_osd(FALSE);		}	}		if((app == APP_VIDEO) && (stream_info.video_type == RM_VIDEO_JPEG)){		app_params.play_opt->waitexit = TRUE;	}	app_params.audio_opt[0].dh_info = &dh_info;	err = play_file_app(&app_params, app);	if (err == RM_DRM_PREVENTS_PLAYBACK)		fprintf(stderr, "DRM prevents this file's playback, skipping\n");	else if(RMFAILED(err)){		RMTermExit();		RMDBGLOG((ENABLE, "Could not play file %d\n", err));		ERROR_CLEANUP(-1);	}	 next_file:	RMTermExit();	if(is_directory){		RMMemcpy(&dcc_info, &local_dcc_info, sizeof(dcc_info));		RMMemcpy(&play_opt, &local_play_opt, sizeof(play_opt));		//RMMemcpy(&disp_opt, &local_disp_opt, sizeof(disp_opt));		//RMMemcpy(&mono_opt, &local_mono_opt, sizeof(mono_opt));		RMMemcpy(&demux_opt, &local_demux_opt, sizeof(demux_opt));		if((play_opt.filename = get_next_filename()) != NULL){			goto new_filename;		}	} cleanup:	if (is_directory) {		RMCloseDirectory(directory[0]);	}	if (rh != 0)		RMFremoteRelease(rh);		if (handle != 0)		RMlocalRemoteClose(&handle);	//if (mono_opt.use_gui){		if(mono_opt.rtk)			RMFRTKClose(mono_opt.rtk);		if (mono_opt.osd_source) {			gui_enable_osd(FALSE);			err = DCCCloseVideoSource(mono_opt.osd_source);			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Cannot close osd source %d\n", err));				return err;			}		}		if (mono_opt.pSPU_double_buffer_source) {			RMDBGLOG((ENABLE, "close doubleBufferOSD\n"));			err = DCCCloseVideoSource(mono_opt.pSPU_double_buffer_source);			mono_opt.pSPU_double_buffer_source = NULL;			if (RMFAILED(err)) {				RMDBGLOG((ENABLE, "Cannot close SPU doubleBuffer source %d\n", err));				return err;			}					}		//}	/* #### Begin DTCP code #### */	if (app_params.dtcpCookieHandle) {		err = term_DTCP_session(((struct dtcp_cookie*)(&app_params.dtcpCookieHandle)),					app_params.pRUA);		if (RMFAILED(err)) 			fprintf(stderr, "Cannot close DTCP-IP session !!!\n");		}	/* #### End DTCP code #### */		err = clear_display_options(&dcc_info, &disp_opt);	if (RMFAILED(err))		RMDBGLOG((ENABLE, "Cannot clear display options %d\n", err));		err = DCCClose(dcc_info.pDCC);	if (RMFAILED(err))		RMDBGLOG((ENABLE, "Cannot close DCC %d\n", err));	err = RUADestroyInstance(dcc_info.pRUA);	if (RMFAILED(err))		RMDBGLOG((ENABLE, "Cannot destroy RUA instance %d\n", err));	return error;}

⌨️ 快捷键说明

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