OctopusRage

OctopusRage

How to use Membrane webrtc for audio only?

hey guys im quite new using membrane, i want to use membrane webrtc to utilize my webrtc call (audio only)

here’s my pipeline

  @impl true
  def handle_init(_ctx, opts) do
    spec =
      child(:webrtc_source, %Membrane.WebRTC.Source{
        signaling: opts[:ingress_signaling]
      })
      |> via_out(:output, options: [kind: :audio])
      |> child(%Membrane.Transcoder{output_stream_format: Membrane.Opus})
      |> child(:audio_realtimer, Membrane.Realtimer)
      |> via_in(:input, options: [kind: :audio])
      |> child(:webrtc_sink, %Membrane.WebRTC.Sink{
        signaling: opts[:egress_signaling]
      })

    {[spec: spec], %{}}
  end

and here’s my channels code

  @impl true
  def join("call:" <> signaling_id, %{"call_id" => call_id, "role" => role} = payload, socket) when role in ["ingress", "egress"] do
    PhoenixSignaling.register_channel(signaling_id)
    signaling = PhoenixSignaling.Registry.get(signaling_id)
    c_pid = CallHandler.new(call_id)
    if role == "egress" do
      CallHandler.add_egress(c_pid, signaling_id, signaling)
    else
      CallHandler.add_ingress(c_pid, signaling_id, signaling)
    end
    socket = assign(socket, :signaling_id, signaling_id)
    {:ok, socket}
  end


  @impl true
  def handle_in(signaling_id, msg, socket) do
    IO.inspect({:receive_frombrows, signaling_id, msg})
    # msg = Jason.decode!(msg)
    PhoenixSignaling.signal(signaling_id, msg)
    {:noreply, socket}
  end

  @impl true
  def handle_info({:membrane_webrtc_signaling, _pid, msg, _metadata}, socket) do
    IO.inspect({:receive_signal, socket.assigns.signaling_id, msg})
    push(socket, socket.assigns.signaling_id, msg)
    {:noreply, socket}
  end

all my peers successfully doing handshake but media wont flow into my peers
no errors in my code either, did i make some mistake on my pipeline?

Most Liked

varsill

varsill

Membrane Core Team

I see, so as I mentioned before - each of the Membrane.WebRTC.Source and Membrane.WebRTC.Sink elements supports only either inbound our outbound traffic for a single PeerConnection, but not both at the time.

However it’s possible to write a Membrane component based on ex_webrtc that would handle both inbound and outbound tracks with a single PeerConnection - you can take a look at how they did it here: membrane_rtc_engine/ex_webrtc/lib/ex_webrtc_endpoint.ex at master · fishjam-cloud/membrane_rtc_engine · GitHub .

Unfortunately it’s more complicated than handling just a single type of tracks.

OctopusRage

OctopusRage

thx for the insight @varsill , ill take a look

Where Next?

Popular in Discussions Top

jswny
I would like to better understand what the advantages/disadvantages of umbrella applications are compared to structuring your app as as s...
New
vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
andre1sk
A big advantage to Elixir is all the distributed goodness but for many applications running on multiple nodes having integrated Etcd, Zoo...
New
blackode
Elixir Upgrading is so Simple in Ubuntu and It worked for me Ubuntu 16.04 git clone https://github.com/elixir-lang/elixir.git cd elixir...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
rower687
Hi all, I’ve been reading a lot about the “let it crash” term and how supervising processes and the whole messaging passing make an elixi...
New
PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
New
jesse
Hi everyone, I hesitated to post this here because I don’t want you to think I’m spamming, but I’ve been working on a Platform-as-a-Serv...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

We're in Beta

About us Mission Statement