Skip to content

Commit

Permalink
Add mermaid graphs visualising specs WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Dec 30, 2024
1 parent a16e2c4 commit c1e023b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
6 changes: 5 additions & 1 deletion guides/timer.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ defmodule MyComplexSource
@one_hundred_millis = Membrane.Time.milliseconds(100)

@impl true
def handle_init(_ctx, _opts), do: {[], %{status: nil}}
def handle_init(_ctx, _opts) do
# after starting a timer, status will always be either :resumed, :paused
# or :pause_on_next_handle_tick
{[], %{status: nil}}
end

@impl true
def handle_playing(_ctx, state) do
Expand Down
48 changes: 48 additions & 0 deletions lib/membrane/bin/action.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,54 @@ defmodule Membrane.Bin.Action do
Children's playback is changed to the current bin playback.
`c:Membrane.Parent.handle_spec_started/3` callback is executed once the children are spawned.
This is an example of spec
```elixir
child(:file_source, %My.File.Source{path: path})
|> child(:demuxer, My.Demuxer)
|> via_out(:video)
|> child(:decoder, My.Decoder)
|> child(:ai_filter, My.AI.Filter{mode: :picasso_effect)
|> child(:encoder, My.Encoder)
|> via_in(:video)
|> child(:webrtc_sink, My.WebRTC.Sink)
```
along with it's visualisation
```mermaid
graph TB;
file_source(File Source) --> demuxer(Demuxer);
demuxer -->|video| decoder(Decoder);
decoder --> ai_filter(AI Filter);
ai_filter --> encoder(Encoder);
encoder --> |video| webrtc_sink(WebRTC Sink);
classDef default fill:#add8e6, stroke:#333, stroke-width:2px, color:black;
linkStyle default stroke:#333, stroke-width:2px, fill:none;
```
Returning another spec like this
```elixir
get_child(:demuxer)
|> via_out(:audio)
|> child(:scratch_remover, My.Scratch.Remover)
|> via_in(:audio)
|> get_child(:webrtc_sink)
```
will result in having such a pipeline topology:
```mermaid
graph TB;
file_source(File Source) --> demuxer(Demuxer);
demuxer -->|video| decoder(Decoder);
decoder --> ai_filter(AI Filter);
ai_filter --> encoder(Encoder);
encoder -->|video| webrtc_sink(WebRTC Sink);
demuxer -->|audio| scratch_remover(Scratch Remover);
scratch_remover -->|audio| webrtc_sink;
classDef default fill:#add8e6, stroke:#333, stroke-width:2px, color:black;
linkStyle default stroke:#333, stroke-width:2px, fill:none;
```
"""
@type spec :: {:spec, ChildrenSpec.t()}

Expand Down

0 comments on commit c1e023b

Please sign in to comment.