Пример #1
0
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;    
}
Пример #2
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;
}
Пример #3
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;
}
Пример #4
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;
}
Пример #5
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;
}
Пример #6
0
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;
}