示例#1
0
 def test_mpd_type_attribute_for_on_demand_profile(self):
     mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
               min_buffer_time=1)
     print mpd.to_xml()
     xml = etree.fromstring(mpd.to_xml())
     assert 'type' in xml.attrib
     assert xml.attrib.get('type') == 'static'
 def test_mpd_xml_serialization(self):
     mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
               min_buffer_time=1)
     assert 'to_xml' in dir(mpd)
     assert isinstance(mpd.to_xml(), basestring)
     assert mpd.to_xml().startswith('<?xml')
     etree.fromstring(mpd.to_xml())
class MPDPeriodsRelationshipTest(unittest.TestCase):
    def setUp(self):
        self.mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
                       min_buffer_time=1)

    def test_mpd_periods_relationship(self):
        assert is_instance_method(self.mpd.periods)
        assert self.mpd.periods() == []

    def test_mpd_append_period_with_degenerate_input(self):
        assert is_instance_method(self.mpd.append_period)
        self.assertRaises(TypeError, self.mpd.append_period, None)
        self.assertRaises(TypeError, self.mpd.append_period, '')
        self.assertRaises(TypeError, self.mpd.append_period, 0)
        self.assertRaises(TypeError, self.mpd.append_period, 0.0)

    def test_mpd_add_single_period(self):
        period_start = 0
        period_duration = 47.175
        period = mpegdash.period.Period(id='0',
                                        start=period_start,
                                        duration=period_duration)
        self.mpd.append_period(period)
        xml = etree.fromstring(self.mpd.to_xml())
        assert len(xml.getchildren()) > 0
        period_element = xml.getchildren()[0]
        assert period_element.attrib.get('id') == '0'
        assert period_element.attrib.get('start') == duration_isoformat(
            datetime.timedelta(seconds=period_start))
        assert period_element.attrib.get(
            'start') == 'P0D'  # isodate uses D by default for 0
        assert period_element.attrib.get('duration') == duration_isoformat(
            datetime.timedelta(seconds=period_duration))
        assert period_element.attrib.get('duration') == 'PT47.175S'
 def test_complete_mpd(self):
     mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
               min_buffer_time=1)
     period_start = 0
     period_duration = 47.175
     period = Period(id='0', start=period_start, duration=period_duration)
     mpd.append_period(period)
     adaptation_set = AdaptationSet()
     period.append_adaptation_set(adaptation_set)
 def test_mpd_model_with_supported_dash_profiles(self):
     self.assertRaises(TypeError,
                       MPD,
                       profiles='urn:mpeg:dash:profile:full:2012',
                       min_buffer_time=0)
     MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
         min_buffer_time=0)
示例#6
0
class MPDXMLSerializationTest(unittest.TestCase):

    def setUp(self):
        self.mpd = MPD(profiles=DASH_PROFILE, min_buffer_time=MINIMUM_BUFFER_TIME)
        self.xml = etree.fromstring(str(self.mpd.to_xml()))

    def test_mpd_node_required_attributes(self):
        duration = datetime.timedelta(seconds=MINIMUM_BUFFER_TIME)
        assert self.xml.attrib.get('minBufferTime') == isodate.duration_isoformat(duration)
        assert self.xml.attrib.get('profiles') == DASH_PROFILE
示例#7
0
    def test_mpd_media_presentation_duration_attribute(self):
        duration = 47.175000
        mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
                  min_buffer_time=1)
        mpd.set_attribute('mediaPresentationDuration', duration)
        xml = etree.fromstring(str(mpd.to_xml()))
        assert 'mediaPresentationDuration' in xml.attrib
        assert xml.attrib.get(
            'mediaPresentationDuration') == duration_isoformat(
                datetime.timedelta(seconds=duration))
        assert xml.attrib.get('mediaPresentationDuration') == 'PT47.175S'

        duration = 90001.234
        mpd.set_attribute('mediaPresentationDuration', duration)
        xml = etree.fromstring(str(mpd.to_xml()))
        assert 'mediaPresentationDuration' in xml.attrib
        assert xml.attrib.get(
            'mediaPresentationDuration') == duration_isoformat(
                datetime.timedelta(seconds=duration))
        assert xml.attrib.get('mediaPresentationDuration') == 'P1DT1H1.234S'
示例#8
0
class MPDXMLNamespace(unittest.TestCase):
    def setUp(self):
        self.mpd = MPD(profiles=DEFAULT_DASH_PROFILE,
                       min_buffer_time=MINIMUM_BUFFER_TIME)
        self.xml = etree.fromstring(str(self.mpd.to_xml()))

    def test_mpd_xml_schema_instance(self):
        assert 'xsi' in self.xml.nsmap
        assert self.xml.nsmap.get('xsi') == XML_SCHEMA_INSTANCE

    def test_mpd_xml_namespace(self):
        assert None in self.xml.nsmap
        assert self.xml.nsmap.get(None) == 'urn:mpeg:dash:schema:mpd:2011'

        xsi_schema_location_attrib = '{{{}}}schemaLocation'.format(
            XML_SCHEMA_INSTANCE)
        assert xsi_schema_location_attrib in self.xml.attrib
        assert self.xml.attrib.get(
            xsi_schema_location_attrib
        ) == 'urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd'
 def setUp(self):
     self.mpd = MPD(profiles='urn:mpeg:dash:profile:isoff-on-demand:2011',
                    min_buffer_time=1)
示例#10
0
 def setUp(self):
     self.mpd = MPD(profiles=DEFAULT_DASH_PROFILE,
                    min_buffer_time=MINIMUM_BUFFER_TIME)
     self.xml = etree.fromstring(str(self.mpd.to_xml()))
示例#11
0
 def test_mpd_model_properties(self):
     model = MPD(profiles=DASH_PROFILE, min_buffer_time=1)
     assert 'profiles' in dir(model)
     assert 'periods' in dir(model)
示例#12
0
 def result():
     mpd = MPD(profiles=DEFAULT_DASH_PROFILE, min_buffer_time=1)
     [mpd.append_period(Period(start=0, duration=10)) for _ in range(0, 100)]
     return mpd.to_xml()