libgpac
Documentation of the core library of GPAC
Base Scenegraph

Scenegraph used for manipulating scenes. More...

+ Collaboration diagram for Base Scenegraph:

Data Structures

struct  _base_node
 
struct  _child_node
 
struct  GF_ParentNode
 
struct  GF_FieldInfo
 
struct  GF_JSAPIURI
 
struct  GF_JSAPIOPT
 
struct  GF_JSAPIINFO
 
union  GF_JSAPIParam
 
struct  GF_CommandField
 
struct  GF_Command
 
union  GF_Command.__unnamed__
 

Macros

#define BASE_NODE   struct _nodepriv *sgprivate;
 
#define CHILDREN   struct _child_node *children;
 

Typedefs

typedef void(* gf_sg_node_callback) (GF_Node *n, void *traverse_state, Bool is_destroy)
 
typedef struct _route GF_Route
 
typedef struct __tag_scene_graph GF_SceneGraph
 
typedef void(* gf_sg_node_init_callback) (void *udta, GF_SGNodeCbkType type, GF_Node *node, void *ctxdata)
 
typedef Bool(* gf_sg_script_action) (void *callback, GF_JSAPIActionType type, GF_Node *node, GF_JSAPIParam *param)
 

Enumerations

enum  {
  TAG_UndefinedNode = 0, TAG_ProtoNode, GF_NODE_RANGE_FIRST_MPEG4, GF_NODE_RANGE_LAST_MPEG4 = GF_NODE_RANGE_FIRST_MPEG4+512,
  GF_NODE_RANGE_FIRST_X3D, GF_NODE_RANGE_LAST_X3D = GF_NODE_RANGE_FIRST_X3D+512, GF_NODE_RANGE_LAST_VRML, TAG_DOMUpdates,
  GF_NODE_FIRST_PARENT_NODE_TAG, TAG_DOMText, GF_NODE_FIRST_DOM_NODE_TAG, TAG_DOMFullNode = GF_NODE_FIRST_DOM_NODE_TAG,
  GF_NODE_RANGE_FIRST_SVG, GF_NODE_RANGE_LAST_SVG = GF_NODE_RANGE_FIRST_SVG+100
}
 
enum  {
  GF_SG_NODE_DIRTY = 1, GF_SG_CHILD_DIRTY = 1<<1, GF_SG_VRML_BINDABLE_DIRTY = 1<<2, GF_SG_VRML_COLOR_DIRTY = 1<<3,
  GF_SG_SVG_GEOMETRY_DIRTY = GF_SG_NODE_DIRTY, GF_SG_SVG_COLOR_DIRTY = 1<<2, GF_SG_SVG_DISPLAYALIGN_DIRTY = 1<<3, GF_SG_SVG_FILL_DIRTY = 1<<4,
  GF_SG_SVG_FILLOPACITY_DIRTY = 1<<5, GF_SG_SVG_FILLRULE_DIRTY = 1<<6, GF_SG_SVG_FONTFAMILY_DIRTY = 1<<7, GF_SG_SVG_FONTSIZE_DIRTY = 1<<8,
  GF_SG_SVG_FONTSTYLE_DIRTY = 1<<9, GF_SG_SVG_FONTVARIANT_DIRTY = 1<<10, GF_SG_SVG_FONTWEIGHT_DIRTY = 1<<11, GF_SG_SVG_LINEINCREMENT_DIRTY = 1<<12,
  GF_SG_SVG_OPACITY_DIRTY = 1<<13, GF_SG_SVG_SOLIDCOLOR_OR_OPACITY_DIRTY = 1<<14, GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY = 1<<15, GF_SG_SVG_STROKE_DIRTY = 1<<16,
  GF_SG_SVG_STROKEDASHARRAY_DIRTY = 1<<17, GF_SG_SVG_STROKEDASHOFFSET_DIRTY = 1<<18, GF_SG_SVG_STROKELINECAP_DIRTY = 1<<19, GF_SG_SVG_STROKELINEJOIN_DIRTY = 1<<20,
  GF_SG_SVG_STROKEMITERLIMIT_DIRTY = 1<<21, GF_SG_SVG_STROKEOPACITY_DIRTY = 1<<22, GF_SG_SVG_STROKEWIDTH_DIRTY = 1<<23, GF_SG_SVG_TEXTPOSITION_DIRTY = 1<<24,
  GF_SG_SVG_DISPLAY_DIRTY = 1<<25, GF_SG_SVG_VECTOREFFECT_DIRTY = 1<<26, GF_SG_SVG_XLINK_HREF_DIRTY = 1<<27
}
 
enum  GF_SGNodeCbkType { GF_SG_CALLBACK_INIT = 0, GF_SG_CALLBACK_MODIFIED, GF_SG_CALLBACK_GRAPH_DIRTY, GF_SG_CALLBACK_NODE_DESTROY }
 
enum  {
  GF_SG_FOCUS_AUTO = 1, GF_SG_FOCUS_NEXT, GF_SG_FOCUS_PREV, GF_SG_FOCUS_NORTH,
  GF_SG_FOCUS_NORTH_EAST, GF_SG_FOCUS_EAST, GF_SG_FOCUS_SOUTH_EAST, GF_SG_FOCUS_SOUTH,
  GF_SG_FOCUS_SOUTH_WEST, GF_SG_FOCUS_WEST, GF_SG_FOCUS_NORTH_WEST
}
 
