Class: M3u8::ServerControlItem

Inherits:
Object
  • Object
show all
Extended by:
M3u8
Includes:
AttributeFormatter, Serializable
Defined in:
lib/m3u8/server_control_item.rb

Overview

ServerControlItem represents an EXT-X-SERVER-CONTROL tag which provides directives for Low-Latency HLS delivery.

Constant Summary

Constants included from M3u8

VERSION

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from M3u8

initialize_with_byterange, parse_attributes, parse_float, parse_int, parse_yes_no, to_yes_no

Methods included from AttributeFormatter

#boolean_format, #decimal_format, #quoted_format, #unquoted_format

Methods included from Serializable

#as_json, serialize, #to_h, #to_json

Constructor Details

#initialize(params = {}) ⇒ ServerControlItem

Returns a new instance of ServerControlItem.

Parameters:

  • params (Hash) (defaults to: {})

    attribute key-value pairs



20
21
22
23
24
# File 'lib/m3u8/server_control_item.rb', line 20

def initialize(params = {})
  params.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#can_block_reloadFloat, ...

Returns:

  • (Float, nil)

    skip threshold in seconds

  • (Boolean, nil)

    whether dateranges can be skipped

  • (Float, nil)

    hold-back duration in seconds

  • (Float, nil)

    part hold-back duration in seconds

  • (Boolean, nil)

    whether blocking reload is supported



16
17
18
# File 'lib/m3u8/server_control_item.rb', line 16

def can_block_reload
  @can_block_reload
end

#can_skip_daterangesFloat, ...

Returns:

  • (Float, nil)

    skip threshold in seconds

  • (Boolean, nil)

    whether dateranges can be skipped

  • (Float, nil)

    hold-back duration in seconds

  • (Float, nil)

    part hold-back duration in seconds

  • (Boolean, nil)

    whether blocking reload is supported



16
17
18
# File 'lib/m3u8/server_control_item.rb', line 16

def can_skip_dateranges
  @can_skip_dateranges
end

#can_skip_untilFloat, ...

Returns:

  • (Float, nil)

    skip threshold in seconds

  • (Boolean, nil)

    whether dateranges can be skipped

  • (Float, nil)

    hold-back duration in seconds

  • (Float, nil)

    part hold-back duration in seconds

  • (Boolean, nil)

    whether blocking reload is supported



16
17
18
# File 'lib/m3u8/server_control_item.rb', line 16

def can_skip_until
  @can_skip_until
end

#hold_backFloat, ...

Returns:

  • (Float, nil)

    skip threshold in seconds

  • (Boolean, nil)

    whether dateranges can be skipped

  • (Float, nil)

    hold-back duration in seconds

  • (Float, nil)

    part hold-back duration in seconds

  • (Boolean, nil)

    whether blocking reload is supported



16
17
18
# File 'lib/m3u8/server_control_item.rb', line 16

def hold_back
  @hold_back
end

#part_hold_backFloat, ...

Returns:

  • (Float, nil)

    skip threshold in seconds

  • (Boolean, nil)

    whether dateranges can be skipped

  • (Float, nil)

    hold-back duration in seconds

  • (Float, nil)

    part hold-back duration in seconds

  • (Boolean, nil)

    whether blocking reload is supported



16
17
18
# File 'lib/m3u8/server_control_item.rb', line 16

def part_hold_back
  @part_hold_back
end

Class Method Details

.parse(text) ⇒ ServerControlItem

Parse an EXT-X-SERVER-CONTROL tag.

Parameters:

  • text (String)

    raw tag line

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/m3u8/server_control_item.rb', line 29

def self.parse(text)
  attributes = parse_attributes(text)
  ServerControlItem.new(
    can_skip_until: parse_float(attributes['CAN-SKIP-UNTIL']),
    can_skip_dateranges:
      parse_yes_no(attributes['CAN-SKIP-DATERANGES']),
    hold_back: parse_float(attributes['HOLD-BACK']),
    part_hold_back: parse_float(attributes['PART-HOLD-BACK']),
    can_block_reload:
      parse_yes_no(attributes['CAN-BLOCK-RELOAD'])
  )
end

Instance Method Details

#to_sString

Render as an m3u8 EXT-X-SERVER-CONTROL tag.

Returns:

  • (String)


44
45
46
# File 'lib/m3u8/server_control_item.rb', line 44

def to_s
  "#EXT-X-SERVER-CONTROL:#{formatted_attributes}"
end