📄 wxosmo4.cpp
字号:
return 0;}void wxOsmo4Frame::ShowViewWindow(Bool do_show){ m_pView->Show(do_show ? 1 : 0);#ifdef __WXGTK__ //m_pView->Show(0);#endif}#ifdef __WXGTK__extern "C" {#ifdef __WXGTK20__ int gdk_x11_drawable_get_xid( void * ); void *gdk_x11_drawable_get_xdisplay( void * );#endif void *gtk_widget_get_parent_window( void * );}#endifvoid wxOsmo4Frame::CheckVideoOut(){ const char *sOpt = gf_cfg_get_key(m_user.config, "Video", "DriverName"); void *os_handle = NULL; void *os_display = NULL; /*build a child window for embed display*/ if (stricmp(sOpt, "SDL Video Output")) { if (m_user.os_window_handler) return; m_bExternalView = 0;#ifdef __WXGTK__ GtkWidget* widget = m_pVisual->GetHandle();#ifdef __WXGTK20__ os_handle = (void *) gdk_x11_drawable_get_xid(gtk_widget_get_parent_window(widget));#else os_handle = (void *)*(int *)( (char *)gtk_widget_get_parent_window(widget) + 2 * sizeof(void *) );#endif#elif defined (WIN32) os_handle = m_pView->GetHandle();#endif if (os_handle) { m_user.os_window_handler = os_handle; m_user.os_display = os_display; ShowViewWindow(1); m_pView->SetSize(320, 240); SetSize(wxSize(320, 240+FRAME_H)); SetWindowStyle(wxDEFAULT_FRAME_STYLE); DoLayout(320, 240); return; } } /*we're using SDL, don't use SDL hack*/ m_bExternalView = 1; m_user.os_window_handler = 0; m_user.os_display = NULL; SetSize(wxSize(320,FRAME_H)); m_pView->SetSize(0, 0); ShowViewWindow(0); DoLayout(); SetWindowStyle(wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER));}static void wxOsmo4_do_log(void *cbk, u32 level, u32 tool, const char *fmt, va_list list){ wxOsmo4Frame *osmo = (wxOsmo4Frame *)cbk; if (osmo->m_logs) { vfprintf(osmo->m_logs, fmt, list); fflush(osmo->m_logs); } else { ::wxVLogMessage(wxString(fmt, wxConvUTF8), list); }}Bool wxOsmo4Frame::LoadTerminal(){ m_term = NULL; memset(&m_user, 0, sizeof(GF_User)); /*locate exec dir for cfg file*/ wxPathList pathList; wxString currentDir(wxGetCwd()); wxString abs_gpac_path = wxT(""); const char *gpac_cfg; ::wxLogMessage(wxT("Looking for GPAC configuration file"));#if defined(__WXMAC__) && !defined(__DARWIN__) // On Mac, the current directory is the relevant one when the application starts. abs_gpac_path = wxGetCwd(); gpac_cfg = "GPAC.cfg";#else#ifdef WIN32 wxOsmo4App &app = wxGetApp(); gpac_cfg = "GPAC.cfg"; /*locate exe*/ if (wxIsAbsolutePath(app.argv[0])) { abs_gpac_path = wxPathOnly(app.argv[0]); } else { if (currentDir.Last() != wxFILE_SEP_PATH) currentDir += wxFILE_SEP_PATH; abs_gpac_path = currentDir + app.argv[0]; if (wxFileExists(abs_gpac_path)) { abs_gpac_path = wxPathOnly(abs_gpac_path); } else { abs_gpac_path = wxT(""); pathList.AddEnvList(wxT("PATH")); abs_gpac_path = pathList.FindAbsoluteValidPath(app.argv[0]); if (!abs_gpac_path.IsEmpty()) { abs_gpac_path = wxPathOnly(abs_gpac_path); } else { /*ask user*/ wxDirDialog dlg(NULL, wxT("Locate GPAC config file directory")); if ( dlg.ShowModal() != wxID_OK ) return 0; abs_gpac_path = dlg.GetPath(); } } }#else gpac_cfg = ".gpacrc"; char *cfg_dir = getenv("HOME"); if (cfg_dir) { abs_gpac_path = wxString(cfg_dir, wxConvUTF8); } else { /*ask user*/ wxDirDialog dlg(NULL, wxT("Locate GPAC config file directory")); if ( dlg.ShowModal() != wxID_OK ) return 0; abs_gpac_path = dlg.GetPath(); }#endif#endif /*load config*/ m_user.config = gf_cfg_new(abs_gpac_path.mb_str(wxConvUTF8), gpac_cfg); if (!m_user.config) { unsigned char config_file[GF_MAX_PATH]; strcpy((char *) config_file, (const char *) abs_gpac_path.mb_str(wxConvUTF8)); if (config_file[strlen((char *) config_file)-1] != GF_PATH_SEPARATOR) { char szSep[2]; szSep[0] = GF_PATH_SEPARATOR; szSep[1] = 0; strcat((char *) config_file, (const char *)szSep); } strcat((char *) config_file, gpac_cfg); FILE *ft = fopen((const char *) config_file, "wt"); if (!ft) { wxMessageDialog(NULL, wxT("Cannot create blank config file"), wxT("Init error"), wxOK).ShowModal(); return 0; } fclose(ft); m_user.config = gf_cfg_new(abs_gpac_path.mb_str(wxConvUTF8), gpac_cfg); if (!m_user.config) { wxMessageDialog(NULL, wxT("Cannot open GPAC configuration file"), wxT("Init error"), wxOK); return 0; } } strcpy(szAppPath, abs_gpac_path.mb_str(wxConvUTF8)); if (szAppPath[strlen(szAppPath)] != GF_PATH_SEPARATOR) sprintf(szAppPath, "%s%c", szAppPath, GF_PATH_SEPARATOR); /*check log file*/ const char *str = gf_cfg_get_key(m_user.config, "General", "LogFile"); if (str) m_logs = fopen(str, "wt"); gf_log_set_callback(this, wxOsmo4_do_log); /*set log level*/ m_log_level = 0; str = gf_cfg_get_key(m_user.config, "General", "LogLevel"); if (str) { if (!stricmp(str, "debug")) m_log_level = GF_LOG_DEBUG; else if (!stricmp(str, "info")) m_log_level = GF_LOG_INFO; else if (!stricmp(str, "warning")) m_log_level = GF_LOG_WARNING; else if (!stricmp(str, "error")) m_log_level = GF_LOG_ERROR; gf_log_set_level(m_log_level); } /*set log tools*/ m_log_tools = 0; str = gf_cfg_get_key(m_user.config, "General", "LogTools"); if (str) { char *sep; char *val = (char *) str; while (val) { sep = strchr(val, ':'); if (sep) sep[0] = 0; if (!stricmp(val, "core")) m_log_tools |= GF_LOG_CODING; else if (!stricmp(val, "coding")) m_log_tools |= GF_LOG_CODING; else if (!stricmp(val, "container")) m_log_tools |= GF_LOG_CONTAINER; else if (!stricmp(val, "network")) m_log_tools |= GF_LOG_NETWORK; else if (!stricmp(val, "rtp")) m_log_tools |= GF_LOG_RTP; else if (!stricmp(val, "author")) m_log_tools |= GF_LOG_AUTHOR; else if (!stricmp(val, "sync")) m_log_tools |= GF_LOG_SYNC; else if (!stricmp(val, "codec")) m_log_tools |= GF_LOG_CODEC; else if (!stricmp(val, "parser")) m_log_tools |= GF_LOG_PARSER; else if (!stricmp(val, "media")) m_log_tools |= GF_LOG_MEDIA; else if (!stricmp(val, "scene")) m_log_tools |= GF_LOG_SCENE; else if (!stricmp(val, "script")) m_log_tools |= GF_LOG_SCRIPT; else if (!stricmp(val, "compose")) m_log_tools |= GF_LOG_COMPOSE; else if (!stricmp(val, "render")) m_log_tools |= GF_LOG_RENDER; else if (!stricmp(val, "service")) m_log_tools |= GF_LOG_SERVICE; else if (!stricmp(val, "mmio")) m_log_tools |= GF_LOG_MMIO; else if (!stricmp(val, "none")) m_log_tools = 0; else if (!stricmp(val, "all")) m_log_tools = 0xFFFFFFFF; if (!sep) break; sep[0] = ':'; val = sep+1; } gf_log_set_tools(m_log_tools); } gf_sys_init(); ::wxLogMessage(wxT("GPAC configuration file opened - looking for modules")); str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); Bool first_launch = 0; if (!str) { first_launch = 1;#ifdef GPAC_MODULES_PATH str = GPAC_MODULES_PATH;#else str = abs_gpac_path.mb_str(wxConvUTF8);#endif } m_user.modules = gf_modules_new(str, m_user.config); /*initial launch*/ if (first_launch || !gf_modules_get_count(m_user.modules)) { const char *sOpt; wxDirDialog dlg(NULL, wxT("Locate GPAC modules directory")); if (!gf_modules_get_count(m_user.modules)) { gf_modules_del(m_user.modules); m_user.modules = NULL; if ( dlg.ShowModal() != wxID_OK ) return false; str = dlg.GetPath().mb_str(wxConvUTF8); m_user.modules = gf_modules_new(str, m_user.config); if (!m_user.modules || !gf_modules_get_count(m_user.modules) ) { wxMessageDialog(NULL, wxT("Cannot find any modules for GPAC"), wxT("Init error"), wxOK); gf_cfg_del(m_user.config); return 0; } } u32 i; for (i=0; i<gf_modules_get_count(m_user.modules); i++) { GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(m_user.modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; if (ifce) { ifce->CanHandleURL(ifce, "test.test"); gf_modules_close_interface((GF_BaseInterface *) ifce); } } gf_cfg_set_key(m_user.config, "General", "ModulesDirectory", (const char *) str); /*setup UDP traffic autodetect*/ gf_cfg_set_key(m_user.config, "Network", "AutoReconfigUDP", "yes"); gf_cfg_set_key(m_user.config, "Network", "UDPNotAvailable", "no"); gf_cfg_set_key(m_user.config, "Network", "UDPTimeout", "10000"); gf_cfg_set_key(m_user.config, "Network", "BufferLength", "3000"); /*check audio config on windows, force config*/ sOpt = gf_cfg_get_key(m_user.config, "Audio", "ForceConfig"); if (!sOpt) { gf_cfg_set_key(m_user.config, "Audio", "ForceConfig", "yes"); gf_cfg_set_key(m_user.config, "Audio", "NumBuffers", "2"); gf_cfg_set_key(m_user.config, "Audio", "TotalDuration", "120"); } gf_cfg_set_key(m_user.config, "Rendering", "RendererName", "GPAC 2D Renderer");#ifdef WIN32 unsigned char str_path[MAX_PATH]; sOpt = gf_cfg_get_key(m_user.config, "Rendering", "Raster2D"); if (!sOpt) gf_cfg_set_key(m_user.config, "Rendering", "Raster2D", "gdip_rend"); sOpt = gf_cfg_get_key(m_user.config, "General", "CacheDirectory"); if (!sOpt) { sprintf((char *) str_path, "%scache", abs_gpac_path.mb_str(wxConvUTF8)); gf_cfg_set_key(m_user.config, "General", "CacheDirectory", (const char *) str_path); } /*by default use GDIplus, much faster than freetype on font loading*/ gf_cfg_set_key(m_user.config, "FontEngine", "DriverName", "gdip_rend"); gf_cfg_set_key(m_user.config, "Video", "DriverName", "DirectX Video Output"); sOpt = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (!sOpt) { sprintf((char *) str_path, "%sgpac.mp4", abs_gpac_path.mb_str(wxConvUTF8)); gf_cfg_set_key(m_user.config, "General", "StartupFile", (const char *) str_path); }#else#if defined(__DARWIN__) || defined(__APPLE__) wxDirDialog dlg3(NULL, wxT("Please specify a cache directory for GPAC")); dlg3.SetPath(wxT("/tmp")); if ( dlg3.ShowModal() == wxID_OK ) gf_cfg_set_key(m_user.config, "General", "CacheDirectory", (const char *) dlg3.GetPath().mb_str(wxConvUTF8) ); wxDirDialog dlg2(NULL, wxT("Please locate a TrueType font repository on your system for text support")); dlg2.SetPath(wxT("/usr/share/fonts/truetype")); if ( dlg2.ShowModal() == wxID_OK ) gf_cfg_set_key(m_user.config, "FontEngine", "FontDirectory", (const char *) dlg2.GetPath().mb_str(wxConvUTF8) ); gf_cfg_set_key(m_user.config, "Video", "DriverName", "SDL Video Output"); gf_cfg_set_key(m_user.config, "Render2D", "ScalableZoom", "no");#else gf_cfg_set_key(m_user.config, "FontEngine", "FontDirectory", "/usr/share/fonts/truetype/"); /*these fonts seems installed by default on many systems...*/ gf_cfg_set_key(m_user.config, "FontEngine", "FontSerif", "Bitstream Vera Serif"); gf_cfg_set_key(m_user.config, "FontEngine", "FontSans", "Bitstream Vera Sans"); gf_cfg_set_key(m_user.config, "FontEngine", "FontFixed", "Bitstream Vera Monospace"); gf_cfg_set_key(m_user.config, "General", "CacheDirectory", "/tmp"); gf_cfg_set_key(m_user.config, "Video", "DriverName", "X11 Video Output"); gf_cfg_set_key(m_user.config, "Render2D", "ScalableZoom", "yes"); gf_cfg_set_key(m_user.config, "Audio", "DriverName", "SDL Audio Output");#endif sOpt = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (!sOpt) { FILE *test; test = fopen("/usr/local/share/gpac/gpac.mp4", "rb"); if (test) { gf_cfg_set_key(m_user.config, "General", "StartupFile", "/usr/local/share/gpac/gpac.mp4"); fclose(test); } else { test = fopen("/usr/share/gpac/gpac.mp4", "rb"); if (test) { gf_cfg_set_key(m_user.config, "General", "StartupFile", "/usr/share/gpac/gpac.mp4"); fclose(test); } } }#endif } if (! gf_modules_get_count(m_user.modules) ) { wxMessageDialog(NULL, wxT("No modules available - system cannot work"), wxT("Fatal Error"), wxOK).ShowModal(); gf_modules_del(m_user.modules); gf_cfg_del(m_user.config); return 0; } ::wxLogMessage(wxT("%d modules found:"), gf_modules_get_count(m_user.modules)); for (u32 i=0; i<gf_modules_get_count(m_user.modules); i++) { ::wxLogMessage(wxT("\t") + wxString(gf_modules_get_file_name(m_user.modules, i), wxConvUTF8) ); } ::wxLogMessage(wxT("Starting GPAC Terminal")); /*now load terminal*/ m_user.opaque = this; m_user.EventProc = GPAC_EventProc; CheckVideoOut(); m_term = gf_term_new(&m_user); if (!m_term) { wxMessageDialog(NULL, wxT("Fatal Error"), wxT("Cannot load GPAC Terminal"), wxOK).ShowModal(); return 0; } else { ::wxLogMessage(wxT("GPAC Terminal started - using ") + wxString(gf_cfg_get_key(m_user.config, "Rendering", "RendererName"), wxConvUTF8) ); } return 1;}wxOsmo4Frame::wxOsmo4Frame() : wxFrame((wxFrame *) NULL, -1, wxT("Osmo4 - GPAC"), wxPoint(-1, -1), wxSize(320, FRAME_H), //wxDEFAULT_FRAME_STYLE & ~(wxMAXIMIZE_BOX | wxRESIZE_BORDER)wxDEFAULT_FRAME_STYLE ){ int ws[3]; m_Address = NULL; m_pView = NULL; m_term = NULL; SetIcon(wxIcon(osmo4)); m_bExternalView = 0; m_last_prog = -1; m_num_chapters = 0; m_chapters_start = NULL; m_bViewRTI = 0; m_logs = NULL; m_bStartupFile = 0; gf_set_progress_callback(this, wxOsmo4_progress_cbk); myDropfiles *droptarget = new myDropfiles(); droptarget->m_pMain = this; SetDropTarget(droptarget); m_pLogs = new GPACLogs(this); m_bGrabbed = 0; /*new menu bar*/ wxMenuBar *b = new wxMenuBar(); /*file*/ wxMenu *menu = new wxMenu(); menu->Append(FILE_OPEN, wxT("&Open File\tCtrl+O"), wxT("Open local presentation")); menu->Append(FILE_OPEN_URL, wxT("&Open URL\tCtrl+U"), wxT("Open remote presentation")); menu->AppendSeparator(); menu->Append(FILE_PROPERTIES, wxT("&Properties\tCtrl+I"), wxT("Show presentation properties")); wxMenu *smenu = new wxMenu(); smenu->Append(ID_MCACHE_ENABLE, wxT("&Enable"), wxT("Turns Recorder On/Off"));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -