How-to use MXM in your application

A generic application wrote in C++ that want to use the MXM APIs has to simply build its source code against the MXM libraries and MXM include directory.
The MXM libraries can be downloaded from the website at the URL http://mxm.wg11.sc29.org/download/binaries/ but any developers can build it on their own following the guide wrote at the URL http://mxm.wg11.sc29.org/mxm-dev-corner/compile-mxm-libs-on-c/. We suggest to identify a person that monthly or whenever is needed delivery these binaries.
The MXM include directory can be downloaded from the MXM svn repository as explained in http://mxm.wg11.sc29.org/download/check-out-the-source-code/c/

Adding dependencies to your project
A generic application has also to include in its project/makefile the MXM’s dependencies: they are xsd/xerces and log4cxx. So on, all the modification needed are (we suppose that the generic application is located in the same “your-workspace-folder/mxm-cpp/src/mxm_apps” directory):
“Additional Include Directory”:
“\apache-log4cxx-0.10.0\src\main\include”;
“\xerces-c\include”;
“\xsd-3.2.0-i686-windows\libxsd”;
“\include”
“Additional Library Directories”:
“\xerces-c\lib”;
“\apache-log4cxx-0.10.0\projects\Debug”;
“\include\library”
“Additional Dependancies” add:
mxm_core.lib;
mxm_dataobject.lib [optional];
xerces-c_3.lib;
log4cxx.lib

Moreover, in your source code you’ve to include any c++ header’s files you’d like to use. I.e., if you want to access the MetadatataEngine APIs, we’ve to include

#include “core/engines/MetadatataEngine/MetadatataEngine.h” (and all others parser/creator’s headers you need)
#include “core/MXM.h” (needed to query MXM-core)
using namespace org::iso::mpeg::mxm (usefull MXM namespace)

Retrieve your engine from MXM
Two function calls are required before starting to use the MXM engines:

the first one is needed to initialise MXM itself:

- core::engines::management::singleton::InstanceReference< MXM > mxm(MXM::getInstance ( , argc, argv) )

The first parameter simply define the path to MXMConfiguration.xml, an xml properties file used by MXM to initialize itself.
The skeleton of an MXM configuration file is:

  • <?xml version=”1.0″ encoding=”UTF-8″?>
    <MXMConfiguration
    xmlns=”urn:org:iso:mpeg:mxm:configuration:schema”
    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
    xsi:schemaLocation=”urn:org:iso:mpeg:mxm:configuration:schema mxmConfiguration.xsd”>
    <MXMParameters>
    <entry key=”mxm.version.number”>Version</entry>
    <entry key=”mxm.version.date”>Date</entry>
    <entry key=”mxm.version.release”>Release</entry>
    <entry key=”mxm.standalone”>true</entry>
    </MXMParameters>
    <GenericEngine id=”0″>
    <DynamicLibrary>
    <LibraryPath><PATH_ENGINE_DLL></LibraryPath>
    </DynamicLibrary>
    <EngineParameters>
    <entry key=”Dependency”><PATH_DEPENDENCIES_DLL></entry>
    </EngineParameters>
    </GenericEngine>
    </MXMConfiguration>

You have to change the <PATH_ENGINE_DLL&gt
according the path where your engine is located and list eventually any dependencies of the engine like in the above skeleton we made for &ltentry key=”Dependency”&gt

The argc, argv data are simply a list of parameters passed directly to the MXM Engines (see above)

the second one to retrieve the real MXM Engine, i.e. MetadataEngine:

- engine::MetadataEngine::MetadataEngine& MetadataEngine = mxm-> getDefaultEngine ( MXMEngine:: MetadataEngine );

It returns the instance of Metadata Engine with the id = “0″ (default id) as listed in the MXMConfiguration.xml above

After you’ve retrieved the Metadata engine you can query him using the APIs you need, as listed on http://mxm.wg11.sc29.org/docs/api/c/.
For a complete and detailed show-case, we suggest to have a look to the MetadataMXMTest.cpp located on the mxm repository under the folder src/mxm-apps.

Testing case: METADATA ENGINE TEST (win 32 and linux/ubuntu)

  • Have these modules already compiled:
    • mxm_core
    • mxm_dataobject
    • basic_metadata_engine
    • metadata_mxm_test
  • Update your <WORKSPACE_FOLDER>/mxm-cpp/resources/MXMConfiguration.xml accordlying to your configuration
  • Launch from the <WORKSPACE_FOLDER>/mxm-cpp/win32/metadata_mxm_test/Release the command: metadata_mxm_test.exe <log4cxx-conf-file> <mxm-conf-file> <document-to-parse> <document-to-create> MetadataEngine:validate=true
    • <log4cxx-conf-file> ==> ..\..\..\resources\log4cxx.info
    • <mxm-conf-file> ==> ..\..\..\resources\MXMConfiguration.xml
    • <document-to-parse> ==> ..\..\..\resources\metadata.xml
    • <document-to-create> ==> ..\..\..\resources\metadata-created.xml
  • The test will:
    • load the mxmConfiguration.xml located in <WORKSPACE_FOLDER>/mxm-cpp/resources
    • instantiate a basic_metadata_engine
    • parse the metadata.xml in <WORKSPACE_FOLDER>/mxm-cpp/resources
    • print to screen the title of the parsed metadata
  • Note that if you’d like to validate the document you’re parsing (on default, this feature is disabled), you’ve to update the metadata.xml with the correct url of the mxm-schema
-->