Esempio n. 1
0
GF_EXPORT
GF_Config *gf_cfg_init(const char *file, Bool *new_cfg)
{
	GF_Config *cfg;
	char szPath[GF_MAX_PATH];

	if (new_cfg) *new_cfg = GF_FALSE;

	if (file) {
		cfg = gf_cfg_new(NULL, file);
		/*force creation of a new config*/
		if (!cfg) {
			FILE *fcfg = gf_fopen(file, "wt");
			if (fcfg) {
				gf_fclose(fcfg);
				cfg = gf_cfg_new(NULL, file);
				if (new_cfg) *new_cfg = GF_TRUE;
			}
		}
		if (cfg) {
			check_modules_dir(cfg);
			return cfg;
		}
	}

	if (!get_default_install_path(szPath, GF_PATH_CFG)) {
		fprintf(stderr, "Fatal error: Cannot create a configuration file in application or user home directory - no write access\n");
		return NULL;
	}

	cfg = gf_cfg_new(szPath, CFG_FILE_NAME);
	if (!cfg) {
		fprintf(stderr, "GPAC config file %s not found in %s - creating new file\n", CFG_FILE_NAME, szPath);
		cfg = create_default_config(szPath);
	}
	if (!cfg) {
		fprintf(stderr, "\nCannot create config file %s in %s directory\n", CFG_FILE_NAME, szPath);
		return NULL;
	}

#ifndef GPAC_IPHONE
	fprintf(stderr, "Using config file in %s directory\n", szPath);
#endif

	check_modules_dir(cfg);

	if (!gf_cfg_get_key(cfg, "General", "StorageDirectory")) {
		get_default_install_path(szPath, GF_PATH_CFG);
		strcat(szPath, "/Storage");
		if (!gf_dir_exists(szPath)) gf_mkdir(szPath);
		gf_cfg_set_key(cfg, "General", "StorageDirectory", szPath);
	}
    
	if (new_cfg) *new_cfg = GF_TRUE;
	return cfg;
}
Esempio n. 2
0
void compositor_init_imagetexture(GF_Compositor *compositor, GF_Node *node)
{
	GF_TextureHandler *txh;
	GF_SAFEALLOC(txh, GF_TextureHandler);
	gf_sc_texture_setup(txh, compositor, node);
	txh->update_texture_fcnt = imagetexture_update;
	gf_node_set_private(node, txh);
	gf_node_set_callback_function(node, imagetexture_destroy);
	txh->flags = 0;

	if (gf_node_get_tag(txh->owner)!=TAG_MPEG4_CacheTexture) {
		if (((M_ImageTexture*)node)->repeatS) txh->flags |= GF_SR_TEXTURE_REPEAT_S;
		if (((M_ImageTexture*)node)->repeatT) txh->flags |= GF_SR_TEXTURE_REPEAT_T;
	} else {
		const char *url;
		u32 i, count;
		M_CacheTexture*ct = (M_CacheTexture*)node;
		if (!ct->image.buffer) return;

		if (ct->repeatS) txh->flags |= GF_SR_TEXTURE_REPEAT_S;
		if (ct->repeatT) txh->flags |= GF_SR_TEXTURE_REPEAT_T;

		/*locate existing cache*/
		url = gf_scene_get_service_url( gf_node_get_graph(node) );
		count = gf_cfg_get_section_count(compositor->user->config);
		for (i=0; i<count; i++) {
			const char *opt;
			const char *name = gf_cfg_get_section_name(compositor->user->config, i);
			if (strncmp(name, "@cache=", 7)) continue;
			opt = gf_cfg_get_key(compositor->user->config, name, "serviceURL");
			if (!opt || stricmp(opt, url)) continue;
			opt = gf_cfg_get_key(compositor->user->config, name, "cacheName");
			if (opt && ct->cacheURL.buffer && !stricmp(opt, ct->cacheURL.buffer)) {
				opt = gf_cfg_get_key(compositor->user->config, name, "cacheFile");
				if (opt) gf_delete_file((char*)opt);
				gf_cfg_del_section(compositor->user->config, name);
				break;
			}
		}

	}
}
Esempio n. 3
0
static Bool gf_inline_is_hardcoded_proto(MFURL *url, GF_Config *cfg)
{
	u32 i;
	const char *sOpt = gf_cfg_get_key(cfg, "Systems", "hardcoded_protos");
	for (i=0; i<url->count; i++) {
		if (!url->vals[i].url) continue;
		if (strstr(url->vals[i].url, "urn:inet:gpac:builtin")) return 1;
		if (sOpt && strstr(sOpt, url->vals[i].url)) return 1;
	}
	return 0;
}
Esempio n. 4
0
static void setup_logs()
{
	if (log_file) fclose(log_file);
	log_file = NULL;

	gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_ERROR);
	gf_log_set_callback(NULL, NULL);

	if (log_rti) {
		const char *filename = gf_cfg_get_key(user.config, "General", "LogFile");
		if (!filename) {
			gf_cfg_set_key(user.config, "General", "LogFile", "\\gpac_logs.txt");
			filename = "\\gpac_logs.txt";
		}
		log_file = gf_f64_open(filename, "a+t");

		fprintf(log_file, "!! GPAC RunTime Info for file %s !!\n", the_url);
		fprintf(log_file, "SysTime(ms)\tSceneTime(ms)\tCPU\tFPS\tMemory(kB)\tObservation\n");

		gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_ERROR);
		gf_log_set_tool_level(GF_LOG_RTI, GF_LOG_DEBUG);
		gf_log_set_callback(log_file, on_gpac_rti_log);

		GF_LOG(GF_LOG_DEBUG, GF_LOG_RTI, ("[RTI] System state when enabling log\n"));
	} else {
		const char *filename = gf_cfg_get_key(user.config, "General", "LogFile");
		if (!filename) {
			gf_cfg_set_key(user.config, "General", "LogFile", "\\gpac_logs.txt");
			filename = "\\gpac_logs.txt";
		}
		const char *logs = gf_cfg_get_key(user.config, "General", "Logs");
		if (logs) {
			if (gf_log_set_tools_levels( logs ) != GF_OK) {
			} else {
				if (log_file = gf_f64_open(filename, "a+t")) {
					gf_log_set_callback(log_file, on_gpac_log);
				}
			}
		}
	}
}
Esempio n. 5
0
BOOL COptGen::OnInitDialog()
{
	CDialog::OnInitDialog();
	COsmo4 *gpac = GetApp();
	const char *sOpt;

	sOpt = gf_cfg_get_key(gpac->m_user.config, "General", "Loop");
	if (sOpt && !stricmp(sOpt, "yes")) {
		m_Loop.SetCheck(1);
	} else {
		m_Loop.SetCheck(0);
	}
	sOpt = gf_cfg_get_key(gpac->m_user.config, "General", "FillScreen");
	m_Fill.SetCheck((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0);
	sOpt = gf_cfg_get_key(gpac->m_user.config, "General", "DisableBackLight");
	m_NoBacklight.SetCheck((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0);

	sOpt = gf_cfg_get_key(gpac->m_user.config, "General", "Logs");
	m_Logs.SetCheck((sOpt && !strstr(sOpt, "none")) ? 1 : 0);
	return TRUE;
}
Esempio n. 6
0
BOOL InitFileDialog(const HWND hWnd)
{
    TCHAR           psz[80];
    ZeroMemory(psz, sizeof(psz));
    SHINITDLGINFO sid;
	ZeroMemory(&sid, sizeof(sid));
    sid.dwMask  = SHIDIM_FLAGS;
    sid.dwFlags = SHIDIF_SIZEDLGFULLSCREEN;
    sid.hDlg    = hWnd;

	if (FALSE == SHInitDialog(&sid))
		return FALSE;

    SHMENUBARINFO mbi;
	ZeroMemory(&mbi, sizeof(SHMENUBARINFO));
	mbi.cbSize      = sizeof(SHMENUBARINFO);
	mbi.hwndParent  = hWnd;
	mbi.nToolBarId  = IDR_MENU_OPEN;
	mbi.hInstRes    = g_hInst;

    if (FALSE == SHCreateMenuBar(&mbi))
    {
        return FALSE;
    }
    g_hWndMenuBar = mbi.hwndMB;
    
    ShowWindow(g_hWndMenuBar, SW_SHOW);

	the_wnd = hWnd;

    hDirTxt = GetDlgItem(hWnd, IDC_DIRNAME);
    hList = GetDlgItem(hWnd, IDC_FILELIST);
    g_hMenuView = (HMENU)SendMessage(g_hWndMenuBar, SHCMBM_GETSUBMENU, 0, ID_OF_VIEW);

	RECT rc;
	GetClientRect(hWnd, &rc);
	u32 caption_h = GetSystemMetrics(SM_CYCAPTION) - 3;
	MoveWindow(hDirTxt, 0, 0, rc.right - rc.left, caption_h, 1);
	MoveWindow(hList, 0, caption_h, rc.right - rc.left, rc.bottom - rc.top - caption_h, 1);
	
	if (playlist_mode) {
		refresh_playlist();
	} else {
		if (!strcmp((const char *) current_dir, "\\")) {
			char *opt = (char *) gf_cfg_get_key(cfg, "General", "LastWorkingDir");
			if (opt) CE_CharToWide(opt, (u16 *) w_current_dir);
		}
		set_directory(w_current_dir);
	}
	switch_menu_pl();
	return TRUE;
}
Esempio n. 7
0
void COsmo4AppView::SetupLogs()
{
	const char *opt;

#ifndef GPAC_GUI_ONLY
	gf_mx_p(m_mx);
	if (do_log) {
		gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_NONE);
		do_log = 0;
	}
	/*setup GPAC logs: log all errors*/
	opt = gf_cfg_get_key(m_user.config, "General", "Logs");
	if (opt && !strstr(opt, "none")){
		const char *filename = gf_cfg_get_key(m_user.config, "General", "LogFile");
		if (!filename) {
			gf_cfg_set_key(m_user.config, "General", "LogFile", "\\data\\gpac_logs.txt");
			filename = "\\data\\gpac_logs.txt";
		}
		m_Logs = gf_f64_open(filename, "wt");
		if (!m_Logs) {
			MessageBox("Cannot open log file - disabling logs", "Warning !");
		} else {
			MessageBox("Debug logs enabled!", filename);
			do_log = 1;
			gf_log_set_tools_levels( opt );
		}
	}
	if (!do_log) {
		gf_log_set_tool_level(GF_LOG_ALL, GF_LOG_ERROR);
		if (m_Logs) fclose(m_Logs);
	}

	gf_log_set_callback(this, on_gpac_log);
	gf_mx_v(m_mx);

	GF_LOG(GF_LOG_DEBUG, GF_LOG_CORE, ("Osmo4 logs initialized\n"));
#endif
}
Esempio n. 8
0
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;
}
Esempio n. 9
0
Bool CPlaylist::IsInPlaylist()
{
	char szURL[1024];
	char szName[100];
	GetSelectionName(szName);
	if ((szName[0] == '+') && (szName[1] == ' ')) return 0;
	else if (szName[1] == ':') return 0;

	/*remove from playlist*/
	sprintf(szURL, "%s\\%s", szCurrentDir, szName);
	const char *opt = gf_cfg_get_key(m_user->config, "Playlist", szURL);
	if (opt) return 1;
	return 0;
}
Esempio n. 10
0
void set_full_screen()
{
	full_screen = !full_screen;
	if (full_screen) {
		show_status = 0;
		do_layout(0);
		gf_term_set_option(term, GF_OPT_FULLSCREEN, full_screen);
	} else {
		const char *str = gf_cfg_get_key(user.config, "General", "ShowStatusBar");
		show_status = (str && !strcmp(str, "yes")) ? 1 : 0;
		gf_term_set_option(term, GF_OPT_FULLSCREEN, full_screen);
		do_layout(1);
	}
}
Esempio n. 11
0
BOOL COptRender3D::OnInitDialog()
{
	CDialog::OnInitDialog();

	COsmo4 *gpac = GetApp();
	const char *sOpt;

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "ForceOpenGL");
	m_Use3DRender.SetCheck( (sOpt && !strcmp(sOpt, "yes")) ? 1 : 0);

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "BackFaceCulling");
	m_NoBackFace.SetCheck( (sOpt && !stricmp(sOpt, "Off")) ? 1 : 0);

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "EmulatePOW2");
	m_EmulatePOW2.SetCheck( (sOpt && !stricmp(sOpt, "yes")) ? 1 : 0);

	m_WireMode.ResetContent();
	m_WireMode.AddString(_T("Solid Draw"));
	m_WireMode.AddString(_T("Wireframe"));
	m_WireMode.AddString(_T("Both"));
	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "Wireframe");
	if (sOpt && !stricmp(sOpt, "WireOnly")) m_WireMode.SetCurSel(1);
	else if (sOpt && !stricmp(sOpt, "WireOnSolid")) m_WireMode.SetCurSel(2);
	else m_WireMode.SetCurSel(0);


	m_DrawNormals.ResetContent();
	m_DrawNormals.AddString(_T("Never"));
	m_DrawNormals.AddString(_T("Per Face"));
	m_DrawNormals.AddString(_T("Per Vertex"));
	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "DrawNormals");
	if (sOpt && !stricmp(sOpt, "PerFace")) m_DrawNormals.SetCurSel(1);
	else if (sOpt && !stricmp(sOpt, "PerVertex")) m_DrawNormals.SetCurSel(2);
	else m_DrawNormals.SetCurSel(0);

	return TRUE;
}
Esempio n. 12
0
void gf_dm_configure_cache(GF_DownloadSession *sess)
{
	u32 i, last_sep;
	char cache_name[GF_MAX_PATH], tmp[GF_MAX_PATH];
	const char *opt;
	char *doubledots;

	if (!sess->dm->cache_directory) return;
	if (sess->flags & GF_NETIO_SESSION_NOT_CACHED) return;

	strcpy(cache_name, sess->dm->cache_directory);

	strcpy(tmp, sess->server_name);
	while ( (doubledots = strchr(tmp, ':')) )
		*doubledots = '_';
	strcat(tmp, sess->remote_path);
	last_sep = 0;

	for (i=0; i<strlen(tmp); i++) {
		if (tmp[i] == '/') tmp[i] = '_';
		else if (tmp[i] == '.') {
			tmp[i] = '_';
			last_sep = i;
		}
	}
	if (last_sep) tmp[last_sep] = '.';
	strcat(cache_name, tmp);

	/*first try, check cached file*/
	if (!sess->cache_start_size) {
		/*if file present figure out how much of the file is downloaded - we assume 2^31 byte file max*/
		FILE *the_cache = fopen(cache_name, "rb");
		if (the_cache) {
			fseek(the_cache, 0, SEEK_END);
			sess->cache_start_size = ftell(the_cache);
			fclose(the_cache);
		}
	}
	/*second try, disable cached file*/
	else {
		sess->cache_start_size = 0;
	}
	sess->cache_name = strdup(cache_name);

	/*are we using existing cached files ?*/
	opt = gf_cfg_get_key(sess->dm->cfg, "Downloader", "RestartFiles");
	if (opt && !stricmp(opt, "yes")) sess->cache_start_size = 0;
}
Esempio n. 13
0
//-------------------------------
void CNativeWrapper::SetupLogs() {
	const char *opt;
	debug_log("SetupLogs()");

	gf_mx_p(m_mx);
	gf_log_set_tools_levels( gf_cfg_get_key(m_user.config, "General", "Logs") );
	gf_log_set_callback(this, on_gpac_log);
	gf_mx_v(m_mx);

	GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Osmo4 logs initialized\n"));
	/* Test for JNI invocations, should work properly
	int k;
	for (k = 0 ; k < 512; k++){
		GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Message %d\n", k));
	}*/
}
Esempio n. 14
0
/*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;
}
Esempio n. 15
0
Bool osd_load_scene(GF_OSD *osd)
{
	GF_Node *n;
	GF_List *nodes;
	const char *opt;
	GF_DOMHandler *hdl;
	/*BT/VRML from string*/
	GF_List *gf_sm_load_bt_from_string(GF_SceneGraph *in_scene, const char *node_str, Bool force_wrl);

	/*create a new scene*/
	osd->odm = gf_odm_new();
	osd->odm->term = osd->term;
	osd->odm->subscene = gf_scene_new(NULL);
	osd->odm->subscene->root_od = osd->odm;
	gf_sg_set_scene_size_info(osd->odm->subscene->graph, 0, 0, 1);

	/*create a scene graph*/
	nodes = gf_sm_load_bt_from_string(osd->odm->subscene->graph, osd_scene_graph, 0);
	n = gf_list_get(nodes, 0);
	gf_list_del(nodes);

	if (!n) return 0;
	
	gf_sg_set_root_node(osd->odm->subscene->graph, n);
	gf_sg_set_scene_size_info(osd->odm->subscene->graph, 0, 0, 1);

	hdl = gf_dom_listener_build(n, GF_EVENT_RESIZE, 0);
	hdl->handle_event = osd_on_resize;
	hdl->evt_listen_obj = osd;

	osd->visible = (M_Switch *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N1");
	osd->transform = (M_Transform2D *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N2");
	osd->ct2d = (M_CompositeTexture2D *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N3");
	osd->text = (M_Text *)gf_sg_find_node_by_name(osd->odm->subscene->graph, "N4");
	if (osd->text->string.vals[0]) {
		gf_free(osd->text->string.vals[0]);
		osd->text->string.vals[0] = NULL;
	}
	strcpy(osd->statBuffer, "Hello World !");
	osd->text->string.vals[0] = osd->statBuffer;

	opt = gf_cfg_get_key(osd->term->user->config, "OSD", "Visible");
	if (!opt || strcmp(opt, "yes")) osd->visible->whichChoice = -1;


	return 1;
}
Esempio n. 16
0
BOOL COptRender::OnInitDialog()
{
	CDialog::OnInitDialog();

	COsmo4 *gpac = GetApp();
	const char *sOpt;

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "DirectDraw");
	if (sOpt && !stricmp(sOpt, "yes")) {
		m_DirectRender.SetCheck(1);
	} else {
		m_DirectRender.SetCheck(0);
	}
	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "ScalableZoom");
	if (sOpt && !stricmp(sOpt, "no")) {
		m_Scalable.SetCheck(0);
	} else {
		m_Scalable.SetCheck(1);
	}
	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "ForceSceneSize");
	if (sOpt && !stricmp(sOpt, "yes")) {
		m_ForceSize.SetCheck(1);
	} else {
		m_ForceSize.SetCheck(0);
	}

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "FrameRate");
	if (!sOpt) sOpt = "30.0";
	s32 select = 0;
	while (m_BIFSRate.GetCount()) m_BIFSRate.DeleteString(0);
	for (s32 i = 0; i<NUM_RATES; i++) {
		TCHAR szText[100];
		CE_CharToWide(BIFSRates[i], (u16 *)szText);
		m_BIFSRate.AddString(szText);
		if (sOpt && !stricmp(sOpt, BIFSRates[i]) ) select = i;
	}
	m_BIFSRate.SetCurSel(select);

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "HighSpeed");
	m_HighSpeed.SetCheck((sOpt && !stricmp(sOpt, "yes")) ? 1 : 0);

	sOpt = gf_cfg_get_key(gpac->m_user.config, "Compositor", "AntiAlias");
	while (m_Antialias.GetCount()) m_Antialias.DeleteString(0);

	m_Antialias.AddString(_T("None"));
	m_Antialias.AddString(_T("Text only"));
	m_Antialias.AddString(_T("Complete"));
	select = 2;
	if (sOpt && !stricmp(sOpt, "Text")) select = 1;
	else if (sOpt && !stricmp(sOpt, "None")) select = 0;
	m_Antialias.SetCurSel(select);

	return TRUE;
}
Esempio n. 17
0
void CPlaylist::ConstructL(const TRect& aRect, GF_User *user)
{
    CreateWindowL();

#ifdef USE_SKIN
	iListBox = new (ELeave) CAknSingleStyleListBox();
#else
	iListBox = new (ELeave) CEikTextListBox();
#endif
	iListBox->ConstructL(this);
	iListBox->SetContainerWindowL(*this);
	iListBox->SetListBoxObserver(this);

	CDesCArray* textArray = new (ELeave) CDesCArrayFlat(16);
	iListBox->Model()->SetItemTextArray( textArray );
    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );

    // Creates scrollbar.
    iListBox->CreateScrollBarFrameL( ETrue );
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto);
    //iListBox->ActivateL();

	iListBox->SetFocus(ETrue);

    SetRect(aRect);
    ActivateL();
	MakeVisible(EFalse);
	m_user = user;

	strcpy(ext_list, "");
	u32 count = gf_cfg_get_key_count(user->config, "MimeTypes");
	for (u32 i=0; i<count; i++) {
		char szKeyList[1000], *sKey;
		const char *sMime = gf_cfg_get_key_name(user->config, "MimeTypes", i);
		const char *opt = gf_cfg_get_key(user->config, "MimeTypes", sMime);
		strcpy(szKeyList, opt+1);
		sKey = strrchr(szKeyList, '\"');
		if (!sKey) continue;
		sKey[0] = 0;
		strcat(ext_list, szKeyList);
		strcat(ext_list, " ");
	}

	strcpy(szCurrentDir, "");
}
Esempio n. 18
0
GF_EXPORT
void gf_sc_reload_audio_filters(GF_Compositor *compositor)
{
	GF_AudioRenderer *ar = compositor->audio_renderer;
	if (!ar) return;

	gf_mixer_lock(ar->mixer, GF_TRUE);

	gf_afc_unload(&ar->filter_chain);
	gf_afc_load(&ar->filter_chain, ar->user, (char*)gf_cfg_get_key(ar->user->config, "Audio", "Filter"));

	gf_ar_pause(ar, GF_TRUE, GF_TRUE, GF_FALSE);
	ar->need_reconfig = GF_FALSE;
	gf_ar_setup_output_format(ar);
	gf_ar_pause(ar, GF_FALSE, GF_TRUE, GF_FALSE);

	gf_mixer_lock(ar->mixer, GF_FALSE);
}
Esempio n. 19
0
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);
}
Esempio n. 20
0
Bool LoadTerminal()
{
	/*by default use current dir*/
	strcpy(the_url, ".");

	setup_logs();

	g_hwnd_disp = CreateWindow(TEXT("STATIC"), NULL, WS_CHILD | WS_VISIBLE , 0, 0, disp_w, disp_h, g_hwnd, NULL, g_hinst, NULL);

	user.EventProc = GPAC_EventProc;
	/*dummy in this case (global vars) but MUST be non-NULL*/
	user.opaque = user.modules;
	user.os_window_handler = g_hwnd_disp;
#ifdef TERM_NOT_THREADED
	user.init_flags = GF_TERM_NO_DECODER_THREAD | GF_TERM_NO_COMPOSITOR_THREAD | GF_TERM_NO_REGULATION;
#endif

	term = gf_term_new(&user);
	if (!term) {
		gf_modules_del(user.modules);
		gf_cfg_del(user.config);
		memset(&user, 0, sizeof(GF_User));
		return 0;
	}

#ifdef _WIN32_WCE
	screen_w = term->compositor->video_out->max_screen_width;
	screen_h = term->compositor->video_out->max_screen_height;
	disp_w = screen_w;
	disp_h = screen_h - menu_h /*- caption_h*/;
#endif

#ifdef TERM_NOT_THREADED
	::SetTimer(g_hwnd, GPAC_TIMER_ID, GPAC_TIMER_DUR, NULL);
#endif

	const char *str = gf_cfg_get_key(user.config, "General", "StartupFile");
	if (str) {
		do_layout(1);
		strcpy(the_url, str);
		gf_term_connect(term, str);
	}
	return 1;
}
Esempio n. 21
0
GF_EXPORT
GF_ModuleManager *gf_modules_new(const char *directory, GF_Config *config)
{
	GF_ModuleManager *tmp;
	u32 loadedModules;
	const char *opt;
	u32 num_dirs = 0;

	if (!config) return NULL;

	/* Try to resolve directory from config file */
	GF_SAFEALLOC(tmp, GF_ModuleManager);
	if (!tmp) return NULL;
	tmp->cfg = config;
	tmp->mutex = gf_mx_new("Module Manager");
	gf_modules_get_module_directories(tmp, &num_dirs);

	/* Initialize module list */
	tmp->plug_list = gf_list_new();
	if (!tmp->plug_list) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("OUT OF MEMORY, cannot create list of modules !!!\n"));
		gf_free(tmp);
		return NULL;
	}
	tmp->plugin_registry = gf_list_new();
	if (!tmp->plugin_registry) {
		GF_LOG(GF_LOG_ERROR, GF_LOG_CORE, ("OUT OF MEMORY, cannot create list of static module registers !!!\n"));
		gf_list_del(tmp->plug_list);
		gf_free(tmp);
		return NULL;
	}

	opt = gf_cfg_get_key(config, "Systems", "ModuleUnload");
	if (opt && !strcmp(opt, "no")) {
		tmp->no_unload = GF_TRUE;
	}
