generated from membraneframework/membrane_template_plugin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Restructure h264 test files * Add h265 test fixtures * Add h265 tests * Fix string slice warning on elixir 1.16 * Improve process all test * rename functions and paths for consistency
- Loading branch information
Showing
81 changed files
with
1,181 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
defmodule Membrane.H265.ModesTest do | ||
@moduledoc false | ||
use ExUnit.Case, async: true | ||
|
||
import Membrane.ChildrenSpec | ||
import Membrane.H26x.Support.Common | ||
import Membrane.Testing.Assertions | ||
|
||
alias Membrane.Buffer | ||
alias Membrane.H265.Parser | ||
alias Membrane.H26x.Support.TestSource | ||
alias Membrane.Testing.{Pipeline, Sink} | ||
|
||
@h265_input_file "test/fixtures/h265/input-8-2K.h265" | ||
|
||
test "if the pts and dts are set to nil in :bytestream mode" do | ||
binary = File.read!(@h265_input_file) | ||
mode = :bytestream | ||
input_buffers = prepare_h265_buffers(binary, mode) | ||
|
||
pid = | ||
Pipeline.start_supervised!( | ||
spec: [ | ||
child(:source, %TestSource{mode: mode, codec: :H265}) | ||
|> child(:parser, Parser) | ||
|> child(:sink, Sink) | ||
] | ||
) | ||
|
||
assert_sink_playing(pid, :sink) | ||
send_buffers_actions = for buffer <- input_buffers, do: {:buffer, {:output, buffer}} | ||
Pipeline.message_child(pid, :source, send_buffers_actions ++ [end_of_stream: :output]) | ||
|
||
output_buffers = prepare_h265_buffers(binary, :au_aligned) | ||
|
||
Enum.each(output_buffers, fn buf -> | ||
payload = buf.payload | ||
assert_sink_buffer(pid, :sink, %Buffer{payload: ^payload, pts: nil, dts: nil}) | ||
end) | ||
|
||
Pipeline.terminate(pid) | ||
end | ||
|
||
test "if the pts and dts are rewritten properly in :nalu_aligned mode" do | ||
binary = File.read!(@h265_input_file) | ||
mode = :nalu_aligned | ||
input_buffers = prepare_h265_buffers(binary, mode) | ||
|
||
pid = | ||
Pipeline.start_supervised!( | ||
spec: [ | ||
child(:source, %TestSource{mode: mode, codec: :H265}) | ||
|> child(:parser, Parser) | ||
|> child(:sink, Sink) | ||
] | ||
) | ||
|
||
assert_sink_playing(pid, :sink) | ||
send_buffers_actions = for buffer <- input_buffers, do: {:buffer, {:output, buffer}} | ||
Pipeline.message_child(pid, :source, send_buffers_actions ++ [end_of_stream: :output]) | ||
|
||
output_buffers = prepare_h265_buffers(binary, :au_aligned) | ||
|
||
Enum.each(output_buffers, fn buf -> | ||
payload = buf.payload | ||
pts = buf.pts | ||
dts = buf.dts | ||
assert_sink_buffer(pid, :sink, %Buffer{payload: ^payload, pts: ^pts, dts: ^dts}) | ||
end) | ||
|
||
Pipeline.terminate(pid) | ||
end | ||
|
||
test "if the pts and dts are rewritten properly in :au_aligned mode" do | ||
binary = File.read!(@h265_input_file) | ||
mode = :au_aligned | ||
input_buffers = prepare_h265_buffers(binary, mode) | ||
|
||
pid = | ||
Pipeline.start_supervised!( | ||
spec: [ | ||
child(:source, %TestSource{mode: mode, codec: :H265}) | ||
|> child(:parser, Parser) | ||
|> child(:sink, Sink) | ||
] | ||
) | ||
|
||
assert_sink_playing(pid, :sink) | ||
send_buffers_actions = for buffer <- input_buffers, do: {:buffer, {:output, buffer}} | ||
Pipeline.message_child(pid, :source, send_buffers_actions ++ [end_of_stream: :output]) | ||
|
||
output_buffers = input_buffers | ||
|
||
Enum.each(output_buffers, fn buf -> | ||
payload = buf.payload | ||
pts = buf.pts | ||
dts = buf.dts | ||
assert_sink_buffer(pid, :sink, %Buffer{payload: ^payload, pts: ^pts, dts: ^dts}) | ||
end) | ||
|
||
Pipeline.terminate(pid) | ||
end | ||
|
||
test "if single NAL unit is sent per buffer with `output_alignment: :nalu`" do | ||
pid = | ||
Pipeline.start_supervised!( | ||
spec: [ | ||
child(:source, %Membrane.File.Source{location: @h265_input_file}) | ||
|> child(:parser, %Parser{output_alignment: :nalu}) | ||
|> child(:sink, Sink) | ||
] | ||
) | ||
|
||
assert_sink_playing(pid, :sink) | ||
assert_sink_stream_format(pid, :sink, %Membrane.H265{alignment: :nalu}) | ||
|
||
binary = File.read!(@h265_input_file) | ||
ref_buffers = prepare_h265_buffers(binary, :nalu_aligned) | ||
|
||
Enum.each(ref_buffers, fn ref_buffer -> | ||
assert_sink_buffer(pid, :sink, buffer) | ||
assert buffer.payload == ref_buffer.payload | ||
assert Map.has_key?(buffer.metadata, :h265) and Map.has_key?(buffer.metadata.h265, :type) | ||
end) | ||
|
||
assert_end_of_stream(pid, :sink) | ||
Pipeline.terminate(pid) | ||
end | ||
end |
Oops, something went wrong.