void compositor_imagetexture_modified(GF_Node *node) { MFURL url; SFURL sfurl; GF_TextureHandler *txh = (GF_TextureHandler *) gf_node_get_private(node); if (!txh) return; if (gf_node_get_tag(node)!=TAG_MPEG4_CacheTexture) { url = ((M_ImageTexture *) node)->url; } else { url.count = 1; sfurl.OD_ID=GF_MEDIA_EXTERNAL_ID; sfurl.url = ((M_CacheTexture *) node)->image.buffer; url.vals = &sfurl; } /*if open and changed, stop and play*/ if (txh->is_open) { if (! gf_sc_texture_check_url_change(txh, &url)) return; gf_sc_texture_stop(txh); gf_sc_texture_play(txh, &url); return; } /*if not open and changed play*/ if (url.count) gf_sc_texture_play(txh, &url); }
static void movietexture_deactivate(MovieTextureStack *stack, M_MovieTexture *mt) { mt->isActive = 0; gf_node_event_out((GF_Node*)mt, 8/*"isActive"*/); stack->time_handle.needs_unregister = 1; if (stack->txh.is_open) { gf_sc_texture_stop(&stack->txh); } }
GF_EXPORT void gf_sc_texture_destroy(GF_TextureHandler *txh) { GF_Compositor *compositor = txh->compositor; Bool lock = gf_mx_try_lock(compositor->mx); gf_sc_texture_release(txh); if (txh->is_open) gf_sc_texture_stop(txh); gf_list_del_item(txh->compositor->textures, txh); if (lock) gf_mx_v(compositor->mx); }
static void back_check_gf_sc_texture_change(GF_TextureHandler *txh, MFURL *url) { /*if open and changed, stop and play*/ if (txh->is_open) { if (! gf_sc_texture_check_url_change(txh, url)) return; gf_sc_texture_stop(txh); gf_sc_texture_play(txh, url); return; } /*if not open and changed play*/ if (url->count) gf_sc_texture_play(txh, url); }
static void svg_play_texture(SVG_video_stack *stack, SVGAllAttributes *atts) { SVGAllAttributes all_atts; Bool lock_scene = GF_FALSE; if (stack->txh.is_open) gf_sc_texture_stop(&stack->txh); if (!atts) { gf_svg_flatten_attributes((SVG_Element*)stack->txh.owner, &all_atts); atts = &all_atts; } if (atts->syncBehavior) lock_scene = (*atts->syncBehavior == SMIL_SYNCBEHAVIOR_LOCKED) ? GF_TRUE : GF_FALSE; gf_sc_texture_play_from_to(&stack->txh, &stack->txurl, atts->clipBegin ? (*atts->clipBegin) : 0.0, atts->clipEnd ? (*atts->clipEnd) : -1.0, GF_FALSE, lock_scene); }
void compositor_movietexture_modified(GF_Node *node) { M_MovieTexture *mt = (M_MovieTexture *)node; MovieTextureStack *st = (MovieTextureStack *) gf_node_get_private(node); if (!st) return; /*if open and changed, stop and play*/ if (gf_sc_texture_check_url_change(&st->txh, &mt->url)) { if (st->txh.is_open) gf_sc_texture_stop(&st->txh); if (mt->isActive) gf_sc_texture_play(&st->txh, &mt->url); } /*update state if we're active*/ else if (mt->isActive) { movietexture_update_time(&st->time_handle); if (!mt->isActive) return; } /*reregister if needed*/ st->time_handle.needs_unregister = 0; if (!st->time_handle.is_registered) gf_sc_register_time_node(st->txh.compositor, &st->time_handle); }
void compositor_background2d_modified(GF_Node *node) { M_Background2D *bck = (M_Background2D *)node; Background2DStack *st = (Background2DStack *) gf_node_get_private(node); if (!st) return; /*dirty node and parents in order to trigger parent visual redraw*/ gf_node_dirty_set(node, 0, 1); /*if open and changed, stop and play*/ if (st->txh.is_open) { if (! gf_sc_texture_check_url_change(&st->txh, &bck->url)) return; gf_sc_texture_stop(&st->txh); gf_sc_texture_play(&st->txh, &bck->url); return; } /*if not open and changed play*/ if (bck->url.count) gf_sc_texture_play(&st->txh, &bck->url); gf_sc_invalidate(st->txh.compositor, NULL); }
static void movietexture_update(GF_TextureHandler *txh) { M_MovieTexture *txnode = (M_MovieTexture *) txh->owner; MovieTextureStack *st = (MovieTextureStack *) gf_node_get_private(txh->owner); /*setup texture if needed*/ if (!txh->is_open) return; if (!txnode->isActive && st->first_frame_fetched) return; /*when fetching the first frame disable resync*/ gf_sc_texture_update_frame(txh, !txnode->isActive); if (txh->stream_finished) { if (movietexture_get_loop(st, txnode)) { gf_sc_texture_restart(txh); } /*if active deactivate*/ else if (txnode->isActive && gf_mo_should_deactivate(st->txh.stream) ) { movietexture_deactivate(st, txnode); } } /*first frame is fetched*/ if (!st->first_frame_fetched && (txh->needs_refresh) ) { st->first_frame_fetched = 1; txnode->duration_changed = gf_mo_get_duration(txh->stream); gf_node_event_out_str(txh->owner, "duration_changed"); /*stop stream if needed*/ if (!txnode->isActive && txh->is_open) { gf_sc_texture_stop(txh); /*make sure the refresh flag is not cleared*/ txh->needs_refresh = 1; } } if (txh->needs_refresh) { /*mark all subtrees using this image as dirty*/ gf_node_dirty_parents(txh->owner); gf_sc_invalidate(txh->compositor, NULL); } }
void compositor_svg_video_modified(GF_Compositor *compositor, GF_Node *node) { /*if href has been modified, stop the video (and associated audio if any) right away - we cannot wait for next traversal to process this as the video could be in a hidden subtree not traversed*/ if (gf_node_dirty_get(node) & GF_SG_SVG_XLINK_HREF_DIRTY) { SVG_video_stack *st = (SVG_video_stack *)gf_node_get_private(node); /*WARNING - stack may be NULL at this point when inserting the video from script*/ if (st && st->txh.is_open) { if (st->audio) { svg_audio_smil_evaluate_ex(NULL, 0, SMIL_TIMING_EVAL_REMOVE, st->audio, st->txh.owner); gf_node_unregister(st->audio, NULL); st->audio = NULL; } /*reset cached URL to avoid reopening the resource in the smil timing callback*/ gf_sg_vrml_mf_reset(&st->txurl, GF_SG_VRML_MFURL); gf_sc_texture_stop(&st->txh); } } gf_node_dirty_set(node, 0, GF_FALSE); /*and force a redraw of next frame*/ gf_sc_next_frame_state(compositor, GF_SC_DRAW_FRAME); }
static void SVG_Update_video(GF_TextureHandler *txh) { GF_FieldInfo init_vis_info; SVG_video_stack *stack = (SVG_video_stack *) gf_node_get_private(txh->owner); if (!txh->is_open) { SVG_InitialVisibility init_vis; if (stack->first_frame_fetched) return; init_vis = SVG_INITIALVISIBILTY_WHENSTARTED; if (gf_node_get_attribute_by_tag(txh->owner, TAG_SVG_ATT_initialVisibility, GF_FALSE, GF_FALSE, &init_vis_info) == GF_OK) { init_vis = *(SVG_InitialVisibility *)init_vis_info.far_ptr; } /*opens stream only at first access to fetch first frame if needed*/ if (init_vis == SVG_INITIALVISIBILTY_ALWAYS) { svg_play_texture((SVG_video_stack*)stack, NULL); gf_sc_invalidate(txh->compositor, NULL); } return; } /*when fetching the first frame disable resync*/ gf_sc_texture_update_frame(txh, GF_FALSE); /* only when needs_refresh = 1, first frame is fetched */ if (!stack->first_frame_fetched) { if (txh->needs_refresh) { stack->first_frame_fetched = GF_TRUE; /*stop stream if needed*/ if (!gf_smil_timing_is_active(txh->owner)) { gf_sc_texture_stop(txh); //make sure the refresh flag is not cleared txh->needs_refresh = GF_TRUE; } } } if (!stack->audio && stack->audio_dirty) { u32 res = gf_mo_has_audio(stack->txh.stream); if (res != 2) { stack->audio_dirty = GF_FALSE; if (res) { GF_FieldInfo att_vid, att_aud; stack->audio = gf_node_new(gf_node_get_graph(stack->txh.owner), TAG_SVG_audio); gf_node_register(stack->audio, NULL); if (gf_node_get_attribute_by_tag(stack->txh.owner, TAG_XLINK_ATT_href, GF_FALSE, GF_FALSE, &att_vid)==GF_OK) { gf_node_get_attribute_by_tag(stack->audio, TAG_XLINK_ATT_href, GF_TRUE, GF_FALSE, &att_aud); gf_svg_attributes_copy(&att_aud, &att_vid, GF_FALSE); } /*BYPASS SMIL TIMING MODULE!!*/ compositor_init_svg_audio(stack->txh.compositor, stack->audio, GF_TRUE); } } } /*we have no choice but retraversing the graph until we're inactive since the movie framerate and the compositor framerate are likely to be different */ if (!txh->stream_finished) if (txh->needs_refresh) gf_sc_invalidate(txh->compositor, NULL); if (stack->stop_requested) { stack->stop_requested = GF_FALSE; gf_sc_texture_stop(&stack->txh); } }