Skip to content

Commit

Permalink
update to core 1.0 (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
mat-hek authored Nov 22, 2023
1 parent c65945b commit 08d1f2d
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 72 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ The package can be installed by adding `membrane_video_compositor_plugin` to you
```elixir
def deps do
[
{:membrane_video_compositor_plugin, "~> 0.5.4"}
{:membrane_video_compositor_plugin, "~> 0.6.0"}
]
end
```
Expand Down
12 changes: 3 additions & 9 deletions lib/membrane/video_compositor/core.ex
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ defmodule Membrane.VideoCompositor.Core do
description: "Struct with video width, height, framerate and pixel format."
]

def_input_pad :input,
availability: :always,
demand_mode: :auto,
accepted_format: %CompositorCoreFormat{}
def_input_pad :input, accepted_format: %CompositorCoreFormat{}

def_output_pad :output,
availability: :always,
demand_mode: :auto,
accepted_format: %RawVideo{pixel_format: :I420}
def_output_pad :output, accepted_format: %RawVideo{pixel_format: :I420}

@impl true
def handle_init(_ctx, options) do
Expand Down Expand Up @@ -95,7 +89,7 @@ defmodule Membrane.VideoCompositor.Core do
end

@impl true
def handle_process(
def handle_buffer(
_pad,
%Buffer{pts: pts, payload: payload},
_context,
Expand Down
10 changes: 3 additions & 7 deletions lib/membrane/video_compositor/queue/strategy/live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Live do
def_input_pad :input,
accepted_format: %RawVideo{pixel_format: :I420},
availability: :on_request,
demand_mode: :auto,
options: [
timestamp_offset: [
spec: Membrane.Time.non_neg(),
Expand All @@ -39,10 +38,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Live do
]
]

def_output_pad :output,
accepted_format: %CompositorCoreFormat{},
availability: :always,
demand_mode: :auto
def_output_pad :output, accepted_format: CompositorCoreFormat

@impl true
def handle_init(_ctx, %{
Expand All @@ -65,7 +61,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Live do

@impl true
def handle_pad_added(pad, context, state) do
state = Bunch.Struct.put_in(state, [:pads_states, pad], PadState.new(context.options))
state = Bunch.Struct.put_in(state, [:pads_states, pad], PadState.new(context.pad_options))

{[], state}
end
Expand Down Expand Up @@ -102,7 +98,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Live do
end

@impl true
def handle_process(pad, buffer, _ctx, state) do
def handle_buffer(pad, buffer, _ctx, state) do
state = State.register_event(state, {{:frame, buffer.pts, buffer.payload}, pad})
{[], state}
end
Expand Down
6 changes: 3 additions & 3 deletions lib/membrane/video_compositor/queue/strategy/offline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline do
})
|> via_in(Pad.ref(:input, pad_id),
options: [
timestamp_offset: context.options.timestamp_offset,
timestamp_offset: context.pad_options.timestamp_offset,
vc_input_ref: Pad.ref(:input, pad_id),
metadata: context.options.metadata
metadata: context.pad_options.metadata
]
)
|> get_child(:queue_element)
Expand All @@ -65,7 +65,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline do

@impl true
def handle_pad_removed(Pad.ref(:input, pad_id), _context, state),
do: {[remove_child: {:framerate_converter, pad_id}], state}
do: {[remove_children: {:framerate_converter, pad_id}], state}

@impl true
def handle_parent_notification(msg, _context, state) do
Expand Down
11 changes: 4 additions & 7 deletions lib/membrane/video_compositor/queue/strategy/offline/element.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline.Element do

def_input_pad :input,
availability: :on_request,
demand_mode: :auto,
accepted_format: %RawVideo{pixel_format: :I420},
options: [
timestamp_offset: [
Expand All @@ -39,9 +38,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline.Element do
]
]

def_output_pad :output,
demand_mode: :auto,
accepted_format: %CompositorCoreFormat{}
def_output_pad :output, accepted_format: CompositorCoreFormat

@impl true
def handle_init(_ctx, options) do
Expand All @@ -55,12 +52,12 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline.Element do

@impl true
def handle_pad_added(pad, context, state = %State{}) do
vc_input_ref = get_in(context, [:options, :vc_input_ref])
vc_input_ref = get_in(context, [:pad_options, :vc_input_ref])

state =
state
|> Bunch.Struct.put_in([:custom_strategy_state, :inputs_mapping, pad], vc_input_ref)
|> State.register_pad(vc_input_ref, context.options)
|> State.register_pad(vc_input_ref, context.pad_options)

{[], state}
end
Expand Down Expand Up @@ -93,7 +90,7 @@ defmodule Membrane.VideoCompositor.Queue.Strategy.Offline.Element do
end

@impl true
def handle_process(
def handle_buffer(
pad,
buffer,
_context,
Expand Down
4 changes: 2 additions & 2 deletions lib/membrane/video_compositor/video_compositor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ defmodule Membrane.VideoCompositor do
bin_input(Pad.ref(:input, pad_id))
|> via_in(Pad.ref(:input, pad_id),
options: [
timestamp_offset: context.options.timestamp_offset,
metadata: context.options.metadata
timestamp_offset: context.pad_options.timestamp_offset,
metadata: context.pad_options.metadata
]
)
|> get_child(:queue)
Expand Down
15 changes: 8 additions & 7 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Membrane.VideoCompositor.Mixfile do
use Mix.Project

@version "0.5.4"
@version "0.6.0"
@github_url "https://github.com/membraneframework/membrane_video_compositor_plugin"

def project do
Expand Down Expand Up @@ -39,16 +39,17 @@ defmodule Membrane.VideoCompositor.Mixfile do
defp deps do
[
{:unifex, "~> 1.0"},
{:membrane_core, "~> 0.12.5"},
{:membrane_framerate_converter_plugin, "~> 0.7.0"},
{:membrane_core, "~> 1.0"},
{:membrane_framerate_converter_plugin, "~> 0.8.0"},
{:membrane_raw_video_format, "~> 0.3.0"},
{:qex, "~> 0.5.1"},
{:rustler, "~> 0.26.0"},
{:ratio, "~> 2.0"},
{:ratio, "~> 3.0"},
# Testing
{:membrane_file_plugin, "~> 0.14.0", only: :test},
{:membrane_h264_ffmpeg_plugin, "~> 0.27.0", only: :test},
{:membrane_raw_video_parser_plugin, "~> 0.11.1", only: :test},
{:membrane_file_plugin, "~> 0.16.0", only: :test},
{:membrane_h264_plugin, "~> 0.9.0", only: :test},
{:membrane_h264_ffmpeg_plugin, "~> 0.31.1", only: :test},
{:membrane_raw_video_parser_plugin, "~> 0.12.0", only: :test},

# Development
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
Expand Down
Loading

0 comments on commit 08d1f2d

Please sign in to comment.