Testing a Membrane Bin used in a WebRTC Engine Endpoint

I'm trying to test a membrane bin that I use in WebRTC engine endpoint. Though I'm having trouble getting my test setup properly.

I was trying to approach is this way:
  1. Start my Membrane.Testing.Pipeline with a simple spec, just the conversation bin
  2. Send a {:new_tracks} event to the bin, simulating what the Membrane.WebRTC.Engine does when a new bin is assed as an endpoint
  3. Then update the spec to connect the Membrane.Testing.DynamicSource and Membrane.Testing.Sink
But I'm never tripping the handle_pad_added callback in my bin, which leads me to believe I'm doing something wrong.

I'm using the Membrane.Testing.Pipeline so I can access the Membrane.Testing.Assertions and assert that my conversation bin is emitting the right events, etc.

Is this the right approach for testing a custom bin used in the webrtc engine? Or is there a better / different approach? I checked out the integration tests in the repo, but none seemed to handle this exact case.



conversation_bin = %Custom.Bin{options: options}
options = [
        spec: [
          # Use tuple name
          child({:endpoint, endpoint_id}, conversation_bin)
        ],
        name: :conversation_pipeline
      ]

      pipeline = Pipeline.start_link_supervised!(options)
Pipeline.notify_child(pipeline, {:endpoint, endpoint_id}, {:new_tracks, [track]})
      updated_spec = [
        child(:source, %DynamicSource{
          output: {0, generator},
          stream_format: @audio_format
        })
        |> via_in(pad)
        |> get_child({:endpoint, endpoint_id}),
        get_child({:endpoint, endpoint_id})
        |> via_in(:input)
        |> child(:sink, %Sink{})
      ]

      # Execute the spec update to link the pads
      Pipeline.execute_actions(pipeline, spec: updated_spec)
Was this page helpful?