int mxf_avid_create_metadictionary(MXFHeaderMetadata* headerMetadata, MXFMetadataSet** metaDictSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(MetaDictionary), &newSet)); *metaDictSet = newSet; return 1; }
int mxf_avid_create_typedef_record(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, MXFMetadataSet** typeDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionRecord), id, name, description, &newSet)); *typeDefSet = newSet; return 1; }
static int is_metadata_only_file(MXFHeaderMetadata* headerMetadata, MXFMetadataSet** materialPackageSet) { MXFMetadataSet* prefaceSet; uint32_t essenceContainerCount = 0; CHK_ORET(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(Preface), &prefaceSet)); if (mxf_have_item(prefaceSet, &MXF_ITEM_K(Preface, EssenceContainers))) { CHK_ORET(mxf_get_array_item_count(prefaceSet, &MXF_ITEM_K(Preface, EssenceContainers), &essenceContainerCount)); } if (essenceContainerCount == 0) { CHK_ORET(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(MaterialPackage), materialPackageSet)); return 1; } return 0; }
int mxf_avid_create_typedef_enum(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, const mxfUL* typeId, MXFMetadataSet** typeDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionEnumeration), id, name, description, &newSet)); CHK_ORET(mxf_set_ul_item(newSet, &MXF_ITEM_K(TypeDefinitionEnumeration, Type), typeId)); *typeDefSet = newSet; return 1; }
int mxf_avid_create_typedef_vararray(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, const mxfUL* elementTypeId, MXFMetadataSet** typeDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionVariableArray), id, name, description, &newSet)); CHK_ORET(mxf_set_ul_item(newSet, &MXF_ITEM_K(TypeDefinitionVariableArray, ElementType), elementTypeId)); *typeDefSet = newSet; return 1; }
int mxf_avid_create_typedef_weakref(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, const mxfUL* referencedTypeId, MXFMetadataSet** typeDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionWeakObjectReference), id, name, description, &newSet)); CHK_ORET(mxf_set_ul_item(newSet, &MXF_ITEM_K(TypeDefinitionWeakObjectReference, ReferencedType), referencedTypeId)); *typeDefSet = newSet; return 1; }
int mxf_write_header_sets(MXFFile* mxfFile, MXFHeaderMetadata* headerMetadata) { MXFListIterator iter; MXFMetadataSet* prefaceSet; /* must write the Preface set first (and there must be a Preface set) */ CHK_ORET(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(Preface), &prefaceSet)); CHK_ORET(mxf_write_set(mxfFile, prefaceSet)); mxf_initialise_list_iter(&iter, &headerMetadata->sets); while (mxf_next_list_iter_element(&iter)) { MXFMetadataSet* set = (MXFMetadataSet*)mxf_get_iter_element(&iter); if (!mxf_equals_key(&set->key, &MXF_SET_K(Preface))) { CHK_ORET(mxf_write_set(mxfFile, set)); } } return 1; }
int mxf_avid_create_typedef_integer(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, uint8_t size, mxfBoolean isSigned, MXFMetadataSet** typeDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionInteger), id, name, description, &newSet)); CHK_ORET(mxf_set_uint8_item(newSet, &MXF_ITEM_K(TypeDefinitionInteger, Size), size)); CHK_ORET(mxf_set_boolean_item(newSet, &MXF_ITEM_K(TypeDefinitionInteger, IsSigned), isSigned)); *typeDefSet = newSet; return 1; }
int mxf_avid_create_classdef(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, const mxfUL* parentId, mxfBoolean isConcrete, MXFMetadataSet** classDefSet) { MXFMetadataSet* newSet = NULL; CHK_ORET(mxf_create_set(metaDictSet->headerMetadata, &MXF_SET_K(ClassDefinition), &newSet)); CHK_ORET(mxf_add_array_item_strongref(metaDictSet, &MXF_ITEM_K(MetaDictionary, ClassDefinitions), newSet)); CHK_ORET(mxf_avid_set_metadef_items(newSet, id, name, description)); CHK_ORET(mxf_set_ul_item(newSet, &MXF_ITEM_K(ClassDefinition, ParentClass), parentId)); CHK_ORET(mxf_set_boolean_item(newSet, &MXF_ITEM_K(ClassDefinition, IsConcrete), isConcrete)); *classDefSet = newSet; return 1; }
int is_archive_mxf(MXFHeaderMetadata* headerMetadata) { MXFMetadataSet* prefaceSet; MXFArrayItemIterator arrayIter; uint8_t* arrayElement; uint32_t arrayElementLen; int haveBBCScheme = 0; mxfUL ul; CHK_OFAIL(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(Preface), &prefaceSet)); /* check is OP-1A */ CHK_OFAIL(mxf_get_ul_item(prefaceSet, &MXF_ITEM_K(Preface, OperationalPattern), &ul)); if (!is_op_1a(&ul)) { return 0; } /* check BBC descriptive metadata scheme */ if (mxf_have_item(prefaceSet, &MXF_ITEM_K(Preface, DMSchemes))) { CHK_OFAIL(mxf_initialise_array_item_iterator(prefaceSet, &MXF_ITEM_K(Preface, DMSchemes), &arrayIter)); while (mxf_next_array_item_element(&arrayIter, &arrayElement, &arrayElementLen)) { mxf_get_ul(arrayElement, &ul); if (mxf_equals_ul(&ul, &MXF_DM_L(APP_PreservationDescriptiveScheme))) { haveBBCScheme = 1; break; } } } if (!haveBBCScheme) { return 0; } return 1; fail: return 0; }
int mxf_avid_create_propertydef(MXFPrimerPack* primerPack, MXFMetadataSet* classDefSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, const mxfUL* typeId, mxfBoolean isOptional, mxfLocalTag localId, mxfBoolean isUniqueIdentifier, MXFMetadataSet** propertyDefSet) { MXFMetadataSet* newSet = NULL; mxfLocalTag assignedLocalId; CHK_ORET(mxf_register_primer_entry(primerPack, id, localId, &assignedLocalId)); CHK_ORET(mxf_create_set(classDefSet->headerMetadata, &MXF_SET_K(PropertyDefinition), &newSet)); CHK_ORET(mxf_add_array_item_strongref(classDefSet, &MXF_ITEM_K(ClassDefinition, Properties), newSet)); CHK_ORET(mxf_avid_set_metadef_items(newSet, id, name, description)); CHK_ORET(mxf_set_ul_item(newSet, &MXF_ITEM_K(PropertyDefinition, Type), typeId)); CHK_ORET(mxf_set_boolean_item(newSet, &MXF_ITEM_K(PropertyDefinition, IsOptional), isOptional)); CHK_ORET(mxf_set_uint16_item(newSet, &MXF_ITEM_K(PropertyDefinition, LocalIdentification), assignedLocalId)); if (isUniqueIdentifier) { CHK_ORET(mxf_set_boolean_item(newSet, &MXF_ITEM_K(PropertyDefinition, IsUniqueIdentifier), isUniqueIdentifier)); } *propertyDefSet = newSet; return 1; }
static int process_metadata(MXFReader *reader, MXFPartition *partition) { MXFFile *mxfFile = reader->mxfFile; EssenceReader *essenceReader = reader->essenceReader; EssenceReaderData *data = essenceReader->data; mxfKey key; uint8_t llen; uint64_t len; MXFMetadataSet *essContainerDataSet; MXFMetadataSet *sourcePackageSet; MXFMetadataSet *sourcePackageTrackSet; MXFMetadataSet *materialPackageSet; MXFMetadataSet *materialPackageTrackSet; MXFMetadataSet *descriptorSet; MXFArrayItemIterator arrayIter; mxfUL dataDefUL; MXFTrack *track; EssenceTrack *essenceTrack; MXFList wrappedTracks; MXFList sortedWrappedTracks; WrappedTrack *newWrappedTrack = NULL; WrappedTrack *wrappedTrack; WrappedTrack *sortedWrappedTrack; WrappedTrack *prevSortedWrappedTrack; WrappedTrack *firstSortedWrappedTrack; MXFListIterator listIter; MXFListIterator sortedListIter; int wasInserted; int haveZeroTrackNumber; uint32_t trackID; mxf_initialise_list(&wrappedTracks, free); mxf_initialise_list(&sortedWrappedTracks, NULL); /* create and read the header metadata */ CHK_OFAIL(mxf_read_next_nonfiller_kl(mxfFile, &key, &llen, &len)); CHK_OFAIL(mxf_is_header_metadata(&key)); CHK_OFAIL(mxf_create_header_metadata(&data->headerMetadata, reader->dataModel)); CHK_OFAIL(mxf_read_header_metadata(mxfFile, data->headerMetadata, partition->headerByteCount, &key, llen, len)); /* check for metadata only files */ if (!mxf_find_singular_set_by_key(data->headerMetadata, &MXF_SET_K(EssenceContainerData), &essContainerDataSet)) { reader->isMetadataOnly = 1; return 1; } /* get the body and index SID from the (single essence container; external essence not supported) */ CHK_OFAIL(mxf_get_uint32_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, BodySID), &data->bodySID)); if (mxf_have_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, IndexSID))) { CHK_OFAIL(mxf_get_uint32_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, IndexSID), &data->indexSID)); } else { data->indexSID = 0; } /* get the clip duration */ CHK_OFAIL(get_clip_duration(data->headerMetadata, &reader->clip, 0)); /* get the tracks from the (single) material package */ haveZeroTrackNumber = 0; CHK_OFAIL(mxf_find_singular_set_by_key(data->headerMetadata, &MXF_SET_K(MaterialPackage), &materialPackageSet)); CHK_OFAIL(mxf_uu_get_package_tracks(materialPackageSet, &arrayIter)); while (mxf_uu_next_track(data->headerMetadata, &arrayIter, &materialPackageTrackSet)) { /* CHK_OFAIL(mxf_uu_get_track_datadef(materialPackageTrackSet, &dataDefUL)); */ /* NOTE: not failing because files from Omneon were found to have a missing DataDefinition item in the Sequence and DMSourceClip referenced by a static DM Track */ if (!mxf_uu_get_track_datadef(materialPackageTrackSet, &dataDefUL)) { continue; } if (mxf_is_picture(&dataDefUL) || mxf_is_sound(&dataDefUL)) { CHK_MALLOC_OFAIL(newWrappedTrack, WrappedTrack); memset(newWrappedTrack, 0, sizeof(WrappedTrack)); CHK_OFAIL(mxf_append_list_element(&wrappedTracks, newWrappedTrack)); wrappedTrack = newWrappedTrack; newWrappedTrack = NULL; /* assigned to list so set to NULL so not free'ed in fail */ CHK_OFAIL(add_track(reader, &track)); wrappedTrack->track = track; if (mxf_have_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber))) { CHK_OFAIL(mxf_get_uint32_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber), &wrappedTrack->trackNumber)); } else { wrappedTrack->trackNumber = 0; } CHK_OFAIL(mxf_get_uint32_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackID), &wrappedTrack->trackID)); CHK_OFAIL(mxf_get_rational_item(materialPackageTrackSet, &MXF_ITEM_K(Track, EditRate), &wrappedTrack->editRate)); CHK_OFAIL(mxf_uu_get_track_duration(materialPackageTrackSet, &wrappedTrack->duration)); CHK_OFAIL(mxf_uu_get_track_reference(materialPackageTrackSet, &wrappedTrack->sourcePackageUID, &wrappedTrack->sourceTrackID)); wrappedTrack->isVideo = mxf_is_picture(&dataDefUL); track->isVideo = wrappedTrack->isVideo; track->materialTrackID = wrappedTrack->trackID; track->materialTrackNumber = wrappedTrack->trackNumber; if (wrappedTrack->isVideo) { track->video.frameRate = wrappedTrack->editRate; } if (wrappedTrack->trackNumber == 0) { haveZeroTrackNumber = 1; } } } /* sort the tracks; use trackNumber if != 0 else use the trackID; video track is always first */ mxf_initialise_list_iter(&listIter, &wrappedTracks); while (mxf_next_list_iter_element(&listIter)) { wrappedTrack = (WrappedTrack*)mxf_get_iter_element(&listIter); wasInserted = 0; mxf_initialise_list_iter(&sortedListIter, &sortedWrappedTracks); while (mxf_next_list_iter_element(&sortedListIter)) { sortedWrappedTrack = (WrappedTrack*)mxf_get_iter_element(&sortedListIter); if ((wrappedTrack->track->isVideo && !sortedWrappedTrack->track->isVideo) || (wrappedTrack->track->isVideo == sortedWrappedTrack->track->isVideo && ((!haveZeroTrackNumber && wrappedTrack->trackNumber < sortedWrappedTrack->trackNumber) || (haveZeroTrackNumber && wrappedTrack->trackID < sortedWrappedTrack->trackID)))) { CHK_OFAIL(mxf_insert_list_element(&sortedWrappedTracks, mxf_get_list_iter_index(&sortedListIter), 1, wrappedTrack)); wasInserted = 1; break; } } if (!wasInserted) { CHK_OFAIL(mxf_append_list_element(&sortedWrappedTracks, wrappedTrack)); } } /* set the MXFTracks to the same order */ prevSortedWrappedTrack = NULL; firstSortedWrappedTrack = NULL; mxf_initialise_list_iter(&sortedListIter, &sortedWrappedTracks); while (mxf_next_list_iter_element(&sortedListIter)) { sortedWrappedTrack = (WrappedTrack*)mxf_get_iter_element(&sortedListIter); if (firstSortedWrappedTrack == NULL) { firstSortedWrappedTrack = sortedWrappedTrack; } if (prevSortedWrappedTrack != NULL) { prevSortedWrappedTrack->track->next = sortedWrappedTrack->track; } prevSortedWrappedTrack = sortedWrappedTrack; } if (prevSortedWrappedTrack != NULL) { prevSortedWrappedTrack->track->next = NULL; } if (firstSortedWrappedTrack != NULL) { reader->clip.tracks = firstSortedWrappedTrack->track; } /* process source package tracks and linked descriptors */ mxf_initialise_list_iter(&sortedListIter, &sortedWrappedTracks); while (mxf_next_list_iter_element(&sortedListIter)) { sortedWrappedTrack = (WrappedTrack*)mxf_get_iter_element(&sortedListIter); CHK_OFAIL(mxf_uu_get_referenced_track(data->headerMetadata, &sortedWrappedTrack->sourcePackageUID, sortedWrappedTrack->sourceTrackID, &sourcePackageTrackSet)); CHK_OFAIL(add_essence_track(essenceReader, &essenceTrack)); essenceTrack->isVideo = sortedWrappedTrack->isVideo; if (mxf_have_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber))) { CHK_OFAIL(mxf_get_uint32_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber), &essenceTrack->trackNumber)); } else { essenceTrack->trackNumber = 0; } CHK_OFAIL(mxf_get_uint32_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackID), &trackID)); essenceTrack->frameRate = reader->clip.frameRate; essenceTrack->playoutDuration = reader->clip.duration; essenceTrack->indexSID = data->indexSID; essenceTrack->bodySID = data->bodySID; /* process the descriptor */ CHK_OFAIL(mxf_uu_get_referenced_package(data->headerMetadata, &sortedWrappedTrack->sourcePackageUID, &sourcePackageSet)); CHK_OFAIL(mxf_uu_get_track_descriptor(sourcePackageSet, trackID, &descriptorSet)); if (mxf_is_subclass_of(data->headerMetadata->dataModel, &descriptorSet->key, &MXF_SET_K(CDCIEssenceDescriptor))) { CHK_OFAIL(process_cdci_descriptor(descriptorSet, sortedWrappedTrack->track, essenceTrack)); } else if (mxf_is_subclass_of(data->headerMetadata->dataModel, &descriptorSet->key, &MXF_SET_K(WaveAudioDescriptor))) { CHK_OFAIL(process_wav_descriptor(descriptorSet, sortedWrappedTrack->track, essenceTrack)); } else if (mxf_is_subclass_of(data->headerMetadata->dataModel, &descriptorSet->key, &MXF_SET_K(GenericSoundEssenceDescriptor))) { CHK_OFAIL(process_sound_descriptor(descriptorSet, track, essenceTrack)); } else { mxf_log_error("Unsupported file descriptor" LOG_LOC_FORMAT, LOG_LOC_PARAMS); return 0; } } /* initialise the playout timecode */ if (!initialise_playout_timecode(reader, materialPackageSet)) { CHK_ORET(initialise_default_playout_timecode(reader)); } /* initialise the source timecodes */ initialise_source_timecodes(reader, sourcePackageSet); mxf_clear_list(&wrappedTracks); mxf_clear_list(&sortedWrappedTracks); return 1; fail: SAFE_FREE(newWrappedTrack); mxf_clear_list(&wrappedTracks); mxf_clear_list(&sortedWrappedTracks); return 0; }
int write_dv50(FILE* dv50File, MXFFile* mxfFile, int test) { MXFFilePartitions partitions; MXFPartition* headerPartition; MXFPartition* bodyPartition; MXFPartition* footerPartition; MXFHeaderMetadata* headerMetadata = NULL; MXFMetadataSet* metaDictSet = NULL; MXFMetadataSet* prefaceSet = NULL; MXFMetadataSet* identSet = NULL; MXFMetadataSet* contentStorageSet = NULL; MXFMetadataSet* sourcePackageSet = NULL; MXFMetadataSet* materialPackageSet = NULL; MXFMetadataSet* sourcePackageTrackSet = NULL; MXFMetadataSet* materialPackageTrackSet = NULL; MXFMetadataSet* sequenceSet = NULL; MXFMetadataSet* sourceClipSet = NULL; MXFMetadataSet* essContainerDataSet = NULL; MXFMetadataSet* cdciDescriptorSet = NULL; MXFDataModel* dataModel = NULL; MXFIndexTableSegment* indexSegment = NULL; MXFEssenceElement* essenceElement = NULL; MXFMetadataItem* durationItem1 = NULL; MXFMetadataItem* durationItem2 = NULL; MXFMetadataItem* durationItem3 = NULL; MXFMetadataItem* durationItem4 = NULL; MXFMetadataItem* durationItem5 = NULL; MXFMetadataItem* imageSizeItem = NULL; mxfTimestamp now; uint32_t bodySID = 1; uint32_t indexSID = 2; mxfUUID thisGeneration; mxfUTF16Char* companyName = L"BBC Research"; mxfUTF16Char* productName = L"Write Avid DV-50 example"; mxfUTF16Char* versionString = L"Alpha version"; mxfUMID sourcePackageUMID; mxfUMID materialPackageUMID; uint32_t sourceTrackID = 1; uint32_t sourceTrackNumber = 0x18010201; mxfRational sampleRate = {25, 1}; mxfRational editRate = sampleRate; mxfLength duration = 0; mxfRational aspectRatio = {4, 3}; mxfUUID indexSegmentUUID; uint32_t frameSize = 288000; int32_t imageSize = 0; int32_t resolutionID = 0x8e; const uint32_t essenceBufferSize = 4096; uint8_t buffer[4096]; int done = 0; uint8_t* arrayElement; int64_t headerMetadataPos; mxf_generate_uuid(&thisGeneration); mxf_get_timestamp_now(&now); /* Older Avids could fail when given files with UMIDs generated using other methods. (Note: not 100% sure this is true) */ mxf_generate_aafsdk_umid(&sourcePackageUMID); mxf_generate_aafsdk_umid(&materialPackageUMID); mxf_generate_uuid(&indexSegmentUUID); mxf_initialise_file_partitions(&partitions); /* set the minimum llen */ mxf_file_set_min_llen(mxfFile, 4); /* load the data model, plus AVID extensions */ CHK_ORET(mxf_load_data_model(&dataModel)); CHK_ORET(mxf_avid_load_extensions(dataModel)); CHK_ORET(mxf_finalise_data_model(dataModel)); /* write the header partition pack */ CHK_ORET(mxf_append_new_partition(&partitions, &headerPartition)); headerPartition->key = MXF_PP_K(ClosedComplete, Header); headerPartition->majorVersion = 1; headerPartition->minorVersion = 2; headerPartition->kagSize = 0x100; headerPartition->operationalPattern = MXF_OP_L(atom, NTracks_1SourceClip); CHK_ORET(mxf_append_partition_esscont_label(headerPartition, &MXF_EC_L(DVBased_50_625_50_ClipWrapped))); CHK_ORET(mxf_write_partition(mxfFile, headerPartition)); CHK_ORET(mxf_fill_to_kag(mxfFile, headerPartition)); /* create the header metadata */ CHK_ORET(mxf_create_header_metadata(&headerMetadata, dataModel)); /* create the Avid meta-dictionary */ CHK_ORET(mxf_avid_create_default_metadictionary(headerMetadata, &metaDictSet)); /* Preface */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Preface), &prefaceSet)); CHK_ORET(mxf_set_timestamp_item(prefaceSet, &MXF_ITEM_K(Preface, LastModifiedDate), &now)); CHK_ORET(mxf_set_version_type_item(prefaceSet, &MXF_ITEM_K(Preface, Version), 0x0102)); CHK_ORET(mxf_set_ul_item(prefaceSet, &MXF_ITEM_K(Preface, OperationalPattern), &MXF_OP_L(atom, NTracks_1SourceClip))); CHK_ORET(mxf_alloc_array_item_elements(prefaceSet, &MXF_ITEM_K(Preface, EssenceContainers), mxfUL_extlen, 1, &arrayElement)); mxf_set_ul(&MXF_EC_L(DVBased_50_625_50_ClipWrapped), arrayElement); /* Preface - Identification */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Identification), &identSet)); CHK_ORET(mxf_add_array_item_strongref(prefaceSet, &MXF_ITEM_K(Preface, Identifications), identSet)); CHK_ORET(mxf_set_uuid_item(identSet, &MXF_ITEM_K(Identification, ThisGenerationUID), &thisGeneration)); CHK_ORET(mxf_set_utf16string_item(identSet, &MXF_ITEM_K(Identification, CompanyName), companyName)); CHK_ORET(mxf_set_utf16string_item(identSet, &MXF_ITEM_K(Identification, ProductName), productName)); CHK_ORET(mxf_set_utf16string_item(identSet, &MXF_ITEM_K(Identification, VersionString), versionString)); CHK_ORET(mxf_set_uuid_item(identSet, &MXF_ITEM_K(Identification, ProductUID), &g_WrapDV50ProductUID_uuid)); CHK_ORET(mxf_set_timestamp_item(identSet, &MXF_ITEM_K(Identification, ModificationDate), &now)); CHK_ORET(mxf_set_product_version_item(identSet, &MXF_ITEM_K(Identification, ToolkitVersion), mxf_get_version())); if (test) { /* use the same string on all platforms to make checking diffs easier */ CHK_ORET(mxf_set_utf16string_item(identSet, &MXF_ITEM_K(Identification, Platform), L"test platform string")); } else { CHK_ORET(mxf_set_utf16string_item(identSet, &MXF_ITEM_K(Identification, Platform), mxf_get_platform_wstring())); } /* Preface - ContentStorage */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(ContentStorage), &contentStorageSet)); CHK_ORET(mxf_set_strongref_item(prefaceSet, &MXF_ITEM_K(Preface, ContentStorage), contentStorageSet)); /* Preface - ContentStorage - MaterialPackage */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(MaterialPackage), &materialPackageSet)); CHK_ORET(mxf_add_array_item_strongref(contentStorageSet, &MXF_ITEM_K(ContentStorage, Packages), materialPackageSet)); CHK_ORET(mxf_set_umid_item(materialPackageSet, &MXF_ITEM_K(GenericPackage, PackageUID), &materialPackageUMID)); CHK_ORET(mxf_set_timestamp_item(materialPackageSet, &MXF_ITEM_K(GenericPackage, PackageCreationDate), &now)); CHK_ORET(mxf_set_timestamp_item(materialPackageSet, &MXF_ITEM_K(GenericPackage, PackageModifiedDate), &now)); CHK_ORET(mxf_set_utf16string_item(materialPackageSet, &MXF_ITEM_K(GenericPackage, Name), L"writedv50 material")); /* Preface - ContentStorage - MaterialPackage - Timeline Track */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Track), &materialPackageTrackSet)); CHK_ORET(mxf_add_array_item_strongref(materialPackageSet, &MXF_ITEM_K(GenericPackage, Tracks), materialPackageTrackSet)); CHK_ORET(mxf_set_uint32_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackID), sourceTrackID)); CHK_ORET(mxf_set_uint32_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber), sourceTrackNumber)); CHK_ORET(mxf_set_rational_item(materialPackageTrackSet, &MXF_ITEM_K(Track, EditRate), &editRate)); CHK_ORET(mxf_set_position_item(materialPackageTrackSet, &MXF_ITEM_K(Track, Origin), 0)); /* Preface - ContentStorage - MaterialPackage - Timeline Track - Sequence */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Sequence), &sequenceSet)); CHK_ORET(mxf_set_strongref_item(materialPackageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), sequenceSet)); CHK_ORET(mxf_set_ul_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, DataDefinition), &MXF_DDEF_L(LegacyPicture))); CHK_ORET(mxf_set_length_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, Duration), duration)); CHK_ORET(mxf_get_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, Duration), &durationItem1)); /* Preface - ContentStorage - MaterialPackage - Timeline Track - Sequence - SourceClip */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(SourceClip), &sourceClipSet)); CHK_ORET(mxf_add_array_item_strongref(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), sourceClipSet)); CHK_ORET(mxf_set_ul_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, DataDefinition), &MXF_DDEF_L(LegacyPicture))); CHK_ORET(mxf_set_length_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, Duration), duration)); CHK_ORET(mxf_set_position_item(sourceClipSet, &MXF_ITEM_K(SourceClip, StartPosition), 0)); CHK_ORET(mxf_set_umid_item(sourceClipSet, &MXF_ITEM_K(SourceClip, SourcePackageID), &sourcePackageUMID)); CHK_ORET(mxf_set_uint32_item(sourceClipSet, &MXF_ITEM_K(SourceClip, SourceTrackID), sourceTrackID)); CHK_ORET(mxf_get_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, Duration), &durationItem2)); /* Preface - ContentStorage - SourcePackage */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(SourcePackage), &sourcePackageSet)); CHK_ORET(mxf_add_array_item_strongref(contentStorageSet, &MXF_ITEM_K(ContentStorage, Packages), sourcePackageSet)); CHK_ORET(mxf_set_weakref_item(prefaceSet, &MXF_ITEM_K(Preface, PrimaryPackage), sourcePackageSet)); CHK_ORET(mxf_set_umid_item(sourcePackageSet, &MXF_ITEM_K(GenericPackage, PackageUID), &sourcePackageUMID)); CHK_ORET(mxf_set_timestamp_item(sourcePackageSet, &MXF_ITEM_K(GenericPackage, PackageCreationDate), &now)); CHK_ORET(mxf_set_timestamp_item(sourcePackageSet, &MXF_ITEM_K(GenericPackage, PackageModifiedDate), &now)); CHK_ORET(mxf_set_utf16string_item(sourcePackageSet, &MXF_ITEM_K(GenericPackage, Name), L"writedv50 source")); /* Preface - ContentStorage - SourcePackage - Timeline Track */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Track), &sourcePackageTrackSet)); CHK_ORET(mxf_add_array_item_strongref(sourcePackageSet, &MXF_ITEM_K(GenericPackage, Tracks), sourcePackageTrackSet)); CHK_ORET(mxf_set_uint32_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackID), sourceTrackID)); CHK_ORET(mxf_set_uint32_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, TrackNumber), sourceTrackNumber)); CHK_ORET(mxf_set_rational_item(sourcePackageTrackSet, &MXF_ITEM_K(Track, EditRate), &editRate)); CHK_ORET(mxf_set_position_item(sourcePackageTrackSet, &MXF_ITEM_K(Track, Origin), 0)); /* Preface - ContentStorage - SourcePackage - Timeline Track - Sequence */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(Sequence), &sequenceSet)); CHK_ORET(mxf_set_strongref_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), sequenceSet)); CHK_ORET(mxf_set_ul_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, DataDefinition), &MXF_DDEF_L(LegacyPicture))); CHK_ORET(mxf_set_length_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, Duration), duration)); CHK_ORET(mxf_get_item(sequenceSet, &MXF_ITEM_K(StructuralComponent, Duration), &durationItem3)); /* Preface - ContentStorage - SourcePackage - Timeline Track - Sequence - SourceClip */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(SourceClip), &sourceClipSet)); CHK_ORET(mxf_add_array_item_strongref(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), sourceClipSet)); CHK_ORET(mxf_set_ul_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, DataDefinition), &MXF_DDEF_L(LegacyPicture))); CHK_ORET(mxf_set_length_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, Duration), duration)); CHK_ORET(mxf_set_position_item(sourceClipSet, &MXF_ITEM_K(SourceClip, StartPosition), 0)); CHK_ORET(mxf_set_umid_item(sourceClipSet, &MXF_ITEM_K(SourceClip, SourcePackageID), &g_Null_UMID)); CHK_ORET(mxf_set_uint32_item(sourceClipSet, &MXF_ITEM_K(SourceClip, SourceTrackID), 0)); CHK_ORET(mxf_get_item(sourceClipSet, &MXF_ITEM_K(StructuralComponent, Duration), &durationItem4)); /* Preface - ContentStorage - SourcePackage - CDCIEssenceDescriptor */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(CDCIEssenceDescriptor), &cdciDescriptorSet)); CHK_ORET(mxf_set_strongref_item(sourcePackageSet, &MXF_ITEM_K(SourcePackage, Descriptor), cdciDescriptorSet)); CHK_ORET(mxf_set_rational_item(cdciDescriptorSet, &MXF_ITEM_K(FileDescriptor, SampleRate), &sampleRate)); CHK_ORET(mxf_set_length_item(cdciDescriptorSet, &MXF_ITEM_K(FileDescriptor, ContainerDuration), duration)); CHK_ORET(mxf_set_ul_item(cdciDescriptorSet, &MXF_ITEM_K(FileDescriptor, EssenceContainer), &MXF_EC_L(DVBased_50_625_50_ClipWrapped))); CHK_ORET(mxf_set_ul_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, PictureEssenceCoding), &MXF_CMDEF_L(DVBased_50_625_50))); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, StoredHeight), 288)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, StoredWidth), 720)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, SampledHeight), 288)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, SampledWidth), 720)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, SampledXOffset), 0)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, SampledYOffset), 0)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, DisplayHeight), 288)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, DisplayWidth), 720)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, DisplayXOffset), 0)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, DisplayYOffset), 0)); CHK_ORET(mxf_set_uint8_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, FrameLayout), 1)); CHK_ORET(mxf_alloc_array_item_elements(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, VideoLineMap), 4, 2, &arrayElement)); mxf_set_int32(23, arrayElement); mxf_set_int32(335, &arrayElement[4]); CHK_ORET(mxf_set_rational_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, AspectRatio), &aspectRatio)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, ImageAlignmentOffset), 1)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, ComponentDepth), 8)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, HorizontalSubsampling), 2)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, VerticalSubsampling), 1)); CHK_ORET(mxf_set_uint8_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, ColorSiting), 4)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, BlackRefLevel), 16)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, WhiteReflevel), 235)); CHK_ORET(mxf_set_uint32_item(cdciDescriptorSet, &MXF_ITEM_K(CDCIEssenceDescriptor, ColorRange), 225)); CHK_ORET(mxf_get_item(cdciDescriptorSet, &MXF_ITEM_K(FileDescriptor, ContainerDuration), &durationItem5)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, ResolutionID), resolutionID)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, FrameSampleSize), frameSize)); CHK_ORET(mxf_set_int32_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, ImageSize), 0)); CHK_ORET(mxf_get_item(cdciDescriptorSet, &MXF_ITEM_K(GenericPictureEssenceDescriptor, ImageSize), &imageSizeItem)); /* Preface - ContentStorage - EssenceContainerData */ CHK_ORET(mxf_create_set(headerMetadata, &MXF_SET_K(EssenceContainerData), &essContainerDataSet)); CHK_ORET(mxf_add_array_item_strongref(contentStorageSet, &MXF_ITEM_K(ContentStorage, EssenceContainerData), essContainerDataSet)); CHK_ORET(mxf_set_umid_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, LinkedPackageUID), &sourcePackageUMID)); CHK_ORET(mxf_set_uint32_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, IndexSID), indexSID)); CHK_ORET(mxf_set_uint32_item(essContainerDataSet, &MXF_ITEM_K(EssenceContainerData, BodySID), bodySID)); /* write the header metadata with Avid extensions */ CHK_ORET((headerMetadataPos = mxf_file_tell(mxfFile)) >= 0); CHK_ORET(mxf_mark_header_start(mxfFile, headerPartition)); CHK_ORET(mxf_avid_write_header_metadata(mxfFile, headerMetadata, headerPartition)); CHK_ORET(mxf_fill_to_kag(mxfFile, headerPartition)); CHK_ORET(mxf_mark_header_end(mxfFile, headerPartition)); /* write the body partition pack */ CHK_ORET(mxf_append_new_from_partition(&partitions, headerPartition, &bodyPartition)); bodyPartition->key = MXF_PP_K(ClosedComplete, Body); bodyPartition->kagSize = 0x200; bodyPartition->bodySID = bodySID; CHK_ORET(mxf_write_partition(mxfFile, bodyPartition)); CHK_ORET(mxf_fill_to_kag(mxfFile, bodyPartition)); /* write the DV-50 essence element */ CHK_ORET(mxf_open_essence_element_write(mxfFile, &MXF_EE_K(DVClipWrapped), 8, 0, &essenceElement)); while (!done) { size_t numRead = fread(buffer, 1, essenceBufferSize, dv50File); if (numRead < essenceBufferSize) { if (!feof(dv50File)) { fprintf(stderr, "Failed to read bytes from dv50 file\n"); return 0; } done = 1; } CHK_ORET(mxf_write_essence_element_data(mxfFile, essenceElement, buffer, (uint32_t)numRead)); } duration = essenceElement->totalLen / frameSize; imageSize = (int32_t)essenceElement->totalLen; CHK_ORET(mxf_finalize_essence_element_write(mxfFile, essenceElement)); mxf_close_essence_element(&essenceElement); CHK_ORET(mxf_fill_to_kag(mxfFile, bodyPartition)); /* write the footer partition pack */ CHK_ORET(mxf_append_new_from_partition(&partitions, headerPartition, &footerPartition)); footerPartition->key = MXF_PP_K(ClosedComplete, Footer); footerPartition->kagSize = 0x200; footerPartition->indexSID = indexSID; CHK_ORET(mxf_write_partition(mxfFile, footerPartition)); CHK_ORET(mxf_fill_to_kag(mxfFile, footerPartition)); /* write the index table segment */ CHK_ORET(mxf_mark_index_start(mxfFile, footerPartition)); CHK_ORET(mxf_create_index_table_segment(&indexSegment)); indexSegment->instanceUID = indexSegmentUUID; indexSegment->indexEditRate = editRate; indexSegment->indexStartPosition = 0; indexSegment->indexDuration = duration; indexSegment->editUnitByteCount = frameSize; indexSegment->indexSID = indexSID; indexSegment->bodySID = bodySID; indexSegment->sliceCount = 0; indexSegment->posTableCount = 0; indexSegment->deltaEntryArray = NULL; indexSegment->indexEntryArray = NULL; CHK_ORET(mxf_write_index_table_segment(mxfFile, indexSegment)); CHK_ORET(mxf_fill_to_kag(mxfFile, footerPartition)); CHK_ORET(mxf_mark_index_end(mxfFile, footerPartition)); /* write the random index pack */ CHK_ORET(mxf_write_rip(mxfFile, &partitions)); /* update and re-write the header metadata */ /* Note: the size will not change so it is safe to re-write */ CHK_ORET(mxf_set_length_item(durationItem1->set, &durationItem1->key, duration)); CHK_ORET(mxf_set_length_item(durationItem2->set, &durationItem2->key, duration)); CHK_ORET(mxf_set_length_item(durationItem3->set, &durationItem3->key, duration)); CHK_ORET(mxf_set_length_item(durationItem4->set, &durationItem4->key, duration)); CHK_ORET(mxf_set_length_item(durationItem5->set, &durationItem5->key, duration)); CHK_ORET(mxf_set_int32_item(imageSizeItem->set, &imageSizeItem->key, imageSize)); CHK_ORET(mxf_file_seek(mxfFile, headerMetadataPos, SEEK_SET)); CHK_ORET(mxf_mark_header_start(mxfFile, headerPartition)); CHK_ORET(mxf_avid_write_header_metadata(mxfFile, headerMetadata, headerPartition)); CHK_ORET(mxf_fill_to_kag(mxfFile, headerPartition)); CHK_ORET(mxf_mark_header_end(mxfFile, headerPartition)); /* update the partitions */ CHK_ORET(mxf_update_partitions(mxfFile, &partitions)); /* free memory resources */ mxf_free_index_table_segment(&indexSegment); mxf_clear_file_partitions(&partitions); mxf_free_header_metadata(&headerMetadata); mxf_free_data_model(&dataModel); return 1; }
int archive_mxf_get_info(MXFHeaderMetadata* headerMetadata, ArchiveMXFInfo* info) { MXFList* list = NULL; MXFListIterator iter; MXFArrayItemIterator arrayIter; uint8_t* arrayElement; uint32_t arrayElementLen; mxfUL dataDef; uint32_t count; mxfUTF16Char* tempWString = NULL; int haveSourceInfaxData = 0; MXFList* nameList = NULL; MXFList* valueList = NULL; MXFMetadataSet* identSet; MXFMetadataSet* fileSourcePackageSet; MXFMetadataSet* sourcePackageSet; MXFMetadataSet* sourcePackageTrackSet; MXFMetadataSet* sequenceSet; MXFMetadataSet* dmSet; MXFMetadataSet* dmFrameworkSet; MXFMetadataSet* descriptorSet; MXFMetadataSet* locatorSet; MXFMetadataSet* materialPackageSet; /* if metadata only then only try reading infax user comments */ if (is_metadata_only_file(headerMetadata, &materialPackageSet)) { if (mxf_avid_read_string_user_comments(materialPackageSet, &nameList, &valueList)) { haveSourceInfaxData = parse_infax_user_comments(nameList, valueList, &info->sourceInfaxData); mxf_free_list(&nameList); mxf_free_list(&valueList); } return 1; } /* Creation timestamp identification info */ CHK_OFAIL(mxf_find_set_by_key(headerMetadata, &MXF_SET_K(Identification), &list)); mxf_initialise_list_iter(&iter, list); if (mxf_next_list_iter_element(&iter)) { identSet = (MXFMetadataSet*)mxf_get_iter_element(&iter); CHK_OFAIL(mxf_get_timestamp_item(identSet, &MXF_ITEM_K(Identification, ModificationDate), &info->creationDate)); } mxf_free_list(&list); /* LTO Infax data */ CHK_OFAIL(mxf_uu_get_top_file_package(headerMetadata, &fileSourcePackageSet)); CHK_OFAIL(mxf_uu_get_package_tracks(fileSourcePackageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &sourcePackageTrackSet)) { CHK_OFAIL(mxf_uu_get_track_datadef(sourcePackageTrackSet, &dataDef)); if (mxf_is_descriptive_metadata(&dataDef)) { /* get to the single DMSegment */ CHK_OFAIL(mxf_get_strongref_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count != 1) { /* Sequence of length 1 is expected for the DMS track */ continue; } CHK_OFAIL(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &dmSet)); } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { CHK_OFAIL(mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); /* if it is a APP_InfaxFramework then it is the Infax data */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_InfaxFramework))) { CHK_OFAIL(get_infax_data(dmFrameworkSet, &info->ltoInfaxData)); break; } } } } } /* original filename */ CHK_OFAIL(mxf_get_strongref_item(fileSourcePackageSet, &MXF_ITEM_K(SourcePackage, Descriptor), &descriptorSet)); if (mxf_have_item(descriptorSet, &MXF_ITEM_K(GenericDescriptor, Locators))) { CHK_OFAIL(mxf_initialise_array_item_iterator(descriptorSet, &MXF_ITEM_K(GenericDescriptor, Locators), &arrayIter)); while (mxf_next_array_item_element(&arrayIter, &arrayElement, &arrayElementLen)) { CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &locatorSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &locatorSet->key, &MXF_SET_K(NetworkLocator))) { CHK_OFAIL(mxf_uu_get_utf16string_item(locatorSet, &MXF_ITEM_K(NetworkLocator, URLString), &tempWString)); CHK_OFAIL(wcstombs(info->filename, tempWString, sizeof(info->filename)) != (size_t)(-1)); info->filename[sizeof(info->filename) - 1] = '\0'; SAFE_FREE(&tempWString); break; } } } /* source Infax data */ CHK_OFAIL(mxf_find_set_by_key(headerMetadata, &MXF_SET_K(SourcePackage), &list)); mxf_initialise_list_iter(&iter, list); while (mxf_next_list_iter_element(&iter)) { sourcePackageSet = (MXFMetadataSet*)(mxf_get_iter_element(&iter)); /* it is the tape SourcePackage if it has a TapeDescriptor */ CHK_OFAIL(mxf_get_strongref_item(sourcePackageSet, &MXF_ITEM_K(SourcePackage, Descriptor), &descriptorSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &descriptorSet->key, &MXF_SET_K(TapeDescriptor))) { /* go through the tracks and find the DMS track */ CHK_OFAIL(mxf_uu_get_package_tracks(sourcePackageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &sourcePackageTrackSet)) { CHK_OFAIL(mxf_uu_get_track_datadef(sourcePackageTrackSet, &dataDef)); if (mxf_is_descriptive_metadata(&dataDef)) { /* get to the single DMSegment */ CHK_OFAIL(mxf_get_strongref_item(sourcePackageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count != 1) { /* Sequence of length 1 is expected for the DMS track */ continue; } CHK_OFAIL(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &dmSet)); } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { CHK_OFAIL(mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); /* if it is a APP_InfaxFramework then it is the Infax data */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_InfaxFramework))) { CHK_OFAIL(get_infax_data(dmFrameworkSet, &info->sourceInfaxData)); haveSourceInfaxData = 1; break; } } } } } break; } } mxf_free_list(&list); /* try reading Infax data from UserComments attached to the MaterialPackage if no data was found elsewhere */ if (!haveSourceInfaxData) { CHK_OFAIL(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(MaterialPackage), &materialPackageSet)); if (mxf_avid_read_string_user_comments(materialPackageSet, &nameList, &valueList)) { haveSourceInfaxData = parse_infax_user_comments(nameList, valueList, &info->sourceInfaxData); mxf_free_list(&nameList); mxf_free_list(&valueList); } } return haveSourceInfaxData; fail: SAFE_FREE(&tempWString); mxf_free_list(&list); mxf_free_list(&nameList); mxf_free_list(&valueList); return 0; }
static int archive_mxf_get_package_timecode_breaks(MXFHeaderMetadata* headerMetadata, MXFMetadataSet* packageSet, TimecodeBreak** timecodeBreaks, long* numTimecodeBreaks) { MXFArrayItemIterator arrayIter; MXFArrayItemIterator arrayIter2; uint8_t* arrayElement; uint32_t arrayElementLen; mxfUL dataDef; uint32_t count; MXFMetadataSet* packageTrackSet; MXFMetadataSet* sequenceSet; MXFMetadataSet* dmSet; MXFMetadataSet* dmFrameworkSet; MXFListIterator setsIter; TimecodeBreak* newTimecodeBreaks = NULL; long totalBreaks = 0; TimecodeBreak* tmp; CHK_OFAIL(mxf_uu_get_package_tracks(packageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &packageTrackSet)) { CHK_OFAIL(mxf_uu_get_track_datadef(packageTrackSet, &dataDef)); if (mxf_is_descriptive_metadata(&dataDef)) { /* get to the sequence */ CHK_OFAIL(mxf_get_strongref_item(packageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count == 0) { continue; } CHK_OFAIL(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &dmSet)); } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { CHK_OFAIL(mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); /* check whether the DMFrameworkSet is a APP_TimecodeBreakFramework */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_TimecodeBreakFramework))) { /* go back to the sequence and extract the timecode breaks */ CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (newTimecodeBreaks == NULL) { CHK_OFAIL((tmp = malloc(sizeof(TimecodeBreak) * (totalBreaks + count))) != NULL); } else { /* multiple tracks with timecode breaks - reallocate the array */ CHK_OFAIL((tmp = realloc(newTimecodeBreaks, sizeof(TimecodeBreak) * (totalBreaks + count))) != NULL); } newTimecodeBreaks = tmp; /* extract the digibeta dropouts */ initialise_sets_iter(headerMetadata, &setsIter); mxf_initialise_array_item_iterator(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &arrayIter2); while (mxf_next_array_item_element(&arrayIter2, &arrayElement, &arrayElementLen)) { TimecodeBreak* timecodeBreak = &newTimecodeBreaks[totalBreaks]; CHK_OFAIL(mxf_get_strongref_s(headerMetadata, &setsIter, arrayElement, &dmSet)); CHK_OFAIL(mxf_get_position_item(dmSet, &MXF_ITEM_K(DMSegment, EventStartPosition), &timecodeBreak->position)); CHK_OFAIL(mxf_get_strongref_item_s(&setsIter, dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); CHK_OFAIL(mxf_get_uint16_item(dmFrameworkSet, &MXF_ITEM_K(APP_TimecodeBreakFramework, APP_TimecodeType), &timecodeBreak->timecodeType)); totalBreaks++; } } } } } } *timecodeBreaks = newTimecodeBreaks; *numTimecodeBreaks = totalBreaks; return 1; fail: SAFE_FREE(&newTimecodeBreaks); return 0; }
static int archive_mxf_get_package_pse_failures(MXFHeaderMetadata* headerMetadata, MXFMetadataSet* packageSet, PSEFailure** failures, long* numFailures) { MXFArrayItemIterator arrayIter; MXFArrayItemIterator arrayIter2; uint8_t* arrayElement; uint32_t arrayElementLen; mxfUL dataDef; uint32_t count; MXFMetadataSet* packageTrackSet; MXFMetadataSet* sequenceSet; MXFMetadataSet* dmSet; MXFMetadataSet* dmFrameworkSet; MXFListIterator setsIter; PSEFailure* newFailures = NULL; long countedPSEFailures = 0; PSEFailure* tmp; int32_t i; CHK_OFAIL(mxf_uu_get_package_tracks(packageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &packageTrackSet)) { CHK_OFAIL(mxf_uu_get_track_datadef(packageTrackSet, &dataDef)); if (mxf_is_descriptive_metadata(&dataDef)) { /* get to the sequence */ CHK_OFAIL(mxf_get_strongref_item(packageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count == 0) { continue; } CHK_OFAIL(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &dmSet)); } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { CHK_OFAIL(mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); /* check whether the DMFrameworkSet is a APP_PSEAnalysisFramework */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_PSEAnalysisFramework))) { /* go back to the sequence and extract the PSE failures */ CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); countedPSEFailures += count; if (newFailures == NULL) { CHK_OFAIL((tmp = malloc(sizeof(PSEFailure) * countedPSEFailures)) != NULL); } else { /* multiple tracks with PSE failures - reallocate the array */ CHK_OFAIL((tmp = realloc(newFailures, sizeof(PSEFailure) * countedPSEFailures)) != NULL); } newFailures = tmp; /* extract the PSE failures */ initialise_sets_iter(headerMetadata, &setsIter); i = 0; mxf_initialise_array_item_iterator(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &arrayIter2); while (mxf_next_array_item_element(&arrayIter2, &arrayElement, &arrayElementLen)) { PSEFailure* pseFailure = &newFailures[i]; CHK_OFAIL(mxf_get_strongref_s(headerMetadata, &setsIter, arrayElement, &dmSet)); CHK_OFAIL(mxf_get_position_item(dmSet, &MXF_ITEM_K(DMSegment, EventStartPosition), &pseFailure->position)); CHK_OFAIL(mxf_get_strongref_item_s(&setsIter, dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); CHK_OFAIL(mxf_get_int16_item(dmFrameworkSet, &MXF_ITEM_K(APP_PSEAnalysisFramework, APP_RedFlash), &pseFailure->redFlash)); CHK_OFAIL(mxf_get_int16_item(dmFrameworkSet, &MXF_ITEM_K(APP_PSEAnalysisFramework, APP_SpatialPattern), &pseFailure->spatialPattern)); CHK_OFAIL(mxf_get_int16_item(dmFrameworkSet, &MXF_ITEM_K(APP_PSEAnalysisFramework, APP_LuminanceFlash), &pseFailure->luminanceFlash)); CHK_OFAIL(mxf_get_boolean_item(dmFrameworkSet, &MXF_ITEM_K(APP_PSEAnalysisFramework, APP_ExtendedFailure), &pseFailure->extendedFailure)); i++; } break; } } } } } *failures = newFailures; *numFailures = countedPSEFailures; return 1; fail: SAFE_FREE(&newFailures); return 0; }
static int archive_mxf_get_package_vtr_errors(MXFHeaderMetadata *headerMetadata, MXFMetadataSet *packageSet, VTRErrorAtPos **errors, size_t *numErrors) { MXFArrayItemIterator arrayIter; MXFArrayItemIterator arrayIter2; uint8_t *arrayElement; uint32_t arrayElementLen; mxfUL dataDef; uint32_t count; MXFMetadataSet *packageTrackSet; MXFMetadataSet *sequenceSet; MXFMetadataSet *dmSet; MXFMetadataSet *dmFrameworkSet; MXFListIterator setsIter; VTRErrorAtPos *newErrors = NULL; size_t totalErrors = 0; VTRErrorAtPos *tmp; CHK_OFAIL(mxf_uu_get_package_tracks(packageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &packageTrackSet)) { CHK_OFAIL(mxf_uu_get_track_datadef(packageTrackSet, &dataDef)); if (mxf_is_descriptive_metadata(&dataDef)) { /* get to the sequence */ CHK_OFAIL(mxf_get_strongref_item(packageTrackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count == 0) { continue; } CHK_OFAIL(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &dmSet)); } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { CHK_OFAIL(mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); /* check whether the DMFrameworkSet is a APP_VTRReplayErrorFramework */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_VTRReplayErrorFramework))) { /* go back to the sequence and extract the VTR errors */ CHK_OFAIL(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (newErrors == NULL) { CHK_OFAIL((tmp = malloc(sizeof(VTRErrorAtPos) * (totalErrors + count))) != NULL); } else { /* multiple tracks with VTR errors - reallocate the array */ CHK_OFAIL((tmp = realloc(newErrors, sizeof(VTRErrorAtPos) * (totalErrors + count))) != NULL); } newErrors = tmp; /* extract the VTR errors */ mxf_initialise_sets_iter(headerMetadata, &setsIter); mxf_initialise_array_item_iterator(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &arrayIter2); while (mxf_next_array_item_element(&arrayIter2, &arrayElement, &arrayElementLen)) { VTRErrorAtPos *vtrError = &newErrors[totalErrors]; CHK_OFAIL(mxf_get_strongref_s(headerMetadata, &setsIter, arrayElement, &dmSet)); CHK_OFAIL(mxf_get_position_item(dmSet, &MXF_ITEM_K(DMSegment, EventStartPosition), &vtrError->position)); CHK_OFAIL(mxf_get_strongref_item_s(&setsIter, dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet)); CHK_OFAIL(mxf_get_uint8_item(dmFrameworkSet, &MXF_ITEM_K(APP_VTRReplayErrorFramework, APP_VTRErrorCode), &vtrError->errorCode)); totalErrors++; } } } } } } *errors = newErrors; *numErrors = totalErrors; return 1; fail: SAFE_FREE(newErrors); return 0; }
int mxf_app_get_info(MXFHeaderMetadata *headerMetadata, ArchiveMXFInfo *info) { MXFList *list = NULL; MXFListIterator iter; MXFArrayItemIterator arrayIter; uint8_t *arrayElement; uint32_t arrayElementLen; mxfUTF16Char *tempWString = NULL; MXFList *nameList = NULL; MXFList *valueList = NULL; MXFMetadataSet *identSet; MXFMetadataSet *fileSourcePackageSet; MXFMetadataSet *sourcePackageSet; MXFMetadataSet *descriptorSet; MXFMetadataSet *locatorSet; MXFMetadataSet *materialPackageSet; MXFMetadataSet *prefaceSet; memset(info, 0, sizeof(*info)); /* read event counts in Preface */ CHK_ORET(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(Preface), &prefaceSet)); #define GET_EVENT_COUNT(name, var) \ if (mxf_have_item(prefaceSet, &MXF_ITEM_K(Preface, name))) \ CHK_ORET(mxf_get_uint32_item(prefaceSet, &MXF_ITEM_K(Preface, name), &var)); GET_EVENT_COUNT(APP_VTRErrorCount, info->vtrErrorCount) GET_EVENT_COUNT(APP_PSEFailureCount, info->pseFailureCount) GET_EVENT_COUNT(APP_DigiBetaDropoutCount, info->digibetaDropoutCount) GET_EVENT_COUNT(APP_TimecodeBreakCount, info->timecodeBreakCount) /* if metadata only then only try reading infax user comments */ if (is_metadata_only_file(headerMetadata, &materialPackageSet)) { if (mxf_avid_read_string_user_comments(materialPackageSet, &nameList, &valueList)) { info->haveSourceInfaxData = parse_infax_user_comments(nameList, valueList, &info->sourceInfaxData); mxf_free_list(&nameList); mxf_free_list(&valueList); } return 1; } /* Creation timestamp identification info */ CHK_OFAIL(mxf_find_set_by_key(headerMetadata, &MXF_SET_K(Identification), &list)); mxf_initialise_list_iter(&iter, list); if (mxf_next_list_iter_element(&iter)) { identSet = (MXFMetadataSet*)mxf_get_iter_element(&iter); CHK_OFAIL(mxf_get_timestamp_item(identSet, &MXF_ITEM_K(Identification, ModificationDate), &info->creationDate)); } mxf_free_list(&list); /* LTO Infax data */ CHK_OFAIL(mxf_uu_get_top_file_package(headerMetadata, &fileSourcePackageSet)); info->haveLTOInfaxData = archive_mxf_get_package_infax_data(headerMetadata, fileSourcePackageSet, &info->ltoInfaxData); /* original filename */ CHK_OFAIL(mxf_get_strongref_item(fileSourcePackageSet, &MXF_ITEM_K(SourcePackage, Descriptor), &descriptorSet)); if (mxf_have_item(descriptorSet, &MXF_ITEM_K(GenericDescriptor, Locators))) { CHK_OFAIL(mxf_initialise_array_item_iterator(descriptorSet, &MXF_ITEM_K(GenericDescriptor, Locators), &arrayIter)); while (mxf_next_array_item_element(&arrayIter, &arrayElement, &arrayElementLen)) { CHK_OFAIL(mxf_get_strongref(headerMetadata, arrayElement, &locatorSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &locatorSet->key, &MXF_SET_K(NetworkLocator))) { CHK_OFAIL(mxf_uu_get_utf16string_item(locatorSet, &MXF_ITEM_K(NetworkLocator, URLString), &tempWString)); CHK_OFAIL(mxf_utf16_to_utf8(info->filename, tempWString, sizeof(info->filename)) != (size_t)(-1)); info->filename[sizeof(info->filename) - 1] = '\0'; SAFE_FREE(tempWString); break; } } } /* source Infax data */ CHK_OFAIL(mxf_find_set_by_key(headerMetadata, &MXF_SET_K(SourcePackage), &list)); mxf_initialise_list_iter(&iter, list); while (mxf_next_list_iter_element(&iter)) { sourcePackageSet = (MXFMetadataSet*)(mxf_get_iter_element(&iter)); /* it is the tape SourcePackage if it has a TapeDescriptor */ CHK_OFAIL(mxf_get_strongref_item(sourcePackageSet, &MXF_ITEM_K(SourcePackage, Descriptor), &descriptorSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &descriptorSet->key, &MXF_SET_K(TapeDescriptor))) { info->haveSourceInfaxData = archive_mxf_get_package_infax_data(headerMetadata, sourcePackageSet, &info->sourceInfaxData); break; } } mxf_free_list(&list); /* try alternative locations for source Infax data */ if (!info->haveSourceInfaxData) { /* framework in the material package */ CHK_OFAIL(mxf_find_singular_set_by_key(headerMetadata, &MXF_SET_K(MaterialPackage), &materialPackageSet)); info->haveSourceInfaxData = archive_mxf_get_package_infax_data(headerMetadata, materialPackageSet, &info->sourceInfaxData); /* UserComments in the MaterialPackage */ if (!info->haveSourceInfaxData) { if (mxf_avid_read_string_user_comments(materialPackageSet, &nameList, &valueList)) { info->haveSourceInfaxData = parse_infax_user_comments(nameList, valueList, &info->sourceInfaxData); mxf_free_list(&nameList); mxf_free_list(&valueList); } } } return info->haveSourceInfaxData; fail: SAFE_FREE(tempWString); mxf_free_list(&list); mxf_free_list(&nameList); mxf_free_list(&valueList); return 0; }
int mxf_avid_is_metadictionary(MXFDataModel* dataModel, const mxfKey* setKey) { return mxf_is_subclass_of(dataModel, setKey, &MXF_SET_K(MetaDictionary)); }
int mxf_avid_create_typedef_stream(MXFMetadataSet* metaDictSet, const mxfUL* id, const mxfUTF16Char* name, const mxfUTF16Char* description, MXFMetadataSet** typeDefSet) { return mxf_avid_create_typedef(metaDictSet, &MXF_SET_K(TypeDefinitionStream), id, name, description, typeDefSet); }
static int archive_mxf_get_package_infax_data(MXFHeaderMetadata *headerMetadata, MXFMetadataSet *packageSet, InfaxData *infaxData) { MXFArrayItemIterator arrayIter; uint8_t *arrayElement; mxfUL dataDef; uint32_t count; MXFMetadataSet *trackSet; MXFMetadataSet *sequenceSet; MXFMetadataSet *dmSet; MXFMetadataSet *dmFrameworkSet; int haveInfaxData = 0; /* go through the tracks and find the DM track */ CHK_ORET(mxf_uu_get_package_tracks(packageSet, &arrayIter)); while (mxf_uu_next_track(headerMetadata, &arrayIter, &trackSet)) { CHK_ORET(mxf_uu_get_track_datadef(trackSet, &dataDef)); if (!mxf_is_descriptive_metadata(&dataDef)) { continue; } /* get to the single DMSegment */ CHK_ORET(mxf_get_strongref_item(trackSet, &MXF_ITEM_K(GenericTrack, Sequence), &sequenceSet)); if (mxf_is_subclass_of(headerMetadata->dataModel, &sequenceSet->key, &MXF_SET_K(Sequence))) { CHK_ORET(mxf_get_array_item_count(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), &count)); if (count != 1) { /* more than one segment */ continue; } CHK_ORET(mxf_get_array_item_element(sequenceSet, &MXF_ITEM_K(Sequence, StructuralComponents), 0, &arrayElement)); if (!mxf_get_strongref(headerMetadata, arrayElement, &dmSet)) { /* unknown DMSegment sub-class */ continue; } } else { dmSet = sequenceSet; } /* if it is a DMSegment with a DMFramework reference then we have the DMS track */ if (mxf_is_subclass_of(headerMetadata->dataModel, &dmSet->key, &MXF_SET_K(DMSegment))) { if (mxf_have_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework))) { /* if it is an APP_InfaxFramework then it is the Infax data */ if (mxf_get_strongref_item(dmSet, &MXF_ITEM_K(DMSegment, DMFramework), &dmFrameworkSet) && mxf_is_subclass_of(headerMetadata->dataModel, &dmFrameworkSet->key, &MXF_SET_K(APP_InfaxFramework))) { CHK_ORET(get_infax_data(dmFrameworkSet, infaxData)); haveInfaxData = 1; break; } } } } return haveInfaxData; }
int mxf_avid_is_metadef(MXFDataModel* dataModel, const mxfKey* setKey) { return mxf_is_subclass_of(dataModel, setKey, &MXF_SET_K(MetaDefinition)); }