GF_FontManager *gf_font_manager_new(GF_User *user) { char *def_font = "SERIF"; u32 i, count; GF_FontManager *font_mgr; GF_FontReader *ifce; const char *opt; ifce = NULL; opt = gf_cfg_get_key(user->config, "FontEngine", "FontReader"); if (opt) { ifce = (GF_FontReader *) gf_modules_load_interface_by_name(user->modules, opt, GF_FONT_READER_INTERFACE); if (ifce && ifce->init_font_engine(ifce) != GF_OK) { gf_modules_close_interface((GF_BaseInterface *)ifce); ifce = NULL; } } if (!ifce) { count = gf_modules_get_count(user->modules); for (i=0; i<count; i++) { ifce = (GF_FontReader *) gf_modules_load_interface(user->modules, i, GF_FONT_READER_INTERFACE); if (!ifce) continue; if (ifce->init_font_engine(ifce) != GF_OK) { gf_modules_close_interface((GF_BaseInterface *)ifce); ifce = NULL; continue; } gf_cfg_set_key(user->config, "FontEngine", "FontReader", ifce->module_name); break; } } GF_SAFEALLOC(font_mgr, GF_FontManager); font_mgr->reader = ifce; font_mgr->id_buffer_size = 20; font_mgr->id_buffer = gf_malloc(sizeof(u32)*font_mgr->id_buffer_size); gf_font_manager_set_font(font_mgr, &def_font, 1, 0); font_mgr->default_font = font_mgr->font; font_mgr->line_path= gf_path_new(); gf_path_add_move_to(font_mgr->line_path, -FIX_ONE/2, FIX_ONE/2); gf_path_add_line_to(font_mgr->line_path, FIX_ONE/2, FIX_ONE/2); gf_path_add_line_to(font_mgr->line_path, FIX_ONE/2, -FIX_ONE/2); gf_path_add_line_to(font_mgr->line_path, -FIX_ONE/2, -FIX_ONE/2); gf_path_close(font_mgr->line_path); opt = gf_cfg_get_key(user->config, "FontEngine", "WaitForFontLoad"); if (!opt) gf_cfg_set_key(user->config, "FontEngine", "WaitForFontLoad", "no"); if (opt && !strcmp(opt, "yes")) font_mgr->wait_font_load = 1; return font_mgr; }
BOOL COptDecoder::OnInitDialog() { u32 i; CDialog::OnInitDialog(); COsmo4 *gpac = GetApp(); const char *sOpt; /*audio dec enum*/ while (m_Audio.GetCount()) m_Audio.DeleteString(0); sOpt = gf_cfg_get_key(gpac->m_user.config, "Systems", "DefAudioDec"); u32 count = gf_modules_get_count(gpac->m_user.modules); GF_BaseDecoder *ifce; s32 select = 0; s32 to_sel = 0; for (i=0; i<count; i++) { ifce = (GF_BaseDecoder *) gf_modules_load_interface(gpac->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE); if (!ifce) continue; if (ifce->CanHandleStream(ifce, GF_STREAM_AUDIO, NULL, 0)) { if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; TCHAR wzTmp[500]; CE_CharToWide((char *) ifce->module_name, (u16 *)wzTmp); m_Audio.AddString(wzTmp); to_sel++; } gf_modules_close_interface((GF_BaseInterface *) ifce); } m_Audio.SetCurSel(select); /*audio dec enum*/ while (m_Video.GetCount()) m_Video.DeleteString(0); sOpt = gf_cfg_get_key(gpac->m_user.config, "Systems", "DefVideoDec"); count = gf_modules_get_count(gpac->m_user.modules); select = 0; to_sel = 0; for (i=0; i<count; i++) { ifce = (GF_BaseDecoder *) gf_modules_load_interface(gpac->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE); if (!ifce) continue; if (ifce->CanHandleStream(ifce, GF_STREAM_VISUAL, NULL, 0)) { if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; TCHAR wzTmp[500]; CE_CharToWide((char *) ifce->module_name, (u16 *)wzTmp); m_Video.AddString(wzTmp); to_sel++; } gf_modules_close_interface((GF_BaseInterface *) ifce); } m_Video.SetCurSel(select); return TRUE; }
void gf_sr_del(GF_Renderer *sr) { if (!sr) return; GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Destroying Renderer\n")); gf_sr_lock(sr, 1); if (sr->VisualThread) { sr->video_th_state = 2; while (sr->video_th_state!=3) gf_sleep(10); gf_th_del(sr->VisualThread); } if (sr->video_out) { GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Closing video output\n")); sr->video_out->Shutdown(sr->video_out); gf_modules_close_interface((GF_BaseInterface *)sr->video_out); } GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Closing visual renderer\n")); sr->visual_renderer->UnloadRenderer(sr->visual_renderer); GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Unloading visual renderer module\n")); gf_modules_close_interface((GF_BaseInterface *)sr->visual_renderer); GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] visual renderer module unloaded\n")); if (sr->audio_renderer) gf_sr_ar_del(sr->audio_renderer); #ifdef GF_SR_EVENT_QUEUE gf_mx_p(sr->ev_mx); while (gf_list_count(sr->events)) { GF_Event *ev = (GF_Event *)gf_list_get(sr->events, 0); gf_list_rem(sr->events, 0); free(ev); } gf_mx_v(sr->ev_mx); gf_mx_del(sr->ev_mx); gf_list_del(sr->events); #endif if (sr->font_engine) { GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Closing font engine\n")); sr->font_engine->shutdown_font_engine(sr->font_engine); gf_modules_close_interface((GF_BaseInterface *)sr->font_engine); } gf_list_del(sr->textures); gf_list_del(sr->time_nodes); gf_list_del(sr->extra_scenes); gf_sr_lock(sr, 0); gf_mx_del(sr->mx); free(sr); GF_LOG(GF_LOG_DEBUG, GF_LOG_RENDER, ("[Render] Renderer destroyed\n")); }
void gf_sc_ar_del(GF_AudioRenderer *ar) { if (!ar) return; GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Destroying compositor\n")); /*resume if paused (might cause deadlock otherwise)*/ if (ar->Frozen) gf_sc_ar_control(ar, GF_SC_AR_RESUME); /*stop and shutdown*/ if (ar->audio_out) { /*kill audio thread*/ if (!ar->audio_out->SelfThreaded) { GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] stopping audio thread\n")); ar->audio_th_state = 2; while (ar->audio_th_state != 3) { gf_sleep(33); } GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] audio thread stopped\n")); gf_th_del(ar->th); GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] audio thread destroyed\n")); } /*lock access before shutdown and emulate a reconfig (avoids mixer lock from self-threaded modules)*/ ar->need_reconfig = GF_TRUE; gf_mixer_lock(ar->mixer, GF_TRUE); if (ar->audio_out->SelfThreaded) ar->audio_out->Shutdown(ar->audio_out); gf_modules_close_interface((GF_BaseInterface *)ar->audio_out); ar->audio_out = NULL; gf_mixer_lock(ar->mixer, GF_FALSE); } gf_mixer_del(ar->mixer); if (ar->audio_listeners) gf_list_del(ar->audio_listeners); gf_afc_unload(&ar->filter_chain); gf_free(ar); GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Renderer destroyed\n")); }
void gf_term_delete_net_service(GF_ClientService *ns) { const char *sOpt = gf_cfg_get_key(ns->term->user->config, "StreamingCache", "AutoSave"); if (ns->cache) gf_term_service_cache_close(ns, (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); if (ns->pending_service_session) gf_dm_sess_del(ns->pending_service_session); assert(!ns->nb_odm_users); assert(!ns->nb_ch_users); assert(!ns->owner); gf_modules_close_interface((GF_BaseInterface *)ns->ifce); gf_free(ns->url); /*delete all the clocks*/ while (gf_list_count(ns->Clocks)) { GF_Clock *ck = (GF_Clock *)gf_list_get(ns->Clocks, 0); gf_list_rem(ns->Clocks, 0); gf_clock_del(ck); } gf_list_del(ns->Clocks); assert(!gf_list_count(ns->dnloads)); gf_list_del(ns->dnloads); gf_free(ns); }
void gf_codec_del(GF_Codec *codec) { if (!codec || !codec->inChannels) return; if (gf_list_count(codec->inChannels)) return; if (!(codec->flags & GF_ESM_CODEC_IS_USE)) { switch (codec->type) { /*input sensor streams are handled internally for now*/ #ifndef GPAC_DISABLE_VRML case GF_STREAM_INTERACT: gf_mx_p(codec->odm->term->net_mx); gf_isdec_del(codec->decio); gf_list_del_item(codec->odm->term->input_streams, codec); gf_mx_v(codec->odm->term->net_mx); break; #endif default: gf_modules_close_interface((GF_BaseInterface *) codec->decio); break; } } if (codec->CB) gf_cm_del(codec->CB); codec->CB = NULL; if (codec->inChannels) gf_list_del(codec->inChannels); codec->inChannels = NULL; gf_free(codec); }
BOOL COptAudio::OnInitDialog() { CDialog::OnInitDialog(); m_AudioSpin.SetBuddy(& m_AudioEdit); m_SpinDur.SetBuddy(& m_AudioDur); m_SpinDur.SetRange(0, 1000); COsmo4 *gpac = GetApp(); const char *sOpt; TCHAR wTmp[500]; sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "ForceConfig"); m_ForceConfig.SetCheck( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "NumBuffers"); if (sOpt) { CE_CharToWide((char *)sOpt, (u16 *)wTmp); m_AudioEdit.SetWindowText(wTmp); } else { m_AudioEdit.SetWindowText(_T("2")); } sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "TotalDuration"); if (sOpt) { CE_CharToWide((char *)sOpt, (u16 *)wTmp); m_AudioDur.SetWindowText(wTmp); } else { m_AudioDur.SetWindowText(_T("200")); } OnForceAudio(); sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "NoResync"); if (sOpt && !stricmp(sOpt, "yes")) { m_AudioResync.SetCheck(1); } else { m_AudioResync.SetCheck(0); } /*driver enum*/ while (m_DriverList.GetCount()) m_DriverList.DeleteString(0); sOpt = gf_cfg_get_key(gpac->m_user.config, "Audio", "DriverName"); u32 count = gf_modules_get_count(gpac->m_user.modules); GF_BaseInterface *ifce; s32 select = 0; s32 to_sel = 0; for (u32 i=0; i<count; i++) { ifce = gf_modules_load_interface(gpac->m_user.modules, i, GF_AUDIO_OUTPUT_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; CE_CharToWide((char *) ((GF_BaseInterface *)ifce)->module_name, (u16 *)wTmp); m_DriverList.AddString(wTmp); gf_modules_close_interface(ifce); to_sel++; } m_DriverList.SetCurSel(select); return TRUE; }
void SR_SetFontEngine(GF_Renderer *sr) { const char *sOpt; u32 i, count; GF_FontRaster *ifce; ifce = NULL; sOpt = gf_cfg_get_key(sr->user->config, "FontEngine", "DriverName"); if (sOpt) ifce = (GF_FontRaster *) gf_modules_load_interface_by_name(sr->user->modules, sOpt, GF_FONT_RASTER_INTERFACE); if (!ifce) { count = gf_modules_get_count(sr->user->modules); for (i=0; i<count; i++) { ifce = (GF_FontRaster *) gf_modules_load_interface(sr->user->modules, i, GF_FONT_RASTER_INTERFACE); if (ifce) { gf_cfg_set_key(sr->user->config, "FontEngine", "DriverName", ifce->module_name); sOpt = ifce->module_name; break; } } } if (!ifce) return; /*cannot init font engine*/ if (ifce->init_font_engine(ifce) != GF_OK) { gf_modules_close_interface((GF_BaseInterface *)ifce); return; } /*shutdown current*/ gf_sr_lock(sr, 1); if (sr->font_engine) { sr->font_engine->shutdown_font_engine(sr->font_engine); gf_modules_close_interface((GF_BaseInterface *)sr->font_engine); } sr->font_engine = ifce; /*success*/ gf_cfg_set_key(sr->user->config, "FontEngine", "DriverName", sOpt); sr->draw_next_frame = 1; gf_sr_lock(sr, 0); }
GF_Err gf_term_service_cache_close(GF_ClientService *ns, Bool no_save) { GF_Err e; if (!ns->cache) return GF_OK; e = ns->cache->Close(ns->cache, no_save); gf_modules_close_interface((GF_BaseInterface *)ns->cache); ns->cache = NULL; return e; }
void gf_afc_unload(GF_AudioFilterChain *afc) { while (afc->filters) { struct _audiofilterentry *tmp = afc->filters; afc->filters = tmp->next; gf_modules_close_interface((GF_BaseInterface *)tmp->filter); if (tmp->in_block) gf_free(tmp->in_block); gf_free(tmp); } if (afc->tmp_block1) gf_free(afc->tmp_block1); if (afc->tmp_block2) gf_free(afc->tmp_block2); memset(afc, 0, sizeof(GF_AudioFilterChain)); }
/*destroy channel*/ void gf_es_del(GF_Channel *ch) { Channel_Reset(ch, 0); if (ch->AU_buffer_pull) { ch->AU_buffer_pull->data = NULL; gf_db_unit_del(ch->AU_buffer_pull); } if (ch->ipmp_tool) gf_modules_close_interface((GF_BaseInterface *) ch->ipmp_tool); if (ch->mx) gf_mx_del(ch->mx); gf_free(ch); }
GF_EXPORT Bool gf_term_is_supported_url(GF_Terminal *term, const char *fileName, Bool use_parent_url, Bool no_mime_check) { GF_InputService *ifce; GF_Err e; char *sURL; char *parent_url = NULL; if (use_parent_url && term->root_scene) parent_url = term->root_scene->root_od->net_service->url; ifce = gf_term_can_handle_service(term, fileName, parent_url, no_mime_check, &sURL, &e, NULL); if (!ifce) return 0; gf_modules_close_interface((GF_BaseInterface *) ifce); gf_free(sURL); return 1; }
/*locates input service (demuxer) based on mime type or segment name*/ static GF_Err MPD_LoadMediaService(GF_MPD_In *mpdin, u32 group_index, const char *mime, const char *init_segment_name) { GF_InputService *segment_ifce; u32 i; const char *sPlug; if (mime) { /* Check MIME type to start the right InputService */ sPlug = gf_cfg_get_key(mpdin->service->term->user->config, "MimeTypes", mime); if (sPlug) sPlug = strrchr(sPlug, '"'); if (sPlug) { sPlug += 2; segment_ifce = (GF_InputService *) gf_modules_load_interface_by_name(mpdin->service->term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); if (segment_ifce) { GF_MPDGroup *group; GF_SAFEALLOC(group, GF_MPDGroup); group->segment_ifce = segment_ifce; group->segment_ifce->proxy_udta = mpdin; group->segment_ifce->query_proxy = MPD_ClientQuery; group->mpdin = mpdin; group->idx = group_index; gf_dash_set_group_udta(mpdin->dash, group_index, group); return GF_OK; } } } if (init_segment_name) { for (i=0; i< gf_modules_get_count(mpdin->service->term->user->modules); i++) { GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(mpdin->service->term->user->modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; if (ifce->CanHandleURL && ifce->CanHandleURL(ifce, init_segment_name)) { GF_MPDGroup *group; GF_SAFEALLOC(group, GF_MPDGroup); group->segment_ifce = ifce; group->segment_ifce->proxy_udta = mpdin; group->segment_ifce->query_proxy = MPD_ClientQuery; group->mpdin = mpdin; group->idx = group_index; gf_dash_set_group_udta(mpdin->dash, group_index, group); return GF_OK; } gf_modules_close_interface((GF_BaseInterface *) ifce); } } GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("[MPD_IN] Error locating plugin for segment - mime type %s - name %s\n", mime, init_segment_name)); return GF_CODEC_NOT_FOUND; }
GF_Err gf_afc_load(GF_AudioFilterChain *afc, GF_User *user, char *filterstring) { struct _audiofilterentry *prev_filter = NULL; while (filterstring) { u32 i, count; GF_AudioFilter *filter; char *sep = strstr(filterstring, ";;"); if (sep) sep[0] = 0; count = gf_modules_get_count(user->modules); filter = NULL; for (i=0; i<count; i++) { filter = (GF_AudioFilter *)gf_modules_load_interface(user->modules, i, GF_AUDIO_FILTER_INTERFACE); if (filter) { if (filter->SetFilter && filter->Configure && filter->Process && filter->Reset && filter->SetOption && filter->GetOption && filter->SetFilter(filter, filterstring) ) break; gf_modules_close_interface((GF_BaseInterface *)filter); } filter = NULL; } if (filter) { struct _audiofilterentry *entry; GF_SAFEALLOC(entry, struct _audiofilterentry); entry->filter = filter; if (prev_filter) prev_filter->next = entry; else afc->filters = entry; prev_filter = entry; } if (sep) { sep[0] = ';'; filterstring = sep + 2; } else { break; } } return GF_OK; }
void gf_font_manager_del(GF_FontManager *fm) { GF_Font *font; if (fm->reader) { fm->reader->shutdown_font_engine(fm->reader); gf_modules_close_interface((GF_BaseInterface *)fm->reader); } font = fm->font; while (font) { GF_Font *next = font->next; gf_font_del(font); font = next; } gf_free(fm->id_buffer); gf_path_del(fm->line_path); gf_free(fm); }
u32 SR_RenderRun(void *par) { GF_Renderer *sr = (GF_Renderer *) par; sr->video_th_state = 1; GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Renderer] Entering thread ID %d\n", gf_th_id() )); while (sr->video_th_state == 1) { /*sleep or render*/ if (sr->is_hidden) gf_sleep(sr->frame_duration); else gf_sr_simulation_tick(sr); } /*destroy video out here if w're using openGL, to avoid threading issues*/ sr->video_out->Shutdown(sr->video_out); gf_modules_close_interface((GF_BaseInterface *)sr->video_out); sr->video_out = NULL; sr->video_th_state = 3; return 0; }
GF_EXPORT GF_BaseInterface *gf_modules_load_interface_by_name(GF_ModuleManager *pm, const char *plug_name, u32 InterfaceFamily) { const char *file_name; u32 i, count; GF_BaseInterface *ifce; if (!pm || !plug_name || !pm->plug_list || !pm->cfg){ GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("[Core] gf_modules_load_interface_by_name has bad parameters pm=%p, plug_name=%s.\n", pm, plug_name)); return NULL; } count = gf_list_count(pm->plug_list); /*look for cache entry*/ file_name = gf_cfg_get_key(pm->cfg, "PluginsCache", plug_name); if (file_name) { for (i=0; i<count; i++) { ModuleInstance *inst = (ModuleInstance *) gf_list_get(pm->plug_list, i); if (!strcmp(inst->name, file_name)) { ifce = gf_modules_load_interface(pm, i, InterfaceFamily); if (ifce) return ifce; } } } GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("[Core] Plugin %s of type %d not found in cache, searching for it...\n", plug_name, InterfaceFamily)); for (i=0; i<count; i++) { ifce = gf_modules_load_interface(pm, i, InterfaceFamily); if (!ifce) continue; if (ifce->module_name && !strnicmp(ifce->module_name, plug_name, MIN(strlen(ifce->module_name), strlen(plug_name)) )) { /*update cache entry*/ gf_cfg_set_key(pm->cfg, "PluginsCache", plug_name, ((ModuleInstance*)ifce->HPLUG)->name); GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("[Core] Added plugin cache %s for %s\n", plug_name, ((ModuleInstance*)ifce->HPLUG)->name)); return ifce; } gf_modules_close_interface(ifce); } GF_LOG(GF_LOG_WARNING, GF_LOG_CORE, ("[Core] Plugin %s not found in %d modules.\n", plug_name, count)); return NULL; }
BOOL COptFont::OnInitDialog() { u32 i; GF_BaseInterface *ifce; CDialog::OnInitDialog(); COsmo4 *gpac = GetApp(); TCHAR wTmp[500]; const char *sOpt; /*video drivers enum*/ while (m_Fonts.GetCount()) m_Fonts.DeleteString(0); sOpt = gf_cfg_get_key(gpac->m_user.config, "FontEngine", "DriverName"); s32 to_sel = 0; s32 select = 0; u32 count = gf_modules_get_count(gpac->m_user.modules); for (i=0; i<count; i++) { ifce = gf_modules_load_interface(gpac->m_user.modules, i, GF_FONT_READER_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; CE_CharToWide((char *) ifce->module_name, (u16 *)wTmp); m_Fonts.AddString(wTmp); gf_modules_close_interface(ifce); to_sel++; } m_Fonts.SetCurSel(select); sOpt = gf_cfg_get_key(gpac->m_user.config, "FontEngine", "FontDirectory"); CE_CharToWide((char *)sOpt, (u16 *)wTmp); if (sOpt) m_BrowseFont.SetWindowText(wTmp); sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "TextureTextMode"); m_UseTexture.SetCheck( (!sOpt || stricmp(sOpt, "Never")) ? 1 : 0); return TRUE; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine, #endif int nShowCmd ) { MSG msg; #ifdef _WIN32_WCE TCHAR wzExePath[GF_MAX_PATH]; #endif HWND hwndOld = NULL; const char *str; Bool initial_launch = 0; if (hwndOld = FindWindow(_T("Osmophone"), NULL)) { SetForegroundWindow(hwndOld); return 0; } memset(&user, 0, sizeof(GF_User)); term = NULL; g_hinst = hInstance; screen_w = GetSystemMetrics(SM_CXSCREEN); screen_h = GetSystemMetrics(SM_CYSCREEN); /*are we in low res or high res*/ RawFrameBufferInfo Info; HDC DC = GetDC(NULL); ExtEscape(DC, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char*)&Info); ReleaseDC(NULL,DC); if (Info.pFramePointer) { recompute_res(Info.cxPixels, Info.cyPixels); } else { recompute_res(screen_w, screen_h); } #ifdef _WIN32_WCE TCHAR szBuf[MAX_PATH]; SystemParametersInfo(SPI_GETPLATFORMTYPE, MAX_PATH, szBuf, 0); if (! lstrcmp(szBuf, __TEXT("PocketPC"))) is_ppc = 1; else if (! lstrcmp(szBuf, __TEXT("Palm PC2"))) is_ppc = 1; #endif user.config = gf_cfg_init(NULL, &initial_launch); if (!user.config) { MessageBox(NULL, _T("Couldn't locate GPAC config file"), _T("Fatal Error"), MB_OK); return 0; } str = gf_cfg_get_key(user.config, "Compositor", "ScreenWidth"); if (str) screen_w = atoi(str); str = gf_cfg_get_key(user.config, "Compositor", "ScreenHeight"); if (str) screen_h = atoi(str); disp_w = screen_w; #ifdef _WIN32_WCE disp_h = screen_h - menu_h /*- caption_h*/; #else disp_h = screen_h; #endif str = gf_cfg_get_key(user.config, "General", "ModulesDirectory"); if (!str) { gf_cfg_del(user.config); MessageBox(NULL, _T("Couldn't locate GPAC plugins"), _T("Fatal Error"), MB_OK); return 0; } gf_sys_init(0); user.modules = gf_modules_new(str, user.config); if (!gf_modules_get_count(user.modules)) { MessageBox(GetForegroundWindow(), _T("No modules found"), _T("GPAC Init Error"), MB_OK); gf_modules_del(user.modules); gf_cfg_del(user.config); memset(&user, 0, sizeof(GF_User)); gf_sys_close(); return 0; } /*first launch, register all files ext*/ if (initial_launch) { /*FFMPEG registration - FFMPEG DLLs compiled with CEGCC cannot be loaded directly under WM 6.1 cf http://cegcc.sourceforge.net/docs/faq.html#DllDoesNotWorkWithWindowsMobile6.1 */ HKEY hKey = NULL; DWORD dwSize; DWORD dwValue; RegCreateKeyEx(HKEY_LOCAL_MACHINE, _T("System\\Loader\\LoadModuleLow"), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, &dwSize); dwSize = 4; dwValue = 1; LONG res = RegSetValueEx(hKey, _T("avcodec-52.dll"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize); res = RegSetValueEx(hKey, _T("avformat-52.dll"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize); res = RegSetValueEx(hKey, _T("avutil-50.dll"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize); res = RegSetValueEx(hKey, _T("swscale-0.dll"), NULL, REG_DWORD, (unsigned char *)&dwValue, dwSize); RegCloseKey(hKey); u32 i; for (i=0; i<gf_modules_get_count(user.modules); i++) { GF_InputService *ifce = (GF_InputService *) gf_modules_load_interface(user.modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; if (ifce) { ifce->CanHandleURL(ifce, "test.test"); gf_modules_close_interface((GF_BaseInterface *)ifce); } } MessageBox(NULL, _T("Thank you for installing GPAC"), _T("Initial setup done"), MB_OK); } str = gf_cfg_get_key(user.config, "General", "Loop"); loop = (!str || !stricmp(str, "yes")) ? 1 : 0; str = gf_cfg_get_key(user.config, "SAXLoader", "Progressive"); use_svg_prog = (str && !strcmp(str, "yes")) ? 1 : 0; str = gf_cfg_get_key(user.config, "General", "RTIRefreshPeriod"); if (str) { rti_update_time_ms = atoi(str); } else { gf_cfg_set_key(user.config, "General", "RTIRefreshPeriod", "200"); } str = gf_cfg_get_key(user.config, "General", "ShowStatusBar"); show_status = (str && !strcmp(str, "yes")) ? 1 : 0; #ifdef _WIN32_WCE if (is_ppc) GXOpenInput(); #endif if (InitInstance(nShowCmd)) { SetForegroundWindow(g_hwnd); show_taskbar(0); force_2d_gl = gf_term_get_option(term, GF_OPT_USE_OPENGL); while (GetMessage(&msg, NULL, 0,0) == TRUE) { TranslateMessage (&msg); DispatchMessage (&msg); if (playlist_act) { switch_playlist(playlist_act-1); playlist_act = 0; } } show_taskbar(1); } #ifdef _WIN32_WCE if (is_ppc) GXCloseInput(); #endif /*and destroy*/ if (term) gf_term_del(term); if (user.modules) gf_modules_del(user.modules); if (user.config) gf_cfg_del(user.config); if (backlight_off) set_backlight_state(0); gf_sys_close(); if (log_file) fclose(log_file); return 0; }
// ----------------------------------------------------------------------------- // COsmo4AppView::ConstructL() // Symbian 2nd phase constructor can leave. // ----------------------------------------------------------------------------- // void COsmo4AppView::ConstructL( const TRect& aRect ) { const char *opt; Bool first_launch = 0; #if defined(__SERIES60_3X__) selector = CRemConInterfaceSelector::NewL(); target = CRemConCoreApiTarget::NewL(*selector, *this); selector->OpenTargetL(); #endif // Create a window for this application view CreateWindowL(); // Set the windows size SetRect( aRect ); //draw ActivateL(); #ifndef GPAC_GUI_ONLY m_window = Window(); m_session = CEikonEnv::Static()->WsSession(); m_mx = gf_mx_new("Osmo4"); //load config file m_user.config = gf_cfg_init(NULL, &first_launch); if (!m_user.config) { MessageBox("Cannot create GPAC Config file", "Fatal Error"); User::Leave(KErrGeneral); } if (first_launch) { MessageBox("Osmo4", "Thank you for Installing"); } /*load modules*/ opt = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); m_user.modules = gf_modules_new(opt, m_user.config); if (!m_user.modules || !gf_modules_get_count(m_user.modules)) { MessageBox(m_user.modules ? "No modules available" : "Cannot create module manager", "Fatal Error"); if (m_user.modules) gf_modules_del(m_user.modules); gf_cfg_del(m_user.config); User::Leave(KErrGeneral); } if (first_launch) { /*first launch, register all files ext*/ for (u32 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); } } } /*we don't thread the terminal, ie appart from the audio renderer, media decoding and visual rendering is handled by the app process*/ m_user.init_flags = GF_TERM_NO_VISUAL_THREAD | GF_TERM_NO_REGULATION; m_user.EventProc = GPAC_EventProc; m_user.opaque = this; m_user.os_window_handler = (void *) &m_window; m_user.os_display = (void *) &m_session; m_term = gf_term_new(&m_user); if (!m_term) { MessageBox("Cannot load GPAC terminal", "Fatal Error"); gf_modules_del(m_user.modules); gf_cfg_del(m_user.config); User::Leave(KErrGeneral); } //MessageBox("GPAC terminal loaded", "Success !"); /*ok set output size*/ TSize s = m_window.Size(); gf_term_set_size(m_term, s.iWidth, s.iHeight); /*start our callback (every ms)*/ const TInt KTickInterval = 33000; m_pTimer = CPeriodic::NewL(CActive::EPriorityStandard); m_pTimer->Start(KTickInterval, KTickInterval, TCallBack(myTick, this)); opt = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (opt) gf_term_connect(m_term, opt); #endif }
wxGPACControl::wxGPACControl(wxWindow *parent) : wxDialog(parent, -1, wxString(wxT("GPAC Control Panel"))) { const char *sOpt; SetSize(320, 240); u32 i; wxBoxSizer *bs; Centre(); m_pApp = (wxOsmo4Frame *)parent; s_main = new wxBoxSizer(wxVERTICAL); s_header = new wxBoxSizer(wxHORIZONTAL); //s_header->Add(new wxStaticText(this, 0, wxT("Category"), wxDefaultPosition, wxSize(60, 20)), wxALIGN_CENTER); m_select = new wxComboBox(this, ID_SELECT, wxT(""), wxDefaultPosition, wxSize(120, 30), 0, NULL, wxCB_READONLY); s_header->Add(m_select, 2, wxALIGN_CENTER | wxADJUST_MINSIZE); s_header->Add( new wxButton(this, ID_APPLY, wxT("Apply"), wxDefaultPosition, #ifdef WIN32 wxSize(40, 20) #else wxSize(40, 30) #endif ), 1, wxALIGN_TOP|wxALIGN_RIGHT|wxADJUST_MINSIZE); s_main->Add(s_header, 0, wxEXPAND, 0); /*general section*/ s_general = new wxBoxSizer(wxVERTICAL); m_loop = new wxCheckBox(this, 0, wxT("Loop at End"), wxPoint(10, 40), wxSize(140, 20)); s_general->Add(m_loop); m_lookforsubs = new wxCheckBox(this, 0, wxT("Look for Subtitles"), wxPoint(180, 40), wxSize(140, 20)); s_general->Add(m_lookforsubs); m_noconsole = new wxCheckBox(this, 0, wxT("Disable console messages"), wxPoint(10, 80), wxSize(180, 20)); s_general->Add(m_noconsole); m_viewxmt = new wxCheckBox(this, 0, wxT("View graph in XMT-A format"), wxPoint(10, 120), wxSize(180, 20)); s_general->Add(m_viewxmt); s_main->Add(s_general, 0, wxEXPAND, 0); /*MPEG-4 systems*/ s_mpeg4 = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Prefered Stream Language")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_lang = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_lang, wxALIGN_CENTER | wxADJUST_MINSIZE); s_mpeg4->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Decoder Threading Mode")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_thread = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_thread, wxALIGN_CENTER | wxADJUST_MINSIZE); s_mpeg4->Add(bs, 0, wxALL|wxEXPAND, 2); m_bifsalwaysdrawn = new wxCheckBox(this, 0, wxT("Always draw late BIFS frames")); s_mpeg4->Add(m_bifsalwaysdrawn); m_singletime = new wxCheckBox(this, 0, wxT("Force Single Timeline")); s_mpeg4->Add(m_singletime); s_main->Add(s_mpeg4, 0, wxEXPAND, 0); /*media decoders*/ s_mdec = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Prefered Audio Output")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_decaudio = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_decaudio, wxALIGN_CENTER | wxADJUST_MINSIZE); s_mdec->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Prefered Video Output")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_decvideo = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_decvideo, wxALIGN_CENTER | wxADJUST_MINSIZE); s_mdec->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_mdec, 0, wxEXPAND, 0); /*Rendering*/ s_rend = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Target Frame Rate")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_fps = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_fps, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Anti-Aliasing")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_aa = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_aa, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Graphics Driver")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_graph = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_graph, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_draw_bounds = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(new wxStaticText(this, 0, wxT("Bounds")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); bs->Add(m_draw_bounds, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend->Add(bs, 0, wxALL|wxEXPAND, 2); m_fast = new wxCheckBox(this, 0, wxT("Fast Rendering")); m_force_size = new wxCheckBox(this, 0, wxT("Force Scene Size")); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(m_fast, wxALIGN_CENTER | wxADJUST_MINSIZE); bs->Add(m_force_size, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend->Add(bs, 0, wxALL|wxEXPAND, 2); m_use3D = new wxCheckBox(this, 0, wxT("Use 3D Renderer")); s_rend->Add(m_use3D, 0, wxALL|wxEXPAND, 2); m_bWas3D = m_use3D->GetValue(); s_main->Add(s_rend, 0, wxEXPAND, 0); /*Render 2D*/ s_rend2d = new wxBoxSizer(wxVERTICAL); m_direct = new wxCheckBox(this, 0, wxT("Direct Rendering")); s_rend2d->Add(m_direct, 0, wxALL|wxEXPAND, 2); m_scalable = new wxCheckBox(this, 0, wxT("Scalable Zoom")); s_rend2d->Add(m_scalable, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_noyuv = new wxCheckBox(this, 0, wxT("Disable YUV hardware")); bs->Add(m_noyuv, wxALIGN_CENTER | wxADJUST_MINSIZE); m_yuvtxt = new wxStaticText(this, 0, wxT("(No YUV used)"), wxDefaultPosition, wxSize(60, 20), wxALIGN_LEFT); bs->Add(m_yuvtxt, wxALIGN_CENTER|wxADJUST_MINSIZE); s_rend2d->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_rend2d, 0, wxEXPAND, 0); /*Render 3D*/ s_rend3d = new wxBoxSizer(wxVERTICAL); m_raster_outlines = new wxCheckBox(this, 0, wxT("Use OpenGL Raster outlines")); s_rend3d->Add(m_raster_outlines, 0, wxALL|wxEXPAND, 2); m_polyaa = new wxCheckBox(this, 0, wxT("Enable polygon anti-aliasing")); s_rend3d->Add(m_polyaa, 0, wxALL|wxEXPAND, 2); m_nobackcull = new wxCheckBox(this, 0, wxT("Disable backface culling")); s_rend3d->Add(m_nobackcull, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Wireframe mode")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_wire = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_wire, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend3d->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Draw Normals")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_normals = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_normals, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rend3d->Add(bs, 0, wxALL|wxEXPAND, 2); m_emulpow2 = new wxCheckBox(this, 0, wxT("Emulate power-of-two textures for video")); s_rend3d->Add(m_emulpow2, 0, wxALL|wxEXPAND, 2); m_norectext = new wxCheckBox(this, 0, wxT("Disable rectangular texture extensions")); s_rend3d->Add(m_norectext, 0, wxALL|wxEXPAND, 2); m_copypixels = new wxCheckBox(this, 0, wxT("Bitmap node uses direct pixel copy")); s_rend3d->Add(m_copypixels, 0, wxALL|wxEXPAND, 2); s_main->Add(s_rend3d, 0, wxEXPAND, 0); /*video*/ s_video = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Video Driver")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_video = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_video , wxALIGN_CENTER | wxADJUST_MINSIZE); s_video->Add(bs, 0, wxALL|wxEXPAND, 2); m_switchres = new wxCheckBox(this, 0, wxT("Change video resolution in fullscreen")); s_video->Add(m_switchres, 0, wxALL|wxEXPAND, 2); m_usehwmem = new wxCheckBox(this, 0, wxT("Use hardware memory in 2D mode")); s_video->Add(m_usehwmem, 0, wxALL|wxEXPAND, 2); s_main->Add(s_video, 0, wxEXPAND, 0); /*audio*/ s_audio = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Audio Driver")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_audio = new wxComboBox(this, ID_AUDIO_DRIVER, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_audio, wxALIGN_CENTER | wxADJUST_MINSIZE); s_audio->Add(bs, 0, wxALL|wxEXPAND, 2); m_forcecfg = new wxCheckBox(this, ID_FORCE_AUDIO, wxT("Force Audio Config")); m_forcecfg->SetValue(1); s_audio->Add(m_forcecfg, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Number of buffers")), wxALIGN_CENTER|wxADJUST_MINSIZE); m_nbbuf = new wxSpinCtrl(this, -1, wxT(""), wxDefaultPosition, wxSize(20, 20), wxSP_WRAP | wxSP_ARROW_KEYS, 1, 30, 15); m_nbbuf->SetValue(8); bs->Add(m_nbbuf, wxALIGN_CENTER | wxADJUST_MINSIZE); s_audio->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Total length in ms")), wxALIGN_CENTER | wxADJUST_MINSIZE); m_buflen = new wxSpinCtrl(this, -1, wxT(""), wxDefaultPosition, wxSize(20, 20), wxSP_WRAP | wxSP_ARROW_KEYS, 1, 1000); m_buflen->SetValue(400); bs->Add(m_buflen, wxALIGN_CENTER | wxADJUST_MINSIZE|wxLEFT,10); s_audio->Add(bs, 0, wxALL|wxEXPAND, 2); m_noresync = new wxCheckBox(this, -1, wxT("Disable Resynchronization")); s_audio->Add(m_noresync); m_nomulitch = new wxCheckBox(this, -1, wxT("Disable Multichannel")); s_audio->Add(m_nomulitch); #ifdef WIN32 m_notifs = new wxCheckBox(this, -1, wxT("Disable DirectSound Notifications")); s_audio->Add(m_notifs); #endif s_main->Add(s_audio, 0, wxEXPAND, 0); /*font*/ s_font = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Font Engine")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_font = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_font, wxALIGN_CENTER | wxADJUST_MINSIZE); s_font->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("System Font Directory")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_fontdir = new wxButton(this, ID_FONT_DIR, wxT("..."), wxDefaultPosition, wxDefaultSize); bs->Add(m_fontdir, wxALIGN_CENTER | wxADJUST_MINSIZE); s_font->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Text Texturing Mode")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_texturemode = new wxComboBox(this, 0, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY); bs->Add(m_texturemode, wxALIGN_CENTER | wxADJUST_MINSIZE); s_font->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_font, 0, wxEXPAND, 0); /*download*/ s_dnld = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Cache Directory")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_cachedir = new wxButton(this, ID_CACHE_DIR, wxT("...")); bs->Add(m_cachedir, wxALIGN_CENTER | wxADJUST_MINSIZE); s_dnld->Add(bs, 0, wxALL|wxEXPAND, 2); m_cleancache = new wxCheckBox(this, -1, wxT("Remove temp files on exit")); s_dnld->Add(m_cleancache); m_restartcache = new wxCheckBox(this, -1, wxT("Always redownload incomplete cached files")); s_dnld->Add(m_restartcache); bs = new wxBoxSizer(wxHORIZONTAL); m_progressive = new wxCheckBox(this, ID_PROGRESSIVE, wxT("XML progressive load")); bs->Add(m_progressive, wxALIGN_CENTER | wxADJUST_MINSIZE); m_sax_duration = new wxTextCtrl(this, 0, wxT(""), wxPoint(10, 120), wxSize(60, 20)); bs->Add(m_sax_duration, wxALIGN_CENTER | wxADJUST_MINSIZE); bs->Add(new wxStaticText(this, 0, wxT("max load slice (ms)")), wxADJUST_MINSIZE | wxALIGN_CENTER); s_dnld->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_use_proxy = new wxCheckBox(this, ID_USE_PROXY, wxT("Use proxy")); bs->Add(m_use_proxy, wxALIGN_CENTER | wxADJUST_MINSIZE); m_proxy_name = new wxTextCtrl(this, 0, wxT(""), wxPoint(10, 120), wxSize(60, 20)); bs->Add(m_proxy_name, wxALIGN_CENTER | wxADJUST_MINSIZE); s_dnld->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_dnld, 0, wxEXPAND, 0); /*streaming*/ s_stream = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Default RTSP port")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_port = new wxComboBox(this, ID_RTSP_PORT, wxT(""), wxPoint(160, 40), wxSize(140, 30), 0, NULL, wxCB_READONLY); bs->Add(m_port, wxALIGN_CENTER | wxADJUST_MINSIZE); s_stream->Add(bs, 0, wxALL|wxEXPAND, 2); m_rtsp = new wxCheckBox(this, ID_RTP_OVER_RTSP, wxT("RTP over RTSP"), wxPoint(10, 80), wxSize(140, 20)); m_reorder = new wxCheckBox(this, -1, wxT("use RTP reordering"), wxPoint(160, 80), wxSize(130, 20)); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(m_rtsp, wxALIGN_CENTER | wxADJUST_MINSIZE); bs->Add(m_reorder, wxALIGN_CENTER | wxADJUST_MINSIZE); s_stream->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_timeout = new wxTextCtrl(this, 0, wxT(""), wxPoint(10, 120), wxSize(60, 20)); bs->Add(new wxStaticText(this, 0, wxT("Control Timeout (ms): ")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); bs->Add(m_timeout, wxALIGN_CENTER | wxADJUST_MINSIZE); s_stream->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_buffer = new wxTextCtrl(this, 0, wxT(""), wxPoint(10, 150), wxSize(60, 20)); bs->Add(new wxStaticText(this, 0, wxT("Media Buffering (ms): ")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); bs->Add(m_buffer, wxALIGN_CENTER | wxADJUST_MINSIZE); s_stream->Add(bs, 0, wxALL|wxEXPAND, 2); bs = new wxBoxSizer(wxHORIZONTAL); m_dorebuffer = new wxCheckBox(this, ID_RTSP_REBUFFER, wxT("Rebuffer if below")); bs->Add(m_dorebuffer, wxALIGN_CENTER | wxADJUST_MINSIZE); m_rebuffer = new wxTextCtrl(this, 0, wxT(""), wxPoint(200, 180), wxSize(60, 20)); bs->Add(m_rebuffer, wxALIGN_CENTER | wxADJUST_MINSIZE); m_rebuffer->Disable(); s_stream->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_stream, 0, wxEXPAND, 0); /*streaming cache*/ s_rec = new wxBoxSizer(wxVERTICAL); bs = new wxBoxSizer(wxHORIZONTAL); bs->Add(new wxStaticText(this, 0, wxT("Record To: ")), wxALIGN_CENTER | wxADJUST_MINSIZE | wxALIGN_RIGHT); m_recdir = new wxButton(this, ID_RECORD_DIR, wxT("...")); bs->Add(m_recdir, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rec->Add(bs, 0, wxALL|wxEXPAND, 2); m_overwrite = new wxCheckBox(this, -1, wxT("Overwrite existing files")); s_rec->Add(m_overwrite); bs = new wxBoxSizer(wxHORIZONTAL); m_usename = new wxCheckBox(this, ID_USE_FILENAME, wxT("Use filename")); m_recfile = new wxTextCtrl(this, 0, wxT("")); bs->Add(m_usename, wxALIGN_CENTER | wxADJUST_MINSIZE); bs->Add(m_recfile, wxALIGN_CENTER | wxADJUST_MINSIZE); s_rec->Add(bs, 0, wxALL|wxEXPAND, 2); s_main->Add(s_rec, 0, wxEXPAND, 0); /*load options*/ GF_Config *cfg = m_pApp->m_user.config; /*general*/ sOpt = gf_cfg_get_key(cfg, "General", "Loop"); m_loop->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "General", "LookForSubtitles"); m_lookforsubs->SetValue((sOpt && !stricmp(sOpt, "no")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "General", "ConsoleOff"); m_noconsole->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "General", "ViewXMT"); m_viewxmt->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); /*systems config*/ sOpt = gf_cfg_get_key(cfg, "Systems", "Language3CC"); if (!sOpt) sOpt = "eng"; u32 select = 0; i=0; while (GF_ISO639_Lang[i]) { /*only use common languages (having both 2- and 3-char code names)*/ if (GF_ISO639_Lang[i+2][0]) { m_lang->Append(wxString(GF_ISO639_Lang[i], wxConvUTF8) ); if (sOpt && !stricmp(sOpt, GF_ISO639_Lang[i+1])) select = m_lang->GetCount() - 1; } i+=3; } m_lang->SetSelection(select); sOpt = gf_cfg_get_key(cfg, "Systems", "ThreadingPolicy"); select = 0; m_thread->Append(wxT("Single Thread")); m_thread->Append(wxT("Mutli Thread")); if (sOpt && !stricmp(sOpt, "Multi")) select = 1; m_thread->Append(wxT("Free")); if (sOpt && !stricmp(sOpt, "Free")) select = 2; m_thread->SetSelection(select); sOpt = gf_cfg_get_key(cfg, "Systems", "ForceSingleClock"); m_singletime->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Systems", "AlwaysDrawBIFS"); m_bifsalwaysdrawn->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); /*audio dec enum*/ sOpt = gf_cfg_get_key(cfg, "Systems", "DefAudioDec"); u32 count = gf_modules_get_count(m_pApp->m_user.modules); GF_BaseDecoder *ifc_d; select = 0; s32 to_sel = 0; for (i=0; i<count; i++) { ifc_d = (GF_BaseDecoder *) gf_modules_load_interface(m_pApp->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE); if (!ifc_d) continue; if (ifc_d->CanHandleStream(ifc_d, GF_STREAM_AUDIO, NULL, 0)) { if (sOpt && !stricmp(ifc_d->module_name, sOpt)) select = to_sel; m_decaudio->Append(wxString(ifc_d->module_name, wxConvUTF8) ); to_sel++; } gf_modules_close_interface((GF_BaseInterface *) ifc_d); } m_decaudio->SetSelection(select); /*video dec enum*/ sOpt = gf_cfg_get_key(cfg, "Systems", "DefVideoDec"); select = to_sel = 0; for (i=0; i<count; i++) { ifc_d = (GF_BaseDecoder *) gf_modules_load_interface(m_pApp->m_user.modules, i, GF_MEDIA_DECODER_INTERFACE); if (!ifc_d) continue; if (ifc_d->CanHandleStream(ifc_d, GF_STREAM_VISUAL, NULL, 0)) { if (sOpt && !stricmp(ifc_d->module_name, sOpt)) select = to_sel; m_decvideo->Append(wxString(ifc_d->module_name, wxConvUTF8) ); to_sel++; } gf_modules_close_interface((GF_BaseInterface *) ifc_d); } m_decvideo->SetSelection(select); /*rendering FIXME*/ m_bWas3D = 0; m_use3D->SetValue(m_bWas3D ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "ForceSceneSize"); m_force_size->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "FrameRate"); if (!sOpt) sOpt = "30.0"; select = 0; for (i = 0; i<NUM_RATES; i++) { m_fps->Append(wxString(BIFSRates[i], wxConvUTF8) ); if (sOpt && !stricmp(sOpt, BIFSRates[i]) ) select = i; } m_fps->SetSelection(select); sOpt = gf_cfg_get_key(cfg, "Compositor", "HighSpeed"); m_fast->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "AntiAlias"); m_aa->Append(wxT("None")); m_aa->Append(wxT("Text only")); m_aa->Append(wxT("Complete")); select = 2; if (sOpt && !stricmp(sOpt, "Text")) select = 1; else if (sOpt && !stricmp(sOpt, "None")) select = 0; m_aa->SetSelection(select); sOpt = gf_cfg_get_key(cfg, "Compositor", "BoundingVolume"); m_draw_bounds->Append(wxT("None")); m_draw_bounds->Append(wxT("Box/Rect")); m_draw_bounds->Append(wxT("AABB Tree")); select = 0; if (sOpt && !stricmp(sOpt, "Box")) select = 1; else if (sOpt && !stricmp(sOpt, "AABB")) select = 2; m_draw_bounds->SetSelection(select); /*render2d*/ sOpt = gf_cfg_get_key(cfg, "Compositor", "DirectDraw"); m_direct->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "ScalableZoom"); m_scalable->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "DisableYUV"); m_noyuv->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); SetYUVLabel(); /*graphics driver enum*/ sOpt = gf_cfg_get_key(cfg, "Compositor", "Raster2D"); GF_BaseInterface *ifce; select = to_sel = 0; for (i=0; i<count; i++) { ifce = gf_modules_load_interface(m_pApp->m_user.modules, i, GF_RASTER_2D_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; m_graph->Append(wxString(((GF_BaseInterface *)ifce)->module_name, wxConvUTF8) ); gf_modules_close_interface(ifce); to_sel++; } m_graph->SetSelection(select); /*render3d*/ sOpt = gf_cfg_get_key(cfg, "Compositor", "RasterOutlines"); m_raster_outlines->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "EmulatePOW2"); m_emulpow2->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "PolygonAA"); m_polyaa->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "BackFaceCulling"); m_nobackcull->SetValue((sOpt && !stricmp(sOpt, "Off")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "Wireframe"); sOpt = gf_cfg_get_key(cfg, "Compositor", "BitmapCopyPixels"); m_copypixels->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Compositor", "DisableRectExt"); m_norectext->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); m_wire->Append(wxT("No Wireframe")); m_wire->Append(wxT("Wireframe Only")); m_wire->Append(wxT("Solid and Wireframe")); sOpt = gf_cfg_get_key(cfg, "Compositor", "Wireframe"); if (sOpt && !stricmp(sOpt, "WireOnly")) m_wire->SetSelection(1); else if (sOpt && !stricmp(sOpt, "WireOnSolid")) m_wire->SetSelection(2); else m_wire->SetSelection(0); m_normals->Append(wxT("Never")); m_normals->Append(wxT("Per Face")); m_normals->Append(wxT("Per Vertex")); sOpt = gf_cfg_get_key(cfg, "Compositor", "DrawNormals"); if (sOpt && !stricmp(sOpt, "PerFace")) m_normals->SetSelection(1); else if (sOpt && !stricmp(sOpt, "PerVertex")) m_normals->SetSelection(2); else m_normals->SetSelection(0); /*video*/ sOpt = gf_cfg_get_key(cfg, "Video", "SwitchResolution"); m_switchres->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Video", "UseHardwareMemory"); m_usehwmem->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Video", "DriverName"); select = to_sel = 0; for (i=0; i<count; i++) { ifce = gf_modules_load_interface(m_pApp->m_user.modules, i, GF_VIDEO_OUTPUT_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; m_video->Append(wxString(((GF_BaseInterface *)ifce)->module_name, wxConvUTF8) ); gf_modules_close_interface(ifce); to_sel++; } m_video->SetSelection(select); /*audio*/ sOpt = gf_cfg_get_key(cfg, "Audio", "ForceConfig"); m_forcecfg->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Audio", "NumBuffers"); m_nbbuf->SetValue( sOpt ? wxString(sOpt, wxConvUTF8) : wxT("2")); sOpt = gf_cfg_get_key(cfg, "Audio", "TotalDuration"); m_buflen->SetValue( sOpt ? wxString(sOpt, wxConvUTF8) : wxT("120")); wxCommandEvent event; ForceAudio(event); sOpt = gf_cfg_get_key(cfg, "Audio", "NoResync"); m_noresync->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Audio", "DisableMultiChannel"); m_nomulitch->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); /*driver enum*/ sOpt = gf_cfg_get_key(cfg, "Audio", "DriverName"); select = to_sel = 0; for (i=0; i<count; i++) { ifce = gf_modules_load_interface(m_pApp->m_user.modules, i, GF_AUDIO_OUTPUT_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; m_audio->Append(wxString(((GF_BaseInterface *)ifce)->module_name, wxConvUTF8) ); gf_modules_close_interface(ifce); to_sel++; } m_audio->SetSelection(select); #ifdef WIN32 sOpt = gf_cfg_get_key(cfg, "Audio", "DisableNotification"); m_notifs->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); wxCommandEvent audevt; OnSetAudioDriver(audevt); #endif /*font*/ sOpt = gf_cfg_get_key(cfg, "FontEngine", "FontReader"); to_sel = select = 0; for (i=0; i<count; i++) { ifce = gf_modules_load_interface(m_pApp->m_user.modules, i, GF_FONT_READER_INTERFACE); if (!ifce) continue; if (sOpt && !stricmp(((GF_BaseInterface *)ifce)->module_name, sOpt)) select = to_sel; m_font->Append(wxString(((GF_BaseInterface *)ifce)->module_name, wxConvUTF8) ); gf_modules_close_interface(ifce); to_sel++; } m_font->SetSelection(select); sOpt = gf_cfg_get_key(cfg, "FontEngine", "FontDirectory"); if (sOpt) m_fontdir->SetLabel(wxString(sOpt, wxConvUTF8) ); sOpt = gf_cfg_get_key(cfg, "Compositor", "TextureTextMode"); m_texturemode->Append(wxT("Default")); m_texturemode->Append(wxT("Never")); m_texturemode->Append(wxT("Always")); if (sOpt && !stricmp(sOpt, "Always")) m_texturemode->SetSelection(2); else if (sOpt && !stricmp(sOpt, "3D")) m_texturemode->SetSelection(1); else m_texturemode->SetSelection(0); /*downloader*/ sOpt = gf_cfg_get_key(cfg, "General", "CacheDirectory"); if (sOpt) m_cachedir->SetLabel(wxString(sOpt, wxConvUTF8) ); sOpt = gf_cfg_get_key(cfg, "Downloader", "CleanCache"); m_cleancache->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "Downloader", "RestartFiles"); m_restartcache->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "SAXLoader", "Progressive"); m_progressive->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); sOpt = gf_cfg_get_key(cfg, "SAXLoader", "MaxDuration"); m_sax_duration->SetValue(sOpt ? wxString(sOpt, wxConvUTF8) : wxT("30")); if (! m_progressive->GetValue()) m_sax_duration->Enable(0); sOpt = gf_cfg_get_key(cfg, "HTTPProxy", "Enabled"); m_use_proxy->SetValue( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); char szProxy[GF_MAX_PATH]; strcpy(szProxy, ""); sOpt = gf_cfg_get_key(cfg, "HTTPProxy", "Name"); if (sOpt) { strcat(szProxy, sOpt); sOpt = gf_cfg_get_key(cfg, "HTTPProxy", "Port"); if (sOpt) { strcat(szProxy, ":"); strcat(szProxy, sOpt); } } else { m_use_proxy->SetValue(0); } m_proxy_name->SetValue( wxString((char *)szProxy, wxConvUTF8) ); if (! m_use_proxy->GetValue()) m_proxy_name->Enable(0); /*streaming*/ m_port->Append(wxT("554 (RTSP standard)")); m_port->Append(wxT("7070 (RTSP ext)")); m_port->Append(wxT("80 (RTSP / HTTP tunnel)")); m_port->Append(wxT("8080 (RTSP / HTTP tunnel)")); sOpt = gf_cfg_get_key(cfg, "Streaming", "DefaultPort"); u32 port = 554; Bool force_rtsp = 0; if (sOpt) port = atoi(sOpt); switch (port) { case 8080: m_port->SetSelection(3); force_rtsp = 1; break; case 80: m_port->SetSelection(2); force_rtsp = 1; break; case 7070: m_port->SetSelection(1); break; default: m_port->SetSelection(0); break; } Bool use_rtsp = 0; sOpt = gf_cfg_get_key(cfg, "Streaming", "RTPoverRTSP"); if (sOpt && !stricmp(sOpt, "yes")) use_rtsp = 1; if (force_rtsp) { m_rtsp->SetValue(1); m_rtsp->Enable(0); m_reorder->SetValue(0); m_reorder->Enable(0); } else { m_rtsp->SetValue(use_rtsp ? 1 : 0); m_rtsp->Enable(1); m_reorder->Enable(1); sOpt = gf_cfg_get_key(cfg, "Streaming", "ReorderSize"); m_reorder->SetValue( (sOpt && !stricmp(sOpt, "0")) ? 1 : 0); } sOpt = gf_cfg_get_key(cfg, "Streaming", "RTSPTimeout"); m_timeout->SetValue(sOpt ? wxString(sOpt, wxConvUTF8) : wxT("30000")); sOpt = gf_cfg_get_key(cfg, "Network", "BufferLength"); m_buffer->SetValue(sOpt ? wxString(sOpt, wxConvUTF8) : wxT("3000")); sOpt = gf_cfg_get_key(cfg, "Network", "RebufferLength"); u32 buf_len = 0; if (sOpt) buf_len = atoi(sOpt); if (buf_len) { m_dorebuffer->SetValue(1); m_rebuffer->SetValue(wxString(sOpt, wxConvUTF8)); m_rebuffer->Enable(1); } else { m_dorebuffer->SetValue(0); m_rebuffer->SetValue(wxT("0")); m_rebuffer->Enable(0); } RTPoverRTSP(event); sOpt = gf_cfg_get_key(cfg, "StreamingCache", "RecordDirectory"); if (!sOpt) sOpt = gf_cfg_get_key(cfg, "General", "CacheDirectory"); if (sOpt) m_recdir->SetLabel(wxString(sOpt, wxConvUTF8)); sOpt = gf_cfg_get_key(cfg, "StreamingCache", "KeepExistingFiles"); m_overwrite->SetValue((sOpt && !stricmp(sOpt, "yes")) ? 0 : 1); sOpt = gf_cfg_get_key(cfg, "StreamingCache", "BaseFileName"); if (sOpt) { m_usename->SetValue(1); m_recfile->Enable(1); m_recfile->SetValue(wxString(sOpt, wxConvUTF8)); } else { m_usename->SetValue(0); m_recfile->Enable(0); m_recfile->SetValue(wxT("uses service URL")); } m_select->Append(wxT("General")); m_select->Append(wxT("MPEG-4 Systems")); m_select->Append(wxT("Media Decoders")); m_select->Append(wxT("Compositor")); m_select->Append(wxT("Renderer 2D")); m_select->Append(wxT("Renderer 3D")); m_select->Append(wxT("Video Output")); m_select->Append(wxT("Audio Output")); m_select->Append(wxT("Text Engine")); m_select->Append(wxT("File Download")); m_select->Append(wxT("Real-Time Streaming")); m_select->Append(wxT("Streaming Cache")); sOpt = gf_cfg_get_key(cfg, "General", "ConfigPanel"); m_sel = sOpt ? atoi(sOpt) : 0; if (m_sel>11) m_sel=11; m_select->SetSelection(m_sel); DoSelect(); }
BOOL COsmo4::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } gf_sys_init(); SetRegistryKey(_T("GPAC")); m_prev_batt_bl = m_prev_ac_bl = 0; m_screen_width = GetSystemMetrics(SM_CXSCREEN); m_screen_height = GetSystemMetrics(SM_CYSCREEN); m_menu_height = GetSystemMetrics(SM_CYMENU); m_scene_width = m_scene_height = 0; CMainFrame* pFrame = new CMainFrame; m_pMainWnd = pFrame; pFrame->LoadFrame(IDR_MAINFRAME, WS_VISIBLE, NULL, NULL); pFrame->ShowWindow(m_nCmdShow); pFrame->UpdateWindow(); char config_path[MAX_PATH]; CE_WideToChar((unsigned short *) (LPCTSTR) AfxGetApp()->m_pszHelpFilePath, (char *) config_path); while (config_path[strlen((char *) config_path)-1] != '\\') config_path[strlen((char *) config_path)-1] = 0; /*setup user*/ memset(&m_user, 0, sizeof(GF_User)); /*init config and plugins*/ m_user.config = gf_cfg_new((const char *) config_path, "GPAC.cfg"); if (!m_user.config) { /*create blank config file in the exe dir*/ unsigned char config_file[MAX_PATH]; strcpy((char *) config_file, (const char *) config_path); strcat((char *) config_file, "GPAC.cfg"); FILE *ft = fopen((const char *) config_file, "wt"); fclose(ft); m_user.config = gf_cfg_new((const char *) config_path, "GPAC.cfg"); if (!m_user.config) { MessageBox(NULL, _T("GPAC Configuration file not found"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_CLOSE); } } const char *str = gf_cfg_get_key(m_user.config, "General", "LogLevel"); EnableLogs((str && !strcmp(str, "debug")) ? 1 : 0); str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); m_user.modules = gf_modules_new(str, m_user.config); if (!m_user.modules) { unsigned char str_path[MAX_PATH]; const char *sOpt; /*inital launch*/ m_user.modules = gf_modules_new(config_path, m_user.config); if (m_user.modules) { gf_cfg_set_key(m_user.config, "General", "ModulesDirectory", (const char *) config_path); gf_cfg_set_key(m_user.config, "Rendering", "RendererName", "GPAC 2D Renderer"); sOpt = gf_cfg_get_key(m_user.config, "Rendering", "Raster2D"); if (!sOpt) gf_cfg_set_key(m_user.config, "Rendering", "Raster2D", "GPAC 2D Raster"); sOpt = gf_cfg_get_key(m_user.config, "General", "CacheDirectory"); if (!sOpt) { sprintf((char *) str_path, "%scache", config_path); gf_cfg_set_key(m_user.config, "General", "CacheDirectory", (const char *) str_path); } /*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"); /*first launch, register all files ext*/ 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); } } } /*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", "200"); } /*by default use GDIplus, much faster than freetype on font loading*/ gf_cfg_set_key(m_user.config, "FontEngine", "DriverName", "ft_font"); sprintf((char *) str_path, "%sgpac.mp4", config_path); gf_cfg_set_key(m_user.config, "General", "StartupFile", (const char *) str_path); ::MessageBox(NULL, _T("Osmo4/GPAC Setup complete"), _T("Initial launch"), MB_OK); } if (! gf_modules_get_count(m_user.modules) ) { MessageBox(NULL, _T("No plugins available - system cannot work"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_QUIT); } /*setup font dir*/ str = gf_cfg_get_key(m_user.config, "FontEngine", "FontDirectory"); if (!str || !strlen(str) ) { strcpy((char *) config_path, "\\Windows"); gf_cfg_set_key(m_user.config, "FontEngine", "FontDirectory", (const char *) config_path); } /*work with iPaq's default fonts ...*/ str = gf_cfg_get_key(m_user.config, "FontEngine", "FontSerif"); if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontSerif", "Tahoma"); str = gf_cfg_get_key(m_user.config, "FontEngine", "FontSans"); if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontSans", "Frutiger"); str = gf_cfg_get_key(m_user.config, "FontEngine", "FontFixed"); if (!str) gf_cfg_set_key(m_user.config, "FontEngine", "FontFixed", "Courier New"); /*check video driver, if none or raw_out use dx_hw by default*/ str = gf_cfg_get_key(m_user.config, "Video", "DriverName"); if (!str || !stricmp(str, "raw_out")) { gf_cfg_set_key(m_user.config, "Video", "DriverName", "gapi"); } m_user.config = m_user.config; m_user.modules = m_user.modules; m_user.EventProc = Osmo4CE_EventProc; m_user.opaque = this; m_user.os_window_handler = pFrame->m_wndView.m_hWnd; m_term = gf_term_new(&m_user); if (! m_term) { MessageBox(NULL, _T("Cannot load MPEG-4 Terminal"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_QUIT); } m_stoped = 0; m_open = 0; m_can_seek = 0; m_DoResume = 0; SetOptions(); pFrame->SendMessage(WM_SETSIZE, 0, 0); ShowTaskBar(0); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (! cmdInfo.m_strFileName.IsEmpty()) { m_filename = cmdInfo.m_strFileName; m_pMainWnd->PostMessage(WM_OPENURL); } else { str = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (str) gf_term_connect(m_term, str); } return TRUE; }
GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_evt, GF_Err error_code) { GF_Err e; u32 i; GF_MPD_In *mpdin = (GF_MPD_In *)dashio->udta; if (dash_evt==GF_DASH_EVENT_PERIOD_SETUP_ERROR) { if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, error_code); mpdin->connection_ack_sent=1; } return GF_OK; } if (dash_evt==GF_DASH_EVENT_SELECT_GROUPS) { const char *opt; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { /*todo: select groups based on user criteria*/ gf_dash_group_select(mpdin->dash, i, 1); } opt = gf_modules_get_option((GF_BaseInterface *)mpdin->plug, "Systems", "Language3CC"); if (opt && strcmp(opt, "und")) gf_dash_groups_set_language(mpdin->dash, opt); return GF_OK; } /*for all selected groups, create input service and connect to init/first segment*/ if (dash_evt==GF_DASH_EVENT_CREATE_PLAYBACK) { /*select input services if possible*/ for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { const char *mime, *init_segment; if (!gf_dash_is_group_selected(mpdin->dash, i)) continue; mime = gf_dash_group_get_segment_mime(mpdin->dash, i); init_segment = gf_dash_group_get_segment_init_url(mpdin->dash, i, NULL, NULL); e = MPD_LoadMediaService(mpdin, i, mime, init_segment); if (e != GF_OK) { gf_dash_group_select(mpdin->dash, i, 0); } else { /*connect our media service*/ GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); e = group->segment_ifce->ConnectService(group->segment_ifce, mpdin->service, init_segment); if (e) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD_IN] Unable to connect input service to %s\n", init_segment)); gf_dash_group_select(mpdin->dash, i, 0); } else { u32 w, h; group->service_connected = 1; w = h = 0; gf_dash_group_get_video_info(mpdin->dash, i, &w, &h); if (w && h && w>mpdin->width && h>mpdin->height) { mpdin->width = w; mpdin->height = h; } } } } if (!mpdin->connection_ack_sent) { gf_term_on_connect(mpdin->service, NULL, GF_OK); mpdin->connection_ack_sent=1; } return GF_OK; } /*for all running services, stop service*/ if (dash_evt==GF_DASH_EVENT_DESTROY_PLAYBACK) { mpdin->service->subservice_disconnect = 1; gf_term_on_disconnect(mpdin->service, NULL, GF_OK); mpdin->service->subservice_disconnect = 2; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); if (!group) continue; if (group->segment_ifce) { if (group->service_connected) { group->segment_ifce->CloseService(group->segment_ifce); group->service_connected = 0; } gf_modules_close_interface((GF_BaseInterface *) group->segment_ifce); } gf_free(group); gf_dash_set_group_udta(mpdin->dash, i, NULL); } mpdin->service->subservice_disconnect = 0; } return GF_OK; }
BOOL COsmo4::InitInstance() { Bool first_load = 0; if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } gf_sys_init(); SetRegistryKey(_T("GPAC")); m_prev_batt_bl = m_prev_ac_bl = 0; m_screen_width = GetSystemMetrics(SM_CXSCREEN); m_screen_height = GetSystemMetrics(SM_CYSCREEN); m_menu_height = GetSystemMetrics(SM_CYMENU); m_scene_width = m_scene_height = 0; CMainFrame* pFrame = new CMainFrame; m_pMainWnd = pFrame; pFrame->LoadFrame(IDR_MAINFRAME, WS_VISIBLE, NULL, NULL); pFrame->ShowWindow(m_nCmdShow); pFrame->UpdateWindow(); TCHAR w_config_path[MAX_PATH]; char config_path[MAX_PATH]; GetModuleFileName(NULL, w_config_path, MAX_PATH); CE_WideToChar((u16 *) w_config_path, (char *) config_path); while (config_path[strlen((char *) config_path)-1] != '\\') config_path[strlen((char *) config_path)-1] = 0; /*setup user*/ memset(&m_user, 0, sizeof(GF_User)); /*init config and plugins*/ m_user.config = gf_cfg_init(NULL, &first_load); if (!m_user.config) { MessageBox(NULL, _T("GPAC Configuration file not found"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_CLOSE); } const char *str = gf_cfg_get_key(m_user.config, "General", "LogLevel"); EnableLogs((str && !strcmp(str, "debug")) ? 1 : 0); if (first_load) { /*first launch, register all files ext*/ 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); } } ::MessageBox(NULL, _T("Osmo4/GPAC Setup complete"), _T("Initial launch"), MB_OK); } str = gf_cfg_get_key(m_user.config, "General", "ModulesDirectory"); m_user.modules = gf_modules_new(str, m_user.config); if (!m_user.modules || ! gf_modules_get_count(m_user.modules) ) { MessageBox(NULL, _T("No plugins available - system cannot work"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_QUIT); return FALSE; } m_user.config = m_user.config; m_user.modules = m_user.modules; m_user.EventProc = Osmo4CE_EventProc; m_user.opaque = this; m_user.os_window_handler = pFrame->m_wndView.m_hWnd; m_term = gf_term_new(&m_user); if (! m_term) { MessageBox(NULL, _T("Cannot load MPEG-4 Terminal"), _T("Fatal Error"), MB_OK); m_pMainWnd->PostMessage(WM_QUIT); } m_stopped = 0; m_open = 0; m_can_seek = 0; m_DoResume = 0; SetOptions(); pFrame->SendMessage(WM_SETSIZE, 0, 0); ShowTaskBar(0); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (! cmdInfo.m_strFileName.IsEmpty()) { m_filename = cmdInfo.m_strFileName; m_pMainWnd->PostMessage(WM_OPENURL); } else { str = gf_cfg_get_key(m_user.config, "General", "StartupFile"); if (str) gf_term_connect(m_term, str); } return TRUE; }
static GF_InputService *gf_term_can_handle_service(GF_Terminal *term, const char *url, const char *parent_url, Bool no_mime_check, char **out_url, GF_Err *ret_code, GF_DownloadSession **the_session) { u32 i; GF_Err e; char *sURL, *qm, *frag, *ext, *mime_type, *url_res; char szExt[50]; const char *force_module = NULL; GF_InputService *ifce; Bool skip_mime = 0; memset(szExt, 0, sizeof(szExt)); (*ret_code) = GF_OK; ifce = NULL; mime_type = NULL; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Looking for plugin for URL %s\n", url)); *out_url = NULL; sURL = NULL; if (!url || !strncmp(url, "\\\\", 2) ) { (*ret_code) = GF_URL_ERROR; goto exit; } if (!strnicmp(url, "libplayer://", 12)) { force_module = "LibPlayer"; } /*used by GUIs scripts to skip URL concatenation*/ if (!strncmp(url, "gpac://", 7)) sURL = gf_strdup(url+7); /*opera-style localhost URLs*/ else if (!strncmp(url, "file://localhost", 16)) sURL = gf_strdup(url+16); else if (parent_url) sURL = gf_url_concatenate(parent_url, url); /*path absolute*/ if (!sURL) sURL = gf_strdup(url); if (gf_url_is_local(sURL)) gf_url_to_fs_path(sURL); if (the_session) *the_session = NULL; if (no_mime_check) { mime_type = NULL; } else { /*fetch a mime type if any. If error don't even attempt to open the service TRYTOFIXME: it would be nice to reuse the downloader created while fetching the mime type, however we don't know if the plugin will want it threaded or not.... */ mime_type = get_mime_type(term, sURL, &e, the_session); if (e) { (*ret_code) = e; goto exit; } } if (mime_type && (!stricmp(mime_type, "text/plain") || !stricmp(mime_type, "video/quicktime") || !stricmp(mime_type, "application/octet-stream") ) ) { skip_mime = 1; } ifce = NULL; /*load from mime type*/ if (mime_type && !skip_mime) { const char *sPlug = gf_cfg_get_key(term->user->config, "MimeTypes", mime_type); GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Mime type found: %s\n", mime_type)); if (!sPlug) { gf_free(mime_type); mime_type=NULL; } if (sPlug) sPlug = strrchr(sPlug, '"'); if (sPlug) { sPlug += 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("%s:%d FOUND matching module %s\n", __FILE__, __LINE__, sPlug)); ifce = (GF_InputService *) gf_modules_load_interface_by_name(term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); if (force_module && ifce && !strstr(ifce->module_name, force_module)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } if (ifce && !net_check_interface(ifce) ) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } } } /* The file extension, if any, is before '?' if any or before '#' if any.*/ url_res = strrchr(sURL, '/'); if (!url_res) url_res = strrchr(sURL, '\\'); if (!url_res) url_res = sURL; qm = strchr(url_res, '?'); if (qm) { qm[0] = 0; ext = strrchr(url_res, '.'); qm[0] = '?'; } else { frag = strchr(url_res, '#'); if (frag) { frag[0] = 0; ext = strrchr(url_res, '.'); frag[0] = '#'; } else { ext = strrchr(url_res, '.'); } } if (ext && !stricmp(ext, ".gz")) { char *anext; ext[0] = 0; anext = strrchr(sURL, '.'); ext[0] = '.'; ext = anext; } /*no mime type: either local or streaming. If streaming discard extension checking*/ if (!ifce && !mime_type && strstr(sURL, "://") && strnicmp(sURL, "file://", 7)) ext = NULL; /*browse extensions for prefered module*/ if (!ifce && ext) { u32 keyCount; strncpy(szExt, &ext[1], 49); ext = strrchr(szExt, '?'); if (ext) ext[0] = 0; ext = strrchr(szExt, '#'); if (ext) ext[0] = 0; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] No mime type found - checking by extension %s\n", szExt)); assert( term && term->user && term->user->modules); keyCount = gf_cfg_get_key_count(term->user->config, "MimeTypes"); for (i=0; i<keyCount; i++) { char *sPlug; const char *sKey; const char *sMime; sMime = gf_cfg_get_key_name(term->user->config, "MimeTypes", i); if (!sMime) continue; sKey = gf_cfg_get_key(term->user->config, "MimeTypes", sMime); if (!sKey) continue; if (!check_extension(sKey, szExt)) continue; sPlug = strrchr(sKey, '"'); if (!sPlug) continue; /*bad format entry*/ sPlug += 2; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Trying module[%i]=%s, mime=%s\n", i, sPlug, sMime)); ifce = (GF_InputService *) gf_modules_load_interface_by_name(term->user->modules, sPlug, GF_NET_CLIENT_INTERFACE); if (!ifce){ GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] module[%i]=%s, mime=%s, cannot be loaded for GF_NET_CLIENT_INTERFACE.\n", i, sPlug, sMime)); continue; } if (force_module && ifce && !strstr(ifce->module_name, force_module)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; continue; } if (ifce && !net_check_interface(ifce)) { gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; continue; } break; } } /*browse all modules*/ if (!ifce) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Not found any interface, trying browsing all modules...\n")); for (i=0; i< gf_modules_get_count(term->user->modules); i++) { ifce = (GF_InputService *) gf_modules_load_interface(term->user->modules, i, GF_NET_CLIENT_INTERFACE); if (!ifce) continue; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[Terminal] Checking if module %s supports URL %s\n", ifce->module_name, sURL)); if (force_module && ifce && !strstr(ifce->module_name, force_module)) { } else if (net_check_interface(ifce) && ifce->CanHandleURL(ifce, sURL)) { break; } gf_modules_close_interface((GF_BaseInterface *) ifce); ifce = NULL; } } exit: if (!ifce){ GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[Terminal] Did not find any input plugin for URL %s (%s)\n", sURL ? sURL : url, mime_type ? mime_type : "no mime type")); if (sURL) gf_free(sURL); if ( (*ret_code) == GF_OK) (*ret_code) = GF_NOT_SUPPORTED; *out_url = NULL; if (the_session && *the_session) { gf_dm_sess_del(*the_session); } } else { *out_url = sURL; GF_LOG(GF_LOG_INFO, GF_LOG_MEDIA, ("[Terminal] Found input plugin %s for URL %s (%s)\n", ifce->module_name, sURL, mime_type ? mime_type : "no mime type")); } if (mime_type) gf_free(mime_type); mime_type = NULL; return ifce; }
GF_Err gf_term_service_cache_load(GF_ClientService *ns) { GF_Err e; const char *sOpt; char szName[GF_MAX_PATH], szURL[1024]; GF_NetworkCommand com; u32 i; GF_StreamingCache *mcache = NULL; /*is service cachable*/ com.base.on_channel = NULL; com.base.command_type = GF_NET_IS_CACHABLE; if (ns->ifce->ServiceCommand(ns->ifce, &com) != GF_OK) return GF_OK; /*locate a cache*/ for (i=0; i< gf_modules_get_count(ns->term->user->modules); i++) { mcache = (GF_StreamingCache *) gf_modules_load_interface(ns->term->user->modules, i, GF_STREAMING_MEDIA_CACHE); if (mcache && mcache->Open && mcache->Close && mcache->Write && mcache->ChannelGetSLP && mcache->ChannelReleaseSLP && mcache->ServiceCommand) break; if (mcache) gf_modules_close_interface((GF_BaseInterface *)mcache); mcache = NULL; } if (!mcache) return GF_NOT_SUPPORTED; sOpt = gf_cfg_get_key(ns->term->user->config, "StreamingCache", "RecordDirectory"); if (!sOpt) sOpt = gf_cfg_get_key(ns->term->user->config, "General", "CacheDirectory"); if (sOpt) { strcpy(szName, sOpt); if (szName[strlen(szName)-1]!='\\') strcat(szName, "\\"); } else { strcpy(szName, ""); } sOpt = gf_cfg_get_key(ns->term->user->config, "StreamingCache", "BaseFileName"); if (sOpt) { strcat(szName, sOpt); } else { char *sep; strcat(szName, "rec_"); sOpt = strrchr(ns->url, '/'); if (!sOpt) sOpt = strrchr(ns->url, '\\'); if (sOpt) sOpt += 1; else { sOpt = strstr(ns->url, "://"); if (sOpt) sOpt += 3; else sOpt = ns->url; } strcpy(szURL, sOpt); sep = strrchr(szURL, '.'); if (sep) sep[0] = 0; for (i=0; i<strlen(szURL); i++) { switch (szURL[i]) { case '/': case '\\': case '.': case ':': case '?': szURL[i] = '_'; break; } } strcat(szName, szURL); } sOpt = gf_cfg_get_key(ns->term->user->config, "StreamingCache", "KeepExistingFiles"); e = mcache->Open(mcache, ns, szName, (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0); if (e) { gf_modules_close_interface((GF_BaseInterface *)mcache); return e; } ns->cache = mcache; return GF_OK; }
static GF_Err IS_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd) { GF_BitStream *bs; u32 len, size, i; char devName[255]; u16 termSeq[20]; ISPriv *is = (ISPriv *)plug->privateStack; if (esd->decoderConfig->upstream) return GF_NOT_SUPPORTED; if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->dataLength) return GF_NON_COMPLIANT_BITSTREAM; /*no more than one UI stream per object*/ if (is->ES_ID) return GF_NOT_SUPPORTED; is->ES_ID = esd->ESID; /*parse config*/ bs = gf_bs_new(esd->decoderConfig->decoderSpecificInfo->data, esd->decoderConfig->decoderSpecificInfo->dataLength, GF_BITSTREAM_READ); len = gf_bs_read_int(bs, 8); for (i=0; i<len; i++) { devName[i] = gf_bs_read_int(bs, 8); } devName[i] = 0; is->type = gf_crc_32(devName, len); size = len + 1; if (!stricmp(devName, "KeySensor")) { is->type = IS_KeySensor; add_field(is, GF_SG_VRML_SFINT32, "keyPressed"); add_field(is, GF_SG_VRML_SFINT32, "keyReleased"); add_field(is, GF_SG_VRML_SFINT32, "actionKeyPressed"); add_field(is, GF_SG_VRML_SFINT32, "actionKeyReleased"); add_field(is, GF_SG_VRML_SFBOOL, "shiftKeyPressed"); add_field(is, GF_SG_VRML_SFBOOL, "controlKeyPressed"); add_field(is, GF_SG_VRML_SFBOOL, "altKeyPressed"); } else if (!stricmp(devName, "StringSensor")) { is->type = IS_StringSensor; add_field(is, GF_SG_VRML_SFSTRING, "enteredText"); add_field(is, GF_SG_VRML_SFSTRING, "finalText"); is->termChar = '\r'; is->delChar = '\b'; /*get escape chars if any specified*/ if (size<esd->decoderConfig->decoderSpecificInfo->dataLength) { const char *src = esd->decoderConfig->decoderSpecificInfo->data + size; gf_utf8_mbstowcs(termSeq, esd->decoderConfig->decoderSpecificInfo->dataLength - size, &src); is->termChar = termSeq[0]; is->delChar = termSeq[1]; } } else if (!stricmp(devName, "Mouse")) { is->type = IS_Mouse; add_field(is, GF_SG_VRML_SFVEC2F, "position"); add_field(is, GF_SG_VRML_SFBOOL, "leftButtonDown"); add_field(is, GF_SG_VRML_SFBOOL, "middleButtonDown"); add_field(is, GF_SG_VRML_SFBOOL, "rightButtonDown"); add_field(is, GF_SG_VRML_SFFLOAT, "wheel"); } else { GF_InputSensorDevice *ifce; /*not found, check all modules*/ u32 plugCount = gf_modules_get_count(is->scene->root_od->term->user->modules); for (i = 0; i < plugCount ; i++) { ifce = (GF_InputSensorDevice *) gf_modules_load_interface(is->scene->root_od->term->user->modules, i, GF_INPUT_DEVICE_INTERFACE); if (!ifce) continue; ifce->input_decoder = plug; if (ifce->RegisterDevice && ifce->RegisterDevice(ifce, devName, bs, isdev_add_field) ) { is->io_dev = ifce; break; } gf_modules_close_interface((GF_BaseInterface *) ifce); } if (!is->io_dev) return GF_NOT_SUPPORTED; is->io_dev->DispatchFrame = isdev_dispatch_frame; plug->module_name = is->io_dev->module_name; plug->author_name = is->io_dev->author_name; } gf_bs_del(bs); return GF_OK; }
void gf_es_config_drm(GF_Channel *ch, GF_NetComDRMConfig *drm_cfg) { GF_Terminal *term = ch->odm->term; u32 i, count; GF_Err e; GF_IPMPEvent evt; GF_OMADRM2Config cfg; GF_OMADRM2Config isma_cfg; /*always buffer when fetching keys*/ ch_buffer_on(ch); ch->is_protected = 1; memset(&evt, 0, sizeof(GF_IPMPEvent)); evt.event_type = GF_IPMP_TOOL_SETUP; evt.channel = ch; /*push all cfg data*/ if (drm_cfg->contentID) { evt.config_data_code = GF_4CC('o','d','r','m'); memset(&cfg, 0, sizeof(cfg)); cfg.scheme_version = drm_cfg->scheme_version; cfg.scheme_type = drm_cfg->scheme_type; cfg.scheme_uri = drm_cfg->scheme_uri; cfg.kms_uri = drm_cfg->kms_uri; memcpy(cfg.hash, drm_cfg->hash, sizeof(char)*20); cfg.contentID = drm_cfg->contentID; cfg.oma_drm_crypt_type = drm_cfg->oma_drm_crypt_type; cfg.oma_drm_use_pad = drm_cfg->oma_drm_use_pad; cfg.oma_drm_use_hdr = drm_cfg->oma_drm_use_hdr; cfg.oma_drm_textual_headers = drm_cfg->oma_drm_textual_headers; cfg.oma_drm_textual_headers_len = drm_cfg->oma_drm_textual_headers_len; evt.config_data = &cfg; } else { evt.config_data_code = GF_4CC('i','s','m','a'); memset(&isma_cfg, 0, sizeof(isma_cfg)); isma_cfg.scheme_version = drm_cfg->scheme_version; isma_cfg.scheme_type = drm_cfg->scheme_type; isma_cfg.scheme_uri = drm_cfg->scheme_uri; isma_cfg.kms_uri = drm_cfg->kms_uri; evt.config_data = &isma_cfg; } if (ch->ipmp_tool) { e = ch->ipmp_tool->process(ch->ipmp_tool, &evt); if (e) gf_term_message(ch->odm->term, ch->service->url, "Error setting up DRM tool", e); ch_buffer_off(ch); return; } /*browse all available tools*/ count = gf_modules_get_count(term->user->modules); for (i=0; i< count; i++) { ch->ipmp_tool = (GF_IPMPTool *) gf_modules_load_interface(term->user->modules, i, GF_IPMP_TOOL_INTERFACE); if (!ch->ipmp_tool) continue; GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[IPMP] Checking if IPMP tool %s can handle channel protection scheme\n", ch->ipmp_tool->module_name)); e = ch->ipmp_tool->process(ch->ipmp_tool, &evt); if (e==GF_OK) { GF_LOG(GF_LOG_DEBUG, GF_LOG_MEDIA, ("[IPMP] Associating IPMP tool %s to channel %d\n", ch->ipmp_tool->module_name, ch->esd->ESID)); ch_buffer_off(ch); return; } gf_modules_close_interface((GF_BaseInterface *) ch->ipmp_tool); ch->ipmp_tool = NULL; } GF_LOG(GF_LOG_ERROR, GF_LOG_MEDIA, ("[IPMP] No IPMP tool suitable to handle channel protection scheme %s (KMS URI %s)\n", drm_cfg->scheme_uri, drm_cfg->kms_uri)); ch_buffer_off(ch); }
GF_AudioRenderer *gf_sc_ar_load(GF_User *user) { const char *sOpt; u32 i, count; u32 num_buffers, total_duration; GF_Err e; GF_AudioRenderer *ar; ar = (GF_AudioRenderer *) gf_malloc(sizeof(GF_AudioRenderer)); memset(ar, 0, sizeof(GF_AudioRenderer)); num_buffers = total_duration = 0; sOpt = gf_cfg_get_key(user->config, "Audio", "ForceConfig"); if (sOpt && !stricmp(sOpt, "yes")) { sOpt = gf_cfg_get_key(user->config, "Audio", "NumBuffers"); num_buffers = sOpt ? atoi(sOpt) : 6; sOpt = gf_cfg_get_key(user->config, "Audio", "TotalDuration"); total_duration = sOpt ? atoi(sOpt) : 400; } sOpt = gf_cfg_get_key(user->config, "Audio", "NoResync"); ar->disable_resync = (sOpt && !stricmp(sOpt, "yes")) ? GF_TRUE : GF_FALSE; sOpt = gf_cfg_get_key(user->config, "Audio", "DisableMultiChannel"); ar->disable_multichannel = (sOpt && !stricmp(sOpt, "yes")) ? GF_TRUE : GF_FALSE; ar->mixer = gf_mixer_new(ar); ar->user = user; sOpt = gf_cfg_get_key(user->config, "Audio", "Volume"); ar->volume = sOpt ? atoi(sOpt) : 75; sOpt = gf_cfg_get_key(user->config, "Audio", "Pan"); ar->pan = sOpt ? atoi(sOpt) : 50; if (! (user->init_flags & GF_TERM_NO_AUDIO) ) { /*get a prefered compositor*/ sOpt = gf_cfg_get_key(user->config, "Audio", "DriverName"); if (sOpt) { ar->audio_out = (GF_AudioOutput *) gf_modules_load_interface_by_name(user->modules, sOpt, GF_AUDIO_OUTPUT_INTERFACE); if (!ar->audio_out) { ar->audio_out = NULL; sOpt = NULL; } } if (!ar->audio_out) { GF_AudioOutput *raw_out = NULL; count = gf_modules_get_count(ar->user->modules); for (i=0; i<count; i++) { ar->audio_out = (GF_AudioOutput *) gf_modules_load_interface(ar->user->modules, i, GF_AUDIO_OUTPUT_INTERFACE); if (!ar->audio_out) continue; //in enum mode, only use raw out if everything else failed ... if (!stricmp(ar->audio_out->module_name, "Raw Audio Output")) { raw_out = ar->audio_out; ar->audio_out = NULL; continue; } GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Audio output module %s loaded\n", ar->audio_out->module_name)); /*check that's a valid audio compositor*/ if ((ar->audio_out->SelfThreaded && ar->audio_out->SetPriority) || ar->audio_out->WriteAudio) { /*remember the module we use*/ gf_cfg_set_key(user->config, "Audio", "DriverName", ar->audio_out->module_name); break; } gf_modules_close_interface((GF_BaseInterface *)ar->audio_out); ar->audio_out = NULL; } if (raw_out) { if (ar->audio_out) gf_modules_close_interface((GF_BaseInterface *)raw_out); else ar->audio_out = raw_out; } } /*if not init we run with a NULL audio compositor*/ if (ar->audio_out) { ar->audio_out->FillBuffer = gf_ar_fill_output; ar->audio_out->audio_renderer = ar; GF_LOG(GF_LOG_DEBUG, GF_LOG_AUDIO, ("[AudioRender] Setting up audio module %s\n", ar->audio_out->module_name)); e = ar->audio_out->Setup(ar->audio_out, ar->user->os_window_handler, num_buffers, total_duration); /*load main audio filter*/ gf_afc_load(&ar->filter_chain, user, (char*)gf_cfg_get_key(user->config, "Audio", "Filter")); if (e != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_MMIO, ("Could not setup audio out %s\n", ar->audio_out->module_name)); gf_modules_close_interface((GF_BaseInterface *)ar->audio_out); ar->audio_out = NULL; } else { if (!ar->audio_out->SelfThreaded) { ar->th = gf_th_new("AudioRenderer"); gf_th_run(ar->th, gf_ar_proc, ar); } else { gf_ar_setup_output_format(ar); if (ar->audio_out->SetPriority) ar->audio_out->SetPriority(ar->audio_out, GF_THREAD_PRIORITY_REALTIME); } } } if (!ar->audio_out) { gf_cfg_set_key(user->config, "Audio", "DriverName", "No Audio Output Available"); } else { if (user->init_flags & GF_TERM_USE_AUDIO_HW_CLOCK) ar->clock_use_audio_out = GF_TRUE; } } /*init compositor timer*/ ar->start_time = gf_sys_clock_high_res(); ar->current_time = 0; return ar; }
GF_Err mpdin_dash_io_on_dash_event(GF_DASHFileIO *dashio, GF_DASHEventType dash_evt, s32 group_idx, GF_Err error_code) { GF_Err e; u32 i; GF_MPD_In *mpdin = (GF_MPD_In *)dashio->udta; if (dash_evt==GF_DASH_EVENT_PERIOD_SETUP_ERROR) { if (!mpdin->connection_ack_sent) { mpdin->fn_connect_ack(mpdin->service, NULL, error_code); mpdin->connection_ack_sent= GF_TRUE; } return GF_OK; } if (dash_evt==GF_DASH_EVENT_SELECT_GROUPS) { const char *opt; //configure buffer in dynamic mode without low latency: we indicate how much the player will buffer if (gf_dash_is_dynamic_mpd(mpdin->dash) && !mpdin->use_low_latency) { u32 buffer_ms = 0; const char *opt = gf_modules_get_option((GF_BaseInterface *)mpdin->plug, "Network", "BufferLength"); if (opt) buffer_ms = atoi(opt); //use min buffer from MPD if (mpdin->buffer_mode>=MPDIN_BUFFER_MIN) { u32 mpd_buffer_ms = gf_dash_get_min_buffer_time(mpdin->dash); if (mpd_buffer_ms > buffer_ms) buffer_ms = mpd_buffer_ms; } if (buffer_ms) { gf_dash_set_user_buffer(mpdin->dash, buffer_ms); } } //let the player decide which group to play: we declare everything //however select the default languague opt = gf_modules_get_option((GF_BaseInterface *)mpdin->plug, "Systems", "LanguageName"); if (opt) gf_dash_groups_set_language(mpdin->dash, opt); return GF_OK; } /*for all selected groups, create input service and connect to init/first segment*/ if (dash_evt==GF_DASH_EVENT_CREATE_PLAYBACK) { /*select input services if possible*/ for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { const char *mime, *init_segment; //let the player decide which group to play if (!gf_dash_is_group_selectable(mpdin->dash, i)) continue; mime = gf_dash_group_get_segment_mime(mpdin->dash, i); init_segment = gf_dash_group_get_segment_init_url(mpdin->dash, i, NULL, NULL); e = MPD_LoadMediaService(mpdin, i, mime, init_segment); if (e != GF_OK) { gf_dash_group_select(mpdin->dash, i, 0); } else { u32 w, h; /*connect our media service*/ GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); gf_dash_group_get_video_info(mpdin->dash, i, &w, &h); if (w && h && w>mpdin->width && h>mpdin->height) { mpdin->width = w; mpdin->height = h; } e = group->segment_ifce->ConnectService(group->segment_ifce, mpdin->service, init_segment); if (e) { GF_LOG(GF_LOG_WARNING, GF_LOG_DASH, ("[MPD_IN] Unable to connect input service to %s\n", init_segment)); gf_dash_group_select(mpdin->dash, i, 0); } else { group->service_connected = 1; } if (mpdin->closed) return GF_OK; } } if (!mpdin->connection_ack_sent) { mpdin->fn_connect_ack(mpdin->service, NULL, GF_OK); mpdin->connection_ack_sent=1; } //we had a seek outside of the period we were setting up, during period setup ! //request the seek again from the player if (mpdin->seek_request>=0) { GF_NetworkCommand com; memset(&com, 0, sizeof(GF_NetworkCommand)); com.command_type = GF_NET_SERVICE_SEEK; com.play.start_range = mpdin->seek_request; mpdin->seek_request = 0; gf_service_command(mpdin->service, &com, GF_OK); } return GF_OK; } /*for all running services, stop service*/ if (dash_evt==GF_DASH_EVENT_DESTROY_PLAYBACK) { mpdin->service->subservice_disconnect = 1; gf_service_disconnect_ack(mpdin->service, NULL, GF_OK); mpdin->service->subservice_disconnect = 2; for (i=0; i<gf_dash_get_group_count(mpdin->dash); i++) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, i); if (!group) continue; if (group->segment_ifce) { if (group->service_connected) { group->segment_ifce->CloseService(group->segment_ifce); group->service_connected = 0; } gf_modules_close_interface((GF_BaseInterface *) group->segment_ifce); } gf_free(group); gf_dash_set_group_udta(mpdin->dash, i, NULL); } mpdin->service->subservice_disconnect = 0; return GF_OK; } if (dash_evt==GF_DASH_EVENT_BUFFERING) { u32 tot, done; gf_dash_get_buffer_info(mpdin->dash, &tot, &done); fprintf(stderr, "DASH: Buffering %g%% out of %d ms\n", (100.0*done)/tot, tot); return GF_OK; } if (dash_evt==GF_DASH_EVENT_SEGMENT_AVAILABLE) { if (group_idx>=0) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, group_idx); if (group) MPD_NotifyData(group, 0); } return GF_OK; } if (dash_evt==GF_DASH_EVENT_QUALITY_SWITCH) { if (group_idx>=0) { GF_MPDGroup *group = gf_dash_get_group_udta(mpdin->dash, group_idx); if (group) { GF_NetworkCommand com; memset(&com, 0, sizeof(GF_NetworkCommand) ); com.command_type = GF_NET_SERVICE_EVENT; com.send_event.evt.type = GF_EVENT_QUALITY_SWITCHED; gf_service_command(mpdin->service, &com, GF_OK); } } return GF_OK; } if (dash_evt==GF_DASH_EVENT_TIMESHIFT_OVERFLOW) { GF_NetworkCommand com; com.command_type = GF_NET_SERVICE_EVENT; com.send_event.evt.type = (group_idx>=0) ? GF_EVENT_TIMESHIFT_OVERFLOW : GF_EVENT_TIMESHIFT_UNDERRUN; gf_service_command(mpdin->service, &com, GF_OK); } if (dash_evt==GF_DASH_EVENT_TIMESHIFT_UPDATE) { GF_NetworkCommand com; com.command_type = GF_NET_SERVICE_EVENT; com.send_event.evt.type = GF_EVENT_TIMESHIFT_UPDATE; gf_service_command(mpdin->service, &com, GF_OK); } return GF_OK; }