⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 loader_xmt.c

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 C
📖 第 1 页 / 共 5 页
字号:
	parser->current_node_tag = tag;	if (parent) container = parent->container_field;	else { 		container.far_ptr = NULL;		container.fieldIndex = 0;		container.fieldType = 0;	}	for (i=0; i<nb_attributes; i++) {		GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];		if (!att->value || !strlen(att->value)) continue;		if (!strcmp(att->name, "DEF")) {			GF_Node *undef_node = gf_sg_find_node_by_name(parser->load->scene_graph, att->value);			register_def = 1;			if (undef_node) {				gf_list_del_item(parser->peeked_nodes, undef_node);				ID = gf_node_get_id(undef_node);				/*if we see twice a DEF N1 then force creation of a new node*/				if (xmt_has_been_def(parser, att->value)) {					ID = xmt_get_node_id(parser, att->value);					xmt_report(parser, GF_OK, "Warning: Node %s has been defined several times - IDs may get corrupted", att->value);				} else {					gf_node_register(node, NULL);					gf_node_unregister(node, NULL);					node = undef_node;					ID = 0;				}			} else {				ID = xmt_get_node_id(parser, att->value);			}			def_name = att->value;		}		/*USE node*/		else if (!strcmp(att->name, "USE")) {			GF_Err e;			GF_Node *def_node;			def_node = xmt_find_node(parser, att->value);			e = GF_OK;			if (!def_node) 				e = xmt_report(parser, GF_BAD_PARAM, "Warning: Cannot find node %s referenced in USE - skipping", att->value);			else if (tag != gf_node_get_tag(def_node)) {				xmt_report(parser, GF_OK, "Warning: Node type %s doesn't match type %s of node %s", gf_node_get_class_name(node), gf_node_get_class_name(def_node), att->value);			}			/*DESTROY NODE*/			gf_node_register(node, NULL);			gf_node_unregister(node, NULL);			if (e) return NULL;			node = def_node;			ID = 0;			register_def = 0;			tag = 0;			break;		}		/*X3D stuff*/		else if (!strcmp(att->name, "containerField")) {			if (parent) {				if (gf_node_get_field_by_name(parent->node, att->value, &container) != GF_OK) {					xmt_report(parser, GF_BAD_PARAM, "Warning: Container field %s not member of node %s", att->value, name);					container.far_ptr = NULL;				}			}		}		/*ignored ones*/		else if (!strcmp(att->name, "bboxCenter") || !strcmp(att->name, "bboxSize")) {		}				/*all other fields*/		else {			e = gf_node_get_field_by_name(node, att->name, &info);			if (e) xmt_report(parser, GF_OK, "Warning: Unknown field %s for node %s - skipping", att->name, name);			else if (gf_sg_vrml_is_sf_field(info.fieldType)) {				xmt_parse_sf_field(parser, &info, node, att->value);			} else {				xmt_parse_mf_field(parser, &info, node, att->value);			}		}	}	if (!parser->parsing_proto) xmt_update_timenode(parser, node);	if (register_def) gf_list_add(parser->def_nodes, node);	if (ID) gf_node_set_id(node, ID, def_name);	if (is_script) {		u32 last_field = gf_node_get_field_count(parent->node);		gf_node_get_field(parent->node, last_field-1, &container);	} 	if (parent) {		if (!container.far_ptr) {			if (parser->doc_type==2) {				x3d_get_default_container(parent->node, node, &container);				parent->last = NULL;			}			if (!container.far_ptr) {				gf_node_get_field_by_name(parent->node, "children", &container);				parent->last = NULL;			}		}		if (container.fieldType == GF_SG_VRML_SFNODE) {			if (* ((GF_Node **)container.far_ptr) ) gf_node_unregister(* ((GF_Node **)container.far_ptr) , parent->node);			* ((GF_Node **)container.far_ptr) = node;			gf_node_register(node, parent->node);			parent->container_field.far_ptr = NULL;			parent->last = NULL;		} else if (container.fieldType == GF_SG_VRML_MFNODE) {			gf_node_list_add_child_last( (GF_ChildNodeItem **)container.far_ptr, node, &parent->last);			gf_node_register(node, parent->node);		}		gf_node_changed(parent->node, NULL);	}			if (!parser->parsing_proto && (tag || proto) )		gf_node_init(node);	return node;}GF_Descriptor *xmt_parse_descriptor(GF_XMTParser *parser, char *name, const GF_XMLAttribute *attributes, u32 nb_attributes, GF_Descriptor *parent){	GF_Err e;	u32 i;	Bool fake_desc = 0;	GF_Descriptor *desc;	char *xmt_desc_name = NULL, *ocr_ref = NULL, *dep_ref = NULL;	u32 binaryID = 0;	u8 tag = gf_odf_get_tag_by_name(name);	if (!tag) {		if (!parent) return NULL;		switch (parent->tag) {		case GF_ODF_IOD_TAG:		case GF_ODF_OD_TAG:			if (!strcmp(name, "Profiles")) fake_desc = 1;			else if (!strcmp(name, "Descr")) fake_desc = 1;			else if (!strcmp(name, "esDescr")) fake_desc = 1;			else if (!strcmp(name, "URL")) fake_desc = 1;			else return NULL;			break;		case GF_ODF_ESD_TAG:			if (!strcmp(name, "decConfigDescr")) fake_desc = 1;			else if (!strcmp(name, "slConfigDescr")) fake_desc = 1;			else return NULL;			break;		case GF_ODF_DCD_TAG:			if (!strcmp(name, "decSpecificInfo")) fake_desc = 1;			else return NULL;			break;		case GF_ODF_SLC_TAG:			if (!strcmp(name, "custom")) fake_desc = 1;			else return NULL;			break;		case GF_ODF_MUXINFO_TAG:			if (!strcmp(name, "MP4MuxHints")) fake_desc = 1;			else return NULL;			break;		case GF_ODF_BIFS_CFG_TAG:			if (!strcmp(name, "commandStream")) fake_desc = 1;			else if (!strcmp(name, "size")) fake_desc = 2;			else return NULL;			break;		default:			return NULL;		}	}	if (fake_desc) {		tag = parent->tag;		desc = parent;	} else {		desc = gf_odf_desc_new(tag);		if (!desc) return NULL;	}	for (i=0; i<nb_attributes; i++) {		GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];		if (!att->value || !strlen(att->value)) continue;		if (!strcmp(att->name, "binaryID")) binaryID = atoi(att->value);		else if (!strcmp(att->name, "objectDescriptorID")) xmt_desc_name = att->value;		else if (!strcmp(att->name, "ES_ID")) xmt_desc_name = att->value;		else if (!strcmp(att->name, "OCR_ES_ID")) ocr_ref = att->value;		else if (!strcmp(att->name, "dependsOn_ES_ID")) dep_ref = att->value;		else {			e = gf_odf_set_field(desc, att->name, att->value);			if (e) xmt_report(parser, e, "Warning: %s not a valid attribute for descriptor %s", att->name, name);		}	}	if (binaryID || xmt_desc_name) {		if ((tag == GF_ODF_IOD_TAG) || (tag == GF_ODF_OD_TAG)) 			xmt_new_od_link(parser, (GF_ObjectDescriptor *)desc, xmt_desc_name, binaryID);		else if (tag == GF_ODF_ESD_TAG) {			xmt_new_esd_link(parser, (GF_ESD *) desc, xmt_desc_name, binaryID);			/*set references once the esd link has been established*/			if (ocr_ref) xmt_set_depend_id(parser, (GF_ESD *) desc, ocr_ref, 1);			if (dep_ref) xmt_set_depend_id(parser, (GF_ESD *) desc, dep_ref, 0);		}	}	if (fake_desc) {		if (fake_desc==2) {			GF_BIFSConfig *bcfg = (GF_BIFSConfig *)desc;			parser->load->ctx->scene_width = bcfg->pixelWidth;			parser->load->ctx->scene_height = bcfg->pixelHeight;			parser->load->ctx->is_pixel_metrics = bcfg->pixelMetrics;		}		return NULL;	}	if (parent) {		e = gf_odf_desc_add_desc(parent, desc);		if (e) {			xmt_report(parser, GF_OK, "Invalid child descriptor");			gf_odf_desc_del(desc);			return NULL;		}		/*finally check for scene manager streams (scene description, OD, ...)*/		if (parent->tag == GF_ODF_ESD_TAG) {			GF_ESD *esd = (GF_ESD *)parent;			if (esd->decoderConfig) {				switch (esd->decoderConfig->streamType) {				case GF_STREAM_SCENE:				case GF_STREAM_OD:					/*watchout for default BIFS stream*/					if (parser->scene_es && !parser->base_scene_id && (esd->decoderConfig->streamType==GF_STREAM_SCENE)) {						parser->scene_es->ESID = parser->base_scene_id = esd->ESID;						parser->scene_es->timeScale = (esd->slConfig && esd->slConfig->timestampResolution) ? esd->slConfig->timestampResolution : 1000;					} else {						GF_StreamContext *sc = gf_sm_stream_new(parser->load->ctx, esd->ESID, esd->decoderConfig->streamType, esd->decoderConfig->objectTypeIndication);						/*set default timescale for systems tracks (ignored for other)*/						if (sc) sc->timeScale = (esd->slConfig && esd->slConfig->timestampResolution) ? esd->slConfig->timestampResolution : 1000;						if (!parser->base_scene_id && (esd->decoderConfig->streamType==GF_STREAM_SCENE)) parser->base_scene_id = esd->ESID;						else if (!parser->base_od_id && (esd->decoderConfig->streamType==GF_STREAM_OD)) parser->base_od_id = esd->ESID;					}					break;				}			}		}	}	return desc;}static void xmt_parse_command(GF_XMTParser *parser, char *name, const GF_XMLAttribute *attributes, u32 nb_attributes){	GF_Err e;	GF_FieldInfo info;	GF_CommandField *field;	u32 i;	if (!strcmp(name, "Scene")) {		parser->doc_state = 4;		return;	}	if (!strcmp(name, "par")) {		for (i=0; i<nb_attributes; i++) {			GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];			if (!att->value || !strlen(att->value)) continue;			if (!strcmp(att->name, "begin")) parser->au_time = atof(att->value);			else if (!strcmp(att->name, "isRAP")) parser->au_is_rap = !strcmp(att->value, "yes") ? 1 : 0;			else if (!strcmp(att->name, "atES_ID")) {				parser->stream_id = xmt_locate_stream(parser, att->value);				if (!parser->stream_id) xmt_report(parser, GF_OK, "Warning: Cannot locate command's target stream %s", att->value);			}		}		return;	}	/*ROUTE insert/replace*/	if (!strcmp(name, "ROUTE")) {		if (!parser->command || ((parser->command->tag!=GF_SG_ROUTE_REPLACE) && (parser->command->tag!=GF_SG_ROUTE_INSERT))) {			xmt_report(parser, GF_BAD_PARAM, "ROUTE declared outside command scope");			return;		}		if (parser->command->tag==GF_SG_ROUTE_INSERT) {			xmt_parse_route(parser, attributes, nb_attributes, 1, parser->command);			gf_list_add(parser->inserted_routes, parser->command);		} else {			xmt_parse_route(parser, attributes, nb_attributes, 0, parser->command);			if (!parser->command->RouteID) {				parser->command->unresolved = 1;				if (gf_list_find(parser->unresolved_routes, parser->command)<0)					gf_list_add(parser->unresolved_routes, parser->command);			}		}		return;	}	/*multiple replace*/	if (!strcmp(name, "repField")) {		char *fieldName = NULL;		char *fieldValue = NULL;		assert(parser->command);		if (!parser->command->node) return;		for (i=0; i<nb_attributes; i++) {			GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];			if (!att->value || !strlen(att->value)) continue;			if (!strcmp(att->name, "atField")) fieldName = att->value;			else if (!strcmp(att->name, "value")) fieldValue = att->value;		}		if (!fieldName) {			parser->doc_state = 4;			return;		}		e = gf_node_get_field_by_name(parser->command->node, fieldName, &info);		if (e) {			xmt_report(parser, GF_BAD_PARAM, "Warning: Field %s not a member of node %s ", fieldName, gf_node_get_class_name(parser->command->node) );			return;		}		if (gf_sg_vrml_get_sf_type(info.fieldType) == GF_SG_VRML_SFNODE) {			parser->doc_state = 4;			return;		}		if (!fieldValue) return;		field = gf_sg_command_field_new(parser->command);		field->fieldIndex = info.fieldIndex;		field->fieldType = info.fieldType;		if (fieldValue) {			field->field_ptr = gf_sg_vrml_field_pointer_new(info.fieldType);			info.far_ptr = field->field_ptr;			if (gf_sg_vrml_is_sf_field(info.fieldType)) {				xmt_parse_sf_field(parser, &info, parser->command->node, fieldValue);			} else {				xmt_parse_mf_field(parser, &info, parser->command->node, fieldValue);			}		} else {			parser->doc_state = 4;		}		return;	}	/*multiple index replace*/	if (!strcmp(name, "repValue")) {		s32 position = -1;		char *fieldValue = NULL;		assert(parser->command);		if (!parser->command->node) return;		for (i=0; i<nb_attributes; i++) {			GF_XMLAttribute *att = (GF_XMLAttribute *) &attributes[i];			if (!att->value || !strlen(att->value)) continue;			if (!strcmp(att->name, "position")) {				if (!strcmp(att->value, "BEGIN")) position = 0;				else if (!strcmp(att->value, "END")) position = -1;				else position = atoi(att->value);			}			else if (!strcmp(att->name, "value")) fieldValue = att->value;		}		gf_node_get_field(parser->command->node, parser->command->fromFieldIndex, &info);		if (info.fieldType == GF_SG_VRML_MFNODE) {			field = gf_sg_command_field_new(parser->command);			field->fieldIndex = info.fieldIndex;			field->fieldType = GF_SG_VRML_SFNODE;			field->pos = position;			parser->doc_state = 4;		} else if (fieldValue) {			field = gf_sg_command_field_new(parser->command);			field->fieldIndex = info.fieldIndex;			field->fieldType = info.fieldType = gf_sg_vrml_get_sf_type(info.fieldType);			field->field_ptr = gf_sg_vrml_field_pointer_new(info.fieldType);			field->pos = position;			info.far_ptr = field->field_ptr;			xmt_parse_sf_field(parser, &info, parser->command->node, fieldValue);		}		return;	}	/*BIFS command*/	if (!strcmp(name, "Replace") || !strcmp(name, "Insert") || !strcmp(name, "Delete")) {		GF_Node *atNode;		u8 tag = GF_SG_UNDEFINED;		u32 stream_id;		Double au_time = parser->au_time;		Bool au_is_rap = parser->au_is_rap;		char *nodeName = NULL;		char *fieldName = NULL;		char *fieldValue = NULL;		char *routeName = NULL;		char *extended = NULL;		s32 position = -2;		if (!parser->stream_id) parser->stream_id = parser->base_scene_id;		stream_id = parser->stream_id;		for (i=0; i<nb_attributes; i++) {			GF_XMLAttribute *att = (GF_XMLAttribute *)&attributes[i];			if (!att->value || !strlen(att->value)) continue;			if (!strcmp(att->name, "begin")) au_time = atoi(att->value);			else if (!strcmp(att->name, "isRAP")) au_is_rap = !strcmp(att->value, "yes") ? 1 : 0;			else if (!strcmp(att->name, "atES_ID")) {				stream_id = xmt_locate_stream(parser, att->value);				if (!stream_id) {					xmt_report(parser, GF_OK, "Warning: Cannot locate command's target stream %s", att->value);					stream_id = parser->stream_id;				}			}			else if (!strcmp(att->name, "atNode")) nodeName = att->value;			else if (!strcmp(att->name, "atField")) fieldName = att->value;			else if (!st

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -