Example #1
0
int main(int argv, const char* argc[])
{
    FILE* dv50File = NULL;
    MXFFile* mxfFile = NULL;
    int result;
    int cmdlnIndex = 1;
    int test = 0;
    
    if (argv < 3 || argv > 4)
    {
        usage(argc[0]);
        return 1;
    }
    
    if (argv == 4)
    {
        if (strcmp(argc[cmdlnIndex], "--test") != 0)
        {
            usage(argc[0]);
            return 1;
        }
        test = 1;
        
        cmdlnIndex++;
    }
    
    if ((dv50File = fopen(argc[cmdlnIndex], "rb")) == NULL)
    {
        fprintf(stderr, "Failed to open %s for reading\n", argc[1]);
        return 1;
    }
    cmdlnIndex++;
    
    if (!mxf_disk_file_open_new(argc[cmdlnIndex], &mxfFile))
    {
        fprintf(stderr, "Failed to open %s for writing\n", argc[2]);
        fclose(dv50File);
        return 1;
    }
    cmdlnIndex++;

    
    if (!write_dv50(dv50File, mxfFile, test))
    {
        result = 1;
    }
    else
    {
        result = 0;
    }

    
    fclose(dv50File);
    mxf_file_close(&mxfFile);
    
    return result;
}
Example #2
0
int test_write(const char* filename)
{
    MXFFile* mxfFile = NULL;
    
    
    if (!mxf_disk_file_open_new(filename, &mxfFile))
    {
        mxf_log_error("Failed to create '%s'" LOG_LOC_FORMAT, filename, LOG_LOC_PARAMS);
        return 0;
    }

    /* TEST */
    CHK_OFAIL(do_write(mxfFile));
    
    mxf_file_close(&mxfFile);
    return 1;
    
fail:
    mxf_file_close(&mxfFile);
    return 0;
}
Example #3
0
int test_create_and_write(const char *filename)
{
    MXFFile *mxfFile = NULL;
    uint8_t runin[RUNIN_LEN];
    MXFFilePartitions partitions;
    MXFPartition *headerPartition = NULL;
    MXFPartition *bodyPartition1 = NULL;
    MXFPartition *bodyPartition2 = NULL;
    MXFPartition *footerPartition = NULL;


    if (!mxf_disk_file_open_new(filename, &mxfFile))
    {
        mxf_log_error("Failed to create '%s'" LOG_LOC_FORMAT, filename, LOG_LOC_PARAMS);
        return 0;
    }

    mxf_initialise_file_partitions(&partitions);

    /* TEST */

    /* write 8 bytes of runin */
    memset(runin, 0, RUNIN_LEN);
    CHK_OFAIL(mxf_file_write(mxfFile, runin, RUNIN_LEN) == RUNIN_LEN);

    /* write the header pp */
    CHK_OFAIL(mxf_append_new_partition(&partitions, &headerPartition));
    headerPartition->key = MXF_PP_K(ClosedComplete, Header);
    headerPartition->indexSID = 1;
    CHK_OFAIL(mxf_append_partition_esscont_label(headerPartition, &MXF_EC_L(SD_Unc_625_50i_422_135_FrameWrapped)));
    CHK_OFAIL(mxf_append_partition_esscont_label(headerPartition, &MXF_EC_L(BWFFrameWrapped)));
    CHK_OFAIL(mxf_write_partition(mxfFile, headerPartition));

    /* write empty header metadata */
    CHK_OFAIL(mxf_mark_header_start(mxfFile, headerPartition));
    CHK_OFAIL(mxf_allocate_space(mxfFile, 1024));
    CHK_OFAIL(mxf_mark_header_end(mxfFile, headerPartition));

    /* write the body pp 1 */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &bodyPartition1));
    bodyPartition1->key = MXF_PP_K(ClosedComplete, Body);
    bodyPartition1->bodySID = 2;
    CHK_OFAIL(mxf_write_partition(mxfFile, bodyPartition1));

    /* write the body pp 2, with KAG 256 */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &bodyPartition2));
    bodyPartition2->key = MXF_PP_K(ClosedComplete, Body);
    bodyPartition2->bodySID = 3;
    bodyPartition2->kagSize = 256;
    CHK_OFAIL(mxf_write_partition(mxfFile, bodyPartition2));
    CHK_OFAIL(mxf_fill_to_kag(mxfFile, bodyPartition2));

    /* write the footer pp */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &footerPartition));
    footerPartition->key = MXF_PP_K(ClosedComplete, Footer);
    footerPartition->indexSID = 1;
    CHK_OFAIL(mxf_write_partition(mxfFile, footerPartition));

    /* write RIP */
    CHK_OFAIL(mxf_write_rip(mxfFile, &partitions));

    /* update the partitions */
    CHK_OFAIL(mxf_update_partitions(mxfFile, &partitions));


    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    return 1;

