Ejemplo n.º 1
0
static GF_Err VTT_AttachScene(GF_SceneDecoder *plug, GF_Scene *scene, Bool is_scene_decoder)
{
	VTTDec *vttdec = (VTTDec *)plug->privateStack;
	/*WebVTT cannot be a root scene object*/
	//if (is_scene_decoder) return GF_BAD_PARAM;
	vttdec->scene = scene;
	vttdec->terminal = scene->root_od->term;

	vttdec->sg = gf_sg_new_subscene(vttdec->scene->graph);
	VTT_load_script(vttdec, vttdec->sg);
	//vtt_create_text_node(vttdec, 2000, GF_TRUE);
	return GF_OK;
}
Ejemplo n.º 2
0
static GF_Err TTD_AttachStream(GF_BaseDecoder *plug, GF_ESD *esd)
{
	TTDPriv *priv = (TTDPriv *)plug->privateStack;
	GF_Err e;
	GF_Node *root, *n1, *n2;
	const char *opt;
	/*no scalable, no upstream*/
	if (priv->nb_streams || esd->decoderConfig->upstream) return GF_NOT_SUPPORTED;
	if (!esd->decoderConfig->decoderSpecificInfo || !esd->decoderConfig->decoderSpecificInfo->data) return GF_NON_COMPLIANT_BITSTREAM;

	priv->cfg = (GF_TextConfig *) gf_odf_desc_new(GF_ODF_TEXT_CFG_TAG);
	e = gf_odf_get_text_config(esd->decoderConfig->decoderSpecificInfo, (u8) esd->decoderConfig->objectTypeIndication, priv->cfg);
	if (e) {
		gf_odf_desc_del((GF_Descriptor *) priv->cfg);
		priv->cfg = NULL;
		return e;
	}
	priv->nb_streams++;
	if (!priv->cfg->timescale) priv->cfg->timescale = 1000;

	priv->sg = gf_sg_new_subscene(priv->inlineScene->graph);

	root = ttd_create_node(priv, TAG_MPEG4_OrderedGroup, NULL);
	gf_sg_set_root_node(priv->sg, root);
	gf_node_register(root, NULL);
	/*root transform*/
	priv->tr_track = (M_Transform2D *)ttd_create_node(priv, TAG_MPEG4_Transform2D, NULL);
	add_child((GF_Node *) priv->tr_track, root);

	TTD_UpdateSizeInfo(priv);

	/*txt track background*/
	n1 = ttd_create_node(priv, TAG_MPEG4_Shape, NULL);
	add_child(n1, (GF_Node *) priv->tr_track);
	((M_Shape *)n1)->appearance = ttd_create_node(priv, TAG_MPEG4_Appearance, NULL);
	gf_node_register(((M_Shape *)n1)->appearance, n1);
	priv->mat_track = (M_Material2D *) ttd_create_node(priv, TAG_MPEG4_Material2D, NULL);
	priv->mat_track->filled = 1;
	priv->mat_track->transparency = 1;
	((M_Appearance *) ((M_Shape *)n1)->appearance)->material = (GF_Node *) priv->mat_track;
	gf_node_register((GF_Node *) priv->mat_track, ((M_Shape *)n1)->appearance);
	n2 = ttd_create_node(priv, TAG_MPEG4_Rectangle, NULL);
	((M_Rectangle *)n2)->size.x = 0;
	((M_Rectangle *)n2)->size.y = 0;
	((M_Shape *)n1)->geometry = n2;
	gf_node_register(n2, n1);
	priv->rec_track = (M_Rectangle *)n2;

	/*txt box background*/
	priv->tr_box = (M_Transform2D *) ttd_create_node(priv, TAG_MPEG4_Transform2D, NULL);
	add_child((GF_Node*) priv->tr_box, (GF_Node*)priv->tr_track);
	n1 = ttd_create_node(priv, TAG_MPEG4_Shape, NULL);
	add_child(n1, (GF_Node*)priv->tr_box);
	((M_Shape *)n1)->appearance = ttd_create_node(priv, TAG_MPEG4_Appearance, NULL);
	gf_node_register(((M_Shape *)n1)->appearance, n1);
	priv->mat_box = (M_Material2D *) ttd_create_node(priv, TAG_MPEG4_Material2D, NULL);
	priv->mat_box->filled = 1;
	priv->mat_box->transparency = 1;
	((M_Appearance *) ((M_Shape *)n1)->appearance)->material = (GF_Node *)priv->mat_box;
	gf_node_register((GF_Node *)priv->mat_box, ((M_Shape *)n1)->appearance);
	priv->rec_box = (M_Rectangle *) ttd_create_node(priv, TAG_MPEG4_Rectangle, NULL);
	priv->rec_box->size.x = 0;
	priv->rec_box->size.y = 0;
	((M_Shape *)n1)->geometry = (GF_Node *) priv->rec_box;
	gf_node_register((GF_Node *) priv->rec_box, n1);

	priv->dlist = (M_Layer2D *) ttd_create_node(priv, TAG_MPEG4_Layer2D, NULL);
	priv->dlist->size.x = priv->cfg->text_width;
	priv->dlist->size.y = priv->cfg->text_height;
	add_child((GF_Node *)priv->dlist, (GF_Node *)priv->tr_box);

	priv->blink_nodes = gf_list_new();
	priv->ts_blink = (M_TimeSensor *) ttd_create_node(priv, TAG_MPEG4_TimeSensor, "TimerBlink");
	priv->ts_blink->cycleInterval = 0.25;
	priv->ts_blink->startTime = 0.0;
	priv->ts_blink->loop = 1;
	priv->process_blink = (M_ScalarInterpolator *) ttd_create_node(priv, TAG_MPEG4_ScalarInterpolator, NULL);
	/*override set_fraction*/
	priv->process_blink->on_set_fraction = ttd_set_blink_fraction;
	gf_node_set_private((GF_Node *) priv->process_blink, priv);
	/*route from fraction_changed to set_fraction*/
	gf_sg_route_new(priv->sg, (GF_Node *) priv->ts_blink, 6, (GF_Node *) priv->process_blink, 0);

	priv->ts_scroll = (M_TimeSensor *) ttd_create_node(priv, TAG_MPEG4_TimeSensor, "TimerScroll");
	priv->ts_scroll->cycleInterval = 0;
	priv->ts_scroll->startTime = -1;
	priv->ts_scroll->loop = 0;
	priv->process_scroll = (M_ScalarInterpolator *) ttd_create_node(priv, TAG_MPEG4_ScalarInterpolator, NULL);
	/*override set_fraction*/
	priv->process_scroll->on_set_fraction = ttd_set_scroll_fraction;
	gf_node_set_private((GF_Node *) priv->process_scroll, priv);
	/*route from fraction_changed to set_fraction*/
	gf_sg_route_new(priv->sg, (GF_Node *) priv->ts_scroll, 6, (GF_Node *) priv->process_scroll, 0);

	gf_node_register((GF_Node *) priv->ts_blink, NULL);
	gf_node_register((GF_Node *) priv->process_blink, NULL);
	gf_node_register((GF_Node *) priv->ts_scroll, NULL);
	gf_node_register((GF_Node *) priv->process_scroll, NULL);

	/*option setup*/
	opt = gf_modules_get_option((GF_BaseInterface *)plug, "StreamingText", "UseTexturing");
	priv->use_texture = (opt && !strcmp(opt, "yes")) ? 1 : 0;
	opt = gf_modules_get_option((GF_BaseInterface *)plug, "StreamingText", "OutlineText");
	priv->outline = (opt && !strcmp(opt, "yes")) ? 1 : 0;
	return e;
}