enum  GF_JSAPIActionType {
  GF_JSAPI_OP_MESSAGE, GF_JSAPI_OP_RESOLVE_URI, GF_JSAPI_OP_GET_SCALE, GF_JSAPI_OP_SET_SCALE,
  GF_JSAPI_OP_GET_ROTATION, GF_JSAPI_OP_SET_ROTATION, GF_JSAPI_OP_GET_TRANSLATE, GF_JSAPI_OP_SET_TRANSLATE,
  GF_JSAPI_OP_GET_TIME, GF_JSAPI_OP_SET_TIME, GF_JSAPI_OP_GET_VIEWPORT, GF_JSAPI_OP_GET_LOCAL_BBOX,
  GF_JSAPI_OP_GET_SCREEN_BBOX, GF_JSAPI_OP_GET_TRANSFORM, GF_JSAPI_OP_MOVE_FOCUS, GF_JSAPI_OP_GET_FOCUS,
  GF_JSAPI_OP_SET_FOCUS, GF_JSAPI_OP_LOAD_URL, GF_JSAPI_OP_GET_OPT, GF_JSAPI_OP_SET_OPT,
  GF_JSAPI_OP_GET_DOWNLOAD_MANAGER, GF_JSAPI_OP_GET_SPEED, GF_JSAPI_OP_GET_FPS, GF_JSAPI_OP_SET_TITLE,
  GF_JSAPI_OP_GET_SUBSCENE, GF_JSAPI_OP_RESOLVE_XLINK, GF_JSAPI_OP_GET_COMPOSITOR, GF_JSAPI_OP_PAUSE_SVG,
  GF_JSAPI_OP_RESUME_SVG, GF_JSAPI_OP_RESTART_SVG, GF_JSAPI_OP_SET_SCENE_SPEED, GF_JSAPI_OP_GET_DPI_X,
  GF_JSAPI_OP_GET_DPI_Y
}
 
enum  {
  GF_SG_RESERVED = 0, GF_SG_SCENE_REPLACE, GF_SG_NODE_REPLACE, GF_SG_FIELD_REPLACE,
  GF_SG_INDEXED_REPLACE, GF_SG_ROUTE_REPLACE, GF_SG_NODE_DELETE, GF_SG_INDEXED_DELETE,
  GF_SG_ROUTE_DELETE, GF_SG_NODE_INSERT, GF_SG_INDEXED_INSERT, GF_SG_ROUTE_INSERT,
  GF_SG_PROTO_INSERT, GF_SG_PROTO_DELETE, GF_SG_PROTO_DELETE_ALL, GF_SG_MULTIPLE_REPLACE,
  GF_SG_MULTIPLE_INDEXED_REPLACE, GF_SG_GLOBAL_QUANTIZER, GF_SG_NODE_DELETE_EX, GF_SG_XREPLACE,
  GF_SG_LAST_BIFS_COMMAND, GF_SG_LSR_NEW_SCENE, GF_SG_LSR_REFRESH_SCENE, GF_SG_LSR_ADD,
  GF_SG_LSR_CLEAN, GF_SG_LSR_REPLACE, GF_SG_LSR_DELETE, GF_SG_LSR_INSERT,
  GF_SG_LSR_RESTORE, GF_SG_LSR_SAVE, GF_SG_LSR_SEND_EVENT, GF_SG_LSR_ACTIVATE,
  GF_SG_LSR_DEACTIVATE, GF_SG_UNDEFINED
}
 

Functions

GF_Err gf_node_list_add_child (GF_ChildNodeItem **list, GF_Node *n)
 
GF_Err gf_node_list_add_child_last (GF_ChildNodeItem **list, GF_Node *n, GF_ChildNodeItem **last_child)
 
GF_Err gf_node_list_insert_child (GF_ChildNodeItem **list, GF_Node *n, u32 pos)
 
Bool gf_node_list_del_child (GF_ChildNodeItem **list, GF_Node *n)
 
s32 gf_node_list_find_child (GF_ChildNodeItem *list, GF_Node *n)
 
GF_Node * gf_node_list_get_child (GF_ChildNodeItem *list, s32 pos)
 
u32 gf_node_list_get_count (GF_ChildNodeItem *list)
 
GF_Node * gf_node_list_del_child_idx (GF_ChildNodeItem **list, u32 pos)
 
u32 gf_node_get_tag (GF_Node *n)
 
GF_Err gf_node_set_id (GF_Node *n, u32 nodeID, const char *nodeDEFName)
 
const char * gf_node_get_name (GF_Node *n)
 
const char * gf_node_get_log_name (GF_Node *n)
 
u32 gf_node_get_id (GF_Node *n)
 
const char * gf_node_get_class_name (GF_Node *n)
 
GF_Err gf_node_remove_id (GF_Node *n)
 
void * gf_node_get_private (GF_Node *n)
 
void gf_node_set_private (GF_Node *n, void *udta)
 
GF_Err gf_node_set_callback_function (GF_Node *n, gf_sg_node_callback NodeFunction)
 
GF_Err gf_node_register (GF_Node *n, GF_Node *parent_node)
 
GF_Err gf_node_unregister (GF_Node *n, GF_Node *parent_node)
 
void gf_node_unregister_children (GF_Node *node, GF_ChildNodeItem *childrenlist)
 
GF_Err gf_node_replace (GF_Node *old_node, GF_Node *new_node, Bool updateOrderedGroup)
 
u32 gf_node_get_num_instances (GF_Node *n)
 
void gf_node_traverse (GF_Node *n, void *udta)
 
void gf_node_allow_cyclic_traverse (GF_Node *n)
 
Bool gf_node_set_cyclic_traverse_flag (GF_Node *n, Bool on)
 
void gf_node_traverse_children (GF_Node *n, void *udta)
 
u32 gf_node_get_parent_count (GF_Node *n)
 
GF_Node * gf_node_get_parent (GF_Node *n, u32 idx)
 
Bool gf_node_parent_of (GF_Node *parent, GF_Node *target)
 
void gf_node_dirty_set (GF_Node *n, u32 flags, Bool dirty_parents)
 
void gf_node_dirty_parents (GF_Node *n)
 
void gf_node_dirty_clear (GF_Node *n, u32 flags)
 
void gf_node_dirty_reset (GF_Node *n, Bool reset_children)
 
u32 gf_node_dirty_get (GF_Node *n)
 
u32 gf_node_get_field_count (GF_Node *n)
 
GF_Err gf_node_get_field (GF_Node *n, u32 FieldIndex, GF_FieldInfo *info)
 
GF_Err gf_node_get_field_by_name (GF_Node *n, char *name, GF_FieldInfo *field)
 
GF_SceneGraphgf_sg_new ()
 
GF_SceneGraphgf_sg_new_subscene (GF_SceneGraph *scene)
 
void gf_sg_del (GF_SceneGraph *sg)
 
void gf_sg_reset (GF_SceneGraph *sg)
 
void gf_sg_set_private (GF_SceneGraph *sg, void *udta)
 
void * gf_sg_get_private (GF_SceneGraph *sg)
 
void gf_sg_set_scene_time_callback (GF_SceneGraph *sg, Double(*GetSceneTime)(void *user_priv))
 
GF_SceneGraphgf_sg_get_parent (GF_SceneGraph *sg)
 
void gf_sg_set_node_callback (GF_SceneGraph *sg, gf_sg_node_init_callback NodeCallback)
 
GF_Node * gf_sg_get_root_node (GF_SceneGraph *sg)
 
void gf_sg_set_root_node (GF_SceneGraph *sg, GF_Node *node)
 
GF_Node * gf_sg_find_node (GF_SceneGraph *sg, u32 nodeID)
 
GF_Node * gf_sg_find_node_by_name (GF_SceneGraph *sg, char *name)
 
void gf_node_changed (GF_Node *n, GF_FieldInfo *fieldChanged)
 
GF_SceneGraphgf_node_get_graph (GF_Node *n)
 
void gf_sg_set_scene_size_info (GF_SceneGraph *sg, u32 width, u32 height, Bool usePixelMetrics)
 
Bool gf_sg_use_pixel_metrics (GF_SceneGraph *sg)
 
Bool gf_sg_get_scene_size_info (GF_SceneGraph *sg, u32 *width, u32 *height)
 
GF_Node * gf_node_new (GF_SceneGraph *sg, u32 tag)
 
void gf_node_init (GF_Node *n)
 
GF_Node * gf_node_clone (GF_SceneGraph *inScene, GF_Node *orig, GF_Node *cloned_parent, char *id_suffix, Bool deep)
 
Double gf_node_get_scene_time (GF_Node *n)
 
u32 gf_sg_get_next_available_node_id (GF_SceneGraph *sg)
 
u32 gf_sg_get_max_node_id (GF_SceneGraph *sg)
 
const char * gf_node_get_name_and_id (GF_Node *n, u32 *ID)
 
void gf_sg_set_script_action (GF_SceneGraph *sg, gf_sg_script_action script_act, void *cbk)
 
void gf_sg_script_load (GF_Node *script)
 
Bool gf_sg_has_scripting ()
 
GF_Commandgf_sg_command_new (GF_SceneGraph *sg, u32 tag)
 
void gf_sg_command_del (GF_Command *com)
 
GF_Err gf_sg_command_apply (GF_SceneGraph *sg, GF_Command *com, Double time_offset)
 
GF_Err gf_sg_command_apply_list (GF_SceneGraph *sg, GF_List *comList, Double time_offset)
 
GF_CommandFieldgf_sg_command_field_new (GF_Command *com)
 
GF_Err gf_scene_execute_script (GF_SceneGraph *sg, const char *com)
 
GF_Err gf_sg_init_from_xml_node (GF_SceneGraph *document, GF_DOMXMLNODE root_node)
 

Detailed Description

This section documents the Scenegraph used in GPAC for all interactive scenes.


Data Structure Documentation

◆ _base_node

struct _base_node

base node type

◆ _child_node

struct _child_node

child storage This is not integrated in the base node, because of VRML/MPEG-4 USE: a node may be present at different places in the tree, hence have different "next" siblings.

+ Collaboration diagram for _child_node:
Data Fields
struct _child_node * next
GF_Node * node

◆ GF_ParentNode

struct GF_ParentNode

generic parent node

◆ GF_JSAPIURI

struct GF_JSAPIURI

JS API Url structure

Data Fields
char * url
const char ** params
u32 nb_params

◆ GF_JSAPIOPT

struct GF_JSAPIOPT

JS API structure for GPAC config file

Data Fields
const char * section
const char * key
const char * key_val

◆ GF_JSAPIINFO

struct GF_JSAPIINFO

JS API structure for script message

Data Fields
GF_Err e
const char * msg

◆ GF_JSAPIParam

union GF_JSAPIParam

JS API parameter type

+ Collaboration diagram for GF_JSAPIParam:
Data Fields
u32 opt
Fixed val
GF_Point2D pt
GF_Rect rc
Double time
GF_BBox bbox
GF_Matrix mx
GF_JSAPIURI uri
GF_JSAPIOPT gpac_cfg
GF_Node * node
struct __gf_download_manager * dnld_man
GF_SceneGraph * scene
void * compositor
GF_JSAPIINFO info

