Skip to content

Commit

Permalink
infinite loop fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
bartkrak committed Jun 19, 2024
1 parent a9166de commit 85e49c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/membrane_rtmp_plugin/rtmp_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ defmodule Membrane.RTMP.Server do

@impl true
def handle_info({:client_register_attempt, app, stream_key, client_handler_pid}, state) do
IO.inspect("handle_info :client_register_attempt #{app} #{stream_key}")
IO.inspect("rtmp_server.ex handle_info :client_register_attempt #{app} #{stream_key}")
# check if anyone is subscribed to app and stream_key
if state.subscriptions[{app, stream_key}] != nil do
IO.inspect("sub exist")
# respond to client handler that subscription exist
send(client_handler_pid, :sub_exists)
end
Expand Down
10 changes: 7 additions & 3 deletions lib/membrane_rtmp_plugin/rtmp_server/client_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ defmodule Membrane.RTMP.Server.ClientHandler do
stream_key: nil,
server: opts.server,
buffers_demanded: 0,
published?: false
published?: false,
client_register_attempt_made?: false
}}
end

Expand Down Expand Up @@ -104,11 +105,14 @@ defmodule Membrane.RTMP.Server.ClientHandler do
{message_handler_state, events} =
MessageHandler.handle_client_messages(messages, state.message_handler_state)

if message_handler_state.publish_msg != nil do
state = if message_handler_state.publish_msg != nil and not state.client_register_attempt_made? do
%{publish_msg: %Membrane.RTMP.Messages.Publish{stream_key: stream_key}} = message_handler_state
IO.inspect(stream_key, label: "stream_key")
IO.inspect(stream_key, label: "client_handler.ex stream_key")
# ask server if someone is subscribed to this
send(state.server, {:client_register_attempt, state.app, stream_key, self()})
%{state | client_register_attempt_made?: true}
else
state
end

state = Enum.reduce(events, state, &handle_event/2)
Expand Down

0 comments on commit 85e49c2

Please sign in to comment.