module BMFF::Box

vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:

Public Class Methods

get_box(io, parent, box_class = nil) click to toggle source
# File lib/bmff/box.rb, line 101
def self.get_box(io, parent, box_class = nil)
  offset = io.pos
  size = io.get_uint32
  type = io.get_ascii(4)
  largesize = nil
  if size == 1
    largesize = io.get_uint64
  end
  usertype = nil
  if type == 'uuid'
    usertype = io.get_uuid
  end

  if box_class
    klass = box_class
  else
    if usertype
      klass = get_uuid_box_class(usertype)
    else
      klass = get_box_class(type)
    end
  end
  klass ||= BMFF::Box::Unknown
  box = klass.new
  box.io = io
  box.offset = offset
  box.parent = parent
  box.size = size
  box.type = type
  box.largesize = largesize
  box.usertype = usertype

  box.parse
  return box
end
get_box_class(type) click to toggle source
# File lib/bmff/box.rb, line 137
def self.get_box_class(type)
  Map.get_box_class(type)
end
get_uuid_box_class(uuid) click to toggle source
# File lib/bmff/box.rb, line 141
def self.get_uuid_box_class(uuid)
  Map.get_uuid_box_class(uuid)
end