Class: M3u8::Scte35
- Inherits:
-
Object
- Object
- M3u8::Scte35
- Defined in:
- lib/m3u8/scte35.rb
Overview
Parses SCTE-35 splice_info_section binary payloads from hex strings
Defined Under Namespace
Classes: ParseError
Instance Attribute Summary collapse
-
#descriptors ⇒ Object
readonly
Returns the value of attribute descriptors.
-
#pts_adjustment ⇒ Object
readonly
Returns the value of attribute pts_adjustment.
-
#splice_command ⇒ Object
readonly
Returns the value of attribute splice_command.
-
#splice_command_type ⇒ Object
readonly
Returns the value of attribute splice_command_type.
-
#table_id ⇒ Object
readonly
Returns the value of attribute table_id.
-
#tier ⇒ Object
readonly
Returns the value of attribute tier.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Scte35
constructor
A new instance of Scte35.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Scte35
Returns a new instance of Scte35.
11 12 13 14 15 |
# File 'lib/m3u8/scte35.rb', line 11 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#descriptors ⇒ Object (readonly)
Returns the value of attribute descriptors.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def descriptors @descriptors end |
#pts_adjustment ⇒ Object (readonly)
Returns the value of attribute pts_adjustment.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def pts_adjustment @pts_adjustment end |
#splice_command ⇒ Object (readonly)
Returns the value of attribute splice_command.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def splice_command @splice_command end |
#splice_command_type ⇒ Object (readonly)
Returns the value of attribute splice_command_type.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def splice_command_type @splice_command_type end |
#table_id ⇒ Object (readonly)
Returns the value of attribute table_id.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def table_id @table_id end |
#tier ⇒ Object (readonly)
Returns the value of attribute tier.
8 9 10 |
# File 'lib/m3u8/scte35.rb', line 8 def tier @tier end |
Class Method Details
.parse(hex_string) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/m3u8/scte35.rb', line 17 def self.parse(hex_string) raw = hex_string.sub(/\A0x/i, '') data = [raw].pack('H*') reader = Scte35BitReader.new(data) header = parse_header(reader) command = parse_command(reader, header) descriptors = parse_descriptors(reader, header) args = header.merge(splice_command: command, descriptors: descriptors, raw: hex_string) new(**args) rescue NoMethodError, ArgumentError => e raise ParseError, "invalid SCTE-35 data: #{e.}" end |
.parse_splice_time(reader) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/m3u8/scte35.rb', line 67 def self.parse_splice_time(reader) unless reader.read_flag # time_specified reader.skip_bits(7) # reserved return nil end reader.skip_bits(6) # reserved reader.read_bits(33) end |
Instance Method Details
#to_s ⇒ Object
33 34 35 |
# File 'lib/m3u8/scte35.rb', line 33 def to_s @raw end |