diff --git a/lib/membrane_native/raw_video.ex b/lib/membrane_native/raw_video.ex deleted file mode 100644 index 95852df..0000000 --- a/lib/membrane_native/raw_video.ex +++ /dev/null @@ -1,68 +0,0 @@ -defmodule Membrane.Native.RawVideo do - @moduledoc """ - Unifex-compatible implementation of the `Membrane.RawVideo` struct. - - Currently, unifex does not support tuples in the structs, so we have to decompose the framerate into two fields. - """ - - @typedoc """ - A numerator of the number of frames per second. To avoid using tuple type, - it is described by 2 separate integers number. - """ - @type framerate_num :: non_neg_integer - - @typedoc """ - The denominator of the number of frames per second. To avoid using tuple type, - it is described by 2 separate integers number. The default value is 1. - """ - @type framerate_den :: pos_integer - - @type t :: %__MODULE__{ - width: Membrane.RawVideo.width(), - height: Membrane.RawVideo.height(), - pixel_format: Membrane.RawVideo.pixel_format(), - framerate_num: framerate_num(), - framerate_den: framerate_den(), - aligned: Membrane.RawVideo.aligned() - } - @enforce_keys [:width, :height, :pixel_format, :framerate_num, :aligned] - defstruct width: nil, - height: nil, - pixel_format: nil, - framerate_num: nil, - framerate_den: 1, - aligned: nil - - @doc """ - Creates unifex compatible struct from Membrane.RawVideo struct. - It may raise error when RawVideo with not supported pixel format is provided. - """ - @spec from_membrane_raw_video(Membrane.RawVideo.t()) :: t() - - def from_membrane_raw_video(%Membrane.RawVideo{} = membrane_raw_video) do - {framerate_num, framerate_den} = membrane_raw_video.framerate - - %__MODULE__{ - width: membrane_raw_video.width, - height: membrane_raw_video.height, - pixel_format: membrane_raw_video.pixel_format, - framerate_num: framerate_num, - framerate_den: framerate_den, - aligned: membrane_raw_video.aligned - } - end - - @doc """ - Convert a native raw video to the Membrane.RawVideo counterpart. - """ - @spec to_membrane_raw_video(t()) :: Membrane.RawVideo.t() - def to_membrane_raw_video(native_raw_video) do - %Membrane.RawVideo{ - width: native_raw_video.width, - height: native_raw_video.height, - pixel_format: native_raw_video.pixel_format, - framerate: {native_raw_video.framerate_num, native_raw_video.framerate_den}, - aligned: native_raw_video.aligned - } - end -end diff --git a/lib/membrane_raw_video.ex b/lib/membrane_raw_video.ex index cb41e8b..6e25c2c 100644 --- a/lib/membrane_raw_video.ex +++ b/lib/membrane_raw_video.ex @@ -4,8 +4,6 @@ defmodule Membrane.RawVideo do """ require Integer - alias Membrane.Native.RawVideo, as: NativeRawVideo - @typedoc """ Width of single frame in pixels. """ @@ -113,21 +111,4 @@ defmodule Membrane.RawVideo do def frame_size(_format, _width, _height) do {:error, :invalid_pixel_format} end - - @doc """ - Creates unifex-compatible struct from Membrane.RawVideo struct. - Raises an error when RawVideo with an unsupported pixel format is provided. - """ - @spec to_native_raw_video(t()) :: NativeRawVideo.t() - def to_native_raw_video(%__MODULE__{} = membrane_raw_video) do - NativeRawVideo.from_membrane_raw_video(membrane_raw_video) - end - - @doc """ - Convert back a native raw video to the Membrane.RawVideo counterpart. - """ - @spec from_native_raw_video(NativeRawVideo.t()) :: t() - def from_native_raw_video(%NativeRawVideo{} = native_raw_video) do - NativeRawVideo.to_membrane_raw_video(native_raw_video) - end end diff --git a/test/native_raw_video_test.exs b/test/native_raw_video_test.exs deleted file mode 100644 index ad5e15c..0000000 --- a/test/native_raw_video_test.exs +++ /dev/null @@ -1,45 +0,0 @@ -defmodule Membrane.Native.RawVideoTest do - use ExUnit.Case - - alias Membrane.Native.RawVideo, as: NativeRawVideo - alias Membrane.RawVideo - - setup do - raw_video = %Membrane.RawVideo{ - width: 1920, - height: 1080, - pixel_format: :I420, - framerate: {30, 1}, - aligned: true - } - - exp_native_raw_video = %NativeRawVideo{ - width: 1920, - height: 1080, - pixel_format: :I420, - framerate_num: 30, - framerate_den: 1, - aligned: true - } - - %{raw_video: raw_video, exp_native_raw_video: exp_native_raw_video} - end - - describe "From Membrane.RawVideo to Native conversion" do - test "using Membrane.RawVideo module", %{ - raw_video: raw_video, - exp_native_raw_video: exp_native_raw_video - } do - assert RawVideo.to_native_raw_video(raw_video) == exp_native_raw_video - assert RawVideo.from_native_raw_video(exp_native_raw_video) == raw_video - end - - test "using Membrane.Native.RawVideo module", %{ - raw_video: raw_video, - exp_native_raw_video: exp_native_raw_video - } do - assert NativeRawVideo.from_membrane_raw_video(raw_video) == exp_native_raw_video - assert NativeRawVideo.to_membrane_raw_video(exp_native_raw_video) == raw_video - end - end -end