📄 renderer_dev.h
字号:
typedef struct visual_render_module GF_VisualRenderer;struct visual_render_module{ /* interface declaration*/ GF_DECL_MODULE_INTERFACE /*load renderer - a pointer to the compositor is passed for later access to generic rendering stuff*/ GF_Err (*LoadRenderer)(GF_VisualRenderer *vr, GF_Renderer *compositor); /*unloads renderer*/ void (*UnloadRenderer)(GF_VisualRenderer *vr); /*the node private stack creation function. Note that some nodes are handled at a higher level thus will never get to the renderer.*/ void (*NodeInit)(GF_VisualRenderer *vr, GF_Node *node); /*signals the given node has been modified. If the module returns FALSE, the node will be marked as dirty and all its parents marked wityh DIRTY_CHILD flag*/ Bool (*NodeChanged)(GF_VisualRenderer *vr, GF_Node *node); /*signals that output size has been changed so that the module may update output scene size (2D mainly)*/ GF_Err (*RecomputeAR)(GF_VisualRenderer *vr); /*signals the scene graph has been deconnected: all vars related to the scene shall be reseted & memory cleanup done*/ void (*SceneReset)(GF_VisualRenderer *vr); /*draw the scene 1 - the first subtree to be rendered SHALL BE the main scene attached to compositor 2 - there may be other graphs to draw (such as subtitles, etc,) not related to the main scene in extra_scenes list. 3 - it is the module responsability to flush the video driver !!! The scene may be NULL, in which case the screen shall be cleared */ void (*DrawScene)(GF_VisualRenderer *vr); /*execute given event. for mouse events, x and y are in BIFS fashion (eg, from x in [-screen_width, screen_width] and y in [-screen_height, screen_height]) return 1 if event matches a pick in the scene, 0 otherwise (this avoids performing shortcuts when user clicks on object...*/ Bool (*ExecuteEvent)(GF_VisualRenderer *vr, GF_Event *event); /*signals the hw driver has been reseted to reload cfg*/ void (*GraphicsReset)(GF_VisualRenderer *vr); /*render inline scene*/ void (*RenderInline)(GF_VisualRenderer *vr, GF_Node *inline_parent, GF_Node *inline_root, void *rs); /*get viewpoints/viewports for main scene - idx is 1-based, or 0 to retrieve by viewpoint name. if idx is greater than number of viewpoints return GF_EOS*/ GF_Err (*GetViewpoint)(GF_VisualRenderer *vr, u32 viewpoint_idx, const char **outName, Bool *is_bound); /*set viewpoints/viewports for main scene given its name - idx is 1-based, or 0 to retrieve by viewpoint name if only one viewpoint is present in the scene, this will bind/unbind it*/ GF_Err (*SetViewpoint)(GF_VisualRenderer *vr, u32 viewpoint_idx, const char *viewpoint_name); /*execut action as defined in gpac/scenegraph.h */ Bool (*ScriptAction)(GF_VisualRenderer *vr, u32 type, GF_Node *n, GF_JSAPIParam *param); /*natural texture handling (image & video)*/ /*allocates hw texture*/ GF_Err (*AllocTexture)(GF_TextureHandler *hdl); /*releases hw texture*/ void (*ReleaseTexture)(GF_TextureHandler *hdl); /*push texture data*/ GF_Err (*SetTextureData)(GF_TextureHandler *hdl); /*signal HW reset in case the driver needs to reload texture*/ void (*TextureHWReset)(GF_TextureHandler *hdl); /*set/get option*/ GF_Err (*SetOption)(GF_VisualRenderer *vr, u32 option, u32 value); u32 (*GetOption)(GF_VisualRenderer *vr, u32 option); /*get/release video memory - READ ONLY*/ GF_Err (*GetScreenBuffer)(GF_VisualRenderer *vr, GF_VideoSurface *framebuffer); /*releases screen buffer and unlocks graph*/ GF_Err (*ReleaseScreenBuffer)(GF_VisualRenderer *vr, GF_VideoSurface *framebuffer); /*set to true if needs an OpenGL context - MUST be set when interface is created (before LoadRenderer)*/ Bool bNeedsGL; /*user private*/ void *user_priv;};/* Audio mixer - MAX 6 CHANNELS SUPPORTED*//*the audio object as used by the mixer. All audio nodes need to implement this interface*/typedef struct _audiointerface{ /*fetch audio data for a given audio delay (~soundcard drift) - if delay is 0 sync should not be performed (eg intermediate mix) */ char *(*FetchFrame) (void *callback, u32 *size, u32 audio_delay_ms); /*release a number of bytes in the indicated frame (ts)*/ void (*ReleaseFrame) (void *callback, u32 nb_bytes); /*get media speed*/ Fixed (*GetSpeed)(void *callback); /*gets volume for each channel - vol = Fixed[6]. returns 1 if volume shall be changed (!= 1.0)*/ Bool (*GetChannelVolume)(void *callback, Fixed *vol); /*returns 1 if muted*/ Bool (*IsMuted)(void *callback); /*user callback*/ void *callback; /*returns 0 if config is not known yet or changed, otherwise AND IF @for_reconf is set, updates member var below and return TRUE You may return 0 to force parent user invalidation*/ Bool (*GetConfig)(struct _audiointerface *ai, Bool for_reconf); /*updated cfg, or 0 otherwise*/ u32 chan, bps, sr, ch_cfg;} GF_AudioInterface;typedef struct __audiomix GF_AudioMixer;/*create mixer - ar is NULL for any sub-mixers, or points to the main audio renderer (mixer outputs to sound driver)*/GF_AudioMixer *gf_mixer_new(struct _audio_render *ar);void gf_mixer_del(GF_AudioMixer *am);void gf_mixer_remove_all(GF_AudioMixer *am);void gf_mixer_add_input(GF_AudioMixer *am, GF_AudioInterface *src);void gf_mixer_remove_input(GF_AudioMixer *am, GF_AudioInterface *src);void gf_mixer_lock(GF_AudioMixer *am, Bool lockIt);/*mix inputs in buffer, return number of bytes written to output*/u32 gf_mixer_get_output(GF_AudioMixer *am, void *buffer, u32 buffer_size);/*reconfig all sources if needed - returns TRUE if main audio config changedNOTE: this is called at each gf_mixer_get_output by the mixer. To call externally for audio hardwarereconfiguration only*/Bool gf_mixer_reconfig(GF_AudioMixer *am);/*retrieves mixer cfg*/void gf_mixer_get_config(GF_AudioMixer *am, u32 *outSR, u32 *outCH, u32 *outBPS, u32 *outChCfg);/*called by audio renderer in case the hardware used a different setup than requested*/void gf_mixer_set_config(GF_AudioMixer *am, u32 outSR, u32 outCH, u32 outBPS, u32 ch_cfg);Bool gf_mixer_is_src_present(GF_AudioMixer *am, GF_AudioInterface *ifce);u32 gf_mixer_get_src_count(GF_AudioMixer *am);void gf_mixer_force_chanel_out(GF_AudioMixer *am, u32 num_channels);u32 gf_mixer_get_block_align(GF_AudioMixer *am);Bool gf_mixer_must_reconfig(GF_AudioMixer *am);enum{ GF_SR_AUDIO_NO_RESYNC = (1), GF_SR_AUDIO_NO_MULTI_CH = (1<<1),};/*the audio renderer*/typedef struct _audio_render{ GF_AudioOutput *audio_out; u32 flags; /*startup time (the audio renderer is used when present as the system clock)*/ u32 startTime; /*frozen time counter if set*/ Bool Frozen; u32 FreezeTime; /*final output*/ GF_AudioMixer *mixer; Bool need_reconfig; /*client*/ GF_User *user; /*audio thread if output not self-threaded*/ GF_Thread *th; /*thread state: 0: not intit, 1: running, 2: waiting for stop, 3: done*/ u32 audio_th_state; u32 audio_delay, volume, pan;} GF_AudioRenderer;/*creates audio renderer*/GF_AudioRenderer *gf_sr_ar_load(GF_User *user);/*deletes audio renderer*/void gf_sr_ar_del(GF_AudioRenderer *ar);/*control audio renderer - CtrlType: 0: pause 1: resume 2: clean HW buffer and play*/void gf_sr_ar_control(GF_AudioRenderer *ar, u32 CtrlType);/*set volume and pan*/void gf_sr_ar_set_volume(GF_AudioRenderer *ar, u32 Volume);void gf_sr_ar_set_pan(GF_AudioRenderer *ar, u32 Balance);/*set audio priority*/void gf_sr_ar_set_priority(GF_AudioRenderer *ar, u32 priority);/*gets time in msec - this is the only clock used by the whole ESM system - depends on the audio driver*/u32 gf_sr_ar_get_clock(GF_AudioRenderer *ar);/*reset all input nodes*/void gf_sr_ar_reset(GF_AudioRenderer *ar);/*add audio node*/void gf_sr_ar_add_src(GF_AudioRenderer *ar, GF_AudioInterface *source);/*remove audio node*/void gf_sr_ar_remove_src(GF_AudioRenderer *ar, GF_AudioInterface *source);/*reconfig audio hardware if needed*/void gf_sr_ar_reconfig(GF_AudioRenderer *ar);u32 gf_sr_ar_get_delay(GF_AudioRenderer *ar);/*the sound node interface for intensity & spatialization*/typedef struct _soundinterface{ /*gets volume for each channel - vol = Fixed[6]. returns 1 if volume shall be changed (!= 1.0) if NULL channels are always at full intensity*/ Bool (*GetChannelVolume)(GF_Node *owner, Fixed *vol); /*get sound priority (0: min, 255: max) - used by mixer to determine*/ u8 (*GetPriority) (GF_Node *owner); /*node owning the structure*/ GF_Node *owner;} GF_SoundInterface;/*audio common to AudioClip and AudioSource*/typedef struct{ GF_Node *owner; GF_Renderer *compositor; GF_AudioInterface input_ifce; /*can be NULL if the audio node generates its output from other input*/ GF_MediaObject *stream; /*object speed and intensity*/ Fixed speed, intensity; Bool stream_finished; Bool need_release; MFURL url; Bool is_open, is_muted; Bool register_with_renderer, register_with_parent; GF_SoundInterface *snd;} GF_AudioInput;/*setup interface with audio renderer - overwrite any functions needed after setup EXCEPT callback object*/void gf_sr_audio_setup(GF_AudioInput *ai, GF_Renderer *sr, GF_Node *node);/*open audio object*/GF_Err gf_sr_audio_open(GF_AudioInput *ai, MFURL *url, Double clipBegin, Double clipEnd);/*closes audio object*/void gf_sr_audio_stop(GF_AudioInput *ai);/*restarts audio object (cf note in MediaObj)*/void gf_sr_audio_restart(GF_AudioInput *ai);Bool gf_sr_audio_check_url(GF_AudioInput *ai, MFURL *url);/*base grouping audio node (nodes with several audio sources as children)*/#define AUDIO_GROUP_NODE \ GF_AudioInput output; \ void (*add_source)(struct _audio_group *_this, GF_AudioInput *src); \typedef struct _audio_group{ AUDIO_GROUP_NODE} GF_AudioGroup;enum{ /*part of a switched-off subtree (needed for audio)*/ GF_SR_TRAV_SWITCHED_OFF = (1<<1),};/*base class for the traversing context: this is needed so that audio renderer can work without knowledge ofthe used graphics driver. All traversing contexts must derive from this onerend_flag (needed for audio): one of the above*/#ifdef GPAC_DISABLE_SVG#define BASE_EFFECT_CLASS \ struct _audio_group *audio_parent; \ GF_SoundInterface *sound_holder; \ u32 trav_flags; \#else#define BASE_EFFECT_CLASS \ struct _audio_group *audio_parent; \ GF_SoundInterface *sound_holder; \ u32 trav_flags; \ SVGPropertiesPointers *svg_props; \ u32 svg_flags; \#endiftypedef struct { BASE_EFFECT_CLASS } GF_BaseEffect;/*register audio node with parent audio renderer (mixer or main renderer)*/void gf_sr_audio_register(GF_AudioInput *ai, GF_BaseEffect *eff);void gf_sr_audio_unregister(GF_AudioInput *ai);#ifndef GPAC_DISABLE_SVGBool gf_term_check_iri_change(GF_Terminal *term, MFURL *url, XMLRI *iri);Bool gf_term_set_mfurl_from_uri(GF_Terminal *sr, MFURL *mfurl, XMLRI *iri);#endif#endif /*_GF_RENDERER_DEV_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -