Skip to content

Commit

Permalink
Fix m4a magic number signature
Browse files Browse the repository at this point in the history
  • Loading branch information
daskycodes committed Apr 26, 2022
1 parent ec399fa commit 33ba48f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.2.3 (2022-04-26)

- Bug fixes
- Fix m4a magic number signature

## 0.2.2 (2022-03-24)

- Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ by adding `infer` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:infer, "~> 0.2.2"}
{:infer, "~> 0.2.3"}
]
end
```
Expand Down
10 changes: 9 additions & 1 deletion lib/matchers/audio.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,17 @@ defmodule Infer.Audio do

@doc """
Takes the binary file contents as arguments. Returns `true` if it's a m4a.
## Examples
iex> binary = File.read!("test/audio/sample.m4a")
iex> Infer.Audio.m4a?(binary)
true
"""
@spec m4a?(binary()) :: boolean()
def m4a?(<<_data::binary-size(4), 0x66, 0x74, 0x79, 0x70, 0x4D, 0x3F, 0x41, _rest::binary>>), do: true
def m4a?(<<_data::binary-size(4), 0x66, 0x74, 0x79, 0x70, 0x4D, 0x34, 0x41, _rest::binary>>), do: true
def m4a?(<<0x4D, 0x34, 0x41, 0x20, _rest::binary>>), do: true
def m4a?(_binary), do: false

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Infer.MixProject do
def project do
[
app: :infer,
version: "0.2.2",
version: "0.2.3",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
Binary file added test/audio/sample.m4a
Binary file not shown.

0 comments on commit 33ba48f

Please sign in to comment.