fail:
    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    return 0;
}
Example #4
0
int test_create_and_write(const char *filename)
{
    MXFFile *mxfFile = NULL;
    MXFFilePartitions partitions;
    MXFPartition *headerPartition = NULL;
    MXFIndexTableSegment *indexSegment = NULL;
    uint32_t sliceOffset[2];
    mxfRational posTable[2];
    const mxfRational editRate = {25, 1};
    int i;
    int k;


    if (!mxf_disk_file_open_new(filename, &mxfFile))
    {
        mxf_log_error("Failed to create '%s'" LOG_LOC_FORMAT, filename, LOG_LOC_PARAMS);
        return 0;
    }

    mxf_initialise_file_partitions(&partitions);

    /* TEST */

    /* write the header pp */
    CHK_OFAIL(mxf_append_new_partition(&partitions, &headerPartition));
    headerPartition->key = MXF_PP_K(ClosedComplete, Header);
    headerPartition->kagSize = 256;
    CHK_OFAIL(mxf_write_partition(mxfFile, headerPartition));

    /* write index table segment */
    CHK_OFAIL(mxf_mark_index_start(mxfFile, headerPartition));

    CHK_OFAIL(mxf_create_index_table_segment(&indexSegment));
    mxf_generate_uuid(&indexSegment->instanceUID);
    indexSegment->indexEditRate = editRate;
    indexSegment->indexDuration = 0x64;
    indexSegment->editUnitByteCount = 0x100;
    indexSegment->indexSID = 1;
    indexSegment->bodySID = 2;
    for (i = 0; i < 4; i++)
    {
        CHK_OFAIL(mxf_default_add_delta_entry(NULL, 0, indexSegment, i, i, i));
    }
    CHK_OFAIL(mxf_write_index_table_segment(mxfFile, indexSegment));

    CHK_OFAIL(mxf_fill_to_kag(mxfFile, headerPartition));

    CHK_OFAIL(mxf_mark_index_end(mxfFile, headerPartition));

    mxf_free_index_table_segment(&indexSegment);


    /* write index table segment */
    CHK_OFAIL(mxf_mark_index_start(mxfFile, headerPartition));

    CHK_OFAIL(mxf_create_index_table_segment(&indexSegment));
    mxf_generate_uuid(&indexSegment->instanceUID);
    indexSegment->indexEditRate = editRate;
    indexSegment->indexDuration = 0x0a;
    indexSegment->editUnitByteCount = 0;
    indexSegment->indexSID = 1;
    indexSegment->bodySID = 2;
    indexSegment->sliceCount = 2;
    indexSegment->posTableCount = 2;
    indexSegment->vbeByteCount = 1;
    indexSegment->singleEssenceLocation = MXF_OPT_BOOL_TRUE;
    indexSegment->forwardIndexDirection = MXF_OPT_BOOL_FALSE;
    for (i = 0; i < indexSegment->indexDuration; i++)
    {
        for (k = 0; k < indexSegment->sliceCount; k++)
        {
            sliceOffset[k] = i;
        }
        for (k = 0; k < indexSegment->posTableCount; k++)
        {
            posTable[k].numerator = i;
            posTable[k].denominator = i + 1;
        }
        CHK_OFAIL(mxf_default_add_index_entry(NULL, 0, indexSegment, i, i, i, i,
            sliceOffset, posTable));
    }
    CHK_OFAIL(mxf_write_index_table_segment(mxfFile, indexSegment));

    CHK_OFAIL(mxf_fill_to_kag(mxfFile, headerPartition));

    CHK_OFAIL(mxf_mark_index_end(mxfFile, headerPartition));



    /* update the partitions */
    CHK_OFAIL(mxf_update_partitions(mxfFile, &partitions));


    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    mxf_free_index_table_segment(&indexSegment);
    return 1;

fail:
    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    mxf_free_index_table_segment(&indexSegment);
    return 0;
}
int test_create_and_write(const char *filename)
{
    MXFFile *mxfFile = NULL;
    MXFFilePartitions partitions;
    MXFPartition *headerPartition = NULL;
    MXFPartition *bodyPartition1 = NULL;
    MXFPartition *bodyPartition2 = NULL;
    MXFPartition *footerPartition = NULL;
    MXFEssenceElement *essenceElement = NULL;
    uint8_t essenceData[1024];
    memset(essenceData, 0, 1024);


    if (!mxf_disk_file_open_new(filename, &mxfFile))
    {
        mxf_log_error("Failed to create '%s'" LOG_LOC_FORMAT, filename, LOG_LOC_PARAMS);
        return 0;
    }

    mxf_initialise_file_partitions(&partitions);

    /* TEST */

    /* write the header pp */
    CHK_OFAIL(mxf_append_new_partition(&partitions, &headerPartition));
    headerPartition->key = MXF_PP_K(ClosedComplete, Header);
    headerPartition->bodySID = 1;
    CHK_OFAIL(mxf_append_partition_esscont_label(headerPartition, &MXF_EC_L(BWFFrameWrapped)));
    CHK_OFAIL(mxf_append_partition_esscont_label(headerPartition, &MXF_EC_L(BWFClipWrapped)));
    CHK_OFAIL(mxf_write_partition(mxfFile, headerPartition));

    /* write essence element directly */
    CHK_OFAIL(mxf_write_fixed_kl(mxfFile, &g_bwfFrameWrappedEEKey, 4, 256));
    CHK_OFAIL(mxf_file_write(mxfFile, essenceData, 256));

    /* write the body pp 1 */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &bodyPartition1));
    bodyPartition1->key = MXF_PP_K(ClosedComplete, Body);
    bodyPartition1->bodySID = 2;
    CHK_OFAIL(mxf_write_partition(mxfFile, bodyPartition1));

    /* write using MXFEssenceElement with known length */
    CHK_OFAIL(mxf_open_essence_element_write(mxfFile, &g_bwfClipWrappedEEKey, 8, 1024, &essenceElement));
    CHK_OFAIL(mxf_write_essence_element_data(mxfFile, essenceElement, essenceData, 1024));
    mxf_close_essence_element(&essenceElement);


    /* write the body pp 2 */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &bodyPartition2));
    bodyPartition2->key = MXF_PP_K(ClosedComplete, Body);
    bodyPartition2->bodySID = 3;
    CHK_OFAIL(mxf_write_partition(mxfFile, bodyPartition2));

    /* write using MXFEssenceElement with uknown length */
    CHK_OFAIL(mxf_open_essence_element_write(mxfFile, &g_bwfClipWrappedEEKey, 8, 0, &essenceElement));
    CHK_OFAIL(mxf_write_essence_element_data(mxfFile, essenceElement, essenceData, 256));
    CHK_OFAIL(mxf_write_essence_element_data(mxfFile, essenceElement, essenceData, 512));
    CHK_OFAIL(mxf_write_essence_element_data(mxfFile, essenceElement, essenceData, 256));
    CHK_ORET(mxf_finalize_essence_element_write(mxfFile, essenceElement));
    mxf_close_essence_element(&essenceElement);


    /* write the footer pp */
    CHK_OFAIL(mxf_append_new_from_partition(&partitions, headerPartition, &footerPartition));
    footerPartition->key = MXF_PP_K(ClosedComplete, Footer);
    CHK_OFAIL(mxf_write_partition(mxfFile, footerPartition));

    /* update the partitions */
    CHK_OFAIL(mxf_update_partitions(mxfFile, &partitions));


    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    mxf_close_essence_element(&essenceElement);
    return 1;

fail:
    mxf_file_close(&mxfFile);
    mxf_clear_file_partitions(&partitions);
    mxf_close_essence_element(&essenceElement);
    return 0;
}