Skip to content
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

stop and restart server when gstreamer window is closed (missing callback is added) #263

Closed
wants to merge 7 commits into from

Conversation

fduncanh
Copy link

@fduncanh fduncanh commented Aug 11, 2021

antimof's UxPlay fork of RPiPlay (which was backported into RPiPlay) did not include the required callback from the Gst bus when the gstreamer window was closed. This leaves the server running, including audio, without video. This pull request adds the missing callback, so when the gstreamer window is closed, the server is stopped and relaunched. ctrl-c in the terminal window will fully stop rpiplay in the usual way.

This fix is backported from the updated UxPlay at https://github.com/FDH2/UxPlay . and has been adjusted for the multiple renderers in RPiPlay.

  1. The call to sleep(1) (between checks for sigint signals while the server is running) is first moved into a new video function bool video_renderer->func->listen(video_renderer). This leaves the behavior of rpiplay unchanged for all renderers.

  2. for the gstreamer renderer, the callback is then implemented only in video_renderer_gstreamer_listen(renderer).

If something similar would be useful for rpi, it could be implemented in video_renderer_rpi_listen, which now just uses the sleep(1) call,

This pull request is completely independent of my other pull request #266 from a different github account.

"sleep(1)" in the loop checking "running" after start_server(..)
is moved to a new video renderer function
   video_renderer->funcs->listen(video_renderer)
This required gstreamer feature was not implemented in antimof's
original code.   It is needed to stop the server when the GStreamer
window is closed.  The behavior after this event is now  to relaunch the
AirPlay server.   (for gstreamer renderer only)

As before, rpiplay itself is stopped with ctrl-C in the terminal window.
@fduncanh
Copy link
Author

The code in this PR has been replaced by a GLib MainLoop as of UxPlay 1.35 at http://github.com/FDH2/UxPlay.

@FD-
Copy link
Owner

FD- commented Nov 6, 2021

Do you still want me to merge this in? Why are you restarting the server in case the window was closed? IMHO, we should either: 1) Stop the server when the window was closed, or 2) restart just the renderer, which should be possible by just changing the gstreamer renderer, without adding the listen callback.

What do you think?

@fduncanh
Copy link
Author

fduncanh commented Nov 7, 2021

The callback is essential. In the mode being used, gstreamer is opaque.
I'll look and see if I can just restart the two renderers and leave the raop running.

I moved on after using this fix to a full g-mainloop in uxplay 1.3x but that doesn't fit well with the RPi renderers.

@fduncanh
Copy link
Author

fduncanh commented Nov 7, 2021

To summarize:
gstreamer is being used in an opaque way: the raop server has no way to know the mirror window was closed, without a callback. When the window is closed, there are two possible ways to proceed (1) shut down everything (2) tell the client to close the connection, shut down the renderers, and wait for a new connection. I don't see any way to implement (2) other than shutting down and restarting the raop server.

If you think (1) is what you want, just tell me. Its trivial to implement.
Please give the answer soon. Once this PR is pulled, I can use this Github account to feed you the API changes I would like, in small chunks for your review.


One issue is that in my setup at least, the mDNS-SD registration quickly becomes "stale" when the server has no connection. Only clients that are already seeking a connection at the time the server registers with avahi see the service.
To counter this I gave uxplay1.3x an option to shut down and restart the server after a specified period with no connections, so it could be running in an "always available " mode. I am sure this shouldn't need to be done, but don't know why (that in my experience) the server becomes unavailable for connection attempts after a short period of inactivity.

@fduncanh fduncanh changed the title stop and restart server when gstreamer window is closed (missing callback is added) NOW ALSO INCLUDES AES_CBC_DECRYPT FIX stop and restart server when gstreamer window is closed (missing callback is added) Nov 7, 2021
@fduncanh
Copy link
Author

fduncanh commented Nov 7, 2021

@FD-
If my PR's are useful, please let me know ASAP whether you want rpiplay to terminate when the gstreamer window is closed, or restart the server.
(its your baby). What happens when the window produced by the RPi renderer is closed? IMHO it is better to relaunch, but you are the boss.

If this PR can be disposed of ASAP, I can use this GitHub account FDH2 to feed you the proposed improvements/
corrections to the AirPlay library in small digestible chunks, if you are willing to consider them.

@fduncanh fduncanh changed the title NOW ALSO INCLUDES AES_CBC_DECRYPT FIX stop and restart server when gstreamer window is closed (missing callback is added) stop and restart server when gstreamer window is closed (missing callback is added) Nov 14, 2021
@fduncanh
Copy link
Author

I will redo this to shut down the server when the gstreamer window is closed and submit a new pull request.

@fduncanh fduncanh closed this Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants