Class: MP4::Parser::Service
- Inherits:
-
Object
- Object
- MP4::Parser::Service
- Defined in:
- lib/mp4/parser/service.rb
Instance Attribute Summary collapse
-
#ftyp ⇒ Object
readonly
Returns the value of attribute ftyp.
-
#mdat ⇒ Object
readonly
Returns the value of attribute mdat.
-
#moov ⇒ Object
readonly
Returns the value of attribute moov.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(source:) ⇒ Service
constructor
A new instance of Service.
- #parse ⇒ Object
- #parse_ftyp(offset, box_size) ⇒ Object
- #parse_mdat(offset, _box_size) ⇒ Object
- #parse_moov(offset, box_size) ⇒ Object
Constructor Details
#initialize(source:) ⇒ Service
Returns a new instance of Service.
5 6 7 |
# File 'lib/mp4/parser/service.rb', line 5 def initialize(source:) @source = source end |
Instance Attribute Details
#ftyp ⇒ Object (readonly)
Returns the value of attribute ftyp.
3 4 5 |
# File 'lib/mp4/parser/service.rb', line 3 def ftyp @ftyp end |
#mdat ⇒ Object (readonly)
Returns the value of attribute mdat.
3 4 5 |
# File 'lib/mp4/parser/service.rb', line 3 def mdat @mdat end |
#moov ⇒ Object (readonly)
Returns the value of attribute moov.
3 4 5 |
# File 'lib/mp4/parser/service.rb', line 3 def moov @moov end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/mp4/parser/service.rb', line 3 def source @source end |
Instance Method Details
#call ⇒ Object
9 10 11 |
# File 'lib/mp4/parser/service.rb', line 9 def call parse end |
#parse ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/mp4/parser/service.rb', line 13 def parse main_boxes = MainBoxes.parse(source) parse_ftyp(*main_boxes.fetch(:ftyp)) parse_moov(*main_boxes.fetch(:moov)) parse_mdat(*main_boxes.fetch(:mdat)) self end |
#parse_ftyp(offset, box_size) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/mp4/parser/service.rb', line 22 def parse_ftyp(offset, box_size) source.set_seek(offset + MP4::Constants::GENERIC_HEADER_SIZE) @ftyp = MP4::Binary::Ftyp.read( StringIO.new(source.read(box_size - MP4::Constants::GENERIC_HEADER_SIZE)), ).snapshot end |
#parse_mdat(offset, _box_size) ⇒ Object
38 39 40 |
# File 'lib/mp4/parser/service.rb', line 38 def parse_mdat(offset, _box_size) @mdat = { offset: offset } end |