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 Compositor 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
25 #ifndef _GF_COMPOSITOR_H_
\r
26 #define _GF_COMPOSITOR_H_
\r
33 /*include scene graph API*/
\r
34 #include <gpac/scenegraph.h>
\r
35 /*GF_User and GF_Terminal */
\r
36 #include <gpac/user.h>
\r
37 /*frame buffer definition*/
\r
38 #include <gpac/color.h>
\r
40 typedef struct __tag_compositor GF_Compositor;
\r
42 /*creates default compositor
\r
43 if self_threaded, video compositor uses a dedicated thread, otherwise visual rendering is done by the user
\r
44 audio compositor always runs in its own thread if enabled
\r
45 term may be NULL, in which case InputSensors won't be enabled
\r
47 GF_Compositor *gf_sc_new(GF_User *user_interface, Bool self_threaded, GF_Terminal *term);
\r
48 void gf_sc_del(GF_Compositor *sr);
\r
50 /*sets simulation frame rate*/
\r
51 void gf_sc_set_fps(GF_Compositor *sr, Double fps);
\r
53 /*set the root scene graph of the compositor - if NULL remove current and reset simulation time*/
\r
54 GF_Err gf_sc_set_scene(GF_Compositor *sr, GF_SceneGraph *scene_graph);
\r
56 /*if the compositor doesn't use its own thread for visual, this will perform a render pass*/
\r
57 Bool gf_sc_draw_frame(GF_Compositor *sr);
\r
59 /*inits rendering info for the node - shall be called for all nodes the parent system doesn't handle*/
\r
60 void gf_sc_on_node_init(GF_Compositor *sr, GF_Node *node);
\r
62 /*notify the given node has been modified. The compositor filters object to decide whether the scene graph has to be
\r
63 traversed or not- if object is NULL, this means complete traversing of the graph is requested (use carefully since it
\r
64 can be a time consuming operation)*/
\r
65 void gf_sc_invalidate(GF_Compositor *sr, GF_Node *byObj);
\r
67 /*return the compositor time - this is the time every time line syncs on*/
\r
68 u32 gf_sc_get_clock(GF_Compositor *sr);
\r
71 /*locks/unlocks the visual scene rendering - modification of the scene tree shall only happen when scene compositor is locked*/
\r
72 void gf_sc_lock(GF_Compositor *sr, Bool doLock);
\r
73 /*locks/unlocks the audio scene rendering - this is needed whenever an audio object changes config on the fly*/
\r
74 void gf_sc_lock_audio(GF_Compositor *sr, Bool doLock);
\r
76 /*notify user input - returns 0 if event hasn't been handled by the compositor*/
\r
77 Bool gf_sc_user_event(GF_Compositor *sr, GF_Event *event);
\r
79 /*maps screen coordinates to bifs 2D coordinates for the current zoom/pan settings
\r
80 X and Y are point coordinates in the display expressed in BIFS-like fashion (0,0) at center of
\r
81 display and Y increasing from bottom to top*/
\r
82 void gf_sc_map_point(GF_Compositor *sr, s32 X, s32 Y, Fixed *bifsX, Fixed *bifsY);
\r
84 /*signal the size of the display area has been changed*/
\r
85 GF_Err gf_sc_size_changed(GF_Compositor *sr, u32 NewWidth, u32 NewHeight);
\r
87 /*set/get user options - options are as defined in user.h*/
\r
88 GF_Err gf_sc_set_option(GF_Compositor *sr, u32 type, u32 value);
\r
89 u32 gf_sc_get_option(GF_Compositor *sr, u32 type);
\r
91 /*returns current FPS
\r
92 if @absoluteFPS is set, the return value is the absolute framerate, eg NbFrameCount/NbTimeSpent regardless of
\r
93 whether a frame has been drawn or not, which means the FPS returned can be much greater than the compositor FPS
\r
94 if @absoluteFPS is not set, the return value is the FPS taking into account not drawn frames (eg, less than or equal to
\r
97 Double gf_sc_get_fps(GF_Compositor *sr, Bool absoluteFPS);
\r
99 Bool gf_sc_has_text_selection(GF_Compositor *compositor);
\r
100 const char *gf_sc_get_selected_text(GF_Compositor *compositor);
\r
102 GF_Err gf_sc_paste_text(GF_Compositor *compositor, const char *text);
\r
104 /*user-define management: this is used for instant visual rendering of the scene graph,
\r
105 for exporting or authoring tools preview. User is responsible for calling render when desired and shall also maintain
\r
108 /*force render tick*/
\r
109 void gf_sc_render(GF_Compositor *sr);
\r
110 /*gets screen buffer - this locks the scene graph too until released is called*/
\r
111 GF_Err gf_sc_get_screen_buffer(GF_Compositor *sr, GF_VideoSurface *framebuffer, Bool depth_buffer);
\r
112 /*releases screen buffer and unlocks graph*/
\r
113 GF_Err gf_sc_release_screen_buffer(GF_Compositor *sr, GF_VideoSurface *framebuffer);
\r
115 /*renders one frame*/
\r
116 void gf_sc_simulation_tick(GF_Compositor *sr);
\r
118 /*forces graphics cache recompute*/
\r
119 void gf_sc_reset_graphics(GF_Compositor *sr);
\r
121 /*picks a node (may return NULL) - coords are given in OS client system coordinate, as in UserInput*/
\r
122 GF_Node *gf_sc_pick_node(GF_Compositor *sr, s32 X, s32 Y);
\r
124 /*get viewpoints/viewports for main scene - idx is 1-based, and if greater than number of viewpoints return GF_EOS*/
\r
125 GF_Err gf_sc_get_viewpoint(GF_Compositor *sr, u32 viewpoint_idx, const char **outName, Bool *is_bound);
\r
126 /*set viewpoints/viewports for main scene given its name - idx is 1-based, or 0 to retrieve by viewpoint name
\r
127 if only one viewpoint is present in the scene, this will bind/unbind it*/
\r
128 GF_Err gf_sc_set_viewpoint(GF_Compositor *sr, u32 viewpoint_idx, const char *viewpoint_name);
\r
130 /*render subscene root node. rs is the current traverse stack
\r
131 this is needed to handle graph metrics changes between scenes...*/
\r
132 void gf_sc_traverse_subscene(GF_Compositor *sr, GF_Node *inline_parent, GF_SceneGraph *subscene, void *rs);
\r
134 /*set outupt size*/
\r
135 GF_Err gf_sc_set_size(GF_Compositor *sr, u32 NewWidth, u32 NewHeight);
\r
136 /*get outupt size*/
\r
137 Bool gf_sc_get_size(GF_Compositor *sr, u32 *Width, u32 *Height);
\r
139 /*returns total length of audio hardware buffer in ms, 0 if no audio*/
\r
140 u32 gf_sc_get_audio_buffer_length(GF_Compositor *sr);
\r
142 /*add/remove extra scene from compositor (extra scenes are OSDs or any other scene graphs not directly
\r
143 usable by main scene, like 3GP text streams*/
\r
144 void gf_sc_register_extra_graph(GF_Compositor *sr, GF_SceneGraph *extra_scene, Bool do_remove);
\r
146 /*gets audio hardware delay*/
\r
147 u32 gf_sc_get_audio_delay(GF_Compositor *sr);
\r
149 /*returns total length of audio hardware buffer in ms, 0 if no audio*/
\r
150 u32 gf_sc_get_audio_buffer_length(GF_Compositor *sr);
\r
152 void *gf_sc_get_visual_compositor(GF_Compositor *sr);
\r
154 GF_Compositor *gf_sc_get_compositor(GF_Node *node);
\r
156 Bool gf_sc_script_action(GF_Compositor *sr, u32 type, GF_Node *n, GF_JSAPIParam *param);
\r
163 #endif /*_GF_COMPOSITOR_H_*/
\r