To read an MPD from a named file:
#include <string>
.
.
.
{
const std::string filename("/path/to/manifest.mpd");
const std::string original_url("https://example.com/media/manifest.mpd");
MPD mpd(filename, original_url);
}
#define LIBMPDPP_NAMESPACE_USING_ALL
Definition macros.hh:85
To read from an input stream:
#include <fstream>
#include <string>
.
.
.
{
std::ifstream infile("/path/to/manifest.mpd");
const std::string original_url("https://example.com/media/manifest.mpd");
MPD mpd(infile, original_url);
}
To read from memory:
#include <string>
#include <vector>
.
.
.
{
std::string mpd_text("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<MPD xmlns=\"urn:mpeg:dash:schema:mpd:2011\" type=\"dynamic\" minBufferTime=\"PT10S\"\n"
" profiles=\"urn:dvb:dash:profile:dvb-dash:isoff-ext-live:2014\">\n"
" <Period id=\"1\" start=\"PT0S\"/>\n"
"</MPD>\n"
);
std::vector<char> mpd_vec(mpd_text.data(), mpd_text.data() + mpd_text.size());
const std::string original_url("https://example.com/media/manifest.mpd");
MPD mpd(mpd_vec, original_url);
}
To create a new MPD:
#include <chrono>
using namespace std::literals::chrono_literals;
.
.
.
{
MPD mpd(3840ms, "urn:dvb:dash:profile:dvb-dash:2014", Period());
}
Output to a stream (compact XML form):
#include <chrono>
using namespace std::literals::chrono_literals;
.
.
.
{
MPD mpd(3840ms, "urn:dvb:dash:profile:dvb-dash:2014", Period());
std::cout << MPD::compact << mpd;
}
Output to a stream (pretty XML form):
#include <chrono>
using namespace std::literals::chrono_literals;
.
.
.
{
MPD mpd(3840ms, "urn:dvb:dash:profile:dvb-dash:2014", Period());
std::cout << mpd << std::endl;
std::cout << MPD::compact;
std::cout << MPD::pretty << mpd << std::endl;
}