Sha256: 80d53a7b50cd5dbb2366dcc8369995bb65bb138fd6f0a72fde539fdafa97e2d5
Contents?: true
Size: 1.47 KB
Versions: 5
Compression:
Stored size: 1.47 KB
Contents
module Mp3file class InvalidXingHeaderError < Mp3fileError; end class XingHeader attr_reader(:name, :frames, :bytes, :toc, :quality) class XingHeaderFormat < BinData::Record string(:vbr_id, :length => 4, :check_value => lambda { value == 'Xing' || value == 'Info' }) uint8(:unused1, :check_value => lambda { value == 0 }) uint8(:unused2, :check_value => lambda { value == 0 }) uint8(:unused3, :check_value => lambda { value == 0 }) bit4(:unused4, :check_value => lambda { value == 0 }) bit1(:quality_present) bit1(:toc_present) bit1(:bytes_present) bit1(:frames_present) uint32be(:frames, :onlyif => lambda { frames_present == 1 }) uint32be(:bytes, :onlyif => lambda { bytes_present == 1 }) array(:toc, :type => :uint8, :read_until => lambda { index == 99 }, :onlyif => lambda { toc_present == 1 }) uint32be(:quality, :onlyif => lambda { quality_present == 1 }) end def initialize(io) head = nil begin head = XingHeaderFormat.read(io) rescue BinData::ValidityError => ve raise InvalidXingHeaderError, ve.message end @name = head.vbr_id @frames = head.frames if (head.frames_present == 1 && head.frames > 0) @bytes = head.bytes if (head.bytes_present == 1 && head.bytes > 0) @toc = head.toc.dup if (head.toc_present == 1 && !head.toc.empty?) @quality = head.quality if (head.quality_present == 1 && head.quality > 0) end end end
Version data entries
5 entries across 5 versions & 1 rubygems