Skip to content

Commit

Permalink
Add one more example about specs
Browse files Browse the repository at this point in the history
  • Loading branch information
FelonEkonom committed Jan 15, 2025
1 parent dca6e27 commit d25ddcc
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/membrane/bin/action.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ defmodule Membrane.Bin.Action do
[comment]: <> (in case of need to edit the diagram below, open assets/drawio_schemes/spec_without_audio.drawio using draw.io)
![](assets/images/spec_with_audio.svg)
Both specs could also be returned together, in a single `spec` action.
This could done by wrapping them into a two-element list.
```elixir
[
# first part
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),
# second part
get_child(:demuxer)
|> via_out(:audio)
|> child(:scratch_remover, My.Scratch.Remover)
|> via_in(:audio)
|> get_child(:webrtc_sink)
]
```
"""
@type spec :: {:spec, ChildrenSpec.t()}

Expand Down
22 changes: 22 additions & 0 deletions lib/membrane/pipeline/action.ex
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ defmodule Membrane.Pipeline.Action do
[comment]: <> (in case of need to edit the diagram below, open assets/drawio_schemes/spec_without_audio.drawio using draw.io)
![](assets/images/spec_with_audio.svg)
Both specs could also be returned together, in a single `spec` action.
This could done by wrapping them into a two-element list.
```elixir
[
# first part
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),
# second part
get_child(:demuxer)
|> via_out(:audio)
|> child(:scratch_remover, My.Scratch.Remover)
|> via_in(:audio)
|> get_child(:webrtc_sink)
]
```
"""
@type spec :: {:spec, ChildrenSpec.t()}

Expand Down

0 comments on commit d25ddcc

Please sign in to comment.