~ubuntu-branches/debian/experimental/gpac/experimental

« back to all changes in this revision

Viewing changes to src/scene_manager/loader_svg.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2014-02-22 18:15:00 UTC
  • mfrom: (1.2.2) (3.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20140222181500-b4phupo05gjpmopa
Tags: 0.5.0+svn5104~dfsg1-1
* New  upstream version 0.5.0+svn5104~dfsg1:
  - src/utils/sha1.c is relicensed under LGPLv2.1, Closes: #730759
* Don't install modules in multi-arch directories, Closes: #730497
* Add libusb-1.0.0-dev headers because libfreenect requires this
* Fix install rule
* Follow upstream soname bump
  - Drop the symbols file for now until it has been revised thourougly
* Let binaries produce the correct svn revision
* Refresh patches
* Patch and build against libav10, Closes: #739321
* Bump standards version, no changes necessary

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
        GF_SceneLoader *load;
54
54
        GF_Err last_error;
55
55
        GF_SAXParser *sax_parser;
56
 
        Bool has_root;
 
56
        u32 has_root;
57
57
        
58
58
        /* stack of SVG nodes*/
59
59
        GF_List *node_stack;
141
141
#endif
142
142
        if (e) {
143
143
                parser->last_error = e;
144
 
                gf_xml_sax_suspend(parser->sax_parser, 1);
 
144
                gf_xml_sax_suspend(parser->sax_parser, GF_TRUE);
145
145
        }
146
146
        return e;
147
147
}
196
196
        u32 i;
197
197
        if (parser->load->ctx && parser->load->ctx->root_od) {
198
198
                for (i=0; i<gf_list_count(parser->load->ctx->root_od->ESDescriptors); i++) {
199
 
                        GF_ESD *esd = gf_list_get(parser->load->ctx->root_od->ESDescriptors, i);
 
199
                        GF_ESD *esd = (GF_ESD *)gf_list_get(parser->load->ctx->root_od->ESDescriptors, i);
200
200
                        if (esd->decoderConfig->streamType==GF_STREAM_SCENE) {
201
201
                                GF_LASERConfig *cfg = (GF_LASERConfig *)esd->decoderConfig->decoderSpecificInfo;
202
202
                                if (cfg && (cfg->tag==GF_ODF_LASER_CFG_TAG)) {
269
269
                        char *buf64;
270
270
                        u64 size64;
271
271
                        char *ext;
272
 
                        buf64 = gf_malloc((size_t)size*2);
 
272
                        buf64 = (char *)gf_malloc((size_t)size*2);
273
273
                        size64 = gf_base64_encode(buffer, (u32)size, buf64, (u32)size*2);
274
274
                        buf64[size64] = 0;
275
275
                        mtype = "application/data";
279
279
                                if (!stricmp(ext, ".jpg") || !stricmp(ext, ".jpeg")) mtype = "image/jpg";
280
280
                        }
281
281
                        gf_free(iri->string);
282
 
                        iri->string = gf_malloc(sizeof(char)*(40+(size_t)size64));
 
282
                        iri->string = (char *)gf_malloc(sizeof(char)*(40+(size_t)size64));
283
283
                        sprintf(iri->string, "data:%s;base64,%s", mtype, buf64);
284
284
                        gf_free(buf64);
285
285
                        gf_free(buffer);
315
315
        gf_free(node_class);
316
316
 
317
317
        if (n) {
318
 
                gf_svg_parse_element_id(n, ID, 0);
 
318
                gf_svg_parse_element_id(n, ID, GF_FALSE);
319
319
                gf_list_add(parser->peeked_nodes, n);
320
320
        }
321
321
        return n;
366
366
                /* if now we have a target, create the xlink:href attribute on the animation element and set it to the found target */
367
367
                if (anim->target) {
368
368
                        XMLRI *iri;
369
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_XLINK_ATT_href, 1, 0, &info);
 
369
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_XLINK_ATT_href, GF_TRUE, GF_FALSE, &info);
370
370
                        iri = (XMLRI *)info.far_ptr;
371
371
                        iri->type = XMLRI_ELEMENTID;
372
372
                        iri->target = anim->target;
376
376
                tag = gf_node_get_tag((GF_Node *)anim->animation_elt);
377
377
                /* get the attribute name attribute if specified */
378
378
                if (anim->type && (tag== TAG_SVG_animateTransform) ) {
379
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_transform_type, 1, 0, &info);
 
379
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_transform_type, GF_TRUE, GF_FALSE, &info);
380
380
                        gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->type, 0);
381
381
                        switch(*(SVG_TransformType *) info.far_ptr) {
382
382
                        case SVG_TRANSFORM_TRANSLATE:
399
399
                                break;
400
400
                        default:
401
401
                                svg_report(parser, GF_OK, "unknown datatype for animate transform");
402
 
                                return 0;
 
402
                                return GF_FALSE;
403
403
                        }
