[vlc-devel] [PATCH V5] dcp: Creation of access-demux module for DCP

Nicolas Bertrand nicoinattendu at gmail.com
Wed Oct 9 17:48:11 CEST 2013


Hi
Comments below


>> +int parserAssetmapXML ( demux_t * p_demux )
>> +{
>> +    dcp_t *p_dcp = p_demux->p_sys->p_dcp;
>> +    int type = 0;
>> +    const char* node = NULL;
>> +    int packinglist = 0;
>> +    int file_number = 0;
>> +    int asset_list = 0;
>> +    string filepath;
>> +    stream_t *p_stream = NULL;
>> +    xml_t *p_xml = NULL;
>> +    xml_reader_t *p_xmlReader = NULL;
>> +
>> +    /* init XML parser */
>> +    if( initXMLParser( p_demux, p_dcp->assetmapURI, &p_stream, &p_xml, &p_xmlReader ) )
>> +    {
>> +        msg_Err( p_demux, "Failed to initialize XML parser" );
>> +        goto error;
>> +    }
>> +
>> +    /* reading XML file ( node by node ) */
>> +    msg_Dbg( p_demux, "reading ASSETMAP file..." );
>> +    while( ( type = xml_ReaderNextNode( p_xmlReader, &node ) ) > 0 )
>> +    {
>> +        /* This condition determines if we are in AssetList part or not */
>> +        if( ( type == XML_READER_STARTELEM ) && ( strcasecmp( node, "AssetList" ) == 0 ) )
>> +        {
>> +            asset_list = 1;
>> +            continue;
>> +        }
>> +
>> +        /* When we are in AssetList part */
>> +        if( asset_list == 1 )
>> +        {
>> +            /* Set the UID of the file */
>> +            if( ( type == XML_READER_STARTELEM ) && ( strcasecmp( node, "Id" ) == 0 ) )
>> +            {
>> +                if( ( type = xml_ReaderNextNode( p_xmlReader, &node ) ) != XML_READER_TEXT )
>> +                {
>> +                    msg_Err( p_demux, "Id missing in ASSETMAP!" );
>> +                    goto error;
>> +                }
>> +                else
>> +                {
>> +                    p_dcp->files[ file_number ] = new ( nothrow ) file_t;
>> +                    if( !p_dcp->files[ file_number ] )
>> +                    {
>> +                        goto error;
>> +                    }
>> +                    if( node != NULL )
>> +                        p_dcp->files[file_number]->id = node;
>> +                    continue;
>> +                }
>> +            }
>> +
>> +            /* It determines if it is PKL File or not */
>> +            /* For PKL File, we have : <PackingList>true</PackingList> */
>> +            /* This tag seems to be used only for PKL file */
>> +            if( ( type == XML_READER_STARTELEM ) && ( strcasecmp ( node, "PackingList" ) == 0 ) )
>> +            {
>> +                packinglist = 1; /* next path info will be for PKL file */
>> +                continue;
>> +            }
>> +
>> +            /* Set the Path of the file */
>> +            /* If the file is an XML file, it is the PKL file or the CPL file */
>> +            if( ( type == XML_READER_STARTELEM ) && ( strcasecmp( node, "Path" ) == 0 ) )
>> +            {
>> +                if( ( type = xml_ReaderNextNode( p_xmlReader, &node ) ) != XML_READER_TEXT )
>> +                {
>> +                    msg_Err( p_demux, "Path missing in ASSETMAP" );
>> +                    goto error;
>> +                }
>> +                else
>> +                {
>> +                    filepath = p_dcp->path + node;
>> +                    if( endsWith( node, ".xml" ) )
>> +                    {
>> +                        if( packinglist == 1 )
>> +                        {
>> +                            /* it is PKL file name */
>> +                            p_dcp->pklfile = filepath;
>> +                            p_dcp->files[file_number]->path = filepath;
>> +                            packinglist = 0;
>> +                        }
>> +                        else
>> +                        {
>> +                            /* it is CPL file name */
>> +                            p_dcp->cplfileURI = vlc_path2uri( filepath.c_str(), "file" );
>> +                            p_dcp->files[file_number]->path = filepath;
>> +                        }
>> +                    }
>> +                    else
>> +                    {
>> +                        /* it is an other file (MXF in theory) */
>> +                        p_dcp->files[file_number]->path = filepath;
>> +                    }
>> +                    file_number++;
> I think this segfaults your file has Path before Id and leaks if the
> file is corrupted and don't have a Path

Well, I review the spec on that part
The Id shall be before path
and shall have id in path --> so yes it means corrupted file






More information about the vlc-devel mailing list