void VTT_load_script(VTTDec *vttdec, GF_SceneGraph *graph) { GF_Node *n, *root; GF_FieldInfo info; const char *path; FILE *jsfile; if (!graph) return; gf_sg_add_namespace(graph, "http://www.w3.org/2000/svg", NULL); gf_sg_add_namespace(graph, "http://www.w3.org/1999/xlink", "xlink"); gf_sg_add_namespace(graph, "http://www.w3.org/2001/xml-events", "ev"); gf_sg_set_scene_size_info(graph, 800, 600, GF_TRUE); /* modify the scene with an Inline/Animation pointing to the VTT Renderer */ n = root = gf_node_new(graph, TAG_SVG_svg); gf_node_register(root, NULL); gf_sg_set_root_node(graph, root); gf_node_get_attribute_by_name(n, "xmlns", 0, GF_TRUE, GF_FALSE, &info); gf_svg_parse_attribute(n, &info, "http://www.w3.org/2000/svg", 0); VTT_UpdateSizeInfo(vttdec); gf_node_init(n); n = gf_node_new(graph, TAG_SVG_script); gf_node_register(n, root); gf_node_list_add_child(&((GF_ParentNode *)root)->children, n); path = gf_modules_get_option((GF_BaseInterface *)vttdec->module, "WebVTT", "RenderingScript"); if (!path) { /* try to find the JS renderer in the default GPAC installation folder */ const char *startuppath = gf_modules_get_option((GF_BaseInterface *)vttdec->module, "General", "StartupFile"); path = gf_url_concatenate(startuppath, "webvtt-renderer.js"); jsfile = gf_fopen(path, "rt"); if (jsfile) { gf_modules_set_option((GF_BaseInterface *)vttdec->module, "WebVTT", "RenderingScript", path); gf_fclose(jsfile); } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[WebVTT] Cannot find Rendering Script [WebVTT:RenderingScript] - check config file\n")); return; } } jsfile = gf_fopen(path, "rt"); if (jsfile) { gf_fclose(jsfile); gf_node_get_attribute_by_tag(n, TAG_XLINK_ATT_href, GF_TRUE, GF_FALSE, &info); if (strstr(path, ":\\")) { gf_svg_parse_attribute(n, &info, (char *) path, 0); } else { char szPath[GF_MAX_PATH]; strcpy(szPath, "file://"); strcat(szPath, path); gf_svg_parse_attribute(n, &info, (char *) szPath, 0); } vttdec->has_rendering_script = GF_TRUE; } else { GF_LOG(GF_LOG_ERROR, GF_LOG_CODEC, ("[WebVTT] Cannot open Rendering Script - %s\n", path)); return; } gf_node_init(n); }
void gf_xml_push_namespaces(GF_DOMNode *elt) { GF_DOMAttribute *att = elt->attributes; while (att) { if (att->tag==TAG_DOM_ATT_any) { GF_DOMFullAttribute *datt = (GF_DOMFullAttribute*)att; if (datt->name && !strncmp(datt->name, "xmlns", 5)) { char *qname = datt->name+5; gf_sg_add_namespace(elt->sgprivate->scenegraph, *(DOM_String *) datt->data, qname[0] ? qname+1 : NULL); } } att = att->next; } }