404
404
                }
405
 
                else if (gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_attributeName, 0, 0, &info) == GF_OK) {
 
405
                else if (gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_attributeName, GF_FALSE, GF_FALSE, &info) == GF_OK) {
406
406
                        SMIL_AttributeName *attname = (SMIL_AttributeName *)info.far_ptr;
407
407
 
408
408
                        /*parse the attribute name even if the target is not found, because a namespace could be specified and 
424
424
                        }
425
425
 
426
426
                        /* the target is still not known stay in stage 0 */
427
 
                        if (!anim->target) return 0;
 
427
                        if (!anim->target) return GF_FALSE;
428
428
 
429
 
                        gf_node_get_attribute_by_name((GF_Node *)anim->target, attname->name, attname->type, 1, 1, &info);
 
429
                        gf_node_get_attribute_by_name((GF_Node *)anim->target, attname->name, attname->type, GF_TRUE, GF_TRUE, &info);
430
430
                        /*set the tag value to avoid parsing the name in the anim node_init phase*/
431
431
                        attname->tag = info.fieldIndex;
432
432
                        attname->type = 0;
440
440
                                return svg_parse_animation(parser, sg, anim, nodeID, 0);
441
441
                        } else {
442
442
                                svg_report(parser, GF_OK, "Missing attributeName attribute on %s", gf_node_get_name((GF_Node *)anim->animation_elt));
443
 
                                return 0;
 
443
                                return GF_FALSE;
444
444
                        }
445
445
                }
446
446
 
447
447
                /* the target is still not known stay in stage 0 */
448
 
                if (!anim->target) return 0;
 
448
                if (!anim->target) return GF_FALSE;
449
449
 
450
450
                if (anim->to) {
451
451
                        /* now that we have a target, if there is a to value to parse, create the attribute and parse it */
452
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_to, 1, 0, &info);
 
452
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_to, GF_TRUE, GF_FALSE, &info);
453
453
                        gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->to, anim_value_type);
454
454
                        if (anim_value_type==XMLRI_datatype) 
455
455
                                svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
456
456
                } 
457
457
                if (anim->from) {
458
458
                        /* now that we have a target, if there is a from value to parse, create the attribute and parse it */
459
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_from, 1, 0, &info);
 
459
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_from, GF_TRUE, GF_FALSE, &info);
460
460
                        gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->from, anim_value_type);
461
461
                        if (anim_value_type==XMLRI_datatype) 
462
462
                                svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
463
463
                } 
464
464
                if (anim->by) {
465
465
                        /* now that we have a target, if there is a by value to parse, create the attribute and parse it */
466
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_by, 1, 0, &info);
 
466
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_by, GF_TRUE, GF_FALSE, &info);
467
467
                        gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->by, anim_value_type);
468
468
                        if (anim_value_type==XMLRI_datatype) 
469
469
                                svg_post_process_href(parser, (XMLRI*)((SMIL_AnimateValue *)info.far_ptr)->value);
470
470
                } 
471
471
                if (anim->values) {
472
472
                        /* now that we have a target, if there is a 'values' value to parse, create the attribute and parse it */
473
 
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_values, 1, 0, &info);
 
473
                        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_values, GF_TRUE, GF_FALSE, &info);
474
474
                        gf_svg_parse_attribute((GF_Node *)anim->animation_elt, &info, anim->values, anim_value_type);
475
475
                        if (anim_value_type==XMLRI_datatype) {
476
476
                                u32 i, count;
489
489
        if (anim->resolve_stage == 1) {
490
490
                /* Stage 1: parsing the begin values 
491
491
                                        we go into the next stage only if at least one begin value is resolved */
492
 
                gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_begin, 1, 0, &info);
493
 
                if (gf_svg_resolve_smil_times((GF_Node *)anim->animation_elt, anim->target, *(GF_List **)info.far_ptr, 0, nodeID)) {
 
492
                gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_begin, GF_TRUE, GF_FALSE, &info);
 
493
                if (gf_svg_resolve_smil_times((GF_Node *)anim->animation_elt, anim->target, *(GF_List **)info.far_ptr, GF_FALSE, nodeID)) {
494
494
                        anim->resolve_stage = 2;
495
495
                } else if (force_type!=2) {
496
 
                        return 0;
 
496
                        return GF_FALSE;
497
497
                }
498
498
        }
499
499
 
500
 
        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_end, 1, 0, &info);
