Sha256: d8363e07b6f8186572d62186deb8ef082c6b0771d2fa3fc10696a47f755b3d7e

Contents?: true

Size: 911 Bytes

Versions: 22

Compression:

Stored size: 911 Bytes

Contents

require_relative 'aac_parser/adts_header_info'

class FormatParser::AACParser
  include FormatParser::IOUtils

  AAC_MIME_TYPE = 'audio/aac'

  def likely_match?(filename)
    filename =~ /\.aac$/i
  end

  def call(raw_io)
    io = FormatParser::IOConstraint.new(raw_io)
    header = safe_read(io, 9)
    header_bits = header.unpack('B*').first.split('')

    header_info = FormatParser::AdtsHeaderInfo.parse_adts_header(header_bits)
    return if header_info.nil?

    FormatParser::Audio.new(
      title: nil,
      album: nil,
      artist: nil,
      format: :aac,
      num_audio_channels: header_info.number_of_audio_channels,
      audio_sample_rate_hz: header_info.mpeg4_sampling_frequency,
      media_duration_seconds: nil,
      media_duration_frames: nil,
      intrinsics: nil,
      content_type: AAC_MIME_TYPE
    )
  end

  FormatParser.register_parser new, natures: :audio, formats: :aac
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
format_parser-2.10.0 lib/parsers/aac_parser.rb
format_parser-2.9.0 lib/parsers/aac_parser.rb
format_parser-2.8.0 lib/parsers/aac_parser.rb
format_parser-2.7.2 lib/parsers/aac_parser.rb
format_parser-2.7.1 lib/parsers/aac_parser.rb
format_parser-2.7.0 lib/parsers/aac_parser.rb
format_parser-2.6.0 lib/parsers/aac_parser.rb
format_parser-2.5.0 lib/parsers/aac_parser.rb
format_parser-2.4.5 lib/parsers/aac_parser.rb
format_parser-2.4.4 lib/parsers/aac_parser.rb
format_parser-2.4.3 lib/parsers/aac_parser.rb
format_parser-2.3.0 lib/parsers/aac_parser.rb
format_parser-2.2.1 lib/parsers/aac_parser.rb
format_parser-2.2.0 lib/parsers/aac_parser.rb
format_parser-2.1.0 lib/parsers/aac_parser.rb
format_parser-2.0.0 lib/parsers/aac_parser.rb
format_parser-2.0.0.pre.4 lib/parsers/aac_parser.rb
format_parser-2.0.0.pre.3 lib/parsers/aac_parser.rb
format_parser-2.0.0.pre.2 lib/parsers/aac_parser.rb
format_parser-2.0.0.pre lib/parsers/aac_parser.rb