GF_Err gf_node_set_id(GF_Node *p, u32 ID, const char *name)
{
	GF_SceneGraph *pSG;
	if (!ID || !p || !p->sgprivate->scenegraph) return GF_BAD_PARAM;

	pSG = p->sgprivate->scenegraph;
#ifndef GPAC_DISABLE_VRML
	/*if this is a proto register to the parent graph, not the current*/
	if (p == (GF_Node*)pSG->pOwningProto) pSG = pSG->parent_scene;
#endif

	/*new DEF ID*/
	if (!(p->sgprivate->flags & GF_NODE_IS_DEF) ) {
		p->sgprivate->flags |= GF_NODE_IS_DEF;
		insert_node_def(pSG, p, ID, name);
	}
	/*reassigning ID, remove node def*/
	else {
		char *_name = gf_strdup(name);
		remove_node_id(pSG, p);
		insert_node_def(pSG, p, ID, _name);
		gf_free(_name);
	}
	return GF_OK;
}
GF_Err gf_node_set_id(GF_Node *p, u32 ID, const char *name)
{
	GF_SceneGraph *pSG;
	if (!ID || !p || !p->sgprivate->scenegraph) return GF_BAD_PARAM;

	pSG = p->sgprivate->scenegraph;
#ifndef GPAC_DISABLE_VRML
	 
	if (p == (GF_Node*)pSG->pOwningProto) pSG = pSG->parent_scene;
#endif

	 
	if (!(p->sgprivate->flags & GF_NODE_IS_DEF) ) {
		p->sgprivate->flags |= GF_NODE_IS_DEF;
		insert_node_def(pSG, p, ID, name);
	}
	 
	else {
		char *_name = gf_strdup(name);
		remove_node_id(pSG, p);
		insert_node_def(pSG, p, ID, _name);
		gf_free(_name);
	}
	return GF_OK;
}