501
 
        if (!gf_svg_resolve_smil_times((GF_Node *)anim->animation_elt, anim->target, *(GF_List **)info.far_ptr, 1, nodeID)) {
502
 
                if (force_type!=2) return 0;
 
500
        gf_node_get_attribute_by_tag((GF_Node *)anim->animation_elt, TAG_SVG_ATT_end, GF_TRUE, GF_FALSE, &info);
 
501
        if (!gf_svg_resolve_smil_times((GF_Node *)anim->animation_elt, anim->target, *(GF_List **)info.far_ptr, GF_TRUE, nodeID)) {
 
502
                if (force_type!=2) return GF_FALSE;
503
503
        }
504
504
 
505
505
        /*animateMotion needs its children to be parsed before it can be initialized !! */
506
506
        if (force_type || gf_node_get_tag((GF_Node *)anim->animation_elt) != TAG_SVG_animateMotion) {
507
507
                gf_node_init((GF_Node *)anim->animation_elt);
508
 
                return 1;
 
508
                return GF_TRUE;
509
509
        } else {
510
 
                return 0;
 
510
                return GF_FALSE;
511
511
        }
512
512
        
513
513
}
543
543
                SVG_Element *listener = (SVG_Element *)gf_list_get(parser->defered_listeners, i);
544
544
 
545
545
                par = NULL;
546
 
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, 0, 0, &info) == GF_OK) {
547
 
                        XMLRI *observer = info.far_ptr;
 
546
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, GF_FALSE, GF_FALSE, &info) == GF_OK) {
 
547
                        XMLRI *observer = (XMLRI *)info.far_ptr;
548
548
                        if (observer->type == XMLRI_ELEMENTID) {
549
549
                                if (!observer->target && observer->string && !strcmp(observer->string, nodeID) ) {
550
550
                                        observer->target = gf_sg_find_node_by_name(sg, (char*) nodeID);
551
551
                                }
552
552
                        }
553
 
                        if (observer->type == XMLRI_ELEMENTID) par = observer->target;
 
553
                        if (observer->type == XMLRI_ELEMENTID) par = (GF_Node *)observer->target;
554
554
                        if (!par) continue;
555
555
                }
