Skip to content

Commit 6c8db9e

Browse files
mat-hekConnorRigby
authored andcommitted
add filter test
1 parent 79ea994 commit 6c8db9e

File tree

3 files changed

+63
-3
lines changed

3 files changed

+63
-3
lines changed

mix.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ defmodule Turbojpeg.MixProject do
3737
{:shmex, "~> 0.2.0"},
3838
{:bundlex, "~> 0.2.6"},
3939
{:membrane_core, "~> 0.5.0"},
40+
{:membrane_common_c, "~> 0.3.0"},
4041
{:ex_doc, "~> 0.21.3", only: [:dev], runtime: false},
4142
{:propcheck, "~> 1.2.0", only: [:test]},
4243
{:mogrify, github: "ConnorRigby/mogrify", branch: "master", only: [:test, :dev]},
43-
{:dialyxir, "~> 1.0.0-rc.7", only: [:dev], runtime: false}
44+
{:membrane_element_rawvideo_parser, "~> 0.2.0", only: :test},
45+
{:dialyxir, "~> 1.0.0", only: [:dev], runtime: false}
4446
]
4547
end
4648

mix.lock

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
"bunch_native": {:hex, :bunch_native, "0.2.1", "0227d2a751a32f8c0b77dfec57c8dc7216351720c9c755c467e6d9387467fd1f", [:mix], [{:bundlex, "~> 0.2.7", [hex: :bundlex, repo: "hexpm", optional: false]}], "hexpm", "f0819b2f9f78086447ac7459a8e7b6e25ad535b9d3a4f9469253c552137de6b4"},
44
"bundlex": {:hex, :bundlex, "0.2.8", "0f4530bf24a2ebb92f2e360111319aae6fc6eb03c6ec5054b529d9ffb78811fa", [:mix], [{:bunch, "~> 1.0", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.5", [hex: :qex, repo: "hexpm", optional: false]}, {:secure_random, "~> 0.5", [hex: :secure_random, repo: "hexpm", optional: false]}], "hexpm", "d583b04ea679297aa08ad2b31866c4848fd99feea036bf5af59df71e2408b096"},
55
"coerce": {:hex, :coerce, "1.0.1", "211c27386315dc2894ac11bc1f413a0e38505d808153367bd5c6e75a4003d096", [:mix], [], "hexpm", "b44a691700f7a1a15b4b7e2ff1fa30bebd669929ac8aa43cffe9e2f8bf051cf1"},
6-
"dialyxir": {:hex, :dialyxir, "1.0.0-rc.7", "6287f8f2cb45df8584317a4be1075b8c9b8a69de8eeb82b4d9e6c761cf2664cd", [:mix], [{:erlex, ">= 0.2.5", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "506294d6c543e4e5282d4852aead19ace8a35bedeb043f9256a06a6336827122"},
6+
"dialyxir": {:hex, :dialyxir, "1.0.0", "6a1fa629f7881a9f5aaf3a78f094b2a51a0357c843871b8bc98824e7342d00a5", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "aeb06588145fac14ca08d8061a142d52753dbc2cf7f0d00fc1013f53f8654654"},
77
"earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"},
8-
"erlex": {:hex, :erlex, "0.2.5", "e51132f2f472e13d606d808f0574508eeea2030d487fc002b46ad97e738b0510", [:mix], [], "hexpm", "756d3e19b056339af674b715fdd752c5dac468cf9d0e2d1a03abf4574e99fbf8"},
8+
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
99
"ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"},
1010
"makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"},
1111
"makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"},
12+
"membrane_caps_video_raw": {:hex, :membrane_caps_video_raw, "0.1.0", "6aa751b0c338ea6672540b7ec7ad2be0d23bad931b8a8776757da9b279070a3b", [:mix], [], "hexpm", "3f60d65189bd9e3b0ab77e0ebf2e0c1b04d0fd6f67c546fc1d54d9958c362ce4"},
13+
"membrane_common_c": {:hex, :membrane_common_c, "0.3.0", "eb17da0e469eacb8f4afbfc47752bd80d749397951d971cd1df67332a5cf77c6", [:mix], [{:bundlex, "~> 0.2.0", [hex: :bundlex, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.5.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:shmex, "~> 0.2.0", [hex: :shmex, repo: "hexpm", optional: false]}, {:unifex, "~> 0.2.0", [hex: :unifex, repo: "hexpm", optional: false]}], "hexpm", "4c09fd3d802aa36f65225778b1fe819d63df835ac6c113a2be1222ab454175bb"},
1214
"membrane_core": {:hex, :membrane_core, "0.5.0", "6fd6de1158ff1e8d58ec381d25b71b23b349718a785d6de67ffe6866e6a05b0a", [:mix], [{:bunch, "~> 1.2", [hex: :bunch, repo: "hexpm", optional: false]}, {:qex, "~> 0.3", [hex: :qex, repo: "hexpm", optional: false]}, {:ratio, "~> 2.0", [hex: :ratio, repo: "hexpm", optional: false]}], "hexpm", "4e9b3b5e8dd0a7836ed9e3687a48607881d47d6c0b5ed02dd3d32e5b4ad4d312"},
15+
"membrane_element_file": {:hex, :membrane_element_file, "0.3.0", "45a7e5d42f794253752f14d15db3749596f32f44e42cc4e001c6b426915fdf4f", [:mix], [{:membrane_core, "~> 0.5.0", [hex: :membrane_core, repo: "hexpm", optional: false]}, {:mockery, "~> 2.2", [hex: :mockery, repo: "hexpm", optional: false]}], "hexpm", "a80ad07f8c772c7c420ded2ef67f3fc9c55c736a2cd94a02fb0f33853b83d10e"},
16+
"membrane_element_rawvideo_parser": {:hex, :membrane_element_rawvideo_parser, "0.2.0", "7e5ea4d725ed1a5ad7b203839e662e509c49784e16b1790175a6df6a4e1fd0c8", [:mix], [{:membrane_caps_video_raw, "~> 0.1.0", [hex: :membrane_caps_video_raw, repo: "hexpm", optional: false]}, {:membrane_core, "~> 0.5.0", [hex: :membrane_core, repo: "hexpm", optional: false]}], "hexpm", "f0b82f3b256e7ce3221b0465b67f7872e104c2a1aea2e4c5746de1ca5d21d9fc"},
17+
"mockery": {:hex, :mockery, "2.3.1", "a02fd60b10ac9ed37a7a2ecf6786c1f1dd5c75d2b079a60594b089fba32dc087", [:mix], [], "hexpm", "1d0971d88ebf084e962da3f2cfee16f0ea8e04ff73a7710428500d4500b947fa"},
1318
"mogrify": {:git, "https://github.com/ConnorRigby/mogrify.git", "2cea3c76873d75893dac99acfe280e242672ddfc", [branch: "master"]},
1419
"nimble_parsec": {:hex, :nimble_parsec, "0.5.3", "def21c10a9ed70ce22754fdeea0810dafd53c2db3219a0cd54cf5526377af1c6", [:mix], [], "hexpm", "589b5af56f4afca65217a1f3eb3fee7e79b09c40c742fddc1c312b3ac0b3399f"},
1520
"numbers": {:hex, :numbers, "5.2.0", "34515afc34b005b347128ea1bf5a5807f69b07836d9f09611471282e04adabf3", [:mix], [{:coerce, "~> 1.0", [hex: :coerce, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "a0565589e41a9a76834f2666abfac022601cf391218862725dae4e794216712e"},

test/turbojpeg/filter_test.exs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
defmodule Turbojpeg.FilterTest do
2+
use ExUnit.Case
3+
import Membrane.Testing.Assertions
4+
alias Membrane.Testing
5+
6+
defmodule MockSource do
7+
use Membrane.Source
8+
9+
def_output_pad :output, mode: :push, caps: :any
10+
11+
def_options yuv: [spec: binary], repeat: [spec: pos_integer]
12+
13+
@impl true
14+
def handle_prepared_to_playing(_ctx, state) do
15+
buffers = %Membrane.Buffer{payload: state.yuv} |> Bunch.Enum.repeated(state.repeat)
16+
send(self(), :end_of_stream)
17+
{{:ok, buffer: {:output, buffers}}, state}
18+
end
19+
20+
@impl true
21+
def handle_other(:end_of_stream, _ctx, state) do
22+
{{:ok, end_of_stream: :output}, state}
23+
end
24+
end
25+
26+
test "integration test" do
27+
repeat = 5
28+
jpeg = File.read!("fixture/ff0000_i444.jpg")
29+
{:ok, yuv} = Turbojpeg.jpeg_to_yuv(jpeg)
30+
31+
children = [
32+
source: %MockSource{yuv: yuv, repeat: repeat},
33+
parser: %Membrane.Element.RawVideo.Parser{format: :I444, width: 64, height: 64},
34+
filter: %Turbojpeg.Filter{quality: 100},
35+
sink: Membrane.Testing.Sink
36+
]
37+
38+
assert {:ok, pipeline} =
39+
Testing.Pipeline.start_link(%Testing.Pipeline.Options{elements: children})
40+
41+
:ok = Testing.Pipeline.play(pipeline)
42+
assert_pipeline_playback_changed(pipeline, _, :playing)
43+
44+
1..repeat
45+
|> Enum.each(fn _ ->
46+
assert_sink_buffer(pipeline, :sink, buffer)
47+
assert Shmex.to_binary(buffer.payload) == jpeg
48+
end)
49+
50+
assert_end_of_stream(pipeline, :sink)
51+
refute_sink_buffer(pipeline, :sink, _, 0)
52+
end
53+
end

0 commit comments

Comments
 (0)