예제 #1
0
void gf_isom_delete_movie(GF_ISOFile *mov)
{
	//these are our two main files
	if (mov->movieFileMap) gf_isom_datamap_del(mov->movieFileMap);

#ifndef GPAC_DISABLE_ISOM_WRITE
	if (mov->editFileMap) {
		gf_isom_datamap_del(mov->editFileMap);
	}
	if (mov->finalName) gf_free(mov->finalName);
#endif

	gf_isom_box_array_del(mov->TopBoxes);
	gf_isom_box_array_del(mov->moof_list);


	if (mov->fileName) gf_free(mov->fileName);
	gf_free(mov);
}
예제 #2
0
파일: data_map.c 프로젝트: fcsteagu/gpac-1
//Close a data entry
void gf_isom_datamap_close(GF_MediaInformationBox *minf)
{
	GF_DataEntryBox *ent;
	if (!minf || !minf->dataHandler) return;

	ent = (GF_DataEntryBox*)gf_list_get(minf->dataInformation->dref->other_boxes, minf->dataEntryIndex - 1);

	//if ent NULL, the data entry was not used (should never happen)
	if (ent == NULL) return;

	//self contained, do nothing
	switch (ent->type) {
	case GF_ISOM_BOX_TYPE_URL:
	case GF_ISOM_BOX_TYPE_URN:
		if (ent->flags == 1) return;
		break;
	default:
		return;
	}

	//finally close it
	gf_isom_datamap_del(minf->dataHandler);
	minf->dataHandler = NULL;
}
예제 #3
0
파일: media.c 프로젝트: Keemotion/GPAC4iOS
GF_Err Media_CheckDataEntry(GF_MediaBox *mdia, u32 dataEntryIndex)
{

	GF_DataEntryURLBox *entry;
	GF_DataMap *map;
	GF_Err e;
	if (!mdia || !dataEntryIndex || dataEntryIndex > gf_list_count(mdia->information->dataInformation->dref->other_boxes)) return GF_BAD_PARAM;

	entry = (GF_DataEntryURLBox*)gf_list_get(mdia->information->dataInformation->dref->other_boxes, dataEntryIndex - 1);
	if (!entry) return GF_ISOM_INVALID_FILE;
	if (entry->flags == 1) return GF_OK;
	
	//ok, not self contained, let's go for it...
	//we don't know what's a URN yet
	if (entry->type == GF_ISOM_BOX_TYPE_URN) return GF_NOT_SUPPORTED;
	if (mdia->mediaTrack->moov->mov->openMode == GF_ISOM_OPEN_WRITE) {
		e = gf_isom_datamap_new(entry->location, NULL, GF_ISOM_DATA_MAP_READ, &map);
	} else {
		e = gf_isom_datamap_new(entry->location, mdia->mediaTrack->moov->mov->fileName, GF_ISOM_DATA_MAP_READ, &map);
	}
	if (e) return e;
	gf_isom_datamap_del(map);
	return GF_OK;
}
예제 #4
0
파일: isom_intern.c 프로젝트: renanyoy/gpac
//Create and parse the movie for READ - EDIT only
GF_ISOFile *gf_isom_open_file(const char *fileName, u32 OpenMode, const char *tmp_dir)
{
    GF_Err e;
    u64 bytes;
    GF_ISOFile *mov = gf_isom_new_movie();
    if (! mov) return NULL;

    mov->fileName = gf_strdup(fileName);
    mov->openMode = OpenMode;

    if ( (OpenMode == GF_ISOM_OPEN_READ) || (OpenMode == GF_ISOM_OPEN_READ_DUMP) ) {
        //always in read ...
        mov->openMode = GF_ISOM_OPEN_READ;
        mov->es_id_default_sync = -1;
        //for open, we do it the regular way and let the GF_DataMap assign the appropriate struct
        //this can be FILE (the only one supported...) as well as remote
        //(HTTP, ...),not suported yet
        //the bitstream IS PART OF the GF_DataMap
        //as this is read-only, use a FileMapping. this is the only place where
        //we use file mapping
        e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_READ_ONLY, &mov->movieFileMap);
        if (e) {
            gf_isom_set_last_error(NULL, e);
            gf_isom_delete_movie(mov);
            return NULL;
        }

#ifndef	GPAC_DISABLE_ISOM_FRAGMENTS
        if (OpenMode == GF_ISOM_OPEN_READ_DUMP) mov->FragmentsFlags |= GF_ISOM_FRAG_READ_DEBUG;
#endif

    } else {

#ifdef GPAC_DISABLE_ISOM_WRITE
        //not allowed for READ_ONLY lib
        gf_isom_delete_movie(mov);
        gf_isom_set_last_error(NULL, GF_ISOM_INVALID_MODE);
        return NULL;

#else

        //set a default output name for edited file
        mov->finalName = (char*)gf_malloc(strlen(fileName) + 5);
        if (!mov->finalName) {
            gf_isom_set_last_error(NULL, GF_OUT_OF_MEM);
            gf_isom_delete_movie(mov);
            return NULL;
        }
        strcpy(mov->finalName, "out_");
        strcat(mov->finalName, fileName);

        //open the original file with edit tag
        e = gf_isom_datamap_new(fileName, NULL, GF_ISOM_DATA_MAP_EDIT, &mov->movieFileMap);
        //if the file doesn't exist, we assume it's wanted and create one from scratch
        if (e) {
            gf_isom_set_last_error(NULL, e);
            gf_isom_delete_movie(mov);
            return NULL;
        }
        //and create a temp fileName for the edit
        e = gf_isom_datamap_new("mp4_tmp_edit", tmp_dir, GF_ISOM_DATA_MAP_WRITE, & mov->editFileMap);
        if (e) {
            gf_isom_set_last_error(NULL, e);
            gf_isom_delete_movie(mov);
            return NULL;
        }

        mov->es_id_default_sync = -1;

#endif
    }

    //OK, let's parse the movie...
    mov->LastError = gf_isom_parse_movie_boxes(mov, &bytes, 0);
    if (mov->LastError) {
        gf_isom_set_last_error(NULL, mov->LastError);
        gf_isom_delete_movie(mov);
        return NULL;
    }

    if (OpenMode == GF_ISOM_OPEN_CAT_FRAGMENTS) {
        gf_isom_datamap_del(mov->movieFileMap);
        /*reopen the movie file map in cat mode*/
        e = gf_isom_datamap_new(fileName, tmp_dir, GF_ISOM_DATA_MAP_CAT, & mov->movieFileMap);
    }
    return mov;
}