Beispiel #1
0
M4Err Media_CreateDataRef(DataReferenceAtom *dref, char *URLname, char *URNname, u32 *dataRefIndex)
{	
	M4Err e;
	DataEntryURLAtom *entry;

	M4Err dref_AddDataEntry(DataReferenceAtom *ptr, Atom *entry);

	if (!URLname && !URNname) {
		//THIS IS SELF CONTAIN, create a regular entry if needed
		entry = (DataEntryURLAtom *) CreateAtom(DataEntryURLAtomType);
		entry->location = NULL;
		entry->flags = 0;
		entry->flags |= 1;
		e = dref_AddDataEntry(dref, (Atom *)entry);
		if (e) return e;
		*dataRefIndex = ChainGetCount(dref->atomList);
		return M4OK;
	} else if (!URNname && URLname) {
		//THIS IS URL
		entry = (DataEntryURLAtom *) CreateAtom(DataEntryURLAtomType);
		entry->flags = 0;
		entry->location = (char*)malloc(strlen(URLname)+1);
		if (! entry->location) {
			DelAtom((Atom *)entry);
			return M4OutOfMem;
		}
		strcpy(entry->location, URLname);
		e = dref_AddDataEntry(dref, (Atom *)entry);
		if (e) return e;
		*dataRefIndex = ChainGetCount(dref->atomList);
		return M4OK;
	} else {
		//THIS IS URN
		entry = (DataEntryURLAtom *) CreateAtom(DataEntryURNAtomType);
		((DataEntryURNAtom *)entry)->flags = 0;
		((DataEntryURNAtom *)entry)->nameURN = (char*)malloc(strlen(URNname)+1);
		if (! ((DataEntryURNAtom *)entry)->nameURN) {
			DelAtom((Atom *)entry);
			return M4OutOfMem;
		}
		strcpy(((DataEntryURNAtom *)entry)->nameURN, URNname);
		//check for URL
		if (URLname) {
			((DataEntryURNAtom *)entry)->location = (char*)malloc(strlen(URLname)+1);
			if (! ((DataEntryURNAtom *)entry)->location) {
				DelAtom((Atom *)entry);
				return M4OutOfMem;
			}
			strcpy(((DataEntryURNAtom *)entry)->location, URLname);
		}
		e = dref_AddDataEntry(dref, (Atom *)entry);
		if (e) return e;
		*dataRefIndex = ChainGetCount(dref->atomList);
		return M4OK;
	}
	return M4OK;
}
Beispiel #2
0
GF_Err Media_CreateDataRef(GF_DataReferenceBox *dref, char *URLname, char *URNname, u32 *dataRefIndex)
{	
	GF_Err e;
	GF_DataEntryURLBox *entry;

	GF_Err dref_AddDataEntry(GF_DataReferenceBox *ptr, GF_Box *entry);

	if (!URLname && !URNname) {
		//THIS IS SELF CONTAIN, create a regular entry if needed
		entry = (GF_DataEntryURLBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_URL);
		entry->location = NULL;
		entry->flags = 0;
		entry->flags |= 1;
		e = dref_AddDataEntry(dref, (GF_Box *)entry);
		if (e) return e;
		*dataRefIndex = gf_list_count(dref->other_boxes);
		return GF_OK;
	} else if (!URNname && URLname) {
		//THIS IS URL
		entry = (GF_DataEntryURLBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_URL);
		entry->flags = 0;
		entry->location = (char*)gf_malloc(strlen(URLname)+1);
		if (! entry->location) {
			gf_isom_box_del((GF_Box *)entry);
			return GF_OUT_OF_MEM;
		}
		strcpy(entry->location, URLname);
		e = dref_AddDataEntry(dref, (GF_Box *)entry);
		if (e) return e;
		*dataRefIndex = gf_list_count(dref->other_boxes);
		return GF_OK;
	} else {
		//THIS IS URN
		entry = (GF_DataEntryURLBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_URN);
		((GF_DataEntryURNBox *)entry)->flags = 0;
		((GF_DataEntryURNBox *)entry)->nameURN = (char*)gf_malloc(strlen(URNname)+1);
		if (! ((GF_DataEntryURNBox *)entry)->nameURN) {
			gf_isom_box_del((GF_Box *)entry);
			return GF_OUT_OF_MEM;
		}
		strcpy(((GF_DataEntryURNBox *)entry)->nameURN, URNname);
		//check for URL
		if (URLname) {
			((GF_DataEntryURNBox *)entry)->location = (char*)gf_malloc(strlen(URLname)+1);
			if (! ((GF_DataEntryURNBox *)entry)->location) {
				gf_isom_box_del((GF_Box *)entry);
				return GF_OUT_OF_MEM;
			}
			strcpy(((GF_DataEntryURNBox *)entry)->location, URLname);
		}
		e = dref_AddDataEntry(dref, (GF_Box *)entry);
		if (e) return e;
		*dataRefIndex = gf_list_count(dref->other_boxes);
		return GF_OK;
	}
	return GF_OK;
}