-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to record with TCP transport (interleaved mode) #52
base: master
Are you sure you want to change the base?
Changes from 6 commits
ec5ab5f
ef449d8
168a08a
650f49a
279f762
6f31ea2
9f9755e
d125b73
105c620
8048a26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,15 +29,50 @@ defmodule Membrane.RTSP.Server.Conn do | |
|
||
@impl true | ||
def handle_continue(:process_client_requests, state) do | ||
do_process_client_requests(state, state.session_timeout) | ||
state.request_handler.handle_closed_connection(state.request_handler_state) | ||
{:stop, :normal, state} | ||
case do_process_client_requests(state, state.session_timeout) do | ||
%Logic.State{recording?: true} = state -> | ||
{:noreply, state} | ||
|
||
state -> | ||
state.request_handler.handle_closed_connection(state.request_handler_state) | ||
{:stop, :normal, state} | ||
end | ||
end | ||
|
||
@impl true | ||
def handle_info({:rtsp, %Request{} = rtsp_request}, state) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can delete this. |
||
case Logic.process_request(rtsp_request, state) do | ||
%Logic.State{recording?: true} = state -> | ||
{:noreply, state} | ||
|
||
state -> | ||
handle_continue(:process_client_requests, state) | ||
end | ||
end | ||
|
||
@impl true | ||
def handle_info({:rtsp, raw_rtsp_request}, state) do | ||
with {:ok, request} <- Request.parse(raw_rtsp_request) do | ||
case Logic.process_request(request, state) do | ||
%Logic.State{recording?: true} = state -> | ||
{:noreply, state} | ||
|
||
state -> | ||
handle_continue(:process_client_requests, state) | ||
end | ||
else | ||
{:error, error} -> | ||
raise "Failed to parse RTSP request: #{inspect(error)}.\nRequest: #{inspect(raw_rtsp_request)}" | ||
end | ||
end | ||
|
||
defp do_process_client_requests(state, timeout) do | ||
with {:ok, request} <- get_request(state.socket, timeout) do | ||
case Logic.process_request(request, state) do | ||
%{session_state: :recording} = state -> | ||
%Logic.State{recording?: true} = state -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looking at the field There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeap, I think |
||
state | ||
|
||
%Logic.State{session_state: :recording} = state -> | ||
do_process_client_requests(state, :infinity) | ||
|
||
state -> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handler should just send the raw rtsp message, no need to parse it beforehand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is to extract the message from the raw TCP stream. How do we know that the RTSP message we are building is done? Is match on "\r\n\r\n" really enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the handler responsibility so he can do the parsing however it wants. You can check here for an example on how it's done on the client side.
However we still need to address the following issue, when an rtsp message is sent to the server, it should parse it and then depending on the returned result, we may need to return control to the server. For example when a client send
GET_PARAMETER
we can just parse it and send the response, however if it sendsPAUSE
, we need to start listening for rtsp messages in the server, since the handler is no longer responsible for parsing them.I think it's fine to raise in case the rtsp message is not valid.
Anyway the rtsp session (tcp socket) should only be closed when the client close it even TEARDOWN should not close it.