void do_open_file() { gf_cfg_set_key(user.config, "RecentFiles", the_url, NULL); gf_cfg_insert_key(user.config, "RecentFiles", the_url, "", 0); u32 count = gf_cfg_get_key_count(user.config, "RecentFiles"); if (count > 10) gf_cfg_set_key(user.config, "RecentFiles", gf_cfg_get_key_name(user.config, "RecentFiles", count-1), NULL); setup_logs(); gf_term_connect(term, the_url); }
Bool LoadTerminal() { /*by default use current dir*/ strcpy(the_url, "."); setup_logs(); g_hwnd_disp = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE , 0, 0, disp_w, disp_h, g_hwnd, NULL, g_hinst, NULL); user.EventProc = GPAC_EventProc; /*dummy in this case (global vars) but MUST be non-NULL*/ user.opaque = user.modules; user.os_window_handler = g_hwnd_disp; #ifdef TERM_NOT_THREADED user.init_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION; #endif term = gf_term_new(&user); if (!term) { gf_modules_del(user.modules); gf_cfg_del(user.config); memset(&user, 0, sizeof(GF_User)); return 0; } #ifdef _WIN32_WCE screen_w = term->compositor->video_out->max_screen_width; screen_h = term->compositor->video_out->max_screen_height; disp_w = screen_w; disp_h = screen_h - menu_h /*- caption_h*/; #endif #ifdef TERM_NOT_THREADED ::SetTimer(g_hwnd, GPAC_TIMER_ID, GPAC_TIMER_DUR, NULL); #endif const char *str = gf_cfg_get_key(user.config, "General", "StartupFile"); if (str) { do_layout(1); strcpy(the_url, str); gf_term_connect(term, str); } return 1; }
static void rewrite_log_tools(u32 tool) { char *logs; if (tool == GF_LOG_ALL) { gf_log_set_tool_level(GF_LOG_ALL, log_level); } else { if (gf_log_tool_level_on(tool, log_level)) { gf_log_set_tool_level(tool, GF_LOG_QUIET); } else { gf_log_set_tool_level(tool, log_level); } } logs = gf_log_get_tools_levels(); if (logs) { gf_cfg_set_key(user.config, "General", "Logs", logs); gf_free(logs); } setup_logs(); }
BOOL HandleCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case IDM_FILE_OPEN: open_file(hwnd); break; case IDM_FILE_LOG_RTI: log_rti = !log_rti; setup_logs(); break; case IDM_FILE_PAUSE: pause_file(); break; case IDM_VIEW_ABOUT: view_about(hwnd); break; case IDM_VIEW_FS: set_full_screen(); break; case IDM_VIEW_STATUS: show_status = !show_status; gf_cfg_set_key(user.config, "General", "ShowStatusBar", show_status ? "yes" : "no"); do_layout(1); break; case IDM_VIEW_CPU: view_cpu = !view_cpu; break; case IDM_VIEW_FORCEGL: force_2d_gl = !force_2d_gl; gf_cfg_set_key(user.config, "Compositor", "ForceOpenGL", force_2d_gl ? "yes" : "no"); gf_term_set_option(term, GF_OPT_USE_OPENGL, force_2d_gl); break; case IDM_NAV_RESET: gf_term_set_option(term, GF_OPT_NAVIGATION_TYPE, 0); break; case IDM_NAV_NONE: gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_NONE); break; case IDM_NAV_SLIDE: gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_SLIDE); break; case IDM_NAV_WALK: gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_WALK); break; case IDM_NAV_FLY: gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_FLY); break; case IDM_NAV_EXAMINE: gf_term_set_option(term, GF_OPT_NAVIGATION, GF_NAVIGATE_EXAMINE); break; case IDM_NAV_HEADLIGHT: gf_term_set_option(term, GF_OPT_HEADLIGHT, !gf_term_get_option(term, GF_OPT_HEADLIGHT) ); break; case IDM_NAV_COL_NONE: gf_term_set_option(term, GF_OPT_COLLISION, GF_COLLISION_NONE); break; case IDM_NAV_COL_REG: gf_term_set_option(term, GF_OPT_COLLISION, GF_COLLISION_NORMAL); break; case IDM_NAV_COL_DISP: gf_term_set_option(term, GF_OPT_COLLISION, GF_COLLISION_DISPLACEMENT); break; case IDM_NAV_GRAVITY: gf_term_set_option(term, GF_OPT_GRAVITY, !gf_term_get_option(term, GF_OPT_GRAVITY)); break; case IDM_VIEW_AR_NONE: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_KEEP); break; case IDM_VIEW_AR_FILL: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_FILL_SCREEN); break; case IDM_VIEW_AR_4_3: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_4_3); break; case IDM_VIEW_AR_16_9: gf_term_set_option(term, GF_OPT_ASPECT_RATIO, GF_ASPECT_RATIO_16_9); break; case IDM_VIEW_LOW_RATE: use_low_fps = !use_low_fps; gf_term_set_simulation_frame_rate(term, use_low_fps ? 15.0 : 30.0); break; case ID_VIDEO_DIRECTDRAW: { u32 drend = (gf_term_get_option(term, GF_OPT_DRAW_MODE)==GF_DRAW_MODE_IMMEDIATE) ? GF_DRAW_MODE_DEFER : GF_DRAW_MODE_IMMEDIATE; gf_term_set_option(term, GF_OPT_DRAW_MODE, drend); gf_cfg_set_key(user.config, "Compositor", "DrawMode", drend ? "immediate" : "defer"); } break; case ID_FILE_CUT_PASTE: do_copy_paste(); break; case IDM_OPEN_FILE1: case IDM_OPEN_FILE2: case IDM_OPEN_FILE3: case IDM_OPEN_FILE4: case IDM_OPEN_FILE5: case IDM_OPEN_FILE6: case IDM_OPEN_FILE7: case IDM_OPEN_FILE8: case IDM_OPEN_FILE9: case IDM_OPEN_FILE10: load_recent_file(LOWORD(wParam) - IDM_OPEN_FILE1); break; case IDS_CAP_DISABLE_PLAYLIST: playlist_navigation_on = !playlist_navigation_on; break; case IDM_VIEW_SVG_LOAD: set_svg_progressive(); break; case ID_VIDEO_DIRECTFB: set_gx_mode(0); break; case ID_VIDEO_GAPI: set_gx_mode(1); break; case ID_VIDEO_GDI: set_gx_mode(2); break; case ID_LOGLEVEL_NONE: log_level = GF_LOG_QUIET; rewrite_log_tools(GF_LOG_ALL); break; case ID_LOGLEVEL_ERROR: log_level = GF_LOG_ERROR; rewrite_log_tools(GF_LOG_ALL); break; case ID_LOGLEVEL_WARNING: log_level = GF_LOG_WARNING; rewrite_log_tools(GF_LOG_ALL); break; case ID_LOGLEVEL_INFO: log_level = GF_LOG_INFO; rewrite_log_tools(GF_LOG_ALL); break; case ID_LOGLEVEL_DEBUG: log_level = GF_LOG_DEBUG; rewrite_log_tools(GF_LOG_ALL); break; case ID_TOOLS_CORE: rewrite_log_tools(GF_LOG_CORE); break; case ID_TOOLS_CODING: rewrite_log_tools(GF_LOG_CODING); break; case ID_TOOLS_CONTAINER: rewrite_log_tools(GF_LOG_CONTAINER); break; case ID_TOOLS_NETWORK: rewrite_log_tools(GF_LOG_NETWORK); break; case ID_TOOLS_RTP: rewrite_log_tools(GF_LOG_RTP); break; case ID_TOOLS_SCRIPT: rewrite_log_tools(GF_LOG_SCRIPT); break; case ID_TOOLS_CODEC: rewrite_log_tools(GF_LOG_CODEC); break; case ID_TOOLS_PARSER: rewrite_log_tools(GF_LOG_PARSER); break; case ID_TOOLS_MEDIA: rewrite_log_tools(GF_LOG_MEDIA); break; case ID_TOOLS_SCENE: rewrite_log_tools(GF_LOG_SCENE); break; case ID_TOOLS_INTERACT: rewrite_log_tools(GF_LOG_INTERACT); break; case ID_TOOLS_COMPOSE: rewrite_log_tools(GF_LOG_COMPOSE); break; case ID_TOOLS_MMIO: rewrite_log_tools(GF_LOG_MMIO); break; case ID_TOOLS_RTI: rewrite_log_tools(GF_LOG_RTI); break; case ID_TOOLS_ALL: rewrite_log_tools(GF_LOG_ALL); break; case ID_TOOLS_NONE: log_level = GF_LOG_QUIET; rewrite_log_tools(GF_LOG_ALL); break; case ID_LOGS_RESET: if (log_file) { fclose(log_file); log_file = NULL; } { const char *filename = gf_cfg_get_key(user.config, "General", "LogFile"); if (filename) gf_delete_file(filename); } setup_logs(); break; case IDM_ITEM_QUIT: DestroyWindow(hwnd); return FALSE; } return TRUE; }
int main(int argc, char* argv[]) { // Simulation configuration int num_of_clients = 50; // Indexing int i,j,n,l; // Temporary Logging generalLog_filepath = TEST3_GENERAL_LOG; starting_k = 5; max_k = 20; ignore_count = 3; if( getenv("SUDO_UID") ) { user_uid = atoi(getenv("SUDO_UID")); } else { printf("You need sudo to run the test\n"); exit(0); } #ifdef HARD_UPPER_LIMIT if( argc > 1 ) { upper_limit = atoi(argv[1]); } #endif if( argc > 2 ) { num_of_clients = atoi(argv[2]); } seteuid(user_uid); setfsuid(user_uid); setup_logs(); // Statistical variables running_stats_t rs; //set_default_running_stats( &rs ); create_service("group",group_count); for( l=1; l <= sizeof(group_size_array)/sizeof(int); l++) { group_size = group_size_array[l-1]; num_of_clients = group_size; set_default_running_stats( &rs ); printf("===================Pre-test Runs=====================\n"); for( j = 0; j < ignore_count; j++ ) { // ignore first few iterations timeLog_file = fopen( timeLog_filepath, "w" ); fclose(timeLog_file); test3( timeLog_filepath, num_of_clients, 1); } printf("===================Starting KSM1=====================\n"); resultsLogRAW_file = fopen( resultsLogRAW_filepath, "a" ); fprintf(resultsLogRAW_file, "===================Starting KSM1=====================\n"); if(resultsLogRAW_file) fclose(resultsLogRAW_file); run_test3(&rs, num_of_clients, 1); log_data( test3_dat_ksm1_filepath, group_size, &rs ); set_default_running_stats( &rs ); printf("===================Pre-test Runs=====================\n"); for( j = 0; j < ignore_count; j++ ) { // ignore first few iterations timeLog_file = fopen( timeLog_filepath, "w" ); fclose(timeLog_file); test3( timeLog_filepath, num_of_clients, 2); } printf("===================Starting KSM2=====================\n"); resultsLogRAW_file = fopen( resultsLogRAW_filepath, "a" ); fprintf(resultsLogRAW_file, "===================Starting KSM2=====================\n"); if(resultsLogRAW_file) fclose(resultsLogRAW_file); run_test3(&rs, num_of_clients, 2); log_data( test3_dat_ksm2_filepath, group_size, &rs ); } delete_service("group",group_count); merge_data(test3_dat_filepath, test3_dat_ksm1_filepath, test3_dat_ksm2_filepath); remove(test3_dat_ksm1_filepath); remove(test3_dat_ksm2_filepath); remove(timeLog_filepath); return 0; }