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

📄 main.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 4 页
字号:
		}		return 0;	/*we use CTRL and not ALT for keys, since windows shortcuts keypressed with ALT*/	case GF_EVENT_KEYDOWN:		if ((evt->key.flags & GF_KEY_MOD_ALT)) {			switch (evt->key.key_code) {			case GF_KEY_LEFT:				if (Duration>=2000) {					s32 res = gf_term_get_time_in_ms(term) - (s32) (5*Duration/100);					if (res<0) res=0;					fprintf(stdout, "seeking to %.2f %% (", 100.0*(s64)res / (s64)Duration);					PrintTime(res);					fprintf(stdout, ")\n");					gf_term_play_from_time(term, res, 0);				} 				break;			case GF_KEY_RIGHT:				if (Duration>=2000) {					u32 res = gf_term_get_time_in_ms(term) + (s32) (5*Duration/100);					if (res>=Duration) res = 0;					fprintf(stdout, "seeking to %.2f %% (", 100.0*(s64)res / (s64)Duration);					PrintTime(res);					fprintf(stdout, ")\n");					gf_term_play_from_time(term, res, 0);				}				break;			/*these 2 are likely not supported by most audio ouput modules*/			case GF_KEY_UP:				if (Volume!=100) { Volume = MIN(Volume + 5, 100); gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, Volume); } 				break;			case GF_KEY_DOWN: 				if (Volume) { Volume = (Volume > 5) ? (Volume-5) : 0; gf_term_set_option(term, GF_OPT_AUDIO_VOLUME, Volume); }				break;			}		} else {			switch (evt->key.key_code) {			case GF_KEY_HOME:				gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 1);				break;			case GF_KEY_ESCAPE:				gf_term_set_option(term, GF_OPT_FULLSCREEN, !gf_term_get_option(term, GF_OPT_FULLSCREEN));				break;			}		}		if (!(evt->key.flags & GF_KEY_MOD_CTRL)) return 0;		switch (evt->key.key_code) {		case GF_KEY_F:			fprintf(stdout, "Rendering rate: %f FPS\n", gf_term_get_framerate(term, 0));			break;		case GF_KEY_T:			fprintf(stdout, "Scene Time: %f \n", gf_term_get_time_in_ms(term)/1000.0);			break;		case GF_KEY_D:			gf_term_set_option(term, GF_OPT_DIRECT_RENDER, !gf_term_get_option(term, GF_OPT_DIRECT_RENDER) );			break;		case GF_KEY_4: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break;		case GF_KEY_5: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break;		case GF_KEY_6: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break;		case GF_KEY_7: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break;		case GF_KEY_P:			gf_term_set_option(term, GF_OPT_PLAY_STATE, (gf_term_get_option(term, GF_OPT_PLAY_STATE)==GF_STATE_PAUSED) ? GF_STATE_PLAYING : GF_STATE_PAUSED);			break;		case GF_KEY_S:			gf_term_set_option(term, GF_OPT_PLAY_STATE, GF_STATE_STEP_PAUSE);			break;		case GF_KEY_B:			if (is_connected) ViewODs(term, 1);			break;		case GF_KEY_M:			if (is_connected) ViewODs(term, 0);			break;		}		break;	case GF_EVENT_CONNECT:		if (evt->connect.is_connected) {			is_connected = 1;			fprintf(stdout, "Service Connected\n");			/* memory_at_gpac_load = 0;*/		} else if (is_connected) {			fprintf(stdout, "Service %s\n", is_connected ? "Disconnected" : "Connection Failed");			is_connected = 0;			Duration = 0;		}		if (init_w && init_h) {			gf_term_set_size(term, init_w, init_h);		}		ResetCaption();		break;	case GF_EVENT_SIZE:		if (user.init_flags & GF_TERM_WINDOWLESS) {			GF_Event move;			move.type = GF_EVENT_MOVE;			move.move.align_x = align_mode & 0xFF;			move.move.align_y = (align_mode>>8) & 0xFF;			move.move.relative = 2;			gf_term_user_event(term, &move);		}		break;	case GF_EVENT_METADATA:		ResetCaption();		break;	case GF_EVENT_QUIT:		Run = 0;		break;	case GF_EVENT_NAVIGATE_INFO:		if (evt->navigate.to_url) fprintf(stdout, "Go to URL: \"%s\"\r", evt->navigate.to_url);		break;	case GF_EVENT_NAVIGATE:		if (gf_term_is_supported_url(term, evt->navigate.to_url, 1, no_mime_check)) {			strcpy(the_url, evt->navigate.to_url);			fprintf(stdout, "Navigating to URL %s\n", the_url);			gf_term_navigate_to(term, evt->navigate.to_url);			return 1;		} else {			fprintf(stdout, "Navigation destination not supported\nGo to URL: %s\n", evt->navigate.to_url);		}		break;	case GF_EVENT_AUTHORIZATION:		if (!strlen(evt->auth.user)) {			fprintf(stdout, "Authorization required for site %s\n", evt->auth.site_url);			fprintf(stdout, "login: ");			scanf("%s", evt->auth.user);		} else {			fprintf(stdout, "Authorization required for %s@%s\n", evt->auth.user, evt->auth.site_url);		}		fprintf(stdout, "password: ");		gf_prompt_set_echo_off(1);		scanf("%s", evt->auth.password);		gf_prompt_set_echo_off(0);		return 1;	case GF_EVENT_SYS_COLORS:#ifdef WIN32		evt->sys_cols.sys_colors[0] = get_sys_col(COLOR_ACTIVEBORDER);		evt->sys_cols.sys_colors[1] = get_sys_col(COLOR_ACTIVECAPTION);		evt->sys_cols.sys_colors[2] = get_sys_col(COLOR_APPWORKSPACE);		evt->sys_cols.sys_colors[3] = get_sys_col(COLOR_BACKGROUND);		evt->sys_cols.sys_colors[4] = get_sys_col(COLOR_BTNFACE);		evt->sys_cols.sys_colors[5] = get_sys_col(COLOR_BTNHIGHLIGHT);		evt->sys_cols.sys_colors[6] = get_sys_col(COLOR_BTNSHADOW);		evt->sys_cols.sys_colors[7] = get_sys_col(COLOR_BTNTEXT);		evt->sys_cols.sys_colors[8] = get_sys_col(COLOR_CAPTIONTEXT);		evt->sys_cols.sys_colors[9] = get_sys_col(COLOR_GRAYTEXT);		evt->sys_cols.sys_colors[10] = get_sys_col(COLOR_HIGHLIGHT);		evt->sys_cols.sys_colors[11] = get_sys_col(COLOR_HIGHLIGHTTEXT);		evt->sys_cols.sys_colors[12] = get_sys_col(COLOR_INACTIVEBORDER);		evt->sys_cols.sys_colors[13] = get_sys_col(COLOR_INACTIVECAPTION);		evt->sys_cols.sys_colors[14] = get_sys_col(COLOR_INACTIVECAPTIONTEXT);		evt->sys_cols.sys_colors[15] = get_sys_col(COLOR_INFOBK);		evt->sys_cols.sys_colors[16] = get_sys_col(COLOR_INFOTEXT);		evt->sys_cols.sys_colors[17] = get_sys_col(COLOR_MENU);		evt->sys_cols.sys_colors[18] = get_sys_col(COLOR_MENUTEXT);		evt->sys_cols.sys_colors[19] = get_sys_col(COLOR_SCROLLBAR);		evt->sys_cols.sys_colors[20] = get_sys_col(COLOR_3DDKSHADOW);		evt->sys_cols.sys_colors[21] = get_sys_col(COLOR_3DFACE);		evt->sys_cols.sys_colors[22] = get_sys_col(COLOR_3DHIGHLIGHT);		evt->sys_cols.sys_colors[23] = get_sys_col(COLOR_3DLIGHT);		evt->sys_cols.sys_colors[24] = get_sys_col(COLOR_3DSHADOW);		evt->sys_cols.sys_colors[25] = get_sys_col(COLOR_WINDOW);		evt->sys_cols.sys_colors[26] = get_sys_col(COLOR_WINDOWFRAME);		evt->sys_cols.sys_colors[27] = get_sys_col(COLOR_WINDOWTEXT);		return 1;#else		memset(evt->sys_cols.sys_colors, 0, sizeof(u32)*28);		return 1;#endif		break;	}	return 0;}GF_Config *loadconfigfile(char *filepath){	GF_Config *cfg;	char *cfg_dir;	char szPath[GF_MAX_PATH];	if (filepath) {		cfg_dir = strrchr(szPath, '\\');		if (!cfg_dir) cfg_dir = strrchr(szPath, '/');		if (cfg_dir) {			char c = cfg_dir[0];			cfg_dir[0] = 0;			cfg = gf_cfg_new(cfg_dir, cfg_dir+1);			cfg_dir[0] = c;			if (cfg) goto success;		}	}	#ifdef WIN32	GetModuleFileNameA(NULL, szPath, GF_MAX_PATH);	cfg_dir = strrchr(szPath, '\\');	if (cfg_dir) cfg_dir[1] = 0;	cfg = gf_cfg_new(szPath, "GPAC.cfg");	if (cfg) goto success;	strcpy(szPath, ".");	cfg = gf_cfg_new(szPath, "GPAC.cfg");	if (cfg) goto success;	strcpy(szPath, "C:\\Program Files\\GPAC");	cfg = gf_cfg_new(szPath, "GPAC.cfg");	if (cfg) goto success;	strcpy(szPath, ".");	cfg = gf_cfg_new(szPath, "GPAC.cfg");	if (cfg) goto success;	GetModuleFileNameA(NULL, szPath, GF_MAX_PATH);	cfg_dir = strrchr(szPath, '\\');	if (cfg_dir) cfg_dir[1] = 0;	cfg = create_default_config(szPath, "GPAC.cfg");#else	/*linux*/	cfg_dir = getenv("HOME");	if (cfg_dir) {		strcpy(szPath, cfg_dir);	} else {		fprintf(stdout, "WARNING: HOME env var not set - using current directory for config file\n");		strcpy(szPath, ".");	}	cfg = gf_cfg_new(szPath, ".gpacrc");	if (cfg) goto success;	fprintf(stdout, "GPAC config file not found in %s - creating new file\n", szPath);	cfg = create_default_config(szPath, ".gpacrc");#endif	if (!cfg) {	  fprintf(stdout, "cannot create config file in %s directory\n", szPath);	  return NULL;	} success:	fprintf(stdout, "Using config file in %s directory\n", szPath);	return cfg;}void list_modules(GF_ModuleManager *modules){	u32 i;	fprintf(stdout, "\rAvailable modules:\n");	for (i=0; i<gf_modules_get_count(modules); i++) {		char *str = (char *) gf_modules_get_file_name(modules, i);		if (str) fprintf(stdout, "\t%s\n", str);	}	fprintf(stdout, "\n");}void set_navigation(){	GF_Err e;	char navstr[20], nav;	u32 type = gf_term_get_option(term, GF_OPT_NAVIGATION_TYPE);	e = GF_OK;	if (!type) {		fprintf(stdout, "Content/renderer doesn't allow user-selectable navigation\n");	} else if (type==1) {		fprintf(stdout, "Select Navigation (\'N\'one, \'E\'xamine, \'S\'lide): ");		scanf("%s", navstr);		nav = navstr[0];		if (nav=='N') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE);		else if (nav=='E') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE);		else if (nav=='S') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE);		else fprintf(stdout, "Unknown selector \'%c\' - only \'N\',\'E\',\'S\' allowed\n", nav);	} else if (type==2) {		fprintf(stdout, "Select Navigation (\'N\'one, \'W\'alk, \'F\'ly, \'E\'xamine, \'P\'an, \'S\'lide, \'G\'ame, \'V\'R, \'O\'rbit): ");		scanf("%s", navstr);		nav = navstr[0];		if (nav=='N') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE);		else if (nav=='W') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_WALK);		else if (nav=='F') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_FLY);		else if (nav=='E') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE);		else if (nav=='P') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_PAN);		else if (nav=='S') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE);		else if (nav=='G') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_GAME);		else if (nav=='O') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_ORBIT);		else if (nav=='V') e = gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_VR);		else fprintf(stdout, "Unknown selector %c - only \'N\',\'W\',\'F\',\'E\',\'P\',\'S\',\'G\', \'V\', \'O\' allowed\n", nav);	}	if (e) fprintf(stdout, "Error setting mode: %s\n", gf_error_to_string(e));}static u32 parse_log_tools(char *val){	char *sep;	u32 flags = 0;	while (val) {		sep = strchr(val, ':');		if (sep) sep[0] = 0;		if (!stricmp(val, "core")) flags |= GF_LOG_CORE;		else if (!stricmp(val, "coding")) flags |= GF_LOG_CODING;		else if (!stricmp(val, "container")) flags |= GF_LOG_CONTAINER;		else if (!stricmp(val, "network")) flags |= GF_LOG_NETWORK;		else if (!stricmp(val, "rtp")) flags |= GF_LOG_RTP;		else if (!stricmp(val, "author")) flags |= GF_LOG_AUTHOR;		else if (!stricmp(val, "sync")) flags |= GF_LOG_SYNC;		else if (!stricmp(val, "codec")) flags |= GF_LOG_CODEC;		else if (!stricmp(val, "parser")) flags |= GF_LOG_PARSER;		else if (!stricmp(val, "media")) flags |= GF_LOG_MEDIA;		else if (!stricmp(val, "scene")) flags |= GF_LOG_SCENE;		else if (!stricmp(val, "script")) flags |= GF_LOG_SCRIPT;		else if (!stricmp(val, "compose")) flags |= GF_LOG_COMPOSE;		else if (!stricmp(val, "render")) flags |= GF_LOG_RENDER;		else if (!stricmp(val, "service")) flags |= GF_LOG_SERVICE;		else if (!stricmp(val, "mmio")) flags |= GF_LOG_MMIO;		else if (!stricmp(val, "none")) flags = 0;		else if (!stricmp(val, "all")) flags = 0xFFFFFFFF;		if (!sep) break;		sep[0] = ':';		val = sep+1;	}	return flags;}static u32 parse_log_level(char *val){	if (!stricmp(val, "error")) return GF_LOG_ERROR;	if (!stricmp(val, "warning")) return GF_LOG_WARNING;	if (!stricmp(val, "info")) return GF_LOG_INFO;	if (!stricmp(val, "debug")) return GF_LOG_DEBUG;	return 0;}static Bool get_time_list(char *arg, u32 *times, u32 *nb_times){	char *str;	Float var;	Double sec;	u32 h, m, s, ms, f, fps;	if (!arg || (arg[0]=='-') || !isdigit(arg[0])) return 0;	/*SMPTE time code*/	if (strchr(arg, ':') && strchr(arg, ';') && strchr(arg, '/')) {		if (sscanf(arg, "%02d:%02d:%02d;%02d/%02d", &h, &m, &s, &f, &fps)==5) {			sec = 0;			if (fps) sec = ((Double)f) / fps;			sec += 3600*h + 60*m + s;			times[*nb_times] = (u32) (1000*sec);			*nb_times ++;			return 1;		}	}	while (arg) {		str = strchr(arg, '-');		if (str) str[0] = 0;		/*HH:MM:SS:MS time code*/		if (strchr(arg, ':') && (sscanf(arg, "%02d:%02d:%02d:%02d", &h, &m, &s, &ms)==4)) {			sec = ms;			sec /= 1000;			sec += 3600*h + 60*m + s;			times[*nb_times] = (u32) (1000*sec);			(*nb_times) ++;		} else if (sscanf(arg, "%f", &var)==1) {			sec = atof(arg);			times[*nb_times] = (u32) (1000*sec);			(*nb_times) ++;		}		if (!str) break;		str[0] = '-';		arg = str+1;	}	return 1;}static void on_gpac_log(void *cbk, u32 ll, u32 lm, const char *fmt, va_list list){	FILE *logs = cbk;    vfprintf(logs, fmt, list);	fflush(logs);}int main (int argc, char **argv){	const char *str;	u32 i, width, height, times[100], nb_times, rend_mode, dump_mode;	Bool start_fs = 0;	Double fps = 25.0;	Bool ret, fill_ar, visible;	char *url_arg, *the_cfg, *rti_file;	GF_SystemRTInfo rti;	FILE *playlist = NULL;	FILE *logfile = NULL;	/*by default use current dir*/	strcpy(the_url, ".");	memset(&user, 0, sizeof(GF_User));	dump_mode = rend_mode = 0;	fill_ar = visible = 0;	url_arg = the_cfg = rti_file = NULL;	width = height = 0;	nb_times = 0;	times[0] = 0;	for (i=1; i<(u32) argc; i++) {		char *arg = argv[i];		if (isalnum(arg[0]) || (arg[0]=='/') || (arg[0]=='.') || (arg[0]=='\\') ) {			url_arg = arg;		} else if (!strcmp(arg, "-c") || !strcmp(arg, "-cfg")) {			the_cfg = argv[i+1];			i++;		} else if (!strcmp(arg, "-rti")) {			rti_file = argv[i+1];			i++;		} else if (!strcmp(arg, "-fill")) {			fill_ar = 1;		} else if (!strcmp(arg, "-show")) {			visible = 1;		} else if (!strcmp(arg, "-avi")) {			dump_mode = 1;			if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;		} else if (!strcmp(arg, "-bmp")) {			dump_mode = 2;			if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;		} else if (!strcmp(arg, "-raw")) {			dump_mode = 3;			if ((url_arg || (i+2<(u32)argc)) && get_time_list(argv[i+1], times, &nb_times)) i++;		} else if (!stricmp(arg, "-size")) {			if (sscanf(argv[i+1], "%dx%d", &width, &height) != 2) {				width = height = 0;			}			i++;		} else if (!stricmp(arg, "-fps")) {			fps = atof(argv[i+1]);			i++;		} else if (!stricmp(arg, "-2d")) {			rend_mode = 1;		} else if (!stricmp(arg, "-3d")) {			rend_mode = 2;		} else if (!strcmp(arg, "-quiet")) {			be_quiet = 1;		} else if (!strcmp(arg, "-log-file")) {			logfile = fopen(argv[i+1], "wt");			gf_log_set_callback(logfile, on_gpac_log);			i++;		} else if (!strcmp(arg, "-log-level")) {			gf_log_set_level(parse_log_level(argv[i+1]));			i++;		} else if (!strcmp(arg, "-log-tools")) {			gf_log_set_tools(parse_log_tools(argv[i+1]));			i++;		} else if (!strcmp(arg, "-align")) {			if (argv[i+1][0]=='m') align_mode = 1;			else if (argv[i+1][0]=='b') align_mode = 2;			align_mode <<= 8;			if (argv[i+1][1]=='m') align_mode |= 1;			else if (argv[i+1][1]=='r') align_mode |= 2;			i++;		}		else if (!strcmp(arg, "-no-wnd")) user.init_flags |= GF_TERM_WINDOWLESS;		else if (!strcmp(arg, "-no-thread")) not_threaded = 1;		else if (!strcmp(arg, "-fs")) start_fs = 1;		else {

⌨️ 快捷键说明

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