Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

First iteration of RTSP endpoint functionality #251

Merged
merged 16 commits into from
Mar 23, 2023

Conversation

sgfn
Copy link
Member

@sgfn sgfn commented Mar 1, 2023

No description provided.

@sgfn sgfn requested a review from mickel8 as a code owner March 1, 2023 12:22
@sgfn sgfn force-pushed the sgfn/RTC-145-rtsp-endpoint-devel branch 2 times, most recently from 9573eed to 7ea7752 Compare March 1, 2023 12:53
Copy link
Contributor

@mickel8 mickel8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coud you please rebase branches at first so that there are only your changes?

@sgfn sgfn force-pushed the sgfn/RTC-145-rtsp-endpoint-devel branch from 88714ef to 02faf14 Compare March 2, 2023 14:43
@sgfn sgfn force-pushed the sgfn/RTC-145-rtsp-endpoint branch from ec5c27c to d815eb3 Compare March 2, 2023 14:44
@sgfn sgfn force-pushed the sgfn/RTC-145-rtsp-endpoint-devel branch from 02faf14 to 1214f75 Compare March 2, 2023 14:49
@sgfn
Copy link
Member Author

sgfn commented Mar 2, 2023

Rebased. Sorry for the inconvenience

@sgfn sgfn requested a review from mickel8 March 6, 2023 14:01
@codecov
Copy link

codecov bot commented Mar 13, 2023

Codecov Report

❗ No coverage uploaded for pull request base (sgfn/RTC-145-rtsp-endpoint@d815eb3). Click here to learn what that means.
The diff coverage is n/a.

@@                      Coverage Diff                      @@
##             sgfn/RTC-145-rtsp-endpoint     #251   +/-   ##
=============================================================
  Coverage                              ?   60.13%           
=============================================================
  Files                                 ?       41           
  Lines                                 ?     1994           
  Branches                              ?        0           
=============================================================
  Hits                                  ?     1199           
  Misses                                ?      795           
  Partials                              ?        0           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d815eb3...0a21e41. Read the comment docs.

@sgfn
Copy link
Member Author

sgfn commented Mar 13, 2023

Fixes:

  • Everything outlined by @mickel8 in his review
  • Resolve race condition between :new_rtp_stream and :rtsp_setup_complete messages
  • Add proposed solution to attempt to create client-side NAT binding

@sgfn sgfn requested a review from daniel-jodlos March 13, 2023 16:10
@sgfn sgfn dismissed mickel8’s stale review March 13, 2023 16:11

@mickel8 is currently unavailable; everything outlined by him in the review has been fixed

Comment on lines 257 to 262
{:ok, keep_alive} =
Task.start(fn ->
rtsp_keep_alive(rtsp_session)
end)

Process.monitor(keep_alive)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think this should be a task. I don't think it has any serious implications, but just looks weird and is very much against what is said about Tasks in the documentation https://hexdocs.pm/elixir/1.12/Task.html
  2. Does it even need to be another process? I think you could use Process.send_after here instead of spawning another process

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a leftover from the original ConnectionManager used in rtsp_to_hls demo -- I didn't touch the parts that worked, but ofc can take a shot at refactoring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I see why this was done as a separate process. It's problematic because it executes RTSP.get_parameter, which is a call -- so, worst case scenario (connection loss), ConnectionManager is blocked for 5 seconds, after which it crashes

    14:28:27.593 [error] GenServer #PID<0.2841.0> terminating
     ** (stop) exited in: GenServer.call(#PID<0.2842.0>, {:execute, %Membrane.RTSP.Request{method: "GET_PARAMETER", path: nil, headers: [], body: ""}}, 5000)
         ** (EXIT) time out
         (elixir 1.14.2) lib/gen_server.ex:1038: GenServer.call/3

[...]

The way I see it, if we don't use a separate process, we either have to change the implementation of membrane_rtsp, rescue or let it crash. If we rescue and handle, ConnectionManager will still block for 5 secs, which right now isn't a big issue, but could become one in the future. If we let it crash, we'll be unable to directly inform Engine's parent about the reason -- no way to send :disconnected message. Of course, further changes could be made to handle ConnectionManager crashing... etc etc.

I'm not a big fan of either of these solutions, tbh. I would propose instead to either leave the task as-is, or create another GenServer module which will be responsible solely for the keep-alives, and thus free to crash at will. Is that an option you'd be alright with?

@sgfn sgfn requested a review from daniel-jodlos March 22, 2023 14:07

Process.monitor(keep_alive)
{keep_alive, _ref} =
Process.spawn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's perfectly okay, but I think you would expect to see spawn_monitor/1 here instead of Process.spawn/2

@sgfn sgfn merged commit a7d3493 into sgfn/RTC-145-rtsp-endpoint Mar 23, 2023
@sgfn sgfn deleted the sgfn/RTC-145-rtsp-endpoint-devel branch March 23, 2023 15:01
sgfn added a commit that referenced this pull request Mar 23, 2023
* Copy ConnectionManager over from RTSP to HLS demo
* First iteration of RTSP endpoint
* lint
* attempt fix tests
* Fixes after review
* More fixes
* Fix call to get_required_deps when endpoint module not defined
* Fix crash on unrecognised RTP mapping
* Bump membrane_rtsp to 0.3.1
* RTSP.PortAllocator first iteration
* Remove PortAllocator, add reconnects, tests, fix things
* Fixes after review
* Fix plugin version in docs
* Make FakeRTSPserver more sophisticated
* lint
* minor fix
sgfn added a commit that referenced this pull request Apr 3, 2023
* Copy ConnectionManager over from RTSP to HLS demo
* First iteration of RTSP endpoint
* lint
* attempt fix tests
* Fixes after review
* More fixes
* Fix call to get_required_deps when endpoint module not defined
* Fix crash on unrecognised RTP mapping
* Bump membrane_rtsp to 0.3.1
* RTSP.PortAllocator first iteration
* Remove PortAllocator, add reconnects, tests, fix things
* Fixes after review
* Fix plugin version in docs
* Make FakeRTSPserver more sophisticated
* lint
* minor fix
sgfn added a commit that referenced this pull request Apr 5, 2023
* Add basic RTSP endpoint API
* Fixes after review
* Lint fix
* RTSP endpoint (#251)
* Copy ConnectionManager over from RTSP to HLS demo
* First iteration of RTSP endpoint
* lint
* attempt fix tests
* Fixes after review
* More fixes
* Fix call to get_required_deps when endpoint module not defined
* Fix crash on unrecognised RTP mapping
* Bump membrane_rtsp to 0.3.1
* RTSP.PortAllocator first iteration
* Remove PortAllocator, add reconnects, tests, fix things
* Fixes after review
* Fix plugin version in docs
* Make FakeRTSPserver more sophisticated
* lint
* minor fix
* Fix nondeterministic tests
* Fixes after review
* more fixes
* rtsp control path fix
* second rtp stream fix
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants