Skip to content

feat(airplay): send the configured display name to the receiver - #47

Open
nikhilshastry2003 wants to merge 1 commit into
masterfrom
feat/airplay-configured-device-name
Open

feat(airplay): send the configured display name to the receiver#47
nikhilshastry2003 wants to merge 1 commit into
masterfrom
feat/airplay-configured-device-name

Conversation

@nikhilshastry2003

Copy link
Copy Markdown
Collaborator

display_name in config.toml (and --name) only ever reached the sender's own window. Every AirPlay request — GET /info, POST /stream, in both the plain and the authenticated flow — sent the constant "OpenPlay" as X-Apple-Device-Name, which is the name a receiver shows for the sender. So a user who named their machine got "OpenPlay" on the TV regardless.

What changes

  • http_session.rs — the OPENPLAY_DEVICE_NAME constant becomes pub const DEFAULT_DEVICE_NAME, and negotiate, get_info, post_stream, post_stream_on, get_info_raw and build_stream_request take a device_name: &str. Each runs it through a new header_safe_device_name() before putting it in the header: control characters (line breaks included) are dropped, whitespace trimmed, and a name with nothing left falls back to the default. A header ends at the first CR/LF, so without that a name from a hand-edited config could cut the request short and have its tail read as further headers. Non-ASCII is kept — Apple's own senders send it.
  • session.rsAirPlaySession::start gains device_name: &str. Internally the format, session id and name travel in a private SessionParams struct, which keeps run_session and negotiate_with_auth under clippy's seven-argument limit instead of adding an #[allow].
  • openplay-senderstart_airplay_cast takes a CastSettings { bitrate_kbps, framerate, force_sw_encode, display_name } built from AppConfig in app.rs, for the same argument-count reason. run_airplay_pipeline stops taking width/height separately — they were already in the CaptureConfig it receives. Miracast's entry points are left as they are; they can move to the same struct when they need a fifth value.
  • Examplespair_probe and control_probe pass DEFAULT_DEVICE_NAME explicitly.
  • Docs / CLI helpdocs/configuration.md, the README usage block and the --name help text now say the name is sent to AirPlay receivers, not only shown in the window.

Tests

Four new unit tests in http_session.rs:

  • the configured name appears as X-Apple-Device-Name in the built POST /stream
  • a name containing \r\n cannot introduce a second header (the negative assertion fails if the sanitiser is removed)
  • blank / whitespace-only / control-only names fall back to DEFAULT_DEVICE_NAME
  • surrounding whitespace is trimmed and non-ASCII kept

Verified

  • cargo fmt --all -- --check clean
  • cargo clippy -p openplay-airplay --all-targets --all-features -- -D warnings clean
  • cargo test -p openplay-airplay — 46 + 27 passed (was 42 + 27)

Not verified locally: openplay-sender. The machine this was written on has no GStreamer, so the three sender files (app.rs, casting.rs, main.rs) are compiled by CI only. The diff there is small and mechanical, but I want to state the gap rather than imply it was built.

Relation to #44

This touches the same negotiate / negotiate_with_auth region of session.rs that #44 rewrites (the retry-on-status block), so whichever lands second will need a small rebase. Happy to do that here once #44 merges — the overlap is the argument list on two calls, nothing in the logic.

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.

1 participant