Unit test for MPD builder

Initial checkin, very small coverage.

Change-Id: I60f3fd768d5b8dca7a84f051e57f59a654272e53
This commit is contained in:
Rintaro Kuroiwa 2013-12-30 15:05:27 -08:00
parent 1eb5236c90
commit db5b2a4740
7 changed files with 955 additions and 4 deletions

View File

@ -165,7 +165,7 @@ uint32 MpdBuilder::GetStaticMpdDuration(XmlNode* mpd_node) {
xmlNodePtr period_node = xmlFirstElementChild(mpd_node->GetRawPtr()); xmlNodePtr period_node = xmlFirstElementChild(mpd_node->GetRawPtr());
DCHECK(period_node); DCHECK(period_node);
DCHECK_NE(strcmp(reinterpret_cast<const char*>(period_node->name), "Period"), DCHECK_EQ(strcmp(reinterpret_cast<const char*>(period_node->name), "Period"),
0); 0);
// TODO(rkuroiwa): Update this so that the duration for each Representation is // TODO(rkuroiwa): Update this so that the duration for each Representation is

View File

@ -0,0 +1,147 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "mpd/base/mpd_builder.h"
#include "mpd/base/xml/scoped_xml_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/libxml/src/include/libxml/parser.h"
namespace dash_packager {
namespace {
// This was validated at a validator site below as well.
// http://www-itec.uni-klu.ac.at/dash/?page_id=605#
const char kValidMpd[] = "<?xml version='1.0' encoding='UTF-8'?>\n\
<MPD\n\
xmlns='urn:mpeg:DASH:schema:MPD:2011'\n\
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\n\
xmlns:xlink='http://www.w3.org/1999/xlink'\n\
xsi:schemaLocation='urn:mpeg:DASH:schema:MPD:2011 DASH-MPD.xsd'\n\
minBufferTime='PT2S'\n\
type='static'\n\
profiles='urn:mpeg:dash:profile:isoff-on-demand:2011'\n\
mediaPresentationDuration='PT101S'>\n\
<BaseURL>http://cdn1.example.com/</BaseURL>\n\
<Period>\n\
<AdaptationSet id='0'>\n\
<Representation id='0' bandwidth='20000' mimeType='video/mp4' codecs='avc1'>\n\
<BaseURL>\n\
something.mp4\n\
</BaseURL>\n\
</Representation>\n\
<Representation id='1' bandwidth='20000' mimeType='video/mp4' codecs='avc1'>\n\
<BaseURL>\n\
somethingelse.mp4\n\
</BaseURL>\n\
</Representation>\n\
</AdaptationSet>\n\
</Period>\n\
</MPD>\n\
";
const size_t kValidMpdSize = arraysize(kValidMpd) - 1; // Exclude '\0'.
base::FilePath GetSchemaPath() {
base::FilePath file_path;
CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
file_path = file_path.Append(FILE_PATH_LITERAL("mpd"))
.Append(FILE_PATH_LITERAL("test"))
.Append(FILE_PATH_LITERAL("schema"))
.Append(FILE_PATH_LITERAL("DASH-MPD.xsd"));
return file_path;
}
std::string GetPathContent(const base::FilePath& file_path) {
std::string content;
bool file_read_to_string = file_util::ReadFileToString(file_path, &content);
DCHECK(file_read_to_string);
return content;
}
bool ValidateMpdSchema(const std::string& mpd) {
xml::ScopedXmlPtr<xmlDoc>::type doc(xmlParseMemory(mpd.data(), mpd.size()));
if (!doc) {
LOG(ERROR) << "Failed to parse mpd into an xml doc.";
return false;
}
base::FilePath schema_path = GetSchemaPath();
std::string schema_str = GetPathContent(schema_path);
// First, I need to load the schema as a xmlDoc so that I can pass the path of
// the DASH-MPD.xsd. Then it can resolve the relative path included from the
// XSD when creating xmlSchemaParserCtxt.
xml::ScopedXmlPtr<xmlDoc>::type schema_as_doc(
xmlReadMemory(schema_str.data(),
schema_str.size(),
schema_path.value().c_str(),
NULL,
0));
DCHECK(schema_as_doc);
xml::ScopedXmlPtr<xmlSchemaParserCtxt>::type schema_parser_ctxt(
xmlSchemaNewDocParserCtxt(schema_as_doc.get()));
DCHECK(schema_parser_ctxt);
xml::ScopedXmlPtr<xmlSchema>::type schema(
xmlSchemaParse(schema_parser_ctxt.get()));
DCHECK(schema);
xml::ScopedXmlPtr<xmlSchemaValidCtxt>::type valid_ctxt(
xmlSchemaNewValidCtxt(schema.get()));
DCHECK(valid_ctxt);
int validation_result =
xmlSchemaValidateDoc(valid_ctxt.get(), doc.get());
DLOG(INFO) << "XSD validation result: " << validation_result;
return validation_result == 0;
}
} // namespace
// Check if the schema validation works. If not, then most of the tests would
// probably fail.
TEST(MpdSchemaMetaTest, CheckSchemaValidatorWorks) {
ASSERT_TRUE(ValidateMpdSchema(std::string(kValidMpd, kValidMpdSize)));
}
// TODO(rkuroiwa): MPD builder does not build a valid MPD yet. Enable these when
// its done. Make sure to compare against a known MPD to validate.
// A normal use case where there are 2 adaptation sets and 2 representations.
TEST(MpdBuilder, DISABLED_VOD_Normal) {
MpdBuilder mpd(MpdBuilder::kStatic);
AdaptationSet* adaptation_set = mpd.AddAdaptationSet();
ASSERT_TRUE(adaptation_set);
AdaptationSet* adaptation_set2 = mpd.AddAdaptationSet();
ASSERT_TRUE(adaptation_set2);
MediaInfo media_info;
media_info.set_bandwidth(100);
ASSERT_TRUE(adaptation_set->AddRepresentation(media_info));
ASSERT_TRUE(adaptation_set2->AddRepresentation(media_info));
std::string mpd_doc;
ASSERT_TRUE(mpd.ToString(&mpd_doc));
ASSERT_TRUE(ValidateMpdSchema(mpd_doc));
}
// Different media duration should not error.
TEST(MpdBuilder, DISABLED_VOD_DifferentMediaDuration) {
MpdBuilder mpd(MpdBuilder::kStatic);
AdaptationSet* adaptation_set = mpd.AddAdaptationSet();
ASSERT_TRUE(adaptation_set);
MediaInfo media_info;
media_info.set_bandwidth(20000);
media_info.set_media_duration_seconds(100);
ASSERT_TRUE(adaptation_set->AddRepresentation(media_info));
media_info.set_media_duration_seconds(101);
ASSERT_TRUE(adaptation_set->AddRepresentation(media_info));
std::string mpd_doc;
ASSERT_TRUE(mpd.ToString(&mpd_doc));
ASSERT_TRUE(ValidateMpdSchema(mpd_doc));
}
} // namespace dash_packager

View File

@ -5,12 +5,20 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "third_party/libxml/src/include/libxml/tree.h" #include "third_party/libxml/src/include/libxml/tree.h"
#include "third_party/libxml/src/include/libxml/xmlschemas.h"
namespace dash_packager { namespace dash_packager {
namespace xml { namespace xml {
struct XmlDeleter { struct XmlDeleter {
// Called by scoped_ptr. http://goo.gl/YaLbcS // Called by scoped_ptr. http://goo.gl/YaLbcS
inline void operator()(xmlSchemaParserCtxtPtr ptr) const {
xmlSchemaFreeParserCtxt(ptr);
}
inline void operator()(xmlSchemaValidCtxtPtr ptr) const {
xmlSchemaFreeValidCtxt(ptr);
}
inline void operator()(xmlSchemaPtr ptr) const { xmlSchemaFree(ptr); }
inline void operator()(xmlNodePtr ptr) const { xmlFreeNode(ptr); } inline void operator()(xmlNodePtr ptr) const { xmlFreeNode(ptr); }
inline void operator()(xmlDocPtr ptr) const { xmlFreeDoc(ptr); } inline void operator()(xmlDocPtr ptr) const { xmlFreeDoc(ptr); }
inline void operator()(xmlChar* ptr) const { xmlFree(ptr); } inline void operator()(xmlChar* ptr) const { xmlFree(ptr); }

View File

@ -1,6 +1,11 @@
# GYP file for any MPD generation targets. # GYP file for any MPD generation targets.
{ {
'target_defaults': {
'include_dirs': [
'..',
],
},
'targets': [ 'targets': [
{ {
'target_name': 'media_info_proto', 'target_name': 'media_info_proto',
@ -28,14 +33,28 @@
'base/xml/xml_node.cc', 'base/xml/xml_node.cc',
'base/xml/xml_node.h', 'base/xml/xml_node.h',
], ],
'include_dirs': [
'..',
],
'dependencies': [ 'dependencies': [
'../base/base.gyp:base', '../base/base.gyp:base',
'../third_party/libxml/libxml.gyp:libxml', '../third_party/libxml/libxml.gyp:libxml',
'media_info_proto', 'media_info_proto',
], ],
'export_dependent_settings': [
'../third_party/libxml/libxml.gyp:libxml',
'media_info_proto',
],
},
{
'target_name': 'mpd_unittest',
'type': 'executable',
'sources': [
'base/mpd_builder_unittest.cc',
],
'dependencies': [
'../base/base.gyp:base',
'../base/base.gyp:run_all_unittests',
'../testing/gtest.gyp:gtest',
'mpd_builder',
],
}, },
], ],
} }

View File

@ -0,0 +1,390 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="urn:mpeg:DASH:schema:MPD:2011"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="urn:mpeg:DASH:schema:MPD:2011">
<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"/>
<xs:annotation>
<xs:appinfo>Media Presentation Description</xs:appinfo>
<xs:documentation xml:lang="en">
This Schema defines the Media Presentation Description for MPEG-DASH.
</xs:documentation>
</xs:annotation>
<!-- MPD: main element -->
<xs:element name="MPD" type="MPDtype"/>
<!-- MPD Type -->
<xs:complexType name="MPDtype">
<xs:sequence>
<xs:element name="ProgramInformation" type="ProgramInformationType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="BaseURL" type="BaseURLType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Location" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Period" type="PeriodType" maxOccurs="unbounded"/>
<xs:element name="Metrics" type="MetricsType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:string"/>
<xs:attribute name="profiles" type="xs:string" use="required"/>
<xs:attribute name="type" type="PresentationType" default="static"/>
<xs:attribute name="availabilityStartTime" type="xs:dateTime"/>
<xs:attribute name="availabilityEndTime" type="xs:dateTime"/>
<xs:attribute name="mediaPresentationDuration" type="xs:duration"/>
<xs:attribute name="minimumUpdatePeriod" type="xs:duration"/>
<xs:attribute name="minBufferTime" type="xs:duration" use="required"/>
<xs:attribute name="timeShiftBufferDepth" type="xs:duration"/>
<xs:attribute name="suggestedPresentationDelay" type="xs:duration"/>
<xs:attribute name="maxSegmentDuration" type="xs:duration"/>
<xs:attribute name="maxSubsegmentDuration" type="xs:duration"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Presentation Type enumeration -->
<xs:simpleType name="PresentationType">
<xs:restriction base="xs:string">
<xs:enumeration value="static"/>
<xs:enumeration value="dynamic"/>
</xs:restriction>
</xs:simpleType>
<!-- Period -->
<xs:complexType name="PeriodType">
<xs:sequence>
<xs:element name="BaseURL" type="BaseURLType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="SegmentBase" type="SegmentBaseType" minOccurs="0"/>
<xs:element name="SegmentList" type="SegmentListType" minOccurs="0"/>
<xs:element name="SegmentTemplate" type="SegmentTemplateType" minOccurs="0"/>
<xs:element name="AdaptationSet" type="AdaptationSetType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Subset" type="SubsetType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="xlink:href"/>
<xs:attribute ref="xlink:actuate" default="onRequest"/>
<xs:attribute name="id" type="xs:string" />
<xs:attribute name="start" type="xs:duration"/>
<xs:attribute name="duration" type="xs:duration"/>
<xs:attribute name="bitstreamSwitching" type="xs:boolean" default="false"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Adaptation Set -->
<xs:complexType name="AdaptationSetType">
<xs:complexContent>
<xs:extension base="RepresentationBaseType">
<xs:sequence>
<xs:element name="Accessibility" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Role" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Rating" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Viewpoint" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ContentComponent" type="ContentComponentType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="BaseURL" type="BaseURLType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="SegmentBase" type="SegmentBaseType" minOccurs="0"/>
<xs:element name="SegmentList" type="SegmentListType" minOccurs="0"/>
<xs:element name="SegmentTemplate" type="SegmentTemplateType" minOccurs="0"/>
<xs:element name="Representation" type="RepresentationType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="xlink:href"/>
<xs:attribute ref="xlink:actuate" default="onRequest"/>
<xs:attribute name="id" type="xs:unsignedInt"/>
<xs:attribute name="group" type="xs:unsignedInt"/>
<xs:attribute name="lang" type="xs:language"/>
<xs:attribute name="contentType" type="xs:string"/>
<xs:attribute name="par" type="RatioType"/>
<xs:attribute name="minBandwidth" type="xs:unsignedInt"/>
<xs:attribute name="maxBandwidth" type="xs:unsignedInt"/>
<xs:attribute name="minWidth" type="xs:unsignedInt"/>
<xs:attribute name="maxWidth" type="xs:unsignedInt"/>
<xs:attribute name="minHeight" type="xs:unsignedInt"/>
<xs:attribute name="maxHeight" type="xs:unsignedInt"/>
<xs:attribute name="minFrameRate" type="FrameRateType"/>
<xs:attribute name="maxFrameRate" type="FrameRateType"/>
<xs:attribute name="segmentAlignment" type="ConditionalUintType" default="false"/>
<xs:attribute name="subsegmentAlignment" type="ConditionalUintType" default="false"/>
<xs:attribute name="subsegmentStartsWithSAP" type="SAPType" default="0"/>
<xs:attribute name="bitstreamSwitching" type="xs:boolean"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Type for Frame Rate -->
<xs:simpleType name="FrameRateType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]*[0-9](/[0-9]*[0-9])?"/>
</xs:restriction>
</xs:simpleType>
<!-- Conditional Unsigned Integer (unsignedInt or boolean) -->
<xs:simpleType name="ConditionalUintType">
<xs:union memberTypes="xs:unsignedInt xs:boolean"/>
</xs:simpleType>
<!-- Content Component -->
<xs:complexType name="ContentComponentType">
<xs:sequence>
<xs:element name="Accessibility" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Role" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Rating" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Viewpoint" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="id" type="xs:unsignedInt"/>
<xs:attribute name="lang" type="xs:language"/>
<xs:attribute name="contentType" type="xs:string"/>
<xs:attribute name="par" type="RatioType"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Representation -->
<xs:complexType name="RepresentationType">
<xs:complexContent>
<xs:extension base="RepresentationBaseType">
<xs:sequence>
<xs:element name="BaseURL" type="BaseURLType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="SubRepresentation" type="SubRepresentationType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="SegmentBase" type="SegmentBaseType" minOccurs="0"/>
<xs:element name="SegmentList" type="SegmentListType" minOccurs="0"/>
<xs:element name="SegmentTemplate" type="SegmentTemplateType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="id" type="StringNoWhitespaceType" use="required"/>
<xs:attribute name="bandwidth" type="xs:unsignedInt" use="required"/>
<xs:attribute name="qualityRanking" type="xs:unsignedInt"/>
<xs:attribute name="dependencyId" type="StringVectorType"/>
<xs:attribute name="mediaStreamStructureId" type="StringVectorType"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- String without white spaces -->
<xs:simpleType name="StringNoWhitespaceType">
<xs:restriction base="xs:string">
<xs:pattern value="[^\r\n\t \p{Z}]*"/>
</xs:restriction>
</xs:simpleType>
<!-- SubRepresentation -->
<xs:complexType name="SubRepresentationType">
<xs:complexContent>
<xs:extension base="RepresentationBaseType">
<xs:attribute name="level" type="xs:unsignedInt"/>
<xs:attribute name="dependencyLevel" type="UIntVectorType"/>
<xs:attribute name="bandwidth" type="xs:unsignedInt"/>
<xs:attribute name="contentComponent" type="StringVectorType"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Representation base (common attributes and elements) -->
<xs:complexType name="RepresentationBaseType">
<xs:sequence>
<xs:element name="FramePacking" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="AudioChannelConfiguration" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ContentProtection" type="DescriptorType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="profiles" type="xs:string"/>
<xs:attribute name="width" type="xs:unsignedInt"/>
<xs:attribute name="height" type="xs:unsignedInt"/>
<xs:attribute name="sar" type="RatioType"/>
<xs:attribute name="frameRate" type="FrameRateType"/>
<xs:attribute name="audioSamplingRate" type="xs:string"/>
<xs:attribute name="mimeType" type="xs:string"/>
<xs:attribute name="segmentProfiles" type="xs:string"/>
<xs:attribute name="codecs" type="xs:string"/>
<xs:attribute name="maximumSAPPeriod" type="xs:double"/>
<xs:attribute name="startWithSAP" type="SAPType"/>
<xs:attribute name="maxPlayoutRate" type="xs:double"/>
<xs:attribute name="codingDependency" type="xs:boolean"/>
<xs:attribute name="scanType" type="VideoScanType"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Ratio Type for sar and par -->
<xs:simpleType name="RatioType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]*:[0-9]*"/>
</xs:restriction>
</xs:simpleType>
<!-- Stream Access Point type enumeration -->
<xs:simpleType name="SAPType">
<xs:restriction base="xs:unsignedInt">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="6"/>
</xs:restriction>
</xs:simpleType>
<!-- Video Scan type enumeration -->
<xs:simpleType name="VideoScanType">
<xs:restriction base="xs:string">
<xs:enumeration value="progressive"/>
<xs:enumeration value="interlaced"/>
<xs:enumeration value="unknown"/>
</xs:restriction>
</xs:simpleType>
<!-- Subset -->
<xs:complexType name="SubsetType">
<xs:attribute name="contains" type="UIntVectorType" use="required"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Segment information base -->
<xs:complexType name="SegmentBaseType">
<xs:sequence>
<xs:element name="Initialization" type="URLType" minOccurs="0"/>
<xs:element name="RepresentationIndex" type="URLType" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="timescale" type="xs:unsignedInt"/>
<xs:attribute name="presentationTimeOffset" type="xs:unsignedInt"/>
<xs:attribute name="indexRange" type="xs:string"/>
<xs:attribute name="indexRangeExact" type="xs:boolean" default="false"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Multiple Segment information base -->
<xs:complexType name="MultipleSegmentBaseType">
<xs:complexContent>
<xs:extension base="SegmentBaseType">
<xs:sequence>
<xs:element name="SegmentTimeline" type="SegmentTimelineType" minOccurs="0"/>
<xs:element name="BitstreamSwitching" type="URLType" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="duration" type="xs:unsignedInt"/>
<xs:attribute name="startNumber" type="xs:unsignedInt"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Segment Info item URL/range -->
<xs:complexType name="URLType">
<xs:sequence>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="sourceURL" type="xs:anyURI"/>
<xs:attribute name="range" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Segment List -->
<xs:complexType name="SegmentListType">
<xs:complexContent>
<xs:extension base="MultipleSegmentBaseType">
<xs:sequence>
<xs:element name="SegmentURL" type="SegmentURLType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute ref="xlink:href"/>
<xs:attribute ref="xlink:actuate" default="onRequest"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Segment URL -->
<xs:complexType name="SegmentURLType">
<xs:sequence>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="media" type="xs:anyURI"/>
<xs:attribute name="mediaRange" type="xs:string"/>
<xs:attribute name="index" type="xs:anyURI"/>
<xs:attribute name="indexRange" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Segment Template -->
<xs:complexType name="SegmentTemplateType">
<xs:complexContent>
<xs:extension base="MultipleSegmentBaseType">
<xs:attribute name="media" type="xs:string"/>
<xs:attribute name="index" type="xs:string"/>
<xs:attribute name="initialization" type="xs:string" />
<xs:attribute name="bitstreamSwitching" type="xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Segment Timeline -->
<xs:complexType name="SegmentTimelineType">
<xs:sequence>
<xs:element name="S" minOccurs="1" maxOccurs="unbounded" >
<xs:complexType>
<xs:attribute name="t" type="xs:unsignedInt"/>
<xs:attribute name="d" type="xs:unsignedInt" use="required"/>
<xs:attribute name="r" type="xs:unsignedInt" use="optional" default="0"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
</xs:element>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Whitespace-separated list of strings -->
<xs:simpleType name="StringVectorType">
<xs:list itemType="xs:string"/>
</xs:simpleType>
<!-- Whitespace-separated list of unsigned integers -->
<xs:simpleType name="UIntVectorType">
<xs:list itemType="xs:unsignedInt"/>
</xs:simpleType>
<!-- Base URL -->
<xs:complexType name="BaseURLType">
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute name="serviceLocation" type="xs:string"/>
<xs:attribute name="byteRange" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!-- Program Information -->
<xs:complexType name="ProgramInformationType">
<xs:sequence>
<xs:element name="Title" type="xs:string" minOccurs="0"/>
<xs:element name="Source" type="xs:string" minOccurs="0"/>
<xs:element name="Copyright" type="xs:string" minOccurs="0"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="lang" type="xs:language"/>
<xs:attribute name="moreInformationURL" type="xs:anyURI"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Descriptor -->
<xs:complexType name="DescriptorType">
<xs:sequence>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="schemeIdUri" type="xs:anyURI" use="required"/>
<xs:attribute name="value" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Metrics -->
<xs:complexType name="MetricsType">
<xs:sequence>
<xs:element name="Reporting" type="DescriptorType" maxOccurs="unbounded"/>
<xs:element name="Range" type="RangeType" minOccurs="0" maxOccurs="unbounded"/>
<xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="metrics" type="xs:string" use="required"/>
<xs:anyAttribute namespace="##other" processContents="lax"/>
</xs:complexType>
<!-- Metrics Range -->
<xs:complexType name="RangeType">
<xs:attribute name="starttime" type="xs:duration"/>
<xs:attribute name="duration" type="xs:duration"/>
</xs:complexType>
</xs:schema>

270
mpd/test/schema/xlink.xsd Normal file
View File

@ -0,0 +1,270 @@
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3.org/1999/xlink" xmlns:xlink="http://www.w3.org/1999/xlink">
<xs:annotation>
<xs:documentation>This schema document provides attribute declarations and
attribute group, complex type and simple type definitions which can be used in
the construction of user schemas to define the structure of particular linking
constructs, e.g.
<![CDATA[
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xl="http://www.w3.org/1999/xlink">
<xs:import namespace="http://www.w3.org/1999/xlink"
location="http://www.w3.org/1999/xlink.xsd">
<xs:element name="mySimple">
<xs:complexType>
...
<xs:attributeGroup ref="xl:simpleAttrs"/>
...
</xs:complexType>
</xs:element>
...
</xs:schema>]]></xs:documentation>
</xs:annotation>
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="xml.xsd"/>
<xs:attribute name="type" type="xlink:typeType"/>
<xs:simpleType name="typeType">
<xs:restriction base="xs:token">
<xs:enumeration value="simple"/>
<xs:enumeration value="extended"/>
<xs:enumeration value="title"/>
<xs:enumeration value="resource"/>
<xs:enumeration value="locator"/>
<xs:enumeration value="arc"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="href" type="xlink:hrefType"/>
<xs:simpleType name="hrefType">
<xs:restriction base="xs:anyURI"/>
</xs:simpleType>
<xs:attribute name="role" type="xlink:roleType"/>
<xs:simpleType name="roleType">
<xs:restriction base="xs:anyURI">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="arcrole" type="xlink:arcroleType"/>
<xs:simpleType name="arcroleType">
<xs:restriction base="xs:anyURI">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="title" type="xlink:titleAttrType"/>
<xs:simpleType name="titleAttrType">
<xs:restriction base="xs:string"/>
</xs:simpleType>
<xs:attribute name="show" type="xlink:showType"/>
<xs:simpleType name="showType">
<xs:restriction base="xs:token">
<xs:enumeration value="new"/>
<xs:enumeration value="replace"/>
<xs:enumeration value="embed"/>
<xs:enumeration value="other"/>
<xs:enumeration value="none"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="actuate" type="xlink:actuateType"/>
<xs:simpleType name="actuateType">
<xs:restriction base="xs:token">
<xs:enumeration value="onLoad"/>
<xs:enumeration value="onRequest"/>
<xs:enumeration value="other"/>
<xs:enumeration value="none"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="label" type="xlink:labelType"/>
<xs:simpleType name="labelType">
<xs:restriction base="xs:NCName"/>
</xs:simpleType>
<xs:attribute name="from" type="xlink:fromType"/>
<xs:simpleType name="fromType">
<xs:restriction base="xs:NCName"/>
</xs:simpleType>
<xs:attribute name="to" type="xlink:toType"/>
<xs:simpleType name="toType">
<xs:restriction base="xs:NCName"/>
</xs:simpleType>
<xs:attributeGroup name="simpleAttrs">
<xs:attribute ref="xlink:type" fixed="simple"/>
<xs:attribute ref="xlink:href"/>
<xs:attribute ref="xlink:role"/>
<xs:attribute ref="xlink:arcrole"/>
<xs:attribute ref="xlink:title"/>
<xs:attribute ref="xlink:show"/>
<xs:attribute ref="xlink:actuate"/>
</xs:attributeGroup>
<xs:group name="simpleModel">
<xs:sequence>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType mixed="true" name="simple">
<xs:annotation>
<xs:documentation>
Intended for use as the type of user-declared elements to make them
simple links.
</xs:documentation>
</xs:annotation>
<xs:group ref="xlink:simpleModel"/>
<xs:attributeGroup ref="xlink:simpleAttrs"/>
</xs:complexType>
<xs:attributeGroup name="extendedAttrs">
<xs:attribute ref="xlink:type" fixed="extended" use="required"/>
<xs:attribute ref="xlink:role"/>
<xs:attribute ref="xlink:title"/>
</xs:attributeGroup>
<xs:group name="extendedModel">
<xs:choice>
<xs:element ref="xlink:title"/>
<xs:element ref="xlink:resource"/>
<xs:element ref="xlink:locator"/>
<xs:element ref="xlink:arc"/>
</xs:choice>
</xs:group>
<xs:complexType name="extended">
<xs:annotation>
<xs:documentation>
Intended for use as the type of user-declared elements to make them
extended links.
Note that the elements referenced in the content model are all abstract.
The intention is that by simply declaring elements with these as their
substitutionGroup, all the right things will happen.
</xs:documentation>
</xs:annotation>
<xs:group ref="xlink:extendedModel" minOccurs="0" maxOccurs="unbounded"/>
<xs:attributeGroup ref="xlink:extendedAttrs"/>
</xs:complexType>
<xs:element name="title" type="xlink:titleEltType" abstract="true"/>
<xs:attributeGroup name="titleAttrs">
<xs:attribute ref="xlink:type" fixed="title" use="required"/>
<xs:attribute ref="xml:lang">
<xs:annotation>
<xs:documentation>
xml:lang is not required, but provides much of the
motivation for title elements in addition to attributes, and so
is provided here for convenience.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="titleModel">
<xs:sequence>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType mixed="true" name="titleEltType">
<xs:group ref="xlink:titleModel"/>
<xs:attributeGroup ref="xlink:titleAttrs"/>
</xs:complexType>
<xs:element name="resource" type="xlink:resourceType" abstract="true"/>
<xs:attributeGroup name="resourceAttrs">
<xs:attribute ref="xlink:type" fixed="resource" use="required"/>
<xs:attribute ref="xlink:role"/>
<xs:attribute ref="xlink:title"/>
<xs:attribute ref="xlink:label"/>
</xs:attributeGroup>
<xs:group name="resourceModel">
<xs:sequence>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType mixed="true" name="resourceType">
<xs:group ref="xlink:resourceModel"/>
<xs:attributeGroup ref="xlink:resourceAttrs"/>
</xs:complexType>
<xs:element name="locator" type="xlink:locatorType" abstract="true"/>
<xs:attributeGroup name="locatorAttrs">
<xs:attribute ref="xlink:type" fixed="locator" use="required"/>
<xs:attribute ref="xlink:href" use="required"/>
<xs:attribute ref="xlink:role"/>
<xs:attribute ref="xlink:title"/>
<xs:attribute ref="xlink:label">
<xs:annotation>
<xs:documentation>
label is not required, but locators have no particular
XLink function if they are not labeled.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="locatorModel">
<xs:sequence>
<xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType name="locatorType">
<xs:group ref="xlink:locatorModel"/>
<xs:attributeGroup ref="xlink:locatorAttrs"/>
</xs:complexType>
<xs:element name="arc" type="xlink:arcType" abstract="true"/>
<xs:attributeGroup name="arcAttrs">
<xs:attribute ref="xlink:type" fixed="arc" use="required"/>
<xs:attribute ref="xlink:arcrole"/>
<xs:attribute ref="xlink:title"/>
<xs:attribute ref="xlink:show"/>
<xs:attribute ref="xlink:actuate"/>
<xs:attribute ref="xlink:from"/>
<xs:attribute ref="xlink:to">
<xs:annotation>
<xs:documentation>
from and to have default behavior when values are missing
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:attributeGroup>
<xs:group name="arcModel">
<xs:sequence>
<xs:element ref="xlink:title" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:group>
<xs:complexType name="arcType">
<xs:group ref="xlink:arcModel"/>
<xs:attributeGroup ref="xlink:arcAttrs"/>
</xs:complexType>
</xs:schema>

117
mpd/test/schema/xml.xsd Normal file
View File

@ -0,0 +1,117 @@
<?xml version='1.0'?>
<!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" >
<xs:schema targetNamespace="http://www.w3.org/XML/1998/namespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" xml:lang="en">
<xs:annotation>
<xs:documentation>
See http://www.w3.org/XML/1998/namespace.html and
http://www.w3.org/TR/REC-xml for information about this namespace.
This schema document describes the XML namespace, in a form
suitable for import by other schema documents.
Note that local names in this namespace are intended to be defined
only by the World Wide Web Consortium or its subgroups. The
following names are currently defined in this namespace and should
not be used with conflicting semantics by any Working Group,
specification, or document instance:
base (as an attribute name): denotes an attribute whose value
provides a URI to be used as the base for interpreting any
relative URIs in the scope of the element on which it
appears; its value is inherited. This name is reserved
by virtue of its definition in the XML Base specification.
lang (as an attribute name): denotes an attribute whose value
is a language code for the natural language of the content of
any element; its value is inherited. This name is reserved
by virtue of its definition in the XML specification.
space (as an attribute name): denotes an attribute whose
value is a keyword indicating what whitespace processing
discipline is intended for the content of the element; its
value is inherited. This name is reserved by virtue of its
definition in the XML specification.
Father (in any context at all): denotes Jon Bosak, the chair of
the original XML Working Group. This name is reserved by
the following decision of the W3C XML Plenary and
XML Coordination groups:
In appreciation for his vision, leadership and dedication
the W3C XML Plenary on this 10th day of February, 2000
reserves for Jon Bosak in perpetuity the XML name
xml:Father
</xs:documentation>
</xs:annotation>
<xs:annotation>
<xs:documentation>This schema defines attributes and an attribute group
suitable for use by
schemas wishing to allow xml:base, xml:lang or xml:space attributes
on elements they define.
To enable this, such a schema must import this schema
for the XML namespace, e.g. as follows:
&lt;schema . . .>
. . .
&lt;import namespace="http://www.w3.org/XML/1998/namespace"
schemaLocation="http://www.w3.org/2001/03/xml.xsd"/>
Subsequently, qualified reference to any of the attributes
or the group defined below will have the desired effect, e.g.
&lt;type . . .>
. . .
&lt;attributeGroup ref="xml:specialAttrs"/>
will define a type which will schema-validate an instance
element with any of those attributes</xs:documentation>
</xs:annotation>
<xs:annotation>
<xs:documentation>In keeping with the XML Schema WG's standard versioning
policy, this schema document will persist at
http://www.w3.org/2001/03/xml.xsd.
At the date of issue it can also be found at
http://www.w3.org/2001/xml.xsd.
The schema document at that URI may however change in the future,
in order to remain compatible with the latest version of XML Schema
itself. In other words, if the XML Schema namespace changes, the version
of this document at
http://www.w3.org/2001/xml.xsd will change
accordingly; the version at
http://www.w3.org/2001/03/xml.xsd will not change.
</xs:documentation>
</xs:annotation>
<xs:attribute name="lang" type="xs:language">
<xs:annotation>
<xs:documentation>In due course, we should install the relevant ISO 2- and 3-letter
codes as the enumerated possible values . . .</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="space" default="preserve">
<xs:simpleType>
<xs:restriction base="xs:NCName">
<xs:enumeration value="default"/>
<xs:enumeration value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="base" type="xs:anyURI">
<xs:annotation>
<xs:documentation>See http://www.w3.org/TR/xmlbase/ for
information about this attribute.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attributeGroup name="specialAttrs">
<xs:attribute ref="xml:base"/>
<xs:attribute ref="xml:lang"/>
<xs:attribute ref="xml:space"/>
</xs:attributeGroup>
</xs:schema>