556
 
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, 0, 0, &info) == GF_OK) {
557
 
                        XMLRI *target = info.far_ptr;
 
556
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, GF_FALSE, GF_FALSE, &info) == GF_OK) {
 
557
                        XMLRI *target = (XMLRI *)info.far_ptr;
558
558
                        if (target->type == XMLRI_ELEMENTID) {
559
559
                                if (!target->target) continue;
560
560
                                else {
587
587
        GF_FieldInfo width_info, height_info;
588
588
        u32 svg_w, svg_h;
589
589
        svg_w = svg_h = 0;
590
 
        if (!gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_width, 0, 0, &width_info)
591
 
                && !gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_height, 0, 0, &height_info)) {
592
 
                SVG_Length * w = width_info.far_ptr;
593
 
                SVG_Length * h = height_info.far_ptr;
 
590
        if (!gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_width, GF_FALSE, GF_FALSE, &width_info)
 
591
                && !gf_node_get_attribute_by_tag((GF_Node *)root_svg, TAG_SVG_ATT_height, GF_FALSE, GF_FALSE, &height_info)) {
 
592
                SVG_Length * w = (SVG_Length *)width_info.far_ptr;
 
593
                SVG_Length * h = (SVG_Length *)height_info.far_ptr;
594
594
                if (w->type == SVG_NUMBER_VALUE) svg_w = FIX2INT(w->value);
595
595
                if (h->type == SVG_NUMBER_VALUE) svg_h = FIX2INT(h->value);
596
 
                gf_sg_set_scene_size_info(parser->load->scene_graph, svg_w, svg_h, 1);
 
596
                gf_sg_set_scene_size_info(parser->load->scene_graph, svg_w, svg_h, GF_TRUE);
597
597
                if (parser->load->ctx) {
598
598
                        parser->load->ctx->scene_width = svg_w;
599
599
                        parser->load->ctx->scene_height = svg_h;
628
628
        
629
629
        GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[SVG Parsing] Parsing node %s\n", name));
630
630
 
631
 
        *has_ns = 0;
 
631
        *has_ns = GF_FALSE;
632
632
        /*parse all att to check for namespaces, to:
633
633
           - add the prefixed namespaces (xmlns:xxxx='...')
634
634
           - change the namespace for this element if no prefix (xmlns='...')*/
649
649
                                parser->current_ns = gf_sg_get_namespace_code_from_name(parser->load->scene_graph, att->value);
650
650
                        }
651
651
                        /* Signal that when ending this element, namespaces will have to be removed */
652
 
                        *has_ns = 1;
 
652
                        *has_ns = GF_TRUE;
653
653
                }
654
654
                /* FIXME: This should be changed to reflect that xml:id has precedence over id if both are specified with different values */
655
655
                else if (!stricmp(att->name, "id") || !stricmp(att->name, "xml:id")) {
681
681
 
682
682
        /* If this element has an ID, we look in the list of elements already created in advance (in case of reference) to see if it is there,
683
683
           in which case we will reuse it*/
684
 
        has_id = 0;
 
684
        has_id = GF_FALSE;
685
685
        count = gf_list_count(parser->peeked_nodes);
686
686
        if (count && ID) {
687
687
                for (i=0; i<count;i++) {
688
 
                        GF_Node *n = gf_list_get(parser->peeked_nodes, i);
 
688
                        GF_Node *n = (GF_Node *)gf_list_get(parser->peeked_nodes, i);
689
689
                        const char *n_id = gf_node_get_name(n);
690
690
                        if (n_id && !strcmp(n_id, ID)) {
691
691
                                gf_list_rem(parser->peeked_nodes, i);
692
 
                                has_id = 1;
 
692
                                has_id = GF_TRUE;
693
693
                                elt = (SVG_Element*)n;
694
694
                                break;
695
695
                        }
719
719
        if (parent && elt) gf_node_list_add_child_last( & parent->node->children, (GF_Node*)elt, & parent->last_child);
720
720
 
721
721
        /* By default, all elements will need initialization for rendering, except some that will explicitly set it to 0 */
722
 
        needs_init = 1;
 
722
        needs_init = GF_TRUE;
723
723
 
724
724
        if (gf_svg_is_animation_tag(tag)) {
725
725
                GF_SAFEALLOC(anim, SVG_DeferedAnimation);
748
748
                anim->resolve_stage = 1;
749
749
        } else if ((tag == TAG_SVG_script) || (tag==TAG_SVG_handler)) {
750
750
                /* Scripts and handlers don't render and have no initialization phase */
751
 
                needs_init = 0;
 
751
                needs_init = GF_FALSE;
752
752
        }
753
753
 
754
754
        ev_event = ev_observer = NULL;
757
757
        nb_attributes = 0;
758
758
#endif
759
759
 
 
760
        /*set the root of the SVG tree BEFORE processing events in order to have it setup for script init (e.g. load events, including in root svg)*/
 
761
        if ((tag == TAG_SVG_svg) && !parser->has_root) {
 
762
                svg_init_root_element(parser, elt);
 
763
        }
 
764
 
760
765
        /*parse all att*/
761
766
        for (i=0; i<nb_attributes; i++) {
762
767
                GF_XMLAttribute *att = (GF_XMLAttribute *)&attributes[i];
830
835
                                   we create the attribute, parse it and try to do some special process it */
831
836
                                GF_FieldInfo info;
832
837
                                XMLRI *iri = NULL;
833
 
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_XLINK_ATT_href, 1, 0, &info)==GF_OK) {
 
838
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_XLINK_ATT_href, GF_TRUE, GF_FALSE, &info)==GF_OK) {
834
839
                                        gf_svg_parse_attribute((GF_Node *)elt, &info, att->value, 0);
835
 
                                        iri = info.far_ptr;
 
840
                                        iri = (XMLRI *)info.far_ptr;
836
841
 
837
842
                                        /* Embed script if needed or clean data URL with proper mime type */
838
843
                                        svg_process_media_href(parser, (GF_Node *)elt, iri);
859
864
                if (ns == GF_XMLNS_LASER) { 
860
865
                        /* CHECK: we should probably check the namespace of the attribute here */
861
866
                        if (!stricmp(att_name, "scale") ) {
862
 
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, 1, 1, &info)==GF_OK) {
 
867
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, GF_TRUE, GF_TRUE, &info)==GF_OK) {
863
868
                                        SVG_Point pt;
864
 
                                        SVG_Transform *mat = info.far_ptr;
 
869
                                        SVG_Transform *mat = (SVG_Transform *)info.far_ptr;
865
870
                                        svg_parse_point(&pt, att->value);
866
871
                                        gf_mx2d_add_scale(&mat->mat, pt.x, pt.y);
867
872
                                        continue;
868
873
                                }
869
874
                        } 
870
875
                        if (!stricmp(att_name, "translation") ) {
871
 
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, 1, 1, &info)==GF_OK) {
 
876
                                if (gf_node_get_attribute_by_tag((GF_Node *)elt, TAG_SVG_ATT_transform, GF_TRUE, GF_TRUE, &info)==GF_OK) {
872
877
                                        SVG_Point pt;
873
 
                                        SVG_Transform *mat = info.far_ptr;
 
878
                                        SVG_Transform *mat = (SVG_Transform *)info.far_ptr;
874
879
                                        svg_parse_point(&pt, att->value);
875
880
                                        gf_mx2d_add_translation(&mat->mat, pt.x, pt.y);
876
881
                                        continue;
886
891
                        if (evtType != GF_EVENT_UNKNOWN) {
887
892
                                SVG_handlerElement *handler = gf_dom_listener_build((GF_Node *) elt, evtType, 0);
888
893
                                gf_dom_add_text_node((GF_Node *)handler, gf_strdup(att->value) );
 
894
                                gf_node_init((GF_Node *)handler);
889
895
                                continue;
890
896
                        } 
891
897
                        svg_report(parser, GF_OK, "Skipping unknown event handler %s on node %s", att->name, name);
894
900
                /* end of special cases of attributes */
895
901
 
896
902
                /* General attribute creation and parsing */
897
 
                if (gf_node_get_attribute_by_name((GF_Node *)elt, att_name, ns, 1, 0, &info)==GF_OK) {
 
903
                if (gf_node_get_attribute_by_name((GF_Node *)elt, att_name, ns, GF_TRUE, GF_FALSE, &info)==GF_OK) {
898
904
#ifndef SKIP_ATTS_PARSING
899
905
                        GF_Err e = gf_svg_parse_attribute((GF_Node *)elt, &info, att->value, 0);
900
906
                        if (e) {
933
939
                svg_report(parser, GF_OK, "Skipping attribute %s on node %s", att->name, name);
934
940
        }
935
941
 
936
 
        /*set the root of the SVG tree BEFORE processing events in order to have it setup for script init (e.g. load events)*/
937
 
        if ((tag == TAG_SVG_svg) && !parser->has_root) {
938
 
                svg_init_root_element(parser, elt);
939
 
        }
940
 
 
941
942
        /* When a handler element specifies the event attribute, an implicit listener is defined */
942
943
        if (ev_event) {
943
944
                GF_Node *node = (GF_Node *)elt;
952
953
 
953
954
                /* this listener listens to the given type of event */
954
955
                type = gf_dom_event_type_by_name(ev_event);
955
 
                gf_node_get_attribute_by_tag(node, TAG_XMLEV_ATT_event, 1, 0, &info);
956
 
                ((XMLEV_Event *)info.far_ptr)->type = type;
957
 
                gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_event, 1, 0, &info);
958
 
                ((XMLEV_Event *)info.far_ptr)->type = type;
959
 
                gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_handler, 1, 0, &info);
 
956
                gf_node_get_attribute_by_tag(node, TAG_XMLEV_ATT_event, GF_TRUE, GF_FALSE, &info);
 
957
                ((XMLEV_Event *)info.far_ptr)->type = type;
 
958
                gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_event, GF_TRUE, GF_FALSE, &info);
 
959
                ((XMLEV_Event *)info.far_ptr)->type = type;
 
960
                gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_handler, GF_TRUE, GF_FALSE, &info);
960
961
                ((XMLRI *)info.far_ptr)->target = node;
961
962
 
962
963
                if (ev_observer) {
963
964
                        /* An observer was specified, so it needs to be used */
964
 
                        gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, 1, 0, &info);
 
965
                        gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, GF_TRUE, GF_FALSE, &info);
