def test_mpd_in_out(self):
     mp = mpdprocessor.MpdProcessor(vodMPD, self.cfg)
     mp.process({'availabilityStartTime': "1971", 'availability_start_time_in_s': 31536000,
                 'BaseURL': "http://india/", 'minimumUpdatePeriod': "0", 'periodOffset': 100000},
                [{'id': "p0", 'startNumber': "0", 'presentationTimeOffset': 0},
                 {'id': "p1", 'startNumber': "3600", 'presentationTimeOffset': 100000}])
     xml = mp.get_full_xml()
 def test_utc_timing_head(self):
     self.cfg['utc_timing_methods'] = ["head"]
     mp = mpdprocessor.MpdProcessor(vodMPD, self.cfg)
     mp.process({'availabilityStartTime': "1971", 'availability_start_time_in_s': 31536000,
                 'BaseURL': "http://india/", 'minimumUpdatePeriod': "0", 'periodOffset': 100000},
                [{'id': "p0", 'startNumber': "0", 'presentationTimeOffset': 0}])
     xml = mp.get_full_xml()
     head_pos = xml.find('<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-head:2014"')
     self.assertGreater(head_pos, 0, "UTCTiming for head method not found.")
 def test_utc_timing_direct_and_head(self):
     self.mpd_cfg['utc_timing_methods'] = ["direct", "head"]
     mp = mpdprocessor.MpdProcessor(vodMPD, self.mpd_cfg)
     mp.process({'availabilityStartTime': "1971", 'availability_start_time_in_s': 31536000,
                 'BaseURL': "http://india/", 'minimumUpdatePeriod': "0", 'periodOffset': 100000},
                [{'id': "p0", 'startNumber': "0", 'presentationTimeOffset': 0}])
     xml = mp.get_full_xml()
     head_pos = xml.find('<UTCTiming schemeIdUri="urn:mpeg:dash:utc:http-head:2014"')
     direct_pos = xml.find('<UTCTiming schemeIdUri="urn:mpeg:dash:utc:direct:2014"')
     self.assertLess(direct_pos, head_pos, "UTCTiming direct method does not come before head method.")
示例#4
0
def generate_dynamic_mpd(dashProv, mpd_filename, in_data, now):
    "Generate the dynamic MPD."
    cfg = dashProv.cfg
    mpd_data = in_data.copy()
    if cfg.minimum_update_period_in_s is not None:
        mpd_data['minimumUpdatePeriod'] = seconds_to_iso_duration(
            cfg.minimum_update_period_in_s)
    else:
        mpd_data['minimumUpdatePeriod'] = DEFAULT_MINIMUM_UPDATE_PERIOD
    if cfg.media_presentation_duration is not None:
        mpd_data['mediaPresentationDuration'] = seconds_to_iso_duration(
            cfg.media_presentation_duration)
    mpd_data['timeShiftBufferDepth'] = seconds_to_iso_duration(
        cfg.timeshift_buffer_depth_in_s)
    mpd_data['timeShiftBufferDepthInS'] = cfg.timeshift_buffer_depth_in_s
    mpd_data['startNumber'] = cfg.adjusted_start_number
    mpd_data['publishTime'] = '%s' % make_timestamp(in_data['publishTime'])
    mpd_data['availabilityStartTime'] = '%s' % make_timestamp(
        in_data['availability_start_time_in_s'])
    mpd_data['duration'] = '%d' % in_data['segDuration']
    mpd_data['maxSegmentDuration'] = 'PT%dS' % in_data['segDuration']
    timescale = 1
    pto = 0
    mpd_data['presentationTimeOffset'] = cfg.adjusted_pto(pto, timescale)
    if mpd_data['suggested_presentation_delay_in_s'] is not None:
        spd = in_data['suggested_presentation_delay_in_s']
        mpd_data['suggestedPresentationDelay'] = \
            seconds_to_iso_duration(spd)
    if 'availabilityEndTime' in in_data:
        mpd_data['availabilityEndTime'] = make_timestamp(
            in_data['availabilityEndTime'])
    if cfg.stop_time is not None and (now > cfg.stop_time):
        mpd_data['type'] = "static"
    mpd_proc_cfg = {
        'scte35Present': (cfg.scte35_per_minute > 0),
        'continuous': in_data['continuous'],
        'segtimeline': in_data['segtimeline'],
        'segtimeline_nr': in_data['segtimeline_nr'],
        'utc_timing_methods': cfg.utc_timing_methods,
        'utc_head_url': dashProv.utc_head_url,
        'now': now
    }
    ll_data = {}  # Low-latency data
    if cfg.chunk_duration_in_s is None:
        mpd_data['availabilityTimeOffset'] = '%f' % in_data[
            'availability_time_offset_in_s']
        if not cfg.availability_time_complete:
            mpd_data['availabilityTimeComplete'] = 'false'
    else:  # Set these values in the ll_data
        ll_data['availabilityTimeOffset'] = '%f' % in_data[
            'availability_time_offset_in_s']
        ll_data['availabilityTimeComplete'] = 'false'

    if cfg.chunk_duration_in_s is not None and cfg.chunk_duration_in_s > 0:
        if len(mpd_proc_cfg['utc_timing_methods']) == 0:
            mpd_proc_cfg['utc_timing_methods'].append('httpiso')
        mpd_data['add_profiles'] = [
            'http://www.dashif.org/guidelines/low-latency-live-v5'
        ]
    full_url = dashProv.base_url + '/'.join(dashProv.url_parts)
    mpmod = mpdprocessor.MpdProcessor(mpd_filename, mpd_proc_cfg, cfg,
                                      full_url)
    period_data = generate_period_data(mpd_data, now, cfg)
    mpmod.process(mpd_data, period_data, ll_data)
    return mpmod.get_full_xml()