Exemple #1
0
    def __init__(self, id):
        SimpleModule.__init__(self, id)

        config_parser = ConfigurationParser.get_instance()

        self.buffering_until = int(config_parser.get_parameter('buffering_until'))
        self.max_buffer_size = int(config_parser.get_parameter('max_buffer_size'))
        self.playback_step = int(config_parser.get_parameter('playbak_step'))
        self.url_mpd = config_parser.get_parameter('url_mpd')

        # last pause started at time
        self.pause_started_at = None
        self.pauses_number = 0

        # tag to verify if buffer has an minimal amount of data
        self.buffer_initialization = True

        # Does the player already started to download a segment?
        self.already_downloading = False

        # buffer itself
        self.buffer = []

        # the buffer played position
        self.buffer_played = 0

        # history of what was played in buffer
        self.playback_history = []

        #initialize with the first segment sequence number to download
        self.segment_id   = 1

        self.parsed_mpd = ''
        self.qi         = []

        self.timer = Timer.get_instance()

        #threading playback
        self.playback_thread = threading.Thread(target=self.handle_video_playback)
        self.player_thread_events = threading.Event()
        self.lock = threading.Lock()
        self.kill_playback_thread = False

        self.request_time = 0

        self.playback_qi = OutVector()
        self.playback_quality_qi = OutVector()
        self.playback_pauses = OutVector()
        self.playback = OutVector()
        self.playback_buffer_size = OutVector()
        self.throughput = OutVector()

        self.whiteboard = Whiteboard.get_instance()
        self.whiteboard.add_playback_history(self.playback.get_items())
        self.whiteboard.add_playback_qi(self.playback_qi.get_items())
        self.whiteboard.add_playback_pauses(self.playback_pauses.get_items())
        self.whiteboard.add_playback_buffer_size(self.playback_buffer_size.get_items())
        self.whiteboard.add_buffer(self.buffer)

        self.whiteboard.add_max_buffer_size(self.max_buffer_size)
    def __init__(self, id):
        SimpleModule.__init__(self, id)
        self.initial_time = 0
        self.qi = []

        # for traffic shaping
        config_parser = ConfigurationParser.get_instance()
        self.traffic_shaping_interval = int(
            config_parser.get_parameter('traffic_shaping_profile_interval'))
        self.traffic_shaping_seed = int(
            config_parser.get_parameter('traffic_shaping_seed'))
        self.traffic_shaping_values = []

        # mark the current traffic shapping interval
        self.current_traffic_shaping_interval = 0

        self.traffic_shaping_sequence = []
        # traffic shaping sequence position
        self.tss_position = 0
        # traffic shaping values position
        self.tsv_position = 0

        token = config_parser.get_parameter('traffic_shaping_profile_sequence')
        for i in range(len(token)):
            if token[i] == 'L':
                self.traffic_shaping_sequence.append(0)
            elif token[i] == 'M':
                self.traffic_shaping_sequence.append(1)
            elif token[i] == 'H':
                self.traffic_shaping_sequence.append(2)

        self.timer = Timer.get_instance()
Exemple #3
0
 def handle_xml_response(self, msg):
     '''
     V = (Q_max - 1) / (v_max + \gamma  * p)
     \gamma = ((Q_max - 1) * (v_0 * S_1 - v_1 * S_0) - 2 * v_max * (S_1 - S_0)) / (p * (S_1 - S_0) * (2 - (Q_max - 1)))
     '''
     parsed_mpd = parse_mpd(msg.get_payload())
     self.S = parsed_mpd.get_qi()
     Q_max = ConfigurationParser.get_instance().get_parameter(
         'max_buffer_size')
     v_max = self.v(len(self.S) - 1)
     self.g = ((Q_max - 1) *
               (self.v(0) * self.S[1] - self.v(1) * self.S[0]) - 2 * v_max *
               (self.S[1] - self.S[0])) / (1 * (self.S[1] - self.S[0]) *
                                           (2 - Q_max - 1))
     self.V = (Q_max - 1) / (v_max + self.g * 1)
     self.send_up(msg)
     print('Qualities: ', self.S)
     print('Smoothness weight: ', self.g)
     print('Performance weight: ', self.V)
     print('Q_max', Q_max)
     print('v_max', v_max)
Exemple #4
0
    def __init__(self):
        config_parser = ConfigurationParser.get_instance()

        r2a_algorithm = str(config_parser.get_parameter('r2a_algorithm'))

        self.scheduler = Scheduler()

        self.modules = []

        # adding modules to manage
        self.player = Player(0)

        # automatic loading class by the name
        r2a_class = getattr(
            importlib.import_module('r2a.' + r2a_algorithm.lower()),
            r2a_algorithm)
        self.r2a = r2a_class(1)

        self.connection_handler = ConnectionHandler(2)

        self.modules.append(self.player)
        self.modules.append(self.r2a)
        self.modules.append(self.connection_handler)
Exemple #5
0
    def initialize(self):
        """Calculating the buffer size, based on segment periods"""
        settings = ConfigurationParser.get_instance()
        period = int(search(r'(\d+)sec', settings.get_parameter('url_mpd')).groups()[0])

        self.throughput_buffer_size = max(self.MIN_THROUGHPUT_BUFFER_SZ, self.MAX_THROUGHPUT_BUFFER_SZ // period)