Start RTMP forwarding when RTMP source arrives
This fixes a ~1 second delay in audio when multi-streaming, tested on Twitch.
It is possible that calling :multicast_algora may still result in a de-sync of audio and video while forwarding. Adding a field/flag to the user/channel would allow multicasting to "Algora" when the RTMP source arrives, instead of ad-hoc like it is now.
Very nice!
I ran into an issue where some pipeline components crashed while the pipeline itself remained running. In this scenario, attempting to reconnect leads to [warning] No demand made for client /live/●●●●●●●●●●●, terminating connection. until the pipeline is manually terminated :thinking:
It seems like starting RTMP forwarding in the same group as the source has messed up reconnecting...
I am getting this error now:
[error] GenServer #PID<0.2169.0> terminating
** (MatchError) no match of right hand side value: %{input: [{Membrane.Pad, :input, #Reference<0.740859990.2745171970.64194>}]}
(membrane_mp4_plugin 0.35.2) lib/membrane_mp4/muxer/cmaf.ex:227: Membrane.MP4.Muxer.CMAF.handle_playing/2
(membrane_core 1.0.1) lib/membrane/core/callback_handler.ex:139: Membrane.Core.CallbackHandler.exec_callback/4
(membrane_core 1.0.1) lib/membrane/core/callback_handler.ex:69: Membrane.Core.CallbackHandler.exec_and_handle_callback/5
(membrane_core 1.0.1) lib/membrane/core/element/lifecycle_controller.ex:84: Membrane.Core.Element.LifecycleController.handle_playing/1
(membrane_core 1.0.1) lib/membrane/core/element.ex:249: Membrane.Core.Element.handle_info/2
(stdlib 6.1) gen_server.erl:2345: :gen_server.try_handle_info/3
(stdlib 6.1) gen_server.erl:2433: :gen_server.handle_msg/6
(stdlib 6.1) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
Last message: {Membrane.Core.Message, :play, [], []}
I don't think that's related to forwarding - been having this issue before this PR, even without any forwarding. Seems to be caused by a timeout when sending link messages between CMAF muxers and the sink. See #131
I've rebased this against main and got rid of the delay when reconnecting. Denying incoming RTMP connections isn't very straight forward, or at least I couldn't figure out a way to do it without adding it to a pipeline, so I added Algora.Pipeline.AbortPipeline which accepts the RTMP connection before letting the pipeline terminate, which does an orderly shutdown of the RTMP connection. Might be worth looking into adding something to membrane_rtmp_plugin to make denying an incoming RTMP connections a bit easier.