Beispiel #1
0
static void svg_traverse_updates(GF_Node *node, void *rs, Bool is_destroy)
{
	/*video stack is just an extension of image stack, type-casting is OK*/
	SVG_updates_stack *stack = (SVG_updates_stack*)gf_node_get_private(node);
	GF_TraverseState *tr_state = (GF_TraverseState *)rs;
	SVGAllAttributes all_atts;
	SVGPropertiesPointers backup_props;
	u32 backup_flags, dirty_flags;

	if (is_destroy) {
		if (stack->resource) {
			if (stack->is_open) {
				gf_mo_set_flag(stack->resource, GF_MO_DISPLAY_REMOVE, GF_TRUE);
				gf_mo_stop(stack->resource);
			}
			gf_mo_unregister(node, stack->resource);
		}
		gf_free(stack);
		return;
	} 

	if (tr_state->traversing_mode!=TRAVERSE_SORT) return;

	/*flatten attributes and apply animations + inheritance*/
	gf_svg_flatten_attributes((SVG_Element *)node, &all_atts);
	if (!compositor_svg_traverse_base(node, &all_atts, (GF_TraverseState *)rs, &backup_props, &backup_flags))
		return;

	dirty_flags = gf_node_dirty_get(node);
	if (dirty_flags) {
		stack->clipBegin = all_atts.clipBegin ? *all_atts.clipBegin : 0;
		stack->clipEnd = all_atts.clipEnd ? *all_atts.clipEnd : -1;
		if (dirty_flags & GF_SG_SVG_XLINK_HREF_DIRTY) {
			GF_MediaObject *new_res;
			MFURL url;
			Bool lock_timeline=GF_FALSE;
			url.vals = NULL;
			url.count = 0;

			if (all_atts.syncBehavior) lock_timeline = (*all_atts.syncBehavior == SMIL_SYNCBEHAVIOR_LOCKED) ? GF_TRUE : GF_FALSE;

			gf_term_get_mfurl_from_xlink(node, &url);

			new_res = gf_mo_register(node, &url, lock_timeline, GF_FALSE);
			gf_sg_mfurl_del(url);
			
			if (stack->resource!=new_res) {
				if (stack->resource) {
					gf_mo_stop(stack->resource);
					gf_mo_unregister(node, stack->resource);
				}
				stack->resource = new_res;
				if (stack->resource && stack->is_open) gf_mo_play(stack->resource, stack->clipBegin, stack->clipEnd, GF_FALSE);
			}
		}
		gf_node_dirty_clear(node, 0);
	}
	memcpy(tr_state->svg_props, &backup_props, sizeof(SVGPropertiesPointers));
	tr_state->svg_flags = backup_flags;
}
Beispiel #2
0
static void animationstream_check_url(AnimationStreamStack *stack, M_AnimationStream *as)
{
    if (!stack->stream) {
        gf_sg_vrml_mf_reset(&stack->current_url, GF_SG_VRML_MFURL);
        gf_sg_vrml_field_copy(&stack->current_url, &as->url, GF_SG_VRML_MFURL);
        stack->stream = gf_mo_register((GF_Node *)as, &as->url, 0, 0);
        gf_sc_invalidate(stack->compositor, NULL);

        /*if changed while playing trigger*/
        if (as->isActive) {
            gf_mo_play(stack->stream, 0, -1, 0);
            gf_mo_set_speed(stack->stream, as->speed);
        }
        return;
    }
    /*check change*/
    if (gf_mo_url_changed(stack->stream, &as->url)) {
        gf_sg_vrml_mf_reset(&stack->current_url, GF_SG_VRML_MFURL);
        gf_sg_vrml_field_copy(&stack->current_url, &as->url, GF_SG_VRML_MFURL);
        /*if changed while playing stop old source*/
        if (as->isActive) {
            gf_mo_set_flag(stack->stream, GF_MO_DISPLAY_REMOVE, 1);
            gf_mo_stop(stack->stream);
        }
        gf_mo_unregister((GF_Node *)as, stack->stream);

        stack->stream = gf_mo_register((GF_Node *)as, &as->url, 0, 0);
        /*if changed while playing play new source*/
        if (as->isActive) {
            gf_mo_play(stack->stream, 0, -1, 0);
            gf_mo_set_speed(stack->stream, as->speed);
        }
        gf_sc_invalidate(stack->compositor, NULL);
    }
}
Beispiel #3
0
/*
				input sensor node handling
*/
static void IS_Unregister(GF_Node *node, ISStack *st)
{
	u32 i;
	GF_ObjectManager *odm;
	ISPriv *is_dec;

	gf_mo_unregister(node, st->mo);
	
	odm = st->mo->odm;
	if (!odm) return;

	assert(odm->codec && (odm->codec->type == GF_STREAM_INTERACT));

	/*get IS dec*/
	is_dec = (ISPriv*)odm->codec->decio->privateStack;
	for (i=0; i<gf_list_count(is_dec->is_nodes); i++) {
		ISStack *tmp = (ISStack *)gf_list_get(is_dec->is_nodes, i);
		if (tmp == st) {
			gf_list_rem(is_dec->is_nodes, i);
			i--;
		}
	}
	/*stop stream*/
	if (st->mo->num_open) gf_mo_stop(st->mo);
	st->mo = NULL;
	if (st->registered) {
		st->registered = 0;
		if (is_dec->io_dev && is_dec->io_dev->Stop) is_dec->io_dev->Stop(is_dec->io_dev);
	}
}
Beispiel #4
0
static void svg_updates_smil_evaluate(SMIL_Timing_RTI *rti, Fixed normalized_scene_time, u32 status)
{
	SVG_updates_stack *stack = (SVG_updates_stack *)gf_node_get_private(gf_smil_get_element(rti));

	switch (status) {
	case SMIL_TIMING_EVAL_UPDATE:
		if (!stack->is_open) { 
			if (stack->resource ) gf_mo_play(stack->resource, stack->clipBegin, stack->clipEnd, GF_FALSE);
			stack->is_open = GF_TRUE;
		}
		else if (gf_mo_is_done(stack->resource) && (gf_smil_get_media_duration(rti)<0) ) { 
			Double dur = gf_mo_get_duration(stack->resource);
			gf_smil_set_media_duration(rti, dur);
		}
		break;
	case SMIL_TIMING_EVAL_FREEZE:
	case SMIL_TIMING_EVAL_REMOVE:
		stack->is_open = GF_FALSE;
		gf_mo_set_flag(stack->resource, GF_MO_DISPLAY_REMOVE, GF_TRUE);
		gf_mo_stop(stack->resource);
		break;
	case SMIL_TIMING_EVAL_REPEAT:
		gf_mo_restart(stack->resource);
		break;
	}
}
Beispiel #5
0
static void svg_animation_smil_evaluate(SMIL_Timing_RTI *rti, Fixed normalized_scene_time, u32 status)
{
	GF_Node *node = gf_smil_get_element(rti);
	SVGlinkStack *stack = gf_node_get_private(node);
	switch (status) {
	case SMIL_TIMING_EVAL_UPDATE:
		svg_animation_smil_update(node, stack, normalized_scene_time);
		break;
	case SMIL_TIMING_EVAL_FREEZE:
		if (stack->resource) {
			gf_mo_stop(stack->resource);
			stack->needs_play = 1;
		}
		break;
	case SMIL_TIMING_EVAL_REMOVE:
		if (stack->resource) {
			svg_reset_xlink_target(node);
			gf_mo_unload_xlink_resource(node, stack->resource);
			stack->resource = NULL;
			stack->fragment_id = NULL;
			stack->inline_sg = NULL;
			gf_node_dirty_set(node, GF_SG_SVG_XLINK_HREF_DIRTY, 0);
		}
		break;
	case SMIL_TIMING_EVAL_REPEAT:
		if (stack->resource) {
			svg_reset_xlink_target(node);
			stack->fragment_id = NULL;
			stack->inline_sg = NULL;
			gf_mo_restart(stack->resource);
		}
		break;
	}
}
Beispiel #6
0
static void animationstream_deactivate(AnimationStreamStack *stack, M_AnimationStream *as)
{
    if (as->isActive) {
        as->isActive = 0;
        gf_node_event_out((GF_Node*)as, 6/*"isActive"*/);
    }
    if (stack->stream) {
        if (gf_mo_url_changed(stack->stream, &as->url))
            gf_mo_set_flag(stack->stream, GF_MO_DISPLAY_REMOVE, 1);
        gf_mo_stop(stack->stream);
    }
    stack->time_handle.needs_unregister = 1;
    gf_sc_invalidate(stack->compositor, NULL);
}
Beispiel #7
0
static void animationstream_destroy(GF_Node *node, void *rs, Bool is_destroy)
{
    if (is_destroy) {
        M_AnimationStream *as = (M_AnimationStream *)node;
        AnimationStreamStack *st = (AnimationStreamStack *) gf_node_get_private(node);

        if (st->time_handle.is_registered) {
            gf_sc_unregister_time_node(st->compositor, &st->time_handle);
        }
        if (st->stream && as->isActive) {
            gf_mo_set_flag(st->stream, GF_MO_DISPLAY_REMOVE, 1);
            gf_mo_stop(st->stream);
        }
        gf_sg_vrml_mf_reset(&st->current_url, GF_SG_VRML_MFURL);
        gf_free(st);
    }
}
Beispiel #8
0
GF_EXPORT
void gf_sc_texture_stop(GF_TextureHandler *txh)
{
	if (!txh->is_open) return;
	/*release texture WITHOUT droping frame*/
	if (txh->needs_release) {
		gf_mo_release_data(txh->stream, 0xFFFFFFFF, -1);
		txh->needs_release = 0;
	}
	gf_sc_invalidate(txh->compositor, NULL);
	if (gf_mo_stop(txh->stream)) {
		txh->data = NULL;
	}
	txh->is_open = 0;

	/*and deassociate object*/
	gf_mo_unregister(txh->owner, txh->stream);
	txh->stream = NULL;
}
Beispiel #9
0
GF_EXPORT
void gf_sc_audio_stop(GF_AudioInput *ai)
{
	if (!ai->is_open) return;
	
	/*we must make sure audio mixer is not using the stream otherwise we may leave it dirty (with unrelease frame)*/
	gf_mixer_lock(ai->compositor->audio_renderer->mixer, 1);

	assert(!ai->need_release);

	gf_mo_stop(ai->stream);
	ai->is_open = 0;
	gf_mo_unregister(ai->owner, ai->stream);
	ai->stream = NULL;

	if (ai->filter) gf_af_del(ai->filter);
	ai->filter = NULL;

	gf_mixer_lock(ai->compositor->audio_renderer->mixer, 0);

}