Class: M4S::Layout::Sidx

Inherits:
Atom
  • Object
show all
Defined in:
lib/m4s/layout/sidx.rb

Instance Attribute Summary

Attributes inherited from Atom

#cache, #segment_index, #track, #track_id

Instance Method Summary collapse

Methods inherited from Atom

generate, #generate, #initialize

Constructor Details

This class inherits a constructor from M4S::Layout::Atom

Instance Method Details

#binary_contentObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/m4s/layout/sidx.rb', line 9

def binary_content
  @binary_content ||= M4S::Binary::Sidx.new(
    version: 1,
    flags: 0,
    reference_id: 1,
    timescale: track.fetch('timescale'),
    earliest_presentation_time: earliest_presentation_time,
    first_offset: 0,
    reference_count: 1,
    references: [
      { reference_type: 0, referenced_size: segment_size, subsegment_duration: segment_duration, starts_with_sap: 1, sap_type: 0, sap_delta_time: 0 },
    ],
  ).to_binary_s
end

#earliest_presentation_timeObject



28
29
30
# File 'lib/m4s/layout/sidx.rb', line 28

def earliest_presentation_time
  cache.segment_earliest_presentation_ticks(track.fetch('track_id'), segment_index)
end

#nameObject



5
6
7
# File 'lib/m4s/layout/sidx.rb', line 5

def name
  'sidx'
end

#segment_durationObject



24
25
26
# File 'lib/m4s/layout/sidx.rb', line 24

def segment_duration
  cache.segment_duration_ticks(track.fetch('track_id'), segment_index)
end

#segment_sizeObject



32
33
34
# File 'lib/m4s/layout/sidx.rb', line 32

def segment_size
  cache.segment_size_bytes(track.fetch('track_id'), segment_index)
end