TapasPlayer

tapas-workflow

When the TapasPlayer‘s play() method is issued the Parser downloads the manifest and populates two lists of dictionaries playlists and levels: the first one maintains information about segments (or chunks), the second one holds video levels (or representations) information. The two lists of dictionaries are then passed to the player. At this point two concurrent threads are started: 1) a thread that fills the playout buffer by fetching the video segments from the HTTP server and 2) a thread that drains the playout buffer to play the videostream. Let us now focus on the thread that fills the buffer. The following operations are executed in a loop until the last video segment has been played:

  1. The Downloader fetches from the HTTP server the current segment at the selected video level.

  2. When the download is completed the following operations are performed:
    1. The segment is enqueued in the playout buffer handled by the MediaEngine component.
    2. The player gets from the MediaEngine the queue length and other feedbacks and builds the player feedback dictionary with this information. Then player feedback is passed to the Controller.
    3. The Controller computes two values: 1) the control action, i.e. the video level rate of the next segment to be downloaded; 2) the idle duration, possibly equal to zero, that is the time interval that has to elapse before the next video segment can be fetched.
  3. A timer of duration idle duration is started. When the timer expires the loop repeats from step 1.

Finally, the thread draining the playout buffer is handled by the MediaEngine that decodes the compressed video frames, and plays the raw video.

Methods

class TapasPlayer.TapasPlayer(controller, parser, media_engine, log_sub_dir='', log_period=0.1, max_buffer_time=60, inactive_cycle=1, initial_level=1, use_persistent_connection=True, check_warning_buffering=True, stress_test=False)[source]
checkBuffering(_arg)[source]

Checks if the playback is going to buffering. Estimates the time required to complete the download of the current segment and verifies that it is less than the playout buffer lenght.

In the case of “warning buffering”, it deletes the current segment download, calculates the control action and sets the new level. This feature is available only with persistent connection.

fetchNextSegment()[source]

Schedules the download of the next segment at current level

getBandwidth()[source]

Gets last estimated available bandwidth in B/s

getCurrentLevel()[source]

Gets index of current level starting from 0 for the lowest video quality level

getCurrentRate()[source]

Gets current video quality level rate in B/s

getCurrentSegmentIndex()[source]

Gets index of the current segment of the sub-playlist

getDownloadedBytes()[source]

Gets total downloaded bytes in B

getDownloadedSegments()[source]

Gets total number of downloaded segments

getInactiveCycles()[source]

Gets the number of inactive cycles before activate the control action

getLastDownloadedTime()[source]

Gets time spent to download the last segment

getLastFragmentBytes()[source]

Gets the last fragment size in B

getLevelRates()[source]

Gets a list of video quality level rates in B/s

getLevelResolutions()[source]

Gets a list of available video resolutions

getLogFileName()[source]

Gets log file name

getMaxBufferTime()[source]

Gets max buffer in seconds under which the playback is considered in Buffering by default

getMaxLevel()[source]

Gets index of maximum level starting from 0 for the lowest video quality level

getMaxRate()[source]

Gets maximum video quality level rate in B/s

getMinRate()[source]

Gets minimum video quality level rate in B/s

getPausedTime()[source]

Gets time spent on pause

getStartSegmentRequest()[source]

Gets timestamp when starts the download of the last segment

getStopSegmentRequest()[source]

Gets timestamp when stops the download of the last segment

log()[source]

Logs useful metrics every log_period seconds

play()[source]

Starts Parser, creates Logger, initializes MediaEngine, and fetches the first segment when the parser has finished

playNextGotError(error, factory)[source]

Handles error when download a segment without persistent connection

Parameters:
  • error – the occurred error
  • factory – the twisted factory (used without persistent connection)
playNextGotRequest(data, factory)[source]

Updates feedbacks, calculates the control action and sets level of the next segment.

Parameters:
  • data – downloaded data
  • factory – the twisted factory (used without persistent connection)
setCurrentLevel(level)[source]

Sets index of current level starting from 0 for the lowest video quality level

Parameters:level – the level index
setCurrentSegmentIndex(index)[source]

Sets index of the current segment of the sub-playlist

Parameters:index – segment index
setLevel(rate)[source]

Sets the level corresponding to the rate specified in B/s

Parameters:rate – rate in B/s that determines the level. The level is the one whose rate is the highest below rate.
startDownload(url, byterange='')[source]

Starts the segment download and set the timestamp of start segment download

Parameters:
  • url – segment url
  • byterange – segment byterange (logical segmentation of video level)
stressTest()[source]

Switches the video quality level cyclically every segment

updateFeedback(flag_check_buffering)[source]

Updates dictionary of feedbacks before passing it to the controller.

Parameters:flag_check_buffering – true if this method is called from checkBuffering. False otherwise.

Table Of Contents

Previous topic

TAPAS documentation - Tool for rApid Prototyping of Adaptive Streaming algorithms

Next topic

Controller

This Page