def testMPDwithStartand2Durations(self): urlParts = [ 'pdash', 'start_1200', 'dur_600', 'dur_300', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=900) d = mpd_proxy.get_mpd(dp) if dash_proxy.PUBLISH_TIME: self.assertTrue(d.find('publishTime="1970-01-01T00:15:00Z"') > 0) self.assertTrue( d.find('availabilityEndTime="1970-01-01T00:30:00Z"') > 0) dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=1795) d = mpd_proxy.get_mpd(dp) if dash_proxy.PUBLISH_TIME: self.assertTrue(d.find('publishTime="1970-01-01T00:29:00Z"') > 0) self.assertTrue( d.find('availabilityEndTime="1970-01-01T00:35:00Z"') > 0)
def testNewSegmentsAdded(self): urlParts = [ 'livesim', 'baseurl_u10_d20', 'segtimeline_1', 'segtimelineloss_1', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=10) d = mpd_proxy.get_mpd(dp) start = d.find('<SegmentTimeline>') end = d.find('</SegmentTimeline>') testOutputFile = "SegTimeline3.txt" write_data_to_outfile(d[start:end + 18].encode('utf-8'), testOutputFile) segTimeline = d[start:end + 18] dp2 = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=31) d2 = mpd_proxy.get_mpd(dp2) start2 = d2.find('<SegmentTimeline>') end2 = d2.find('</SegmentTimeline>') testOutputFile = "SegTimeline4.txt" write_data_to_outfile(d2[start2:end2 + 18].encode('utf-8'), testOutputFile) segTimeline2 = d2[start2:end2 + 18] self.assertNotEqual(segTimeline, segTimeline2)
def testThatTimesDontJump(self): "Test that times don't jump as reported in ISSUE #91." # First get the MPD corresponding to 5.mpd.txt now = 1578681199 urlParts = ['livesim', 'segtimeline_1', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=now) d = mpd_proxy.get_mpd(dp) root = ElementTree.fromstring(d) first_t, first_d = find_first_audio_t(root) # tsbd = 300 # TimeShiftBufferDepth self.assertTrue(now - first_t / 48000 > 300, "Did not get before timeshift window start") later = now + 6 urlParts = ['livesim', 'segtimeline_1', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=later) d = mpd_proxy.get_mpd(dp) root = ElementTree.fromstring(d) second_t, second_d = find_first_audio_t(root) self.assertEqual(second_t, first_t + first_d, "Second t is not first t + first d ")
def testMpdPeriodReplaced(self): "Check whether before every xlink period, duration attribute has been inserted." collect_result = [] urlParts = [ 'livesim', 'periods_60', 'xlink_30', 'insertad_1', 'testpic_2s', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("10.4.247.98", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=10000) d = mpd_proxy.get_mpd(dp) xml = ET.fromstring(d) # Make the string as a xml document. # In the following, we will check if for every period before every xlink period, duration attribute has been # added or not. prev_child = [] for child in xml.findall('{urn:mpeg:dash:schema:mpd:2011}Period' ): # Collect all period elements first if '{http://www.w3.org/1999/xlink}actuate' in child.attrib: # If the period element has the duration attribute. collect_result.append( 'duration' in prev_child.attrib) # Then collect its period id in this prev_child = child # Ideally, at the periods should have a duration attribute, if no then the test fails. self.assertFalse(False in collect_result)
def testMpdPeriodReplaced(self): " Check whether appropriate periods have been replaced by in .mpd file" collectresult = 0 for k in [1, 2, 5, 10, 20, 30]: nr_period_per_hour = 60 nr_etp_periods_per_hour = k urlParts = ['livesim', 'periods_%s' % nr_period_per_hour, 'etp_%s' % nr_etp_periods_per_hour, 'testpic_2s', 'Manifest.mpd'] dp = dash_proxy.DashProvider("10.4.247.98", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=10000) d = mpd_proxy.get_mpd(dp) xml = ET.fromstring(d) # Make the string as a xml document. periods_containing_duration_attribute = [] # This array would contain all the period id that have duration attributes. # In the following, we will check if the correct period element have been assigned duration attributes. for child in xml.findall('{urn:mpeg:dash:schema:mpd:2011}Period'): # Collect all period elements first if 'duration' in child.attrib: # If the period element has the duration attribute. periods_containing_duration_attribute.append(child.attrib['id']) # Then collect its period id in this array one_etp_for_how_many_periods = nr_period_per_hour/nr_etp_periods_per_hour checker_array = [int(x[1:]) % one_etp_for_how_many_periods for x in periods_containing_duration_attribute] # In the above line, we check if each period id evaluates to zero or not. # Ideally, if everything worked well, then the checker array would be all zero. collectresult = collectresult + sum(checker_array) # Here, we keep collecting the sum of checker array. Even if one element evaluates to non zero values, then # the whole test will fail. self.assertTrue(collectresult == 0)
def testMpdGenerationHttps(self): "Check if availabilityTimeOffset works with https" urlParts = ['livesim', 'ato_2.5', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0, is_https=True) d = mpd_proxy.get_mpd(dp) self.assertEqual(d.find('availabilityTimeOffset="2.5')-d.find('<BaseURL'), len('<BaseURL')+1)
def testMpdAtoSettings(self): "availabilityTimeOffset shouldn't appear if the setting is invalid" testelem = ['ato_0', 'ato_-10', 'ato_aa'] for test in testelem: urlParts = ['livesim', test, 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertTrue(d.find('availabilityTimeOffset') < 0)
def testMpdGeneration(self): "Check if availabilityTimeOffset is added correctly to the MPD file." testOutputFile = "ato.mpd" rm_outfile(testOutputFile) urlParts = ['livesim', 'ato_30', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) write_data_to_outfile(d.encode('utf-8'), testOutputFile) self.assertEqual(d.find('availabilityTimeOffset="30')-d.find('<BaseURL'), len('<BaseURL')+1)
def setUp(self): now = 1356998460 urlParts = ['pdash', 'scte35_1', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("127.0.0.1", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=now) self.mpd = mpd_proxy.get_mpd(dp)
def testStartNumber(self): "Check that all 3 media components have startNumber=0" urlParts = ['livesim', 'testpic_stpp', 'Manifest_stpp.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertEqual(d.count('startNumber="0'), 3)
def testSuggestedPresentationDelayPresent(self): "Check that suggestedPresentationDelay get the right value." urlParts = ['pdash', 'spd_10', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertTrue(d.find('suggestedPresentationDelay="PT10S"') > 0)
def testSuggestedPresentationDelayNotPresent(self): "Check that suggestedPresentationDelayIsNotPresent." urlParts = ['pdash', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertTrue(d.find('suggestedPresentationDelay') < 0)
def testThatNoPresentationTimeOffsetForTfdt32(self): now = 1393936560 # segNr = 232322749 urlParts = ['pdash', 'tfdt_32', 'testpic', 'V1', 'Manifest.mpd'] dp = dash_proxy.DashProvider("127.0.0.1", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=now) d = mpd_proxy.get_mpd(dp) self.assertFalse(d.find('presentationTimeOffset') > 0)
def testMpdWithStartNrIs1(self): "Check that startNumber=1." urlParts = ['pdash', 'snr_1', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertEqual(len(findAllIndexes('startNumber="1"', d)), 2) self.assertTrue( d.find('availabilityStartTime="1970-01-01T00:00:00Z"') > 0)
def testMPDhandling(self): mpdprocessor.SET_BASEURL = True urlParts = ['pdash', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertTrue( d.find("<BaseURL>http://streamtest.eu/pdash/testpic/</BaseURL>") > 0)
def testMpdWithImplicitStartNr(self): "Check that startNumber is not present in MPD." urlParts = ['pdash', 'snr_-1', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) self.assertTrue(d.find('startNumber=') < 0) self.assertTrue( d.find('availabilityStartTime="1970-01-01T00:00:00Z"') > 0)
def testInbandStreamElemInMPD(self): urlParts = [ 'livesim', 'baseurl_u10_d20', 'segtimeline_1', 'segtimelineloss_1', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=10) d = mpd_proxy.get_mpd(dp) inbandEventElement = d.find("<InbandEventStream") self.assertGreater(inbandEventElement, 0)
def setUp(self): self.now = 100 urlParts = [ 'livesim', 'segtimeline_1', 'start_60', 'stop_120', 'timeoffset_0', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=self.now) self.d = mpd_proxy.get_mpd(dp) self.root = ElementTree.fromstring(self.d)
def testMultiPeriod(self): testOutputFile = "multiperiod.mpd" rm_outfile(testOutputFile) urlParts = ['pdash', 'periods_10', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=3602) d = mpd_proxy.get_mpd(dp) write_data_to_outfile(d.encode('utf-8'), testOutputFile) periodPositions = findAllIndexes("<Period", d) self.assertEqual(len(periodPositions), 2)
def setUp(self): self.now = 6003 self.tsbd = 90 urlParts = [ 'livesim', 'segtimeline_1', 'periods_60', 'tsbd_%d' % self.tsbd, 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=self.now) self.d = mpd_proxy.get_mpd(dp)
def testMpdWithNormalStartNr(self): "Check that startNumber=0." urlParts = ['pdash', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) with open(join(OUT_DIR, 'tmp.mpd'), 'wb') as ofh: ofh.write(d.encode('utf-8')) self.assertEqual(len(findAllIndexes('startNumber="0"', d)), 2) self.assertTrue( d.find('availabilityStartTime="1970-01-01T00:00:00Z"') > 0)
def setUp(self): self.now = 6003 self.tsbd = 30 urlParts = [ 'livesim', 'segtimelinenr_1', 'tsbd_%d' % self.tsbd, 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=self.now) self.d = mpd_proxy.get_mpd(dp) self.root = ElementTree.fromstring(self.d)
def testMpdGenerationHttps(self): urlParts = [ 'livesim', 'baseurl_u40_d20', 'baseurl_d40_u20', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0, is_https=True) d = mpd_proxy.get_mpd(dp) httpsIndexes = findAllIndexes("<BaseURL>https://", d) self.assertEqual(len(httpsIndexes), 2)
def testHttpsBaseURL(self): "Check that protocol is set to https if signalled to DashProvider." mpdprocessor.SET_BASEURL = True urlParts = ['pdash', 'testpic', 'Manifest.mpd'] is_https = 1 dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0, is_https=is_https) d = mpd_proxy.get_mpd(dp) self.assertTrue( d.find("<BaseURL>https://streamtest.eu/pdash/testpic/</BaseURL>") > 0)
def testUtcTiming(self): "Test that direct and head works." urlParts = ['pdash', 'utc_direct-head', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) head_pos = d.find( '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-head:2014" ' 'value="http://streamtest.eu/dash/time.txt" />') direct_pos = d.find( '<UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014"') self.assertLess(direct_pos, head_pos)
def test_absolute_times_after_stop(self): mpdprocessor.SET_BASEURL = True urlParts = [ 'pdash', 'start_978', 'stop_1044', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=1046) d = mpd_proxy.get_mpd(dp) self.assertTrue( d.find('availabilityStartTime="1970-01-01T00:16:18Z"') > 0) self.assertTrue(d.find('type="static"') > 0) self.assertTrue(d.find('mediaPresentationDuration="PT1M6S') > 0) self.assertTrue(d.find('minimumUpdatePeriod') < 0)
def testMPDwithChangedAST(self): "Put AST to 1200s later than epoch start. There should be no PTO and startNumber=0 still." testOutputFile = "start.mpd" rm_outfile(testOutputFile) urlParts = ['pdash', 'start_1200', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) write_data_to_outfile(d.encode('utf-8'), testOutputFile) self.assertTrue( d.find('availabilityStartTime="1970-01-01T00:20:00Z"') > 0) self.assertTrue(d.find('startNumber="0"') > 0) self.assertTrue(d.find('presentationTimeOffset') < 0)
def testContinuous(self): testOutputFile = "ContMultiperiod.mpd" rm_outfile(testOutputFile) urlParts = [ 'pdash', 'continuous_1', 'periods_10', 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=3602) d = mpd_proxy.get_mpd(dp) write_data_to_outfile(d.encode('utf-8'), testOutputFile) periodPositions = findAllIndexes( "urn:mpeg:dash:period_continuity:2014", d) self.assertGreater(len(periodPositions), 1)
def testCorrectFieldsInMPD(self): mpdprocessor.SET_BASEURL = True urlParts = ['livesim', 'chunkdur_1', 'ato_7', 'testpic', 'Manifest.mpd'] dp = dash_proxy.DashProvider("streamtest.eu", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=0) d = mpd_proxy.get_mpd(dp) #print(d) self.assertTrue(d.find('UTCTiming') > 0, "Should find UTC-timing element") self.assertTrue(d.find('http://www.dashif.org/guidelines/low-latency-live-v5') > 0, "Should find low-latency profile") self.assertTrue(d.find("<BaseURL>http://streamtest.eu/livesim/chunkdur_1/ato_7/testpic/</BaseURL>") > 0, "Should not have availabilityTimeComplete here") self.assertTrue(d.find('availabilityTimeComplete="false" availabilityTimeOffset="7.000000"') > 0, "Should find availabilityTimeComplete in SegmentTemplate") self.assertTrue(d.find('<ServiceDescription') > 0, "Should find ServiceDescription in MPD") self.assertTrue(d.find('<ProducerReferenceTime') > 0, "Should find ProducerReferenceTime in MPD")
def testBefore(self): self.now = 3590 self.tsbd = 60 urlParts = [ 'livesim', 'segtimeline_1', 'tsbd_%d' % self.tsbd, 'testpic', 'Manifest.mpd' ] dp = dash_proxy.DashProvider("server.org", urlParts, None, VOD_CONFIG_DIR, CONTENT_ROOT, now=self.now) self.d = mpd_proxy.get_mpd(dp) self.root = ElementTree.fromstring(self.d) nrSegments = self.getNrSegments(self.root) self.assertEqual(2 * 10, nrSegments) write_data_to_outfile(self.d.encode('utf-8'), "BeforeWrap.mpd")