◆ GF_CommandField

struct GF_CommandField

structure used to store field info, pos and static pointers to GF_Node/MFNode in commands

Data Fields
u32 fieldIndex
u32 fieldType
void * field_ptr
s32 pos
GF_Node * new_node
GF_ChildNodeItem * node_list

◆ GF_Command

struct GF_Command

structure used to store decoded BIFS command

Note
In order to maintain node registry, the nodes replaced/inserted MUST be registered with their parents even when the command is never applied. Registering shall be performed with gf_node_register (see below). If you fail to do so, a node may be destroyed when destroying a command while still used in another command or in the graph - this will just crash.
Data Fields
GF_SceneGraph * in_scene
u32 tag
GF_Node * node
GF_List * command_fields
GF_List * scripts_to_load
Bool unresolved
char * unres_name
union GF_Command __unnamed__
GF_List * new_proto_list
u32 * del_proto_list
union GF_Command __unnamed__
union GF_Command __unnamed__
union GF_Command __unnamed__
union GF_Command __unnamed__
union GF_Command __unnamed__
union GF_Command __unnamed__
Bool aggregated
Bool never_apply

◆ GF_Command.__unnamed__

union GF_Command.__unnamed__
Data Fields
Bool use_names
u32 RouteID
s32 ChildNodeTag

Macro Definition Documentation

◆ BASE_NODE

#define BASE_NODE   struct _nodepriv *sgprivate;

macro for defining base node (apply to all nodes)

◆ CHILDREN

#define CHILDREN   struct _child_node *children;

grouping nodes macro children: list of children SFNodes

Typedef Documentation

◆ gf_sg_node_callback

typedef void(* gf_sg_node_callback) (GF_Node *n, void *traverse_state, Bool is_destroy)

node callback function

Parameters
nthe target node
traverse_stateopaque data passed during traversal
is_destroyset when the node is about to be destroyed

◆ GF_Route

typedef struct _route GF_Route

VRML/BIFS route object

◆ GF_SceneGraph

typedef struct __tag_scene_graph GF_SceneGraph

Scenegraph structure

◆ gf_sg_node_init_callback

typedef void(* gf_sg_node_init_callback) (void *udta, GF_SGNodeCbkType type, GF_Node *node, void *ctxdata)

node callback function for scene graph

Parameters
udtauser private data of scene graph, see gf_sg_set_private
typethe type of callback
nodethe target node for the callback
ctxdataassociated data, type depends on the callback type

◆ gf_sg_script_action

typedef Bool(* gf_sg_script_action) (void *callback, GF_JSAPIActionType type, GF_Node *node, GF_JSAPIParam *param)

interface to various get/set options:

Parameters
callbackopaque data passed to the function
typeoperand type, one of the above
nodetarget node, scene root node or NULL
parami/o param, depending on operand type
Returns
GF_TRUE if success, GF_FALSE otherwise

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Tags of scene graph nodes TAG definitions are static, in order to be able to mix nodes from different standard in a single scenegraph. These TAGs are only used internally (they do not match any binary encoding)

◆ anonymous enum

anonymous enum

node dirty flags

◆ GF_SGNodeCbkType

node callback type

◆ anonymous enum

anonymous enum

SVG focus types

◆ GF_JSAPIActionType

JS API action types

Enumerator
GF_JSAPI_OP_MESSAGE 

push message from script engine.

GF_JSAPI_OP_RESOLVE_URI 

resolves a given URI.

GF_JSAPI_OP_GET_SCALE 

get current user agent scale.

GF_JSAPI_OP_SET_SCALE 

set current user agent scale.

GF_JSAPI_OP_GET_ROTATION 

get current user agent rotation.

GF_JSAPI_OP_SET_ROTATION 

set current user agent rotation.

GF_JSAPI_OP_GET_TRANSLATE 

get current user agent translation.

GF_JSAPI_OP_SET_TRANSLATE 

set current user agent translation.

GF_JSAPI_OP_GET_TIME 

get node time.

GF_JSAPI_OP_SET_TIME 

set node time.

GF_JSAPI_OP_GET_VIEWPORT 

get current viewport.

GF_JSAPI_OP_GET_LOCAL_BBOX 

get object bounding box in object local coord system.

GF_JSAPI_OP_GET_SCREEN_BBOX 

get object bounding box in world (screen) coord system.

GF_JSAPI_OP_GET_TRANSFORM 

get transform matrix at object.

GF_JSAPI_OP_MOVE_FOCUS 

move focus according to opt value.

GF_JSAPI_OP_GET_FOCUS 

set focus to given node.

GF_JSAPI_OP_SET_FOCUS 

set focus to given node.

GF_JSAPI_OP_LOAD_URL 

replace target scene URL

GF_JSAPI_OP_GET_OPT 

get option by section and key

GF_JSAPI_OP_SET_OPT 

get option by section and key

GF_JSAPI_OP_GET_DOWNLOAD_MANAGER 

retrieve download manager

GF_JSAPI_OP_GET_SPEED 

get navigation speed if any

GF_JSAPI_OP_GET_FPS 

get current frame rate

GF_JSAPI_OP_SET_TITLE 

set current title

GF_JSAPI_OP_GET_SUBSCENE 

gets subscene for current node if any

GF_JSAPI_OP_RESOLVE_XLINK 

resolves relative Xlink based on xml:base

