Esempio n. 1
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;
}
Esempio n. 2
0
int mxf_write_fill(MXFFile *mxfFile, uint32_t size)
{
    return mxf_allocate_space(mxfFile, size);
}