FD- / RPiPlay

An open-source AirPlay mirroring server for the Raspberry Pi. Supports iOS 9 and up.
GNU General Public License v3.0
4.91k stars 355 forks source link

API extension for (1) setting network ports (2) mirror window resolution and maximum streaming framerate. #266

Closed fduncanh closed 2 years ago

fduncanh commented 2 years ago

The API extension allows the choice of network ports to be stored in struct raop_s so they are available when the connection is established. This allows use behind a firewall.

Also allow "plist" items to be set and stored in struct raop_s: these are sent on request to the client, and determine the resolution of the mirrored image width x height @ refresh_rate, whether overscanned, and the maximum streaming rate. This last plist setting "maxFPS" was accidentally omitted in a 2019 commit, but is seen by using plistutil on the binary plist used before May 2019. Setting it is confirmed to work (tested using the gstreamer renderer "fpsdisplaysink" which displays the framerate of the video stream.)

rpiplay.cpp has been given options to set these parameters, and Usage section of README.md has been updated.

FD- commented 2 years ago

I'll try to find time to review this PR. Please note I generally appreciate a separate PR for every change, so they can be more easily reviewed and merged in :)

fduncanh commented 2 years ago

@FD- Unfortunately, GitHub makes it very difficult to contribute separate PR's (cant have multiple forks of same project without a paid account) and I'm not sure how to use branches for this. I would have to delete my github fork repository and remake everything. I'll do it if you want, and actually use these changes, otherwise its a lot of work .. I can turn it into a sequential set of small changes (separate commits) added to a single PR pull by pull

I would like to get the changes in the airplay library changes I am using in UxPlay 1.3x backported. These have no effect on current rpiplay usage, but provide ways to build new features into the rpiplay or uxplay executable. New features in rpiplay that make use of these changes can be added afterwards.

---------------------------proposed changes to Airplay library----------------------------------------------------------

(1) bugfix for the OpenSSL use just found. (replace "encryptedlen" with "encryptedlen + 15" in call to aes_cbc_decrypt (raop_buffers.c) Since github prevents me from submitting a PR for this without deleting my big PR, its easier if you just do that one yourself. it's the only "MUSTFIX". The AAC audio problems with OpenSSL3.0.0 appear to go away with this fix, even if the corruption of the AAC audio stream wasn't obvious under OpenSSL1.1.1.

(2) some errors in the INFO plist entries (missing maxFPS, incorrect form for refreshRate (you followed an obsolete or incorrect (?) real variable reciprocal form 1/60 (from the "unoffical AirPlay protocol") rather than (uint) 60 for refreshRate, and some boolean<-> integer mixups. The correct variable types are seen when libplist is used.

(3) extend the API to set and store user-selected choices for local ports and some plist entries (width, height, refreshrate, overscanned, maxfps) to be stored in struct raop_s, and use them in the raop_handlers setup process. I recently saw an even cleaner way to get data and control ports from raop_t into raop_rtp_t and raop_rtp_mirror_t. than my earlier scheme, with much less code surgery, using the calls to raopstart(audio/mirror) during setup.

(4) fix a few unused variables left from commented-out debug printouts and a misplaced prototype ( for a static function at the end of a file, but placed in an include file instead of at the head of the file) that show up as warnings with strict compile options.

(5) add an optional callback reporting the compression type ct extracted from the plist sent by the client at a "96" audio connection in raop_handlers.h (this is used for AAC/ALAC switch in new UxPlay).

(6) (cosmetic) add some LOGGER_DEBUG debug info logs for ports, and silence metadata LOGGER_INFO (make them LOGGER_DEBUG)reports that are annoying when ALAC Airplay audio is being streamed.

fduncanh commented 2 years ago

The components for the AirPlay library are now posted as separated Pull Request. They are used in UxPlay 1.42.

If there is any interest in adding code to rpiplay to use the new API features, I will be happy to do so