965
966
                        gf_svg_parse_attribute((GF_Node *)elt, &info, (char*)ev_observer, 0);
966
967
                } else {
967
968
                        /* No observer specified, this listener listens with the parent of the handler as the event target */
968
 
                        gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, 1, 0, &info);
 
969
                        gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, GF_TRUE, GF_FALSE, &info);
969
970
                        ((XMLRI *)info.far_ptr)->target = parent->node;
970
971
                }
971
972
                /* if the target was found (already parsed), we are fine, otherwise we need to try to find it again, 
980
981
        if (node_name) {
981
982
                if (!has_id) {
982
983
                        /* if the element was already created before this call, we don't need to get a numerical id, we have it already */
983
 
                        gf_svg_parse_element_id((GF_Node *)elt, node_name, parser->command_depth ? 1 : 0);
 
984
                        gf_svg_parse_element_id((GF_Node *)elt, node_name, parser->command_depth ? GF_TRUE : GF_FALSE);
984
985
                }
985
986
                svg_resolved_refs(parser, parser->load->scene_graph, node_name);
986
987
        }
990
991
        if (anim) {
991
992
                /*FIXME - we need to parse from/to/values but not initialize the stack*/
992
993
//              if (parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK) {
993
 
                        needs_init = 0;
 
994
                        needs_init = GF_FALSE;
994
995
                        if (svg_parse_animation(parser, parser->load->scene_graph, anim, NULL, 0)) {
995
996
                                svg_delete_defered_anim(anim, NULL);
996
997
                        } else {
1010
1011
 
1011
1012
        if (parent && elt) {
1012
1013
                /*mark parent element as dirty (new child added) and invalidate parent graph for progressive rendering*/
1013
 
                gf_node_dirty_set((GF_Node *)parent->node, GF_SG_CHILD_DIRTY, 1);
 
1014
                gf_node_dirty_set((GF_Node *)parent->node, GF_SG_CHILD_DIRTY, GF_TRUE);
1014
1015
                /*request scene redraw*/
1015
1016
                if (parser->load->scene_graph->NodeCallback) {
1016
1017
                        parser->load->scene_graph->NodeCallback(parser->load->scene_graph->userpriv, GF_SG_CALLBACK_MODIFIED, NULL, NULL);
1020
1021
        /*If we are in playback mode, we register (reference counting for safe deleting) the listener element with the element that uses it */
1021
1022
        if ((parser->load->flags & GF_SM_LOAD_FOR_PLAYBACK) && elt && (tag==TAG_SVG_listener)) {
1022
1023
                GF_FieldInfo info;
1023
 
                Bool post_pone = 0;
 
1024
                Bool post_pone = GF_FALSE;
1024
1025
                SVG_Element *par = NULL;
1025
1026
                SVG_Element *listener = (SVG_Element *)elt;
1026
1027
 
1027
 
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, 0, 0, &info) == GF_OK) {
1028
 
                        XMLRI *observer = info.far_ptr;
 
1028
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_observer, GF_FALSE, GF_FALSE, &info) == GF_OK) {
 
1029
                        XMLRI *observer = (XMLRI *)info.far_ptr;
1029
1030
                        if (observer->type == XMLRI_ELEMENTID) {
1030
 
                                if (!observer->target) post_pone = 1;
1031
 
                                else par = observer->target;
 
1031
                                if (!observer->target) post_pone = GF_TRUE;
 
1032
                                else par = (SVG_Element *)observer->target;
1032
1033
                        }
1033
1034
                }
1034
1035
 
1035
 
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, 0, 0, &info) == GF_OK) {
1036
 
                        XMLRI *target = info.far_ptr;
 
1036
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_target, GF_FALSE, GF_FALSE, &info) == GF_OK) {
 
1037
                        XMLRI *target = (XMLRI *)info.far_ptr;
1037
1038
                        if (!par && (target->type == XMLRI_ELEMENTID)) {
1038
 
                                if (!target->target) post_pone = 1;
1039
 
                                else par = target->target;
 
1039
                                if (!target->target) post_pone = GF_TRUE;
 
1040
                                else par = (SVG_Element *)target->target;
1040
1041
                        }
1041
1042
                }
1042
1043
                /*check handler, create it if not specified*/
1043
 
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_handler, 1, 0, &info) == GF_OK) {
1044
 
                        XMLRI *handler = info.far_ptr;
 
1044
                if (gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_handler, GF_TRUE, GF_FALSE, &info) == GF_OK) {
 
1045
                        XMLRI *handler = (XMLRI *)info.far_ptr;
1045
1046
                        if (!handler->target) {
1046
1047
                                if (!handler->string) handler->target = parent->node;
1047
1048
                        }
1048
1049
                }
1049
1050
                /*if event is a key event, register it with root*/
1050
 
                if (!par && gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_event, 0, 0, &info) == GF_OK) {
1051
 
                        XMLEV_Event *ev = info.far_ptr;
 
1051
                if (!par && gf_node_get_attribute_by_tag((GF_Node *)listener, TAG_XMLEV_ATT_event, GF_FALSE, GF_FALSE, &info) == GF_OK) {
 
1052
                        XMLEV_Event *ev = (XMLEV_Event *)info.far_ptr;
1052
1053
                        if ((ev->type>=GF_EVENT_KEYUP) && (ev->type<=GF_EVENT_TEXTINPUT)) par = (SVG_Element*) listener->sgprivate->scenegraph->RootNode;
1053
1054
                }
1054
1055
 
1067
1068
{
1068
1069
        GF_FieldInfo info;
1069
1070
        GF_Node *opNode;
1070
 
        Bool is_replace = 0;
 
1071
        Bool is_replace = GF_FALSE;
1071
1072
        char *atNode = NULL;
1072
1073
        char *atAtt = NULL;
1073
1074
        char *atOperandNode = NULL;
1103
1104
                                field->fieldIndex = 0;
1104
1105
                                field->fieldType = 0;
1105
1106
                        } else {
1106
 
                                if (gf_node_get_attribute_by_name(parser->command->node, atAtt, parser->current_ns, 0, 0, &info)==GF_OK) {
 
1107
                                if (gf_node_get_attribute_by_name(parser->command->node, atAtt, parser->current_ns, GF_FALSE, GF_FALSE, &info)==GF_OK) {
1107
1108
                                        field = gf_sg_command_field_new(parser->command);
1108
1109
                                        field->pos = index;
1109
1110
                                        field->fieldIndex = info.fieldIndex;
1117
1118
                gf_node_register(parser->command->node, NULL);
1118
1119
                return GF_OK;
1119
1120
        case GF_SG_LSR_REPLACE:
1120
 
                is_replace = 1;
 
1121
                is_replace = GF_TRUE;
1121
1122
        case GF_SG_LSR_ADD:
1122
1123
        case GF_SG_LSR_INSERT:
1123
1124
                for (i=0; i<nb_attributes; i++) {
1348
1349
                        /* Create a default AU to behave as other streams (LASeR, BIFS)
1349
1350
                           but it is left empty, there is no notion of REPLACE Scene or NEw Scene, 
1350
1351
                           the RAP is the graph */
1351
 
                        parser->laser_au = gf_sm_stream_au_new(parser->laser_es, 0, 0, 1);
 
1352
                        parser->laser_au = gf_sm_stream_au_new(parser->laser_es, 0, 0, GF_TRUE);
1352
1353
                } else {
1353
1354
                        parser->laser_es = gf_list_get(parser->load->ctx->streams, 0);
1354
1355
                        parser->laser_au = gf_list_last(parser->laser_es->AUs);
1375
1376
                        return;
1376
1377
                }
1377
1378
                if (!strcmp(name, "sceneUnit") ) {
1378
 
                        u32 time, rap, i;
1379
 
                        time = rap = 0;
1380
 
                        if (!gf_list_count(parser->laser_es->AUs)) rap = 1;
 
1379
                        u32 time, i;
 
1380
                        Bool rap;
 
1381
                        time = 0;
 
1382
                        rap =  GF_FALSE;
 
1383
                        if (!gf_list_count(parser->laser_es->AUs)) rap = GF_TRUE;
1381
1384
                        for (i=0; i<nb_attributes;i++) {
1382
1385
                                GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];
1383
1386
                                if (!strcmp(att->name, "time")) time = atoi(att->value);
1384
 
                                else if (!strcmp(att->name, "rap")) rap = !strcmp(att->value, "yes") ? 1 : 0;
 
1387
                                else if (!strcmp(att->name, "rap")) rap = !strcmp(att->value, "yes") ? GF_TRUE : GF_FALSE;
1385
1388
                        }
1386
1389
                        /*create new laser unit*/
1387
1390
                        parser->laser_au = gf_sm_stream_au_new(parser->laser_es, time, 0, rap);
1432
1435
                        st->stream_name = gf_strdup(ID);
1433
1436
 
1434
1437
                        /*create new SAF unit*/
1435
 
                        parser->saf_au = gf_sm_stream_au_new(parser->saf_es, time, 0, 0);
 
1438
                        parser->saf_au = gf_sm_stream_au_new(parser->saf_es, time, 0, GF_FALSE);
1436
1439
                        odU = (GF_ODUpdate *) gf_odf_com_new(GF_ODF_OD_UPDATE_TAG);
1437
1440
                        gf_list_add(parser->saf_au->commands, odU);
1438
1441
                        od = (GF_ObjectDescriptor *) gf_odf_desc_new(GF_ODF_OD_TAG);
1472
1475
                                        fprintf(nhml, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");
1473
1476
                                        fprintf(nhml, "<NHNTStream version=\"1.0\" timeScale=\"%d\" streamType=\"%d\" objectTypeIndication=\"%d\" inRootOD=\"no\" trackID=\"%d\">\n", ts_res, ST, OTI, st->id);
1474
1477
                                        fclose(nhml);
1475
 
                                        mux->delete_file = 1;
 
1478
                                        mux->delete_file = GF_TRUE;
1476
1479
                                }
1477
1480
                        }
1478
1481
                        return;
1534
1537
                if ((parser->load->type==GF_SM_LOAD_XSR) && !parser->laser_au && !cond) {
1535
1538
                        if (parser->load->flags & GF_SM_LOAD_CONTEXT_READY) {
1536
1539
                                assert(parser->laser_es);
1537
 
                                parser->laser_au = gf_sm_stream_au_new(parser->laser_es, 0, 0, 0);
 
1540
                                parser->laser_au = gf_sm_stream_au_new(parser->laser_es, 0, 0, GF_FALSE);
1538
1541
                        } else {
1539
1542
                                svg_report(parser, GF_BAD_PARAM, "LASeR sceneUnit not defined for command %s", name);
1540
1543
                                return;
1597
1600
                return;
1598
1601
 
1599
1602
        xmlns = parser->current_ns;
1600
 
        has_ns = 0;
 
1603
        has_ns = GF_FALSE;
1601
1604
 
1602
1605
        elt = svg_parse_element(parser, name, name_space, attributes, nb_attributes, parent, &has_ns);
1603
1606
        if (!elt) {
1694
1697
#endif
1695
1698
        {
1696
1699
                const char *the_name;
1697
 
                Bool mismatch = 0;
 
1700
                Bool mismatch = GF_FALSE;
1698
1701
                SVG_Element *node = top->node;
1699
1702
                /*check node name...*/
1700
1703
                the_name = gf_node_get_class_name((GF_Node *)node);
1701
1704
                if (name_space && strstr(the_name, name_space) && strstr(the_name, name) ) {}
1702
1705
                else if (!strcmp(the_name, name) ) {}
1703
 
                else mismatch = 1;
 
1706
                else mismatch = GF_TRUE;
1704
1707
 
1705
1708
                if (mismatch) {
1706
1709
                        if (top->unknown_depth) {
1781
1784
        SVG_NodeStack *top = (SVG_NodeStack *)gf_list_last(parser->node_stack);
1782
1785
        SVG_Element *elt = (top ? top->node : NULL);
1783
1786
        GF_DOMText *text;
1784
 
        u32 skip_text;
 
1787
        Bool skip_text;
1785
1788
        u32 tag;
1786
1789
 
1787
1790
#ifdef SKIP_ALL
1826
1829
                }
1827
1830
                return;
1828
1831
        }
1829
 
        skip_text = 1;
 
1832
        skip_text = GF_TRUE;
1830
1833
        switch (tag) {
1831
1834
        case TAG_DOMFullNode:
1832
1835
        case TAG_SVG_a:
1836
1839
        case TAG_SVG_text:
1837
1840
        case TAG_SVG_tspan:
1838
1841
        case TAG_SVG_textArea:
1839
 
                skip_text = 0;
 
1842
                skip_text = GF_FALSE;
1840
1843
                break;
1841
1844
        /*for script and handlers only add text if not empty*/
1842
1845
        case TAG_SVG_handler:
1843
1846
        case TAG_SVG_script:
1844
1847
        {
1845
 
                u32 i, len = strlen(text_content);
 
1848
                u32 i, len = (u32) strlen(text_content);
1846
1849
                for (i=0; i<len; i++) {
1847
1850
                        if (!strchr(" \n\r\t", text_content[i])) {
1848
 
                                skip_text = 0;
 
1851
                                skip_text = GF_FALSE;
1849
1852
                                break;
1850
1853
                        }
1851
1854
                }
1884
1887
        parser->sax_parser = gf_xml_sax_new(svg_node_start, svg_node_end, svg_text_content, parser);
1885
1888
        parser->load = load;
1886
1889
        load->loader_priv = parser;
1887
 
        if (load->ctx) load->ctx->is_pixel_metrics = 1;
 
1890
        if (load->ctx) load->ctx->is_pixel_metrics = GF_TRUE;
1888
1891
 
1889
1892
        /*to cope with old files not signaling XMLNS, add the SVG NS by default*/
1890
1893
        gf_sg_add_namespace(parser->load->scene_graph, "http://www.w3.org/2000/svg", NULL);
1911
1914
        /*FIXME - if there still are som defered listeners, we should pass them to the scene graph
1912
1915
        and wait for the parent to be defined*/
1913
1916
        while (gf_list_count(parser->defered_listeners)) {
1914
 
                GF_Node *l = gf_list_last(parser->defered_listeners);
 
1917
                GF_Node *l = (GF_Node *)gf_list_last(parser->defered_listeners);
1915
1918
                gf_list_rem_last(parser->defered_listeners);
1916
1919
                /*listeners not resolved are not inserted in the tree - destroy them*/
1917
1920
                gf_node_register(l, NULL);
1984
1987
        GF_SVG_Parser *parser = (GF_SVG_Parser *)load->loader_priv;
1985
1988
 
1986
1989
        if (!parser) {
1987
 
                e = gf_sm_load_initialize_svg(load, NULL, 0);
 
1990
                e = gf_sm_load_initialize_svg(load, NULL, GF_FALSE);
1988
1991
                if (e) return e;
1989
1992
                parser = (GF_SVG_Parser *)load->loader_priv;
1990
1993
        }
2034
2037
        GF_SVG_Parser *parser = (GF_SVG_Parser *)load->loader_priv;
2035
2038
 
2036
2039
        if (!parser) {
2037
 
                e = gf_sm_load_initialize_svg(load, str, 0);
 
2040
                e = gf_sm_load_initialize_svg(load, str, GF_FALSE);
2038
2041
                parser = (GF_SVG_Parser *)load->loader_priv;
2039
2042
        } else {
2040
2043
                e = gf_xml_sax_parse(parser->sax_parser, str);
2078
2081
        ctx.scene_graph = in_scene;
2079
2082
        ctx.type = GF_SM_LOAD_SVG;
2080
2083
 
2081
 
        e = gf_sm_load_initialize_svg(&ctx, node_str, 1);
 
2084
        e = gf_sm_load_initialize_svg(&ctx, node_str, GF_TRUE);
2082
2085
        
2083
2086
        parser = (GF_SVG_Parser *)ctx.loader_priv;
2084
2087
        node = parser->fragment_root;