2 * GPAC - Multimedia Framework C SDK
\r
4 * Copyright (c) Jean Le Feuvre 2000-2005
\r
5 * All rights reserved
\r
7 * This file is part of GPAC / Scene Graph sub-project
\r
9 * GPAC is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU Lesser General Public License as published by
\r
11 * the Free Software Foundation; either version 2, or (at your option)
\r
12 * any later version.
\r
14 * GPAC is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU Lesser General Public License for more details.
\r
19 * You should have received a copy of the GNU Lesser General Public
\r
20 * License along with this library; see the file COPYING. If not, write to
\r
21 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
\r
26 #ifndef _GF_SCENEGRAPH_H_
\r
27 #define _GF_SCENEGRAPH_H_
\r
33 #include <gpac/list.h>
\r
34 #include <gpac/math.h>
\r
37 TAG definitions are static, in order to be able to mix nodes from different standard
\r
38 in a single scenegraph. These TAGs are only used internally (they do not match any
\r
42 /*undefined node: just the base node class, used for parsing*/
\r
43 TAG_UndefinedNode = 0,
\r
44 /*all MPEG-4/VRML/X3D proto instances have this tag*/
\r
47 /*reserved TAG ranges per standard*/
\r
50 GF_NODE_RANGE_FIRST_MPEG4,
\r
51 GF_NODE_RANGE_LAST_MPEG4 = GF_NODE_RANGE_FIRST_MPEG4+512,
\r
54 GF_NODE_RANGE_FIRST_X3D,
\r
55 GF_NODE_RANGE_LAST_X3D = GF_NODE_RANGE_FIRST_X3D+512,
\r
57 /*all nodes after this are always parent nodes*/
\r
58 GF_NODE_RANGE_LAST_VRML,
\r
60 /*DOM container for BIFS/LASeR/etc updates*/
\r
63 /*all nodes below MUST be parent nodes*/
\r
64 GF_NODE_FIRST_PARENT_NODE_TAG,
\r
68 /*all nodes below MUST use the base DOM structure (with dyn attribute list)*/
\r
69 GF_NODE_FIRST_DOM_NODE_TAG,
\r
72 TAG_DOMFullNode = GF_NODE_FIRST_DOM_NODE_TAG,
\r
75 GF_NODE_RANGE_FIRST_SVG,
\r
76 GF_NODE_RANGE_LAST_SVG = GF_NODE_RANGE_FIRST_SVG+100,
\r
79 GF_NODE_RANGE_FIRST_XBL,
\r
80 TAG_XBL_bindings = GF_NODE_RANGE_FIRST_XBL,
\r
84 TAG_XBL_implementation,
\r
85 TAG_XBL_constructor,
\r
99 GF_NODE_RANGE_LAST_XBL,
\r
104 /*private handler for this library on all nodes*/
\r
105 #define BASE_NODE struct _nodepriv *sgprivate;
\r
108 typedef struct _base_node
\r
113 /*child storage - this is not integrated in the base node, because of VRML/MPEG-4 USE: a node
\r
114 may be present at different places in the tree, hence have different "next" siblings.*/
\r
115 typedef struct _child_node
\r
117 struct _child_node *next;
\r
119 } GF_ChildNodeItem;
\r
121 /*grouping nodes macro :
\r
122 children: list of children SFNodes
\r
126 struct _child_node *children;
\r
134 /*adds a child to a given container*/
\r
135 GF_Err gf_node_list_add_child(GF_ChildNodeItem **list, GF_Node *n);
\r
136 /*adds a child to a given container, updating last position*/
\r
137 GF_Err gf_node_list_add_child_last(GF_ChildNodeItem **list, GF_Node *n, GF_ChildNodeItem **last_child);
\r
138 /*inserts a child to a given container - if pos doesn't match, append the child*/
\r
139 GF_Err gf_node_list_insert_child(GF_ChildNodeItem **list, GF_Node *n, u32 pos);
\r
140 /*removes a child to a given container - return 0 if child not found*/
\r
141 Bool gf_node_list_del_child(GF_ChildNodeItem **list, GF_Node *n);
\r
142 /*finds a child in a given container, returning its 0-based index if found, -1 otherwise*/
\r
143 s32 gf_node_list_find_child(GF_ChildNodeItem *list, GF_Node *n);
\r
144 /*finds a child in a given container given its index, returning the child or NULL if not found
\r
145 if pos is <0, returns the last child*/
\r
146 GF_Node *gf_node_list_get_child(GF_ChildNodeItem *list, s32 pos);
\r
147 /*gets the number of children in a given container*/
\r
148 u32 gf_node_list_get_count(GF_ChildNodeItem *list);
\r
149 /*deletes node entry at given idx, returning node if found, NULL otherwise*/
\r
150 GF_Node *gf_node_list_del_child_idx(GF_ChildNodeItem **list, u32 pos);
\r
154 /*tag is set upon creation and cannot be modified*/
\r
155 u32 gf_node_get_tag(GF_Node*);
\r
157 @ID: node ID, !=0 set def node - if a different node with the same ID exists, returns error.
\r
158 You may change the node ID by recalling the function with a different ID value. You may get a node ID
\r
159 by calling the gf_sg_get_next_available_node_id function
\r
160 @defName: optional readable name (script, MPEGJ). To change the name, recall the function with a different name and the same ID
\r
162 GF_Err gf_node_set_id(GF_Node*n, u32 nodeID, const char *nodeDEFName);
\r
163 /*get def name of the node , NULL if not set*/
\r
164 const char *gf_node_get_name(GF_Node*);
\r
165 /*get def name of the node , or the string representation of the node pointer if not set*/
\r
166 const char *gf_node_get_log_name(GF_Node*);
\r
167 /*get def ID of the node, 0 if node not def*/
\r
168 u32 gf_node_get_id(GF_Node*);
\r
169 /* gets node built-in name (eg 'Appearance', ..) */
\r
170 const char *gf_node_get_class_name(GF_Node *Node);
\r
172 u32 gf_sg_node_get_tag_by_class_name(const char *name, u32 xmlns);
\r
174 /*unset the node ID*/
\r
175 GF_Err gf_node_remove_id(GF_Node *p);
\r
177 /*get/set user private stack*/
\r
178 void *gf_node_get_private(GF_Node*);
\r
179 void gf_node_set_private(GF_Node*, void *);
\r
181 /*set traversal callback function. If a node has no associated callback, the traversing of the
\r
182 graph won't propagate below it. It is the app responsability to setup traversing functions as needed
\r
183 VRML/MPEG4: Instanciated Protos are handled internally as well as interpolators, valuators and scripts
\r
184 @is_destroy: set when the node is about to be destroyed
\r
186 GF_Err gf_node_set_callback_function(GF_Node *, void (*NodeFunction)(GF_Node *node, void *traverse_state, Bool is_destroy) );
\r
188 /*register a node (DEFed or not), specifying parent if any.
\r
189 A node must be registered whenever used by something (a parent node, a command, whatever) to prevent its
\r
190 destruction (think of it as a reference counting).
\r
191 NOTE: NODES ARE CREATED WITHOUT BEING REGISTERED
\r
193 GF_Err gf_node_register(GF_Node *node, GF_Node *parent_node);
\r
195 /*unregister a node from parent (node may or not be DEF'ed). Parent may be NULL (DEF root node, commands).
\r
196 This MUST be called whenever a node is destroyed (removed from a parent node)
\r
197 If this is the last instance of the node, the node is destroyed
\r
198 NOTE: NODES ARE CREATED WITHOUT BEING REGISTERED, hence they MUST be registered at least once before
\r
201 GF_Err gf_node_unregister(GF_Node *node, GF_Node *parent_node);
\r
202 /*deletes all node instances in the given list*/
\r
203 void gf_node_unregister_children(GF_Node *node, GF_ChildNodeItem *childrenlist);
\r
205 /*get all parents of the node and replace the old_node by the new node in all parents
\r
206 Note: if the new node is not DEFed, only the first instance of "old_node" will be replaced, the other ones deleted*/
\r
207 GF_Err gf_node_replace(GF_Node *old_node, GF_Node *new_node, Bool updateOrderedGroup);
\r
209 /*returns number of instances for this node*/
\r
210 u32 gf_node_get_num_instances(GF_Node *node);
\r
213 /*calls node traverse callback routine on this node*/
\r
214 void gf_node_traverse(GF_Node *node, void *udta);
\r
215 /*allows a node to be re-rendered - by default a node in its render phase will never be rendered a second time.
\r
216 Use this function to enable a second render for this node - this must be called while node is being rendered*/
\r
217 void gf_node_allow_cyclic_traverse(GF_Node *node);
\r
219 /*blindly calls traverse callback on all children nodes */
\r
220 void gf_node_traverse_children(GF_Node *node, void *renderStack);
\r
221 /*returns number of parent for this node (parent are kept regardless of DEF state)*/
\r
222 u32 gf_node_get_parent_count(GF_Node *node);
\r
223 /*returns desired parent for this node (parent are kept regardless of DEF state)
\r
224 idx is 0-based parent index*/
\r
225 GF_Node *gf_node_get_parent(GF_Node *node, u32 idx);
\r
230 /*flag set whenever a field of the node has been modified*/
\r
231 GF_SG_NODE_DIRTY = 1,
\r
232 /*flag set whenever a child node of this node has been modified
\r
233 NOTE: unloaded extern protos always invalidate their parent subgraph to get a chance
\r
234 of being loaded. It is the user responsability to clear the CHILD_DIRTY flag before traversing
\r
235 if relying on this flag for sub-tree discarding (eg, culling or similar)*/
\r
236 GF_SG_CHILD_DIRTY = 1<<1,
\r
238 /*flag set by bindable nodes to indicate a modification of the bindable stack. This is
\r
239 only used for offscreen rendering of Layer3D*/
\r
240 GF_SG_VRML_BINDABLE_DIRTY = 1<<2,
\r
242 /*flag set whenever a ColorTransform node is removed from a parent node*/
\r
243 GF_SG_VRML_COLOR_DIRTY = 1<<3,
\r
246 /*SVG-specific flags due to mix of geometry and appearance & co attributes*/
\r
247 /*SVG geometry changed is the same as base flag*/
\r
248 GF_SG_SVG_GEOMETRY_DIRTY = GF_SG_NODE_DIRTY,
\r
249 GF_SG_SVG_COLOR_DIRTY = GF_SG_VRML_BINDABLE_DIRTY,
\r
250 GF_SG_SVG_DISPLAYALIGN_DIRTY = 1<<3,
\r
251 GF_SG_SVG_FILL_DIRTY = 1<<4,
\r
252 GF_SG_SVG_FILLOPACITY_DIRTY = 1<<5,
\r
253 GF_SG_SVG_FILLRULE_DIRTY = 1<<6,
\r
254 GF_SG_SVG_FONTFAMILY_DIRTY = 1<<7,
\r
255 GF_SG_SVG_FONTSIZE_DIRTY = 1<<8,
\r
256 GF_SG_SVG_FONTSTYLE_DIRTY = 1<<9,
\r
257 GF_SG_SVG_FONTVARIANT_DIRTY = 1<<10,
\r
258 GF_SG_SVG_FONTWEIGHT_DIRTY = 1<<11,
\r
259 GF_SG_SVG_LINEINCREMENT_DIRTY = 1<<12,
\r
260 GF_SG_SVG_OPACITY_DIRTY = 1<<13,
\r
261 GF_SG_SVG_SOLIDCOLOR_OR_OPACITY_DIRTY = 1<<14,
\r
262 GF_SG_SVG_STOPCOLOR_OR_OPACITY_DIRTY = 1<<15,
\r
263 GF_SG_SVG_STROKE_DIRTY = 1<<16,
\r
264 GF_SG_SVG_STROKEDASHARRAY_DIRTY = 1<<17,
\r
265 GF_SG_SVG_STROKEDASHOFFSET_DIRTY= 1<<18,
\r
266 GF_SG_SVG_STROKELINECAP_DIRTY = 1<<19,
\r
267 GF_SG_SVG_STROKELINEJOIN_DIRTY = 1<<20,
\r
268 GF_SG_SVG_STROKEMITERLIMIT_DIRTY= 1<<21,
\r
269 GF_SG_SVG_STROKEOPACITY_DIRTY = 1<<22,
\r
270 GF_SG_SVG_STROKEWIDTH_DIRTY = 1<<23,
\r
271 GF_SG_SVG_TEXTPOSITION_DIRTY = 1<<24,
\r
272 GF_SG_SVG_DISPLAY_DIRTY = 1<<25,
\r
273 GF_SG_SVG_VECTOREFFECT_DIRTY = 1<<26,
\r
274 GF_SG_SVG_XLINK_HREF_DIRTY = 1<<27,
\r
278 if @flags is 0, sets the base flags on (GF_SG_NODE_DIRTY).
\r
279 if @flags is not 0, adds the flags to the node dirty state
\r
281 If @invalidate_parents is set, all parent subtrees for this node are marked as GF_SG_CHILD_DIRTY
\r
282 Note: parent subtree marking aborts if a node in the subtree is already marked with GF_SG_CHILD_DIRTY
\r
283 which means tat if you never clean the dirty flags, no propagation will take place
\r
285 void gf_node_dirty_set(GF_Node *node, u32 flags, Bool dirty_parents);
\r
287 /*mark all parent subtrees for this node as GF_SG_CHILD_DIRTY
\r
288 Note: parent subtree marking aborts if a node in the subtree is already marked with GF_SG_CHILD_DIRTY
\r
289 which means that if you never clean the dirty flags, no propagation will take place
\r
291 void gf_node_dirty_parents(GF_Node *node);
\r
293 /*set dirty flag off. It is the user responsability to clear dirty flags
\r
294 if @flags is 0, all flags are set off
\r
295 if @flags is not 0, removes the indicated flags from the node dirty state
\r
297 void gf_node_dirty_clear(GF_Node *node, u32 flags);
\r
299 /*if the node is in a dirty state, resets it and the state of all its children*/
\r
300 void gf_node_dirty_reset(GF_Node *node);
\r
302 /*get dirty flag value*/
\r
303 u32 gf_node_dirty_get(GF_Node *node);
\r
305 /*Notes on GF_FieldInfo
\r
306 all scene graph implementations should answer node field query with this interface.
\r
307 In case an implementation does not use this:
\r
308 - the implementation shall handle the parent node dirty flag itself most of the time
\r
309 - the implementation shall NOT allow referencing of a graph node in a parent graph node (when inlining
\r
310 content) otherwise the app is guaranteed to crash.
\r
313 /*other fieldTypes may be ignored by implmentation not using VRML/MPEG4 native types*/
\r
317 /*0-based index of the field in the node*/
\r
319 /*field type - VRML/MPEG4 types are listed in scenegraph_vrml.h*/
\r
321 /*far ptr to the field (eg GF_Node **, GF_List**, MFInt32 *, ...)*/
\r
325 /*NDT type in case of SF/MFNode field - cf BIFS specific tools*/
\r
329 /*eventin handler if any*/
\r
330 void (*on_event_in)(GF_Node *pNode);
\r
333 /*returns number of field for this node*/
\r
334 u32 gf_node_get_field_count(GF_Node *node);
\r
336 /*fill the field info structure for the given field*/
\r
337 GF_Err gf_node_get_field(GF_Node *node, u32 FieldIndex, GF_FieldInfo *info);
\r
339 /*get the field by its name*/
\r
340 GF_Err gf_node_get_field_by_name(GF_Node *node, char *name, GF_FieldInfo *field);
\r
342 typedef struct __tag_scene_graph GF_SceneGraph;
\r
344 /*scene graph constructor*/
\r
345 GF_SceneGraph *gf_sg_new();
\r
347 /*creates a sub scene graph (typically used with Inline node): independent graph with same private stack,
\r
348 and user callbacks as parent. All routes triggered in this subgraph are executed in the parent graph (this
\r
349 means you only have to activate routes on the main graph)
\r
350 NOTE: the resulting graph is not destroyed when the parent graph is
\r
352 GF_SceneGraph *gf_sg_new_subscene(GF_SceneGraph *scene);
\r
355 void gf_sg_del(GF_SceneGraph *sg);
\r
356 /*reset the full graph - all nodes, routes and protos are destroyed*/
\r
357 void gf_sg_reset(GF_SceneGraph *sg);
\r
359 /*parses the given XML document and returns a scene graph composed of GF_DOMFullNode*/
\r
360 GF_Err gf_sg_new_from_xml_doc(const char *src, GF_SceneGraph **scene);
\r
362 /*set/get user private data*/
\r
363 void gf_sg_set_private(GF_SceneGraph *sg, void *user_priv);
\r
364 void *gf_sg_get_private(GF_SceneGraph *sg);
\r
366 /*set the scene timer (fct returns time in sec)*/
\r
367 void gf_sg_set_scene_time_callback(GF_SceneGraph *scene, Double (*GetSceneTime)(void *user_priv) );
\r
371 /*function called upon node creation.
\r
372 ctxdata is not used*/
\r
373 GF_SG_CALLBACK_INIT = 0,
\r
374 /*function called upon node modification. You typically will set some of the dirty flags here.
\r
375 ctxdata is the fieldInfo pointer of the modified field*/
\r
376 GF_SG_CALLBACK_MODIFIED,
\r
377 /*function called when the a "set dirty" propagates to root node of the graph
\r
378 ctxdata is not used*/
\r
379 GF_SG_CALLBACK_GRAPH_DIRTY,
\r
382 /*set node callback: function called upon node creation.
\r
383 Application should instanciate the node rendering stack and any desired callback*/
\r
384 void gf_sg_set_node_callback(GF_SceneGraph *sg, void (*NodeCallback)(void *user_priv, u32 type, GF_Node *node, void *ctxdata) );
\r
386 /*get/set the root node of the graph*/
\r
387 GF_Node *gf_sg_get_root_node(GF_SceneGraph *sg);
\r
388 void gf_sg_set_root_node(GF_SceneGraph *sg, GF_Node *node);
\r
390 /*finds a registered node by ID*/
\r
391 GF_Node *gf_sg_find_node(GF_SceneGraph *sg, u32 nodeID);
\r
392 /*finds a registered node by DEF name*/
\r
393 GF_Node *gf_sg_find_node_by_name(GF_SceneGraph *sg, char *name);
\r
395 /*used to signal modification of a node, indicating which field is modified - exposed for BIFS codec,
\r
396 should not be needed by other apps*/
\r
397 void gf_node_changed(GF_Node *node, GF_FieldInfo *fieldChanged);
\r
399 /*returns the graph this node belongs to*/
\r
400 GF_SceneGraph *gf_node_get_graph(GF_Node *node);
\r
402 /*Set size info for the graph - by default graphs have no size and are in meter metrics (VRML like)
\r
403 if any of width or height is 0, the graph has no size info*/
\r
404 void gf_sg_set_scene_size_info(GF_SceneGraph *sg, u32 width, u32 Height, Bool usePixelMetrics);
\r
405 /*returns 1 if pixelMetrics*/
\r
406 Bool gf_sg_use_pixel_metrics(GF_SceneGraph *sg);
\r
407 /*returns 0 if no size info, otherwise 1 and set width/height*/
\r
408 Bool gf_sg_get_scene_size_info(GF_SceneGraph *sg, u32 *width, u32 *Height);
\r
410 /*creates a node of the given tag. sg is the parent scenegraph of the node,
\r
411 eg the root one for scene nodes or the proto one for proto code (cf proto)
\r
413 - NODE IS NOT REGISTERED (no instances) AND CANNOT BE DESTROYED UNTIL REGISTERED
\r
414 - this doesn't perform application setup for the node, this must be done by the caller
\r
416 GF_Node *gf_node_new(GF_SceneGraph *sg, u32 tag);
\r
417 /*inits node (either internal stack or user-defined) - usually called once the node has been fully loaded*/
\r
418 void gf_node_init(GF_Node *node);
\r
420 /*clones a node in the given graph and register with parent cloned. The cloning handles ID based on id_suffix:
\r
421 id_suffix = NULL: all IDs are removed from the cloned subtree, (each node instance will become a hard copy)
\r
422 id_suffix = "": ID will be kept exactly as they where in the original subtree - this may lead to errors due to
\r
423 the presence of the same ID depending on the standard (DOM, ...).
\r
424 id_suffix = anything: all IDs are translated ($(name) -> $(name)id_suffix) and bynary IDs are generated on the fly
\r
426 GF_Node *gf_node_clone(GF_SceneGraph *inScene, GF_Node *orig, GF_Node *cloned_parent, char *id_suffix, Bool deep);
\r
428 /*gets scene time for scene this node belongs too, 0 if timeline not specified*/
\r
429 Double gf_node_get_scene_time(GF_Node *node);
\r
431 /*retuns next available NodeID*/
\r
432 u32 gf_sg_get_next_available_node_id(GF_SceneGraph *sg);
\r
433 /*retuns max ID used in graph*/
\r
434 u32 gf_sg_get_max_node_id(GF_SceneGraph *sg);
\r
436 const char *gf_node_get_name_and_id(GF_Node*node, u32 *id);
\r
441 GF_SG_FOCUS_AUTO = 1,
\r
445 GF_SG_FOCUS_NORTH_EAST,
\r
447 GF_SG_FOCUS_SOUTH_EAST,
\r
449 GF_SG_FOCUS_SOUTH_WEST,
\r
451 GF_SG_FOCUS_NORTH_WEST
\r
457 const char **params;
\r
463 const char *section;
\r
465 const char *key_val;
\r
468 /*for script message option*/
\r
486 GF_JSAPIOPT gpac_cfg;
\r
488 struct __gf_download_manager *dnld_man;
\r
489 GF_SceneGraph *scene;
\r
496 /*!push message from script engine.*/
\r
497 GF_JSAPI_OP_MESSAGE,
\r
498 /*!get scene URI.*/
\r
499 GF_JSAPI_OP_GET_SCENE_URI,
\r
500 /*!get current user agent scale.*/
\r
501 GF_JSAPI_OP_GET_SCALE,
\r
502 /*!set current user agent scale.*/
\r
503 GF_JSAPI_OP_SET_SCALE,
\r
504 /*!get current user agent rotation.*/
\r
505 GF_JSAPI_OP_GET_ROTATION,
\r
506 /*!set current user agent rotation.*/
\r
507 GF_JSAPI_OP_SET_ROTATION,
\r
508 /*!get current user agent translation.*/
\r
509 GF_JSAPI_OP_GET_TRANSLATE,
\r
510 /*!set current user agent translation.*/
\r
511 GF_JSAPI_OP_SET_TRANSLATE,
\r
512 /*!get node time.*/
\r
513 GF_JSAPI_OP_GET_TIME,
\r
514 /*!set node time.*/
\r
515 GF_JSAPI_OP_SET_TIME,
\r
516 /*!get current viewport.*/
\r
517 GF_JSAPI_OP_GET_VIEWPORT,
\r
518 /*!get object bounding box in object local coord system.*/
\r
519 GF_JSAPI_OP_GET_LOCAL_BBOX,
\r
520 /*!get object bounding box in world (screen) coord system.*/
\r
521 GF_JSAPI_OP_GET_SCREEN_BBOX,
\r
522 /*!get transform matrix at object.*/
\r
523 GF_JSAPI_OP_GET_TRANSFORM,
\r
524 /*!move focus according to opt value.*/
\r
525 GF_JSAPI_OP_MOVE_FOCUS,
\r
526 /*!set focus to given node.*/
\r
527 GF_JSAPI_OP_GET_FOCUS,
\r
528 /*!set focus to given node.*/
\r
529 GF_JSAPI_OP_SET_FOCUS,
\r
530 /*!replace target scene URL*/
\r
531 GF_JSAPI_OP_LOAD_URL,
\r
532 /*!get option by section and key*/
\r
533 GF_JSAPI_OP_GET_OPT,
\r
534 /*!get option by section and key*/
\r
535 GF_JSAPI_OP_SET_OPT,
\r
536 /*!retrieve download manager*/
\r
537 GF_JSAPI_OP_GET_DOWNLOAD_MANAGER,
\r
538 /*!get navigation speed if any*/
\r
539 GF_JSAPI_OP_GET_SPEED,
\r
540 /*!get current frame rate*/
\r
541 GF_JSAPI_OP_GET_FPS,
\r
542 /*!set current title*/
\r
543 GF_JSAPI_OP_SET_TITLE,
\r
544 /*!gets DCCI scenegraph if any*/
\r
545 GF_JSAPI_OP_GET_DCCI,
\r
546 /*!gets subscene for current node if any*/
\r
547 GF_JSAPI_OP_GET_SUBSCENE,
\r
548 /*!resolves relative Xlink based on xml:base*/
\r
549 GF_JSAPI_OP_RESOLVE_XLINK,
\r
550 /*!evaluates if the given IRI is available for playback (returns 1) or not. If the IRI is
\r
551 NULL, this evaluates whether the scene is ready for composition (canvas setup) or not.*/
\r
552 GF_JSAPI_OP_EVAL_IRI,
\r
554 /*!gets GPAC terminal*/
\r
555 GF_JSAPI_OP_GET_TERM,
\r
557 /*!pauses an SVG element*/
\r
558 GF_JSAPI_OP_PAUSE_SVG,
\r
559 /*!resumes an SVG ELEMENT*/
\r
560 GF_JSAPI_OP_RESUME_SVG,
\r
562 GF_JSAPI_OP_GET_DPI_X,
\r
563 GF_JSAPI_OP_GET_DPI_Y,
\r
566 interface to various get/set options:
\r
567 type: operand type, one of the above
\r
568 node: target node, scene root node or NULL
\r
569 param: i/o param, depending on operand type
\r
571 typedef Bool (*gf_sg_script_action)(void *callback, u32 type, GF_Node *node, GF_JSAPIParam *param);
\r
573 /*assign API to scene graph - by default, sub-graphs inherits the API if set*/
\r
574 void gf_sg_set_script_action(GF_SceneGraph *scene, gf_sg_script_action script_act, void *cbk);
\r
576 /*load script into engine - this should be called only for script in main scene, loading of scripts
\r
577 in protos is done internally when instanciating the proto*/
\r
578 void gf_sg_script_load(GF_Node *script);
\r
580 /*returns true if current lib has javascript support*/
\r
581 Bool gf_sg_has_scripting();
\r
586 scene graph command tools used for BIFS and LASeR
\r
587 These are used to store updates in memory without applying changes to the graph,
\r
588 for dumpers, encoders ...
\r
589 The commands can then be applied through this lib
\r
593 Currently defined possible modifications
\r
598 GF_SG_SCENE_REPLACE = 0,
\r
599 GF_SG_NODE_REPLACE,
\r
600 GF_SG_FIELD_REPLACE,
\r
601 GF_SG_INDEXED_REPLACE,
\r
602 GF_SG_ROUTE_REPLACE,
\r
604 GF_SG_INDEXED_DELETE,
\r
605 GF_SG_ROUTE_DELETE,
\r
607 GF_SG_INDEXED_INSERT,
\r
608 GF_SG_ROUTE_INSERT,
\r
609 /*extended updates (BIFS-only)*/
\r
610 GF_SG_PROTO_INSERT,
\r
611 GF_SG_PROTO_DELETE,
\r
612 GF_SG_PROTO_DELETE_ALL,
\r
613 GF_SG_MULTIPLE_REPLACE,
\r
614 GF_SG_MULTIPLE_INDEXED_REPLACE,
\r
615 GF_SG_GLOBAL_QUANTIZER,
\r
616 /*same as NodeDelete, and also updates OrderedGroup.order when deleting a child*/
\r
617 GF_SG_NODE_DELETE_EX,
\r
620 GF_SG_FIELD_REPLACE_OP,
\r
621 GF_SG_INDEXED_REPLACE_OP,
\r
623 GF_SG_LAST_BIFS_COMMAND,
\r
627 GF_SG_LSR_NEW_SCENE,
\r
628 GF_SG_LSR_REFRESH_SCENE,
\r
636 GF_SG_LSR_SEND_EVENT,
\r
637 GF_SG_LSR_ACTIVATE,
\r
638 GF_SG_LSR_DEACTIVATE,
\r
645 single command wrapper
\r
647 NOTE: In order to maintain node registry, the nodes replaced/inserted MUST be registered with
\r
648 their parents even when the command is never applied. Registering shall be performed
\r
649 with gf_node_register (see below).
\r
650 If you fail to do so, a node may be destroyed when destroying a command while still used
\r
651 in another command or in the graph - this will just crash.
\r
654 /*structure used to store field info, pos and static pointers to GF_Node/MFNode in commands*/
\r
660 /*field pointer for multiple replace/multiple indexed replace - if multiple indexed replace, must be the SF field being changed*/
\r
662 /*replace/insert/delete pos - -1 is append except in multiple indexed replace*/
\r
665 /*Whenever field pointer is of type GF_Node, store the node here and set the far pointer to this address.*/
\r
667 /*Whenever field pointer is of type MFNode, store the node list here and set the far pointer to this address.*/
\r
668 GF_ChildNodeItem *node_list;
\r
673 GF_SceneGraph *in_scene;
\r
676 /*node the command applies to - may be NULL*/
\r
679 /*list of GF_CommandField for all field commands replace/ index insert / index replace / index delete / MultipleReplace / MultipleIndexedreplace
\r
680 the content is destroyed when deleting the command*/
\r
681 GF_List *command_fields;
\r
683 /*may be NULL, and may be present with any command inserting a node*/
\r
684 GF_List *scripts_to_load;
\r
685 /*for authoring purposes - must be cleaned by user*/
\r
689 /*scene replace command:
\r
690 root node is stored in com->node
\r
691 protos are stored in com->new_proto_list
\r
692 routes are stored as RouteInsert in the same frame
\r
697 /*proto list to insert - BIFS only*/
\r
698 GF_List *new_proto_list;
\r
699 /*proto ID list to delete - BIFS only*/
\r
700 u32 *del_proto_list;
\r
701 u32 del_proto_list_size;
\r
704 /*route insert, replace and delete (BIFS only)
\r
705 fromNodeID is also used to identify operandElementId in LASeR Add/Replace
\r
712 u32 send_event_name;
\r
716 char *send_event_string;
\r
720 s32 send_event_integer;
\r
722 u32 fromFieldIndex;
\r
736 /*creates command - graph only needed for SceneReplace*/
\r
737 GF_Command *gf_sg_command_new(GF_SceneGraph *in_scene, u32 tag);
\r
738 /*deletes command*/
\r
739 void gf_sg_command_del(GF_Command *com);
\r
740 /*apply command to graph - the command content is kept unchanged for authoring purposes - THIS NEEDS TESTING AND FIXING
\r
741 @time_offset: offset for time fields if desired*/
\r
742 GF_Err gf_sg_command_apply(GF_SceneGraph *inScene, GF_Command *com, Double time_offset);
\r
743 /*apply list if command to graph - the command content is kept unchanged for authoring purposes
\r
744 @time_offset: offset for time fields if desired*/
\r
745 GF_Err gf_sg_command_apply_list(GF_SceneGraph *graph, GF_List *comList, Double time_offset);
\r
746 /*returns new commandFieldInfo structure and registers it with command*/
\r
747 GF_CommandField *gf_sg_command_field_new(GF_Command *com);
\r
748 /*clones the command in another graph - needed for uncompressed conditional in protos
\r
749 if force_clone is not set and the target graph is the same as the command graph, nodes are just registered
\r
750 with the new commands rather than cloned*/
\r
751 GF_Command *gf_sg_command_clone(GF_Command *com, GF_SceneGraph *inGraph, Bool force_clone);
\r
759 #endif /*_GF_SCENEGRAPH_H_*/
\r