def main(): """ Main Program wrapper """ # configure the log file # Create arguments parser = ArgumentParser(description='Process Client parameters') create_arguments(parser) args = parser.parse_args() globals().update(vars(args)) configure_log_file(playback_type=PLAYBACK.lower()) config_client.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return None config_client.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_opener = get_opener() mpd_file = get_mpd(MPD, mpd_opener) domain = get_domain_name(MPD) # Reading the MPD file created dp_object = read_mpd.read_mpd(mpd_file) config_client.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None else: config_client.LOG.critical("Started DASH Playback") start_playback(dp_object, domain, "BASIC", DOWNLOAD)
def main(): """ Main Program wrapper """ # configure the log file # Create arguments parser = ArgumentParser(description='Process Client parameters') create_arguments(parser) args = parser.parse_args() globals().update(vars(args)) configure_log_file(playback_type=PLAYBACK.lower()) config_dash.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if QUIC: config_dash.JSON_HANDLE['transport'] = 'quic' else: config_dash.JSON_HANDLE['transport'] = 'tcp' if MP: config_dash.JSON_HANDLE['scheduler'] = SCHEDULER else: config_dash.JSON_HANDLE['scheduler'] = 'singlePath' if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return None glueConnection.setupPM(QUIC, MP, not NO_KEEP_ALIVE, SCHEDULER) config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = get_mpd(MPD) domain = get_domain_name(MPD) dp_object = DashPlayback() # Reading the MPD file created dp_object, video_segment_duration = read_mpd.read_mpd(mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") start_playback_all(dp_object, domain) elif "basic" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic-DASH Playback") start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration) elif "sara" in PLAYBACK.lower(): config_dash.LOG.critical("Started SARA-DASH Playback") start_playback_smart(dp_object, domain, "SMART", DOWNLOAD, video_segment_duration) elif "netflix" in PLAYBACK.lower(): config_dash.LOG.critical("Started Netflix-DASH Playback") start_playback_smart(dp_object, domain, "NETFLIX", DOWNLOAD, video_segment_duration) else: config_dash.LOG.error("Unknown Playback parameter {}".format(PLAYBACK)) return None
def main(): """ Main Program wrapper """ # configure the log file # Create arguments parser = ArgumentParser(description='Process Client parameters') create_arguments(parser) args = parser.parse_args() globals().update(vars(args)) configure_log_file(playback_type=PLAYBACK.lower()) config_dash.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if not MPD: print("ERROR: Please provide the URL to the MPD file. Try Again..") return None config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = get_mpd(MPD) domain = get_domain_name(MPD) dp_object = DashPlayback() # Reading the MPD file created dp_object, video_segment_duration = read_mpd.read_mpd(mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") start_playback_all(dp_object, domain) elif "basic" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic-DASH Playback") start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration, RETRANS) elif "sara" in PLAYBACK.lower(): config_dash.LOG.critical("Started SARA-DASH Playback") start_playback_smart(dp_object, domain, "SMART", DOWNLOAD, video_segment_duration, RETRANS) elif "netflix" in PLAYBACK.lower(): config_dash.LOG.critical("Started Netflix-DASH Playback") start_playback_smart(dp_object, domain, "NETFLIX", DOWNLOAD, video_segment_duration, RETRANS) elif "vlc" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic2-DASH Playback") start_playback_smart(dp_object, domain, "VLC", DOWNLOAD, video_segment_duration, RETRANS) elif "empirical" in PLAYBACK.lower(): config_dash.LOG.critical("Started Hello-DASH Playback") start_playback_smart(dp_object, domain, "EMPIRICAL", DOWNLOAD, video_segment_duration, RETRANS) else: config_dash.LOG.error("Unknown Playback parameter {}".format(PLAYBACK)) return None
def main(): """ Main Program wrapper """ # configure the log file # Create arguments parser = ArgumentParser(description='Process Client parameters') create_arguments(parser) args = parser.parse_args() globals().update(vars(args)) configure_log_file(playback_type=PLAYBACK.lower()) config_dash.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return None config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = get_mpd(MPD) domain = get_domain_name(MPD) dp_object = DashPlayback() # Reading the MPD file created dp_object, video_segment_duration = read_mpd.read_mpd(mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") start_playback_all(dp_object, domain) elif "basic" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic-DASH Playback") start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration, RETRANS) elif "sara" in PLAYBACK.lower(): config_dash.LOG.critical("Started SARA-DASH Playback") start_playback_smart(dp_object, domain, "SMART", DOWNLOAD, video_segment_duration, RETRANS) elif "netflix" in PLAYBACK.lower(): config_dash.LOG.critical("Started Netflix-DASH Playback") start_playback_smart(dp_object, domain, "NETFLIX", DOWNLOAD, video_segment_duration, RETRANS) elif "vlc" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic2-DASH Playback") start_playback_smart(dp_object, domain, "VLC", DOWNLOAD, video_segment_duration, RETRANS) elif "empirical" in PLAYBACK.lower(): config_dash.LOG.critical("Started Hello-DASH Playback") start_playback_smart(dp_object, domain, "EMPIRICAL", DOWNLOAD, video_segment_duration, RETRANS) else: config_dash.LOG.error("Unknown Playback parameter {}".format(PLAYBACK)) return None
def main(): """ Main Program wrapper""" # configure the log file configure_log_file() # Create arguments parser = ArgumentParser(description='Process Client paameters') create_arguments(parser) args = parser.parse_args() update_config(args) if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = get_mpd(MPD) domain = get_domain_name(MPD) dp_object = read_mpd.DashPlayback() dp_object = read_mpd.read_mpd(mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d audio representations" % ( len(dp_object.audio))) config_dash.LOG.info("The DASH media has %d video representations" %( len(dp_object.video))) if LIST: # Print the representations and and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") start_playback_all(dp_object, domain) elif "smart" in PLAYBACK.lower(): config_dash.LOG.critical("Start SMART Playback") start_playback_smart(dp_object, domain) else: config_dash.LOG.error("Unknow Playback parameter") return None
def parse_mpd(mpd_file, request, mpd_headers, client_id): """ Module to parse the MPD_file and update the global dictionaries MPD_DICT, USER_DICT :param mpd_file: Path to mpd_file on local machine :param request: HTTP request path string :param mpd_headers: HPP Headers :param client_address: (ip_address, port) of the user :return: """ #parse mpd that you have in cache global USER_DICT, MPD_DICT, USER_DICT_LOCK dash_playback_object = read_mpd.read_mpd(mpd_file) MPD_DICT[request] = {'bandwidth_list': dash_playback_object.video['bandwidth_list'], 'http_headers': mpd_headers} # use json file in cache config_cdash.LOG.info('Added info of {}: {} to MPD_DICT'.format(request, MPD_DICT)) with open(config_cdash.MPD_DICT_JSON_FILE, 'wb') as outfile: json.dump(MPD_DICT, outfile) with USER_DICT_LOCK: USER_DICT[client_id] = {'bitrates': dash_playback_object.video['bandwidth_list'], 'created': time.time()} config_cdash.LOG.info('Updated the USER_DICT with {} and bitrates {}'.format( client_id, dash_playback_object.video['bandwidth_list']))
def main(): """ Main Program wrapper """ # configure the log file # Create arguments sumOfTotalDownloaded = 0.0 sumOfPlaybackTime = 0.0 program_start_time = datetime.now() for runNo in range(1, 11): parser = ArgumentParser(description='Process Client parameters') create_arguments(parser) args = parser.parse_args() globals().update(vars(args)) if QUIC: CONNECTION_TYPE_STR = "QUIC_" + str(runNo) + "_" + PLAYBACK elif CURL: CONNECTION_TYPE_STR = "CURL_" + str(runNo) + "_" + PLAYBACK else: CONNECTION_TYPE_STR = "URLLIB_" + str(runNo) + "_" + PLAYBACK configure_log_file(playback_type=PLAYBACK.lower(), connection_type=CONNECTION_TYPE_STR) config_dash.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return None config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = None while mpd_file == None: mpd_file = get_mpd(MPD) if mpd_file != None: break domain = get_domain_name(MPD) dp_object = DashPlayback() # Reading the MPD file created dp_object, video_segment_duration = read_mpd.read_mpd( mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") playbackTime, totalDownloaded = start_playback_all( dp_object, domain) elif "basic" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic-DASH Playback") playbackTime, totalDownloaded = start_playback_smart( dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration, CONNECTION_TYPE_STR, JUMP_SCENARIO) elif "sara" in PLAYBACK.lower(): config_dash.LOG.critical("Started SARA-DASH Playback") playbackTime, totalDownloaded = start_playback_smart( dp_object, domain, "SMART", DOWNLOAD, video_segment_duration, CONNECTION_TYPE_STR, JUMP_SCENARIO) elif "netflix" in PLAYBACK.lower(): config_dash.LOG.critical("Started Netflix-DASH Playback") playbackTime, totalDownloaded = start_playback_smart( dp_object, domain, "NETFLIX", DOWNLOAD, video_segment_duration, CONNECTION_TYPE_STR, JUMP_SCENARIO) else: config_dash.LOG.error( "Unknown Playback parameter {}".format(PLAYBACK)) return None sumOfTotalDownloaded = sumOfTotalDownloaded + totalDownloaded sumOfPlaybackTime = sumOfPlaybackTime + playbackTime print "Run No:", runNo, "TOTAL DOWNLOADED: ", totalDownloaded print "Run No:", runNo, "PLAYPACK TIME: ", playbackTime print "Run No:", runNo, "SUM TOTAL DOWNLOADED: ", sumOfTotalDownloaded print "Run No:", runNo, "SUM PLAYPACK TIME: ", sumOfPlaybackTime totalDownloaded = 0 playbackTime = 0 program_end_time = datetime.now() delta = program_end_time - program_start_time print CONNECTION_TYPE_STR, "PROGRAM STARTED AT: ", program_start_time print CONNECTION_TYPE_STR, "PROGRAM FINISHED AT: ", program_end_time print CONNECTION_TYPE_STR, "PROGRAM DURATION: ", delta.total_seconds() print CONNECTION_TYPE_STR, "FINAL SUM OF TOTAL DOWNLOADED: ", sumOfTotalDownloaded print CONNECTION_TYPE_STR, "FINAL SUM OF PLAYPACK TIME: ", sumOfPlaybackTime
def main(mpd, playback, segment_limit, download, directory): #CM: input parameters added to main function """ Main Program wrapper """ # configure the log file # Create arguments #CM: commented out following section # parser = ArgumentParser(description='Process Client parameters') # create_arguments(parser) # args = parser.parse_args() # globals().update(vars(args)) #CM: added alternative lines args_updated = dict() args_updated['MPD'] = mpd args_updated['PLAYBACK'] = playback args_updated['SEGMENT_LIMIT'] = segment_limit args_updated['DOWNLOAD'] = download args_updated['VIDEO_DIRECTORY'] = directory globals().update(args_updated) config_dash.LOG_FOLDER = "/opt/monroe/astream/" configure_log_file(playback_type=PLAYBACK.lower()) config_dash.JSON_HANDLE['playback_type'] = PLAYBACK.lower() if not MPD: print "ERROR: Please provide the URL to the MPD file. Try Again.." return None config_dash.LOG.info('Downloading MPD file %s' % MPD) # Retrieve the MPD files for the video mpd_file = get_mpd(MPD) domain = get_domain_name(MPD) dp_object = DashPlayback() # Reading the MPD file created dp_object, video_segment_duration = read_mpd.read_mpd(mpd_file, dp_object) config_dash.LOG.info("The DASH media has %d video representations" % len(dp_object.video)) if LIST: # Print the representations and EXIT print_representations(dp_object) return None if "all" in PLAYBACK.lower(): if mpd_file: config_dash.LOG.critical("Start ALL Parallel PLayback") start_playback_all(dp_object, domain) elif "basic" in PLAYBACK.lower(): config_dash.LOG.critical("Started Basic-DASH Playback") start_playback_smart(dp_object, domain, "BASIC", DOWNLOAD, video_segment_duration) elif "sara" in PLAYBACK.lower(): config_dash.LOG.critical("Started SARA-DASH Playback") start_playback_smart(dp_object, domain, "SMART", DOWNLOAD, video_segment_duration) elif "netflix" in PLAYBACK.lower(): config_dash.LOG.critical("Started Netflix-DASH Playback") start_playback_smart(dp_object, domain, "NETFLIX", DOWNLOAD, video_segment_duration) else: config_dash.LOG.error("Unknown Playback parameter {}".format(PLAYBACK)) return None