GF_JSAPI_OP_GET_COMPOSITOR 

gets parent filter

GF_JSAPI_OP_PAUSE_SVG 

pauses an SVG element

GF_JSAPI_OP_RESUME_SVG 

resumes an SVG ELEMENT

GF_JSAPI_OP_RESTART_SVG 

restarts an SVG ELEMENT: this restarts all the media tunning on the main timeline

GF_JSAPI_OP_SET_SCENE_SPEED 

sets scene speed

GF_JSAPI_OP_GET_DPI_X 

gets the DPI

◆ anonymous enum

anonymous enum

Scene command tags

scene graph command tools used for BIFS and LASeR These are used to store updates in memory without applying changes to the graph, for dumpers, encoders ... The commands can then be applied through this lib

Function Documentation

◆ gf_node_list_add_child()

GF_Err gf_node_list_add_child ( GF_ChildNodeItem **  list,
GF_Node *  n 
)

adds a child to a given container

Parameters
listpointer to target child list
nnode to add
Returns
error if any

◆ gf_node_list_add_child_last()

GF_Err gf_node_list_add_child_last ( GF_ChildNodeItem **  list,
GF_Node *  n,
GF_ChildNodeItem **  last_child 
)

adds a child to a given container, updating last position

Parameters
listpointer to target child list
nnode to add
last_childset to position of add child
Returns
error if any

◆ gf_node_list_insert_child()

GF_Err gf_node_list_insert_child ( GF_ChildNodeItem **  list,
GF_Node *  n,
u32  pos 
)

inserts a child to a given container - if pos doesn't match, append the child

Parameters
listpointer to target child list
nnode to insert
pos0-based index at which to insert
Returns
error if any

◆ gf_node_list_del_child()

Bool gf_node_list_del_child ( GF_ChildNodeItem **  list,
GF_Node *  n 
)

removes a child to a given container

Parameters
listpointer to target child list
nnode to remove
Returns
GF_TRUE if OK, GF_FALSE if not found

◆ gf_node_list_find_child()

s32 gf_node_list_find_child ( GF_ChildNodeItem *  list,
GF_Node *  n 
)

finds a child in a given container

Parameters
listtarget child list
nnode to find
Returns
0-based index if found, -1 otherwise

◆ gf_node_list_get_child()

GF_Node* gf_node_list_get_child ( GF_ChildNodeItem *  list,
s32  pos 
)

finds a child in a given container given its index. if pos is <0, returns the last child

Parameters
listtarget child list
pos0-based index at which to insert
Returns
the child or NULL if not found

◆ gf_node_list_get_count()

u32 gf_node_list_get_count ( GF_ChildNodeItem *  list)

gets the number of children in a given list

Parameters
listtarget child list
Returns
the number of children

◆ gf_node_list_del_child_idx()

GF_Node* gf_node_list_del_child_idx ( GF_ChildNodeItem **  list,
u32  pos 
)

removes node at given idx

Parameters
listpointer to target child list
pos0-based index at which to insert
Returns
the removed node, or NULL if not found

◆ gf_node_get_tag()

u32 gf_node_get_tag ( GF_Node *  n)

gets tag of node (tag is set upon creation and cannot be modified)

Parameters
nthe target node
Returns
the node tag

◆ gf_node_set_id()

GF_Err gf_node_set_id ( GF_Node *  n,
u32  nodeID,
const char *  nodeDEFName 
)

set node ID/def If a different node with the same ID exists, returns error. You may change the node ID by recalling the function with a different ID value. You may get a node ID by calling gf_sg_get_next_available_node_id

Parameters
nthe target node
nodeIDID to set to the node, ignored if 0.
nodeDEFNameoptional readable name (script, MPEGJ). To change the name, recall the function with a different name and the same ID
Returns
error if any

◆ gf_node_get_name()

const char* gf_node_get_name ( GF_Node *  n)

gets def name of the node

Parameters
nthe target node
Returns
node name or NULL if not set

◆ gf_node_get_log_name()

const char* gf_node_get_log_name ( GF_Node *  n)

gets def name of the node, or the string representation of the node pointer if not set

Parameters
nthe target node
Returns
node name or NULL if error

◆ gf_node_get_id()

u32 gf_node_get_id ( GF_Node *  n)

gets def ID of the node

Parameters
nthe target node
Returns
the ID of the node, 0 if node not def

◆ gf_node_get_class_name()

const char* gf_node_get_class_name ( GF_Node *  n)

gets node built-in name (eg 'Appearance', ..)

Parameters
nthe target node
Returns
node class name

◆ gf_node_remove_id()

GF_Err gf_node_remove_id ( GF_Node *  n)

unsets the node ID

Parameters
nthe target node
Returns
error if any

◆ gf_node_get_private()

void* gf_node_get_private ( GF_Node *  n)

gets user private of node

Parameters
nthe target node
Returns
user data if any, NULL if error or not assigned

◆ gf_node_set_private()

void gf_node_set_private ( GF_Node *  n,
void *  udta 
)

sets user private of node

Parameters
nthe target node
udtauser data to assign to the node

◆ gf_node_set_callback_function()

GF_Err gf_node_set_callback_function ( GF_Node *  n,
gf_sg_node_callback  NodeFunction 
)

sets traversal callback function. If a node has no associated callback, the traversing of the graph won't propagate below it. It is the app responsability to setup traversing functions as needed VRML/MPEG4: Instantiated Protos are handled internally as well as interpolators, valuators and scripts

Parameters
nthe target node
NodeFunctionthe callback function
Returns
error if any