#ifndef GPAC_MODULE_CUSTOM_LOAD
	load_all_modules(tmp);
#endif
	loadedModules = gf_modules_refresh(tmp);
	GF_LOG(GF_LOG_INFO, GF_LOG_CORE, ("Loaded %d modules from directory %s.\n", loadedModules, directory));

	return tmp;
}
Esempio n. 22
0
/*refresh modules - note we don't check for deleted modules but since we've open them the OS should forbid delete*/
GF_EXPORT
u32 gf_modules_refresh(GF_ModuleManager *pm)
{
	if (!pm) return 0;
	//!! symbian 9.1 doesn't allow for DLL browsing in /sys/bin, and can only load DLLs in /sys/bin !!
#if 0
	gf_enum_directory((char*)pm->dir, 0, enum_modules, pm, ".dll");
#else
	u32 i, mod_count;

	mod_count = gf_cfg_get_key_count(pm->cfg, "SymbianDLLs");
	for (i=0; i<mod_count; i++) {
		const char *mod = gf_cfg_get_key_name(pm->cfg, "SymbianDLLs", i);
		if (stricmp(gf_cfg_get_key(pm->cfg, "SymbianDLLs", mod), "yes")) continue;
		enum_modules(pm, (char*)mod, NULL);
	}
#endif
	return gf_list_count(pm->plug_list);
}
Esempio n. 23
0
GF_Err gf_es_start(GF_Channel *ch)
{
	if (!ch) return GF_BAD_PARAM;

	switch (ch->es_state) {
	case GF_ESM_ES_UNAVAILABLE:
	case GF_ESM_ES_SETUP:
		return GF_BAD_PARAM;
	/*if the channel is already running, don't reset its settings. This only happens in the case of broadcast 
	objects started several times by the scene but not stopped at the ODManager level (cf gf_odm_stop)*/
	case GF_ESM_ES_RUNNING:
		return GF_OK;
	default:
		break;
	}
	GF_LOG(GF_LOG_INFO, GF_LOG_SYNC, ("[SyncLayer] Starting ES %d\n", ch->esd->ESID));

	/*reset clock if we own it*/
	if (gf_es_owns_clock(ch) && !ch->clock->no_time_ctrl) 
		gf_clock_reset(ch->clock);

	/*reset channel*/
	Channel_Reset(ch, 1);
	/*create pull buffer if needed*/
	if (ch->is_pulling && !ch->AU_buffer_pull) ch->AU_buffer_pull = gf_db_unit_new();

	/*and start buffering - pull channels always turn off buffering immediately, otherwise 
	buffering size is setup by the network service - except InputSensor*/
	if ((ch->esd->decoderConfig->streamType != GF_STREAM_INTERACT) || ch->esd->URLString) {
		/*don't trigger rebuffer*/
		//if (ch->MinBuffer || (ch->clock->clock_init && ch->clock->Paused))
			ch_buffer_on(ch);
	}
	ch->last_au_time = gf_term_get_time(ch->odm->term);
	ch->es_state = GF_ESM_ES_RUNNING;

	ch->resync_drift = 0;
	if (ch->clock->clockID==ch->esd->ESID) {
		const char *opt = gf_cfg_get_key(ch->clock->term->user->config, "Systems", "ResyncLateClock");
		if (opt) ch->resync_drift = atoi(opt);
	}
	return GF_OK;
}
Esempio n. 24
0
GF_Err parse_config(GF_Config *gf_config_file, CONF_Data *conf, int debug) 
{
	conf->scene_init_file = gf_cfg_get_key(gf_config_file, MAIN_SECTION, SCENE_INIT);
	if (!conf->scene_init_file) {
		fprintf(stderr, "Cannot find initial scene from configuration file\n");
		return GF_IO_ERR;
	} else {
		dprintf(DEBUG_broadcaster, "Using initial scene: %s\n", conf->scene_init_file);
	}

	conf->rap_timer = gf_cfg_get_key(gf_config_file, MAIN_SECTION, RAP_TIMER);
	if (!conf->rap_timer) conf->rap_timer = "2";
	dprintf(DEBUG_broadcaster, "Using a RAP period of %s seconds\n", conf->rap_timer);

	conf->config_input_port = gf_cfg_get_key(gf_config_file, MAIN_SECTION, PORT_CONFIG);
	if (!conf->config_input_port) conf->config_input_port = "5000";
	dprintf(DEBUG_broadcaster, "Using Configuration Port: %s\n", conf->config_input_port);

	conf->modif_input_port = gf_cfg_get_key(gf_config_file, MAIN_SECTION, PORT_MODIF);
	if (!conf->modif_input_port)
		conf->modif_input_port = "8000";
	dprintf(DEBUG_broadcaster, "Using Update Port: %s\n", conf->modif_input_port);

	conf->dest_ip = gf_cfg_get_key(gf_config_file, DEST_SECTION, DEST_ADDRESS);
	if (!conf->dest_ip)
		conf->dest_ip = "127.0.0.1";		
	conf->dest_port = gf_cfg_get_key(gf_config_file, DEST_SECTION, PORT_OUTPUT);
	if (!conf->dest_port)
		conf->dest_port = "7000";
	dprintf(DEBUG_broadcaster, "Destination: %s:%s\n", conf->dest_ip, conf->dest_port);

	conf->feedback_ip = gf_cfg_get_key(gf_config_file, FEEDBACK_SECTION, IP_FEEDBACK);
	if (!conf->feedback_ip) conf->feedback_ip = "127.0.0.1";		
	conf->feedback_port = gf_cfg_get_key(gf_config_file, FEEDBACK_SECTION, PORT_FEEDBACK);
	if (!conf->feedback_port) conf->feedback_port = "5757";
	dprintf(DEBUG_broadcaster, "Feedback host: %s:%s\n", conf->feedback_ip, conf->feedback_port);
	return GF_OK;
}
Esempio n. 25
0
//-------------------------------
int CNativeWrapper::connect(const char *url)
{
	const char *str;
	char the_url[256];

	if (m_term)
	{
		debug_log("Starting to connect ...");
		str = gf_cfg_get_key(m_user.config, "General", "StartupFile");
		if (str)
		{
			gf_cfg_set_key(m_user.config, "Temp", "GUIStartupFile", url);
			gf_term_connect(m_term, str);
		}
		if( url )
		{
			gf_term_connect_from_time(m_term, url, 0, GF_FALSE);
		}
	}
	debug_log("connected ...");
}
Esempio n. 26
0
STDMETHODIMP CGPAXPlugin::Play()
{
	if (m_term) {
		if (!m_bIsConnected) {
			if (strlen(m_url)) {
				/*connect from 0 and pause if not autoplay*/
				const char *gui = gf_cfg_get_key(m_user.config, "General", "StartupFile");
				if (gui && m_bUseGUI) {
					gf_cfg_set_key(m_user.config, "Temp", "BrowserMode", "yes");
					gf_cfg_set_key(m_user.config, "Temp", "GUIStartupFile", m_url);
					gf_term_connect(m_term, gui);
				} else {
					gf_term_connect(m_term, m_url);
				}
				gf_term_set_option(m_term, GF_OPT_ASPECT_RATIO, m_AR);
			}
		} else
			gf_term_set_option(m_term, GF_OPT_PLAY_STATE, GF_STATE_PLAYING);   //if target is connected, set it playing
	}
    return S_OK;
}
Esempio n. 27
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;
}
Esempio n. 28
0
static void term_on_message(void *user_priv, GF_ClientService *service, GF_Err error, const char *message)
{
	GET_TERM();

	/*check for UDP timeout*/
	if (error==GF_IP_UDP_TIMEOUT) {
		const char *sOpt = gf_cfg_get_key(term->user->config, "Network", "AutoReconfigUDP");
		if (sOpt && !stricmp(sOpt, "yes")) {
			char szMsg[1024];
			sprintf(szMsg, "!! UDP down (%s) - Retrying with TCP !!\n", message);
			gf_term_message(term, service->url, szMsg, GF_OK);

			/*reload scene*/
			if (term->reload_url) gf_free(term->reload_url);
			term->reload_state = 1;
			term->reload_url = gf_strdup(term->root_scene->root_od->net_service->url);
			gf_cfg_set_key(term->user->config, "Network", "UDPNotAvailable", "yes");
			return;
		}
	}
	gf_term_message(term, service->url, message, error);
}
Esempio n. 29
0
GF_EXPORT
GF_Err gf_term_get_mfurl_from_xlink(GF_Node *node, MFURL *mfurl)
{
	u32 stream_id = 0;
	GF_Err e = GF_OK;
	SFURL *sfurl = NULL;
	GF_FieldInfo info;
	XMLRI *iri;
	GF_Scene *scene = gf_sg_get_private(gf_node_get_graph(node));
	if (!scene) return GF_BAD_PARAM;

	gf_sg_vrml_mf_reset(mfurl, GF_SG_VRML_MFURL);

	e = gf_node_get_attribute_by_tag(node, TAG_XLINK_ATT_href, 0, 0, &info);
	if (e) return e;

	iri = (XMLRI*)info.far_ptr;

	if (iri->type==XMLRI_STREAMID) {
		stream_id = iri->lsr_stream_id;
	} else if (!iri->string) return GF_OK;

	mfurl->count = 1;
	GF_SAFEALLOC(mfurl->vals, SFURL)
	sfurl = mfurl->vals;
	sfurl->OD_ID = stream_id;
	if (stream_id) return GF_OK;

	if (!strncmp(iri->string, "data:", 5)) {
		const char *cache_dir = gf_cfg_get_key(scene->root_od->term->user->config, "General", "CacheDirectory");
		e = gf_node_store_embedded_data(iri, cache_dir, "embedded_");
		if (e) return e;
		sfurl->url = gf_strdup(iri->string);
		return GF_OK;
	}
	sfurl->url = gf_term_resolve_xlink(node, iri->string);
	return e;
}
Esempio n. 30
0
void refresh_playlist()
{
	TCHAR w_name[GF_MAX_PATH];
	u32 count, i;

	SetWindowText(hDirTxt, _T("Playlist"));
	SendMessage(hList, LB_RESETCONTENT, 0, 0);

	count = gf_cfg_get_key_count(cfg, "Playlist");
	for (i=0; i<count; i++) {
		const char *file = gf_cfg_get_key_name(cfg, "Playlist", i);
		char *name = strrchr(file, '\\');
		if (!name) name = strrchr(file, '/');
		CE_CharToWide(name ? name+1 : (char *) file, (u16 *) w_name);
		SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR) w_name);
	}
	i = 0;
	const char *ple = gf_cfg_get_key(cfg, "General", "PLEntry");
	i = ple ? atoi(ple) : 0;
	if (i>=count) i=0;
    SendMessage(hList, LB_SETCURSEL, i, 0);
	SetFocus(hList);
}