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

📄 main.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 4 页
字号:
			PrintUsage();			return 1;		}	}	if (dump_mode && !url_arg) {		fprintf(stdout, "Missing argument for dump\n");		PrintUsage();		if (logfile) fclose(logfile);		return 1;	}	if (dump_mode) rti_file = NULL;	cfg_file = loadconfigfile(the_cfg);	if (!cfg_file) {		fprintf(stdout, "Error: Configuration File \"GPAC.cfg\" not found\n");		if (logfile) fclose(logfile);		return 1;	}	gf_sys_init();		gf_sys_get_rti(500, &rti, GF_RTI_SYSTEM_MEMORY_ONLY);	memory_at_gpac_startup = rti.physical_memory_avail;	if (rti_file) init_rti_logs(rti_file, url_arg);	/*setup dumping options*/	if (dump_mode) {		if (rend_mode==2) user.init_flags |= GF_TERM_FORCE_3D;		else if (rend_mode==1) user.init_flags |= GF_TERM_FORCE_2D;		user.init_flags |= GF_TERM_NO_AUDIO | GF_TERM_NO_VISUAL_THREAD | GF_TERM_NO_REGULATION /*| GF_TERM_INIT_HIDE*/;		if (!visible) user.init_flags |= GF_TERM_INIT_HIDE;	} else {		init_w = width;		init_h = height;	}	fprintf(stdout, "Loading modules ... ");	str = gf_cfg_get_key(cfg_file, "General", "ModulesDirectory");	user.modules = gf_modules_new((const unsigned char *) str, cfg_file);	i = gf_modules_get_count(user.modules);	if (!i) {		fprintf(stdout, "Error: no modules found in %s - exiting\n", str);		gf_modules_del(user.modules);		gf_cfg_del(cfg_file);		gf_sys_close();		if (logfile) fclose(logfile);		return 1;	}	fprintf(stdout, "OK (%d found in %s)\n", i, str);	user.config = cfg_file;	user.EventProc = GPAC_EventProc;	/*dummy in this case (global vars) but MUST be non-NULL*/	user.opaque = user.modules;	if (not_threaded) user.init_flags |= GF_TERM_NO_VISUAL_THREAD;	fprintf(stdout, "Loading GPAC Terminal ... ");		term = gf_term_new(&user);	if (!term) {		fprintf(stdout, "\nInit error - check you have at least one video out...\nFound modules:\n");		list_modules(user.modules);		gf_modules_del(user.modules);		gf_cfg_del(cfg_file);		gf_sys_close();		if (logfile) fclose(logfile);		return 1;	}	fprintf(stdout, "OK\n");	if (dump_mode) {//		gf_term_set_option(term, GF_OPT_VISIBLE, 0);		if (fill_ar) gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN);	} else {		/*check video output*/		str = gf_cfg_get_key(cfg_file, "Video", "DriverName");		if (!strcmp(str, "Raw Video Output")) fprintf(stdout, "WARNING: using raw output video (memory only) - no display used\n");		/*check audio output*/		str = gf_cfg_get_key(cfg_file, "Audio", "DriverName");		if (!strcmp(str, "No Audio Output Available")) fprintf(stdout, "WARNING: no audio output availble - make sure no other program is locking the sound card\n");		str = gf_cfg_get_key(cfg_file, "General", "NoMIMETypeFetch");		no_mime_check = (str && !stricmp(str, "yes")) ? 1 : 0;	}	if (rend_mode) {		fprintf(stdout, "Using %dD renderer\n", (rend_mode==2) ? 3 : 2);	} else {		fprintf(stdout, "Using %s\n", gf_cfg_get_key(cfg_file, "Rendering", "RendererName"));	}	str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Enabled");	if (str && !strcmp(str, "yes")) {		str = gf_cfg_get_key(cfg_file, "HTTPProxy", "Name");		if (str) fprintf(stdout, "HTTP Proxy %s enabled\n", str);	}	if (rti_file) {		memory_at_gpac_load = 0;		UpdateRTInfo("Before connecting ...");	}	Run = 1;	ret = 1;#ifndef GPAC_READ_ONLY	if (dump_mode) {		if (!nb_times) {			times[0] = 0;			nb_times++;		}		ret = dump_file(url_arg, dump_mode, fps, width, height, times, nb_times);		Run = 0;	} else#endif	/*connect if requested*/	if (url_arg) {		char *ext;		strcpy(the_url, url_arg);		ext = strrchr(the_url, '.');		if (ext && !stricmp(ext, ".m3u")) {			fprintf(stdout, "Opening Playlist %s\n", the_url);			playlist = fopen(the_url, "rt");			if (playlist) {				fscanf(playlist, "%s", the_url);				fprintf(stdout, "Opening URL %s\n", the_url);				gf_term_connect(term, the_url);			} else {				fprintf(stdout, "Hit 'h' for help\n\n");			}		} else {			fprintf(stdout, "Opening URL %s\n", the_url);			gf_term_connect(term, the_url);		}	} else {		fprintf(stdout, "Hit 'h' for help\n\n");		str = gf_cfg_get_key(cfg_file, "General", "StartupFile");		if (str) {			strcpy(the_url, "MP4Client "GPAC_VERSION);			gf_term_connect(term, str);			startup_file = 1;		}	}	if (start_fs) gf_term_set_option(term, GF_OPT_FULLSCREEN, 1);	while (Run) {		char c;				/*we don't want getchar to block*/		if (!gf_prompt_has_input()) {//			UpdateRTInfo("");			if (not_threaded) {				gf_term_process_step(term);			} else {				gf_sleep(RTI_UPDATE_TIME_MS);			}			continue;		}		c = gf_prompt_get_char();		switch (c) {		case 'q':			Run = 0;			break;		case 'o':			startup_file = 0;			gf_term_disconnect(term);			fprintf(stdout, "Enter the absolute URL\n");			scanf("%s", the_url);			if (rti_file) init_rti_logs(rti_file, the_url);			gf_term_connect(term, the_url);			break;		case 'O':			gf_term_disconnect(term);			fprintf(stdout, "Enter the absolute URL to the playlist\n");			scanf("%s", the_url);			playlist = fopen(the_url, "rt");			if (playlist) {				fscanf(playlist, "%s", the_url);				fprintf(stdout, "Opening URL %s\n", the_url);				gf_term_connect(term, the_url);			}			break;		case '\n':		case 'N':			if (playlist) {				gf_term_disconnect(term);				if (fscanf(playlist, "%s", the_url) == EOF) {					fprintf(stdout, "No more items - exiting\n");					Run = 0;				} else {					fprintf(stdout, "Opening URL %s\n", the_url);					gf_term_connect(term, the_url);				}			}			break;		case 'P':			if (playlist) {				u32 count;				gf_term_disconnect(term);				scanf("%d", &count);				while (count) {					fscanf(playlist, "%s", the_url);					count--;				}				fprintf(stdout, "Opening URL %s\n", the_url);				gf_term_connect(term, the_url);			}			break;		case 'r':			if (is_connected) {				gf_term_disconnect(term);				gf_term_connect(term, startup_file ? gf_cfg_get_key(cfg_file, "General", "StartupFile") : the_url);			}			break;				case 'D':			if (is_connected) gf_term_disconnect(term);			break;		case 'p':			if (is_connected) {				Bool is_pause = gf_term_get_option(term, GF_OPT_PLAY_STATE);				fprintf(stdout, "[Status: %s]\n", is_pause ? "Playing" : "Paused");				gf_term_set_option(term, GF_OPT_PLAY_STATE, is_pause ? GF_STATE_PLAYING : GF_STATE_PAUSED);			}			break;		case 's':			if (is_connected) {				gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);				fprintf(stdout, "Step time: ");				PrintTime(gf_term_get_time_in_ms(term));				fprintf(stdout, "\n");			}			break;		case 'z':			if (!CanSeek || (Duration<=2000)) {				fprintf(stdout, "scene not seekable\n");			} else {				Double res;				s32 seekTo;				fprintf(stdout, "Duration: ");				PrintTime(Duration);				res = gf_term_get_time_in_ms(term);				res *= 100; res /= (s64)Duration;				fprintf(stdout, " (current %.2f %%)\nEnter Seek percentage:\n", res);				if (scanf("%d", &seekTo) == 1) { 					if (seekTo > 100) seekTo = 100;					res = (Double)(s64)Duration; res /= 100; res *= seekTo;					gf_term_play_from_time(term, (u64) (s64) res, 0);				}			}			break;		case 't':		{			if (is_connected) {				fprintf(stdout, "Current Time: ");				PrintTime(gf_term_get_time_in_ms(term));				fprintf(stdout, " - Duration: ");				PrintTime(Duration);				fprintf(stdout, "\n");			}		}			break;		case 'w':			if (is_connected) PrintWorldInfo(term);			break;		case 'v':			if (is_connected) PrintODList(term);			break;		case 'i':			if (is_connected) {				u32 ID;				fprintf(stdout, "Enter OD ID (0 for main OD): ");				scanf("%d", &ID);				ViewOD(term, ID);			}			break;		case 'b':			if (is_connected) ViewODs(term, 1);			break;		case 'm':			if (is_connected) ViewODs(term, 0);			break;		case 'l':			list_modules(user.modules);			break;		case 'n':			if (is_connected) set_navigation();			break;		case 'x':			if (is_connected) gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0);			break;		case 'd':			if (is_connected) {				char file[GF_MAX_PATH], *sExt;				GF_Err e;				Bool xml_dump, std_out;				fprintf(stdout, "Enter file radical name (+\'.x\' for XML dumping) - \"std\" for stdout: ");				scanf("%s", file);				sExt = strrchr(file, '.');				xml_dump = 0;				if (sExt) {					if (!stricmp(sExt, ".x")) xml_dump = 1;					sExt[0] = 0;				}				std_out = strnicmp(file, "std", 3) ? 0 : 1;				e = gf_term_dump_scene(term, std_out ? NULL : file, xml_dump, 0, NULL);				fprintf(stdout, "Dump done (%s)\n", gf_error_to_string(e));			}			break;		case 'c':			PrintGPACConfig();			break;		case '2':		case '3':		{			GF_Terminal *a_term;			u32 now = gf_term_get_time_in_ms(term);			Bool reconnect = (is_connected && !startup_file) ? 1 : 0;			str = gf_cfg_get_key(cfg_file, "Rendering", "RendererName");			if (strstr(str, "2D") && (c=='2')) { fprintf(stdout, "Already using 2D Renderer\n"); break; }			if (strstr(str, "3D") && (c=='3')) { fprintf(stdout, "Already using 3D Renderer\n"); break; }			if (is_connected) gf_term_disconnect(term);			a_term = term;			term = NULL;			gf_term_del(a_term);			gf_cfg_set_key(cfg_file, "Rendering", "RendererName", (c=='2') ? "GPAC 2D Renderer" : "GPAC 3D Renderer");			term = gf_term_new(&user);			if (!term) {				fprintf(stdout, "Error reloading renderer - aborting\n");				goto exit;			}			fprintf(stdout, "Using %s\n", gf_cfg_get_key(cfg_file, "Rendering", "RendererName"));			if (reconnect) gf_term_connect_from_time(term, the_url, now, 0);			else if (startup_file) {				gf_term_connect(term, gf_cfg_get_key(cfg_file, "General", "StartupFile"));			}		}			break;		case 'k':		{			Bool opt = gf_term_get_option(term, GF_OPT_STRESS_MODE);			opt = !opt;			fprintf(stdout, "Turning stress mode %s\n", opt ? "on" : "off");			gf_term_set_option(term, GF_OPT_STRESS_MODE, opt);		}			break;		case '4': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break;		case '5': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break;		case '6': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break;		case '7': gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break;		case 'C':			switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {			case GF_MEDIA_CACHE_DISABLED: gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_ENABLED); break;			case GF_MEDIA_CACHE_ENABLED: gf_term_set_option(term, GF_OPT_MEDIA_CACHE, GF_MEDIA_CACHE_DISABLED); break;			case GF_MEDIA_CACHE_RUNNING: fprintf(stdout, "Streaming Cache is running - please stop it first\n"); continue;			}			switch (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)) {			case GF_MEDIA_CACHE_ENABLED: fprintf(stdout, "Streaming Cache Enabled\n"); break;			case GF_MEDIA_CACHE_DISABLED: fprintf(stdout, "Streaming Cache Disabled\n"); break;			case GF_MEDIA_CACHE_RUNNING: fprintf(stdout, "Streaming Cache Running\n"); break;			}			break;		case 'S':		case 'A':			if (gf_term_get_option(term, GF_OPT_MEDIA_CACHE)==GF_MEDIA_CACHE_RUNNING) {				gf_term_set_option(term, GF_OPT_MEDIA_CACHE, (c=='S') ? GF_MEDIA_CACHE_DISABLED : GF_MEDIA_CACHE_DISCARD);				fprintf(stdout, "Streaming Cache stoped\n");			} else {				fprintf(stdout, "Streaming Cache not running\n");			}			break;		case 'R':			display_rti = !display_rti;			ResetCaption();			break;		case 'u':		{			GF_Err e;			char szCom[8192];			fprintf(stdout, "Enter command to send:\n");			fflush(stdin);			szCom[0] = 0;			scanf("%[^\t\n]", szCom);			e = gf_term_scene_update(term, NULL, szCom);			if (e) fprintf(stdout, "Processing command failed: %s\n", gf_error_to_string(e));		}			break;		case 'L':		{			char szLog[1024];			fprintf(stdout, "Enter new log level:\n");			scanf("%s", szLog);			gf_log_set_level(parse_log_level(szLog));		}			break;		case 'M':		{			char szLog[1024];			fprintf(stdout, "Enter new log tools:\n");			scanf("%s", szLog);			gf_log_set_tools(parse_log_tools(szLog));		}			break;		case 'g':		{			GF_SystemRTInfo rti;			gf_sys_get_rti(RTI_UPDATE_TIME_MS, &rti, 0);			fprintf(stdout, "GPAC allocated memory "LLD"\n", rti.gpac_memory);		}			break;		case 'h':			PrintHelp();			break;		default:			break;		}	}	gf_term_disconnect(term);	if (rti_file) UpdateRTInfo("disconnected");	fprintf(stdout, "Deleting terminal... ");	if (playlist) fclose(playlist);	gf_term_del(term);	fprintf(stdout, "OK\n");exit:	fprintf(stdout, "Unloading modules... ");	gf_modules_del(user.modules);	fprintf(stdout, "OK\n");	gf_cfg_del(cfg_file);	gf_sys_close();	if (rti_logs) fclose(rti_logs);	if (logfile) fclose(logfile);	return 0;}

⌨️ 快捷键说明

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