◆ gf_node_register()

GF_Err gf_node_register ( GF_Node *  n,
GF_Node *  parent_node 
)

registers a node (DEFed or not), specifying parent if any. A node must be registered whenever used by something (a parent node, a command, whatever) to prevent its destruction (think of it as a reference counting).

Warning
NODES ARE CREATED WITHOUT BEING REGISTERED
Parameters
nthe target node
parent_nodethe parent node this node should be registered with
Returns
error if any

◆ gf_node_unregister()

GF_Err gf_node_unregister ( GF_Node *  n,
GF_Node *  parent_node 
)

unregister a node from parent (node may or not be DEF'ed). Parent may be NULL (DEF root node, commands). This MUST be called whenever a node is destroyed (removed from a parent node) If this is the last instance of the node, the node is destroyed

Warning
NODES ARE CREATED WITHOUT BEING REGISTERED, hence they MUST be registered at least once before being destroyed
Parameters
nthe target node
parent_nodethe parent node this node should be unregistered from
Returns
error if any

◆ gf_node_unregister_children()

void gf_node_unregister_children ( GF_Node *  node,
GF_ChildNodeItem *  childrenlist 
)

unregisters all children in the given list

Parameters
nodethe target parent node owning the list
childrenlistthe list of children to unregister

◆ gf_node_replace()

GF_Err gf_node_replace ( GF_Node *  old_node,
GF_Node *  new_node,
Bool  updateOrderedGroup 
)

gets all parents of the node and replace the old_node by the new node in all parents

Note
if the new node is not DEFed, only the first instance of "old_node" will be replaced, the other ones deleted
Parameters
old_nodeold node to replace
new_nodenew node to replace with
updateOrderedGroupif GF_TRUE, update the order field of parent OrderdedGroup nodes
Returns
error if any

◆ gf_node_get_num_instances()

u32 gf_node_get_num_instances ( GF_Node *  n)

gets the number of node instances

Parameters
nthe target node
Returns
the number of node instances

◆ gf_node_traverse()

void gf_node_traverse ( GF_Node *  n,
void *  udta 
)

calls node traverse callback routine on this node

Parameters
nthe target node
udtaopaque data passed to the node traverse callback

◆ gf_node_allow_cyclic_traverse()

void gf_node_allow_cyclic_traverse ( GF_Node *  n)

allows a node to be re-rendered - by default a node in its render callback will never be retraversed a second time. Use this function to enable a second traverse for this node while traversing it

Parameters
nthe target node

◆ gf_node_set_cyclic_traverse_flag()

Bool gf_node_set_cyclic_traverse_flag ( GF_Node *  n,
Bool  on 
)

sets the cyclic traverse flag

Parameters
nthe target node
onindicates if cyclic traverse shall be turned on or off
Returns
GF_FALSE if flag was already set, GF_TRUE otherwise

◆ gf_node_traverse_children()

void gf_node_traverse_children ( GF_Node *  n,
void *  udta 
)

blindly calls traverse callback on all children nodes

Parameters
nthe target node
udtaopaque data passed to the node traverse callback

◆ gf_node_get_parent_count()

u32 gf_node_get_parent_count ( GF_Node *  n)

get the number of parent for this node (parent are kept regardless of DEF state)

Parameters
nthe target node
Returns
the number of parents

◆ gf_node_get_parent()

GF_Node* gf_node_get_parent ( GF_Node *  n,
u32  idx 
)

returns desired parent for this node (parent are kept regardless of DEF state)

Parameters
nthe target node
idx0-based parent index
Returns
the parent node, or NULL of error

◆ gf_node_parent_of()

Bool gf_node_parent_of ( GF_Node *  parent,
GF_Node *  target 
)

checks if a node belongs to a subtree

Parameters
parentthe target parent node
targetthe target node
Returns
GF_TRUE if target is in the subtree below parent, GF_FALSE otherwise

◆ gf_node_dirty_set()

void gf_node_dirty_set ( GF_Node *  n,
u32  flags,
Bool  dirty_parents 
)

sets dirty flags

Parameters
nthe target node
flagsif 0, sets the base flags on (GF_SG_NODE_DIRTY); otherwise, adds the flags to the node dirty state
dirty_parentsif GF_TRUE, all parent subtrees for this node are marked as GF_SG_CHILD_DIRTY
Note
parent subtree marking aborts if a node in the subtree is already marked with GF_SG_CHILD_DIRTY which means tat if you never clean the dirty flags, no propagation will take place

◆ gf_node_dirty_parents()

void gf_node_dirty_parents ( GF_Node *  n)

marks all parent subtrees for this node as GF_SG_CHILD_DIRTY

Note
parent subtree marking aborts if a node in the subtree is already marked with GF_SG_CHILD_DIRTY which means that if you never clean the dirty flags, no propagation will take place
Parameters
nthe target node

◆ gf_node_dirty_clear()

void gf_node_dirty_clear ( GF_Node *  n,
u32  flags 
)

sets dirty flag off. It is the user responsability to clear dirty flags

Parameters
nthe target node
flagsif 0, all flags are set off; otherwise, removes the indicated flags from the node dirty state

◆ gf_node_dirty_reset()

void gf_node_dirty_reset ( GF_Node *  n,
Bool  reset_children 
)

reset dirty state of a node

Parameters
nthe target node
reset_childrenif GF_TRUE and node was dirty, resets the state of all its children

◆ gf_node_dirty_get()

u32 gf_node_dirty_get ( GF_Node *  n)

gets dirty flag value

Parameters
nthe target node
Returns
the dirty fkags

◆ gf_node_get_field_count()

u32 gf_node_get_field_count ( GF_Node *  n)

returns number of field for this node. For BIFS/VRML/X3D, this is the number of defined fields by the spec. For SVG/DOM, this is the number of attributes defined for the node.

Parameters
nthe target node
Returns
the number of defined fields

◆ gf_node_get_field()

GF_Err gf_node_get_field ( GF_Node *  n,
u32  FieldIndex,
GF_FieldInfo info 
)

fills the field info structure for the given field

Parameters
nthe target node
FieldIndexthe 0-based index of the target field
infofilled with field info
Returns
error if any

◆ gf_node_get_field_by_name()

GF_Err gf_node_get_field_by_name ( GF_Node *  n,
char *  name,
GF_FieldInfo field 
)

gets the field by its name

Parameters
nthe target node
namename of the target field
fieldfilled with field info
Returns
error if any

◆ gf_sg_new()

GF_SceneGraph* gf_sg_new ( )

creates a new scene graph

Returns
a new scene graph

◆ gf_sg_new_subscene()

GF_SceneGraph* gf_sg_new_subscene ( GF_SceneGraph scene)

creates a sub scene graph (typically used with Inline node): independent graph with same private stack, and user callbacks as parent. All routes triggered in this subgraph are executed in the parent graph (this means you only have to activate routes on the main graph)

Note
The resulting graph is not destroyed when the parent graph is
Parameters
scenethe parent scene graph
Returns
a new scene graph

◆ gf_sg_del()

void gf_sg_del ( GF_SceneGraph sg)

destroys a scene graph

Parameters
sgthe target scene graph

◆ gf_sg_reset()

void gf_sg_reset ( GF_SceneGraph sg)

resets the graph - all nodes, routes and protos are destroyed

Parameters
sgthe target scene graph

◆ gf_sg_set_private()

void gf_sg_set_private ( GF_SceneGraph sg,
void *  udta 
)

sets user private data for scene graph

Parameters
sgthe target scene graph
udtauser private data to set

◆ gf_sg_get_private()

void* gf_sg_get_private ( GF_SceneGraph sg)

gets user private data of scene graph

Parameters
sgthe target scene graph
Returns
user private data

◆ gf_sg_set_scene_time_callback()

void gf_sg_set_scene_time_callback ( GF_SceneGraph sg,
Double(*)(void *user_priv)  GetSceneTime 
)

sets the scene time query callback (functions returns time in sec)

Parameters
sgthe target scene graph
GetSceneTimethe scene time query callback

◆ gf_sg_get_parent()

GF_SceneGraph* gf_sg_get_parent ( GF_SceneGraph sg)

gets the parent scene graph of a graph

Parameters
sgthe target scene graph
Returns
the parent graph or NULL if none defined

◆ gf_sg_set_node_callback()

void gf_sg_set_node_callback ( GF_SceneGraph sg,
gf_sg_node_init_callback  NodeCallback 
)

sets node callback: function called upon node creation. Application should instantiate the node rendering stack and any desired callback

Parameters
sgthe target scene graph
NodeCallbackthe node callback function

◆ gf_sg_get_root_node()

GF_Node* gf_sg_get_root_node ( GF_SceneGraph sg)

gets the root node of the graph

Parameters
sgthe target scene graph
Returns
root node of the scene graph, NULL otherwise

◆ gf_sg_set_root_node()

void gf_sg_set_root_node ( GF_SceneGraph sg,
GF_Node *  node 
)

sets the root node of the graph

Parameters
sgthe target scene graph
noderoot node of the scene graph

◆ gf_sg_find_node()

GF_Node* gf_sg_find_node ( GF_SceneGraph sg,
u32  nodeID 
)

finds a registered node by ID

Parameters
sgthe target scene graph
nodeIDID of the node to find
Returns
node if found, NULL otherwise

◆ gf_sg_find_node_by_name()

GF_Node* gf_sg_find_node_by_name ( GF_SceneGraph sg,
char *  name 
)

finds a registered node by DEF name

Parameters
sgthe target scene graph
namename of the node to find
Returns
node if found, NULL otherwise

◆ gf_node_changed()

void gf_node_changed ( GF_Node *  n,
GF_FieldInfo fieldChanged 
)

signals node has been modified, indicating which field is modified

Note
this is exposed for BIFS codec and BIFS/VRML rendering, it should not be needed by other apps
Parameters
nthe target node
fieldChangedthe modified field, may be NULL of global node modification

◆ gf_node_get_graph()

GF_SceneGraph* gf_node_get_graph ( GF_Node *  n)

gets the scene graph of a node

Parameters
nthe target node
Returns
the parent scene graph

◆ gf_sg_set_scene_size_info()

void gf_sg_set_scene_size_info ( GF_SceneGraph sg,
u32  width,
u32  height,
Bool  usePixelMetrics 
)

sets size info for the graph - by default graphs have no size and are in meter metrics (VRML like) if any of width or height is 0, the graph has no size info

Parameters
sgthe target scene graph
widthwidth in pixels
heightheight in pixels
usePixelMetricsindicates coordinates in graph are given in pixels

◆ gf_sg_use_pixel_metrics()

Bool gf_sg_use_pixel_metrics ( GF_SceneGraph sg)

checks if pixel metrics is used

Parameters
sgthe target scene graph
Returns
GF_TRUE if pixelMetrics

◆ gf_sg_get_scene_size_info()

Bool gf_sg_get_scene_size_info ( GF_SceneGraph sg,
u32 width,
u32 height 
)

gets size information of graph

Parameters
sgthe target scene graph
widthset to width of scene
heightset to height of scene
Returns
GF_FALSE if no size info, otherwise GF_TRUE and set width/height

◆ gf_node_new()

GF_Node* gf_node_new ( GF_SceneGraph sg,
u32  tag 
)

creates a node of the given tag. sg is the parent scenegraph of the node, eg the root one for scene nodes or the proto one for proto code (cf proto)

Note
  • NODE IS NOT REGISTERED (no instances) AND CANNOT BE DESTROYED UNTIL REGISTERED
  • this doesn't perform application setup for the node, this must be done by the caller
Parameters
sgthe target scene graph
tagtag of node to create
Returns
new node

◆ gf_node_init()

void gf_node_init ( GF_Node *  n)

inits node (either internal stack or user-defined) - usually called once the node has been fully loaded

Parameters
nthe target node

◆ gf_node_clone()

GF_Node* gf_node_clone ( GF_SceneGraph inScene,
GF_Node *  orig,
GF_Node *  cloned_parent,
char *  id_suffix,
Bool  deep 
)

clones a node in the given graph and register with parent cloned.

Parameters
inScenethe target scene graph in which the node should be cloned
origthe target node to clone
cloned_parentthe parent of the node to clone
id_suffixif NULL, all IDs are removed from the cloned subtree, (each node instance will become a hard copy). If empty string "", ID will be kept exactly as they where in the original subtree (this may lead to errors due to the presence of the same ID depending on the standard). Otherwise, all IDs are translated ( -> id_suffix) and binary IDs are generated on the fly
deepclones children as well
Returns
the cloned node

◆ gf_node_get_scene_time()

Double gf_node_get_scene_time ( GF_Node *  n)

gets scene time for scene this node belongs too

Parameters
nthe target node
Returns
the scene time for the node, 0 if timeline not specified

◆ gf_sg_get_next_available_node_id()

u32 gf_sg_get_next_available_node_id ( GF_SceneGraph sg)

gets next available NodeID

Parameters
sgthe target scene graph
Returns
next available NodeID

◆ gf_sg_get_max_node_id()

u32 gf_sg_get_max_node_id ( GF_SceneGraph sg)

gets max ID used in graph

Parameters
sgthe target scene graph
Returns
max NodeID

◆ gf_node_get_name_and_id()

const char* gf_node_get_name_and_id ( GF_Node *  n,
u32 ID 
)

gets node ID and name

Parameters
nthe target node
IDset to the node ID or to 0 if not defined
Returns
the node name or NULL if not defined

◆ gf_sg_set_script_action()

void gf_sg_set_script_action ( GF_SceneGraph sg,
gf_sg_script_action  script_act,
void *  cbk 
)

assigns API to scene graph - by default, sub-graphs inherits the API if set

Parameters
sgthe target scene graph
script_actthe script action callback
cbkopaque data to pass to the script action callback

◆ gf_sg_script_load()

void gf_sg_script_load ( GF_Node *  script)

loads script into engine - this should be called only for script in main scene, loading of scripts in protos is done internally when instanciating the proto

Parameters
scriptthe target script node

◆ gf_sg_has_scripting()

Bool gf_sg_has_scripting ( )

checks if scripting is supported in GPAC (built-in and run-time enabled)

Returns
GF_TRUE if javascript is supported

◆ gf_sg_command_new()

GF_Command* gf_sg_command_new ( GF_SceneGraph sg,
u32  tag 
)

creates a command - graph is only needed for SceneReplace

Parameters
sgparent scene graph of the command, only needed for SceneReplace
tagthe command tag
Returns
a new command

◆ gf_sg_command_del()

void gf_sg_command_del ( GF_Command com)

destroys a command

Parameters
comthe target command

◆ gf_sg_command_apply()

GF_Err gf_sg_command_apply ( GF_SceneGraph sg,
GF_Command com,
Double  time_offset 
)

applies command to graph - the command content is kept unchanged for authoring purposes - THIS NEEDS TESTING AND FIXING

Parameters
sgthe target scene graph where to apply the command
comthe target command
time_offsettime offset in seconds for time fields if desired
Returns
error if any

◆ gf_sg_command_apply_list()

GF_Err gf_sg_command_apply_list ( GF_SceneGraph sg,
GF_List comList,
Double  time_offset 
)

applies list if command to graph - the command content is kept unchanged for authoring purposes

Parameters
sgthe target scene graph where to apply the command
comListthe list of commands
time_offsettime offset in seconds for time fields if desired
Returns
error if any

◆ gf_sg_command_field_new()

GF_CommandField* gf_sg_command_field_new ( GF_Command com)

creates a new command field structire (some commands may target multiple fields at once) and registers it with command

Parameters
comthe parent command
Returns
new commandFieldInfo structure

◆ gf_scene_execute_script()

GF_Err gf_scene_execute_script ( GF_SceneGraph sg,
const char *  com 
)

executes JS code in the root context of the scene graph

Parameters
sgthe target scene graph where to execute the script
comjavascript code to execute
Returns
error if any

◆ gf_sg_init_from_xml_node()

GF_Err gf_sg_init_from_xml_node ( GF_SceneGraph document,
GF_DOMXMLNODE  root_node 
)

Creates a GF_SceneGraph from an XML root node. This is mostly used to allow using DOM API on an XML doc

Parameters
documentan empty scene graph object
root_nodethe root node of an XML document
Returns
error if any