The libmpd++ library is a C++ class library for parsing, manipulating, querying and outputting DASH MPD XML documents.
The library can parse an MPD from a variety of sources such as a memory block or file. The library also allows the creation of new MPDs in a programatic fashion.
The MPD is modelled by a set of classes which can contain the various values held by an MPD in within its hierarchy of elements. This allows the MPD to be programatically traversed and modified easily in a C++ program.
The top level of the MPD model is an MPD object.
The MPD model can also be queried to find a set of next available media segments or the initialization segments for the Representations in the MPD. This is done by marking Representations in the model as selected and then using the query methods on the MPD object to obtain a list of next segments or the availability of the initialization segments.
The MPD that is modelled can be output as a DASH MPD XML string. This can be in either a compact form for communication, or as a formatted (pretty) form with extra whitespace for readability.
As mentioned above, the MPD model provides methods at various levels to mark Representations as selected. There are also some query methods on the MPD object, selectedSegmentAvailability() and selectedInitializationSegments(), which will use the selected Representations of the current Period to perform a query for the next available media segments or the initialization segments respectively.
Individual Representations can be selected by using the selection methods in the AdaptationSet class. These methods allow individual Representations to be selected or deselected, or the selection to be changed to a new Representation. This is useful for playback where only the segments from the currently selected Representations, in the AdaptationSets which are in use, are required.
For broadcast/multicast operations, where all Representations are needed at the same time, the MPD, Period and AdaptationSet classes all provide selectAllRepresentations() and deselectAllRepresentations() methods to select all the Representations below that object's level.
Both media segment and initialization segment queries will return a set of SegmentAvailability objects which contain the resolved segment URL and availability start time for that segment. They may also contain an availability end time, if one is provided in the MPD. For media segments, the segment duration is also returned to assist in scheduling of the next query.