mirror of
https://github.com/jeffvli/feishin.git
synced 2026-11-20 00:51:26 -08:00
development
1
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6578ba42ea |
Implementation of DLNA casting with additional fixes and features (#1887)
* feat: Add DLNA/UPnP casting support Add ability to cast audio to DLNA/UPnP media renderers (e.g. WiiM, Sonos, smart TVs) with gapless playback, album art, and volume sync. - SSDP device discovery via child process (bypasses Electron sandbox) - SOAP/UPnP control: play, pause, stop, seek, volume, mute - SetNextAVTransportURI for gapless track transitions - Gapless transition detection via position monitoring - Cast button in player controls with device picker popover - Volume sync from device on connect - DIDL-Lite metadata with album art, artist, album, duration - macOS network entitlements for LAN access - Electron net.fetch for SOAP (Chromium networking stack) - Startup fallback from DLNA to web player type - Error boundary around DLNA player component Closes #1431 Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: Resolve TypeScript lint errors for CI - Remove unused imports (PlayerStatus, Flex, useTranslation) - Add itemType to ImageQuery calls - Inline DlnaDevice interface to avoid cross-boundary import - Prefix unused parameter with underscore Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: Clear gapless skip flag on explicit play/next/prev actions Prevents the first track of a new album from being silently skipped on the DLNA device when the previous album ended with a gapless transition. Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: Resolve prettier/eslint formatting and empty catch blocks Co-Authored-By: Claude Opus 4.6 <[email protected]> * fix: Apply perfectionist sorting rules and remaining lint fixes Co-Authored-By: Claude Opus 4.6 <[email protected]> * Significant overhauls to discovery, casting, and remote control * Stop overwriting MPV with Web when DLNA casting finishes, keep volume and player settings if Feishin is closed while casting, prevent changes to player type while casting * Fixes for DLNA sync/queue logic and player logic * Linting fixes and perfectionist-sort * Fixed DLNA looping behavior and improved speaker -> Feishin latency * Accidentally merged changes in the wrong order inside of Github GUI * URL handling within DLNA player must now be asynchronous * feat: switch to cast icon * feat: improve ui * Radio implementation & Sonos grouping/configuration * Merge upstream changes * Fix package.json * Memory optimisation for CI attempt 1 * Memory optimisation for CI attempt 2 * Test packages and Electron builder against CI * Test packages and Electron builder against CI 2 * Revert packages and Electron builder * Memory optimisation for CI attempt 3 * Memory optimisation for CI attempt 4 * Memory optimisation for CI attempt 5 * Memory optimisation for CI attempt 6 * Revert src and build files to before tests * Revert build files pending fix on main * Accidentally prevented changing player from DLNA * feature: improve design and refactor * Implement DLNA-local switching and playback speed * Linting fixes * Fix radio bug, group detection, UI fixes, etc * Syntax fixes * Lint fixes & merge upstream * On-discovery group isolation & general fixes, etc * Fixed various issues & stereo pairs * Possible fix for devices not being properly discovered * XML decoding fix & Node location improvement * Change disconnect, volume, and missing dependency behavior * Simplify discovery on macOS * Fix playback issues for DLNA and local players * Build files reversion for merge * Fix issue with looping for the second time * Fix skipping back and forwards erroneously * Transcode OPUS files to MP3 before casting * Fix merge issues before IPC migration * Fix upstream changes, playback, and IPC migration * Fix multiple playback logic issues * Fix erroneous stop state and disconnect color * Fix all currently-known playback issues * Fix 1.15.1 merge * Fix CI memory issue * Fix issues with grouping and reconnection * Update position in queue when reconnecting * fix(player): stop the DLNA renderer on mediaStop instead of seeking to zero mediaStop sets PlayerStatus.STOPPED and resets the timestamp to 0 in one store update, then emits PLAYER_STOP. The DLNA engine only handled PLAYING and PAUSED and never subscribed to PLAYER_STOP, so the renderer received the timestamp reset as Seek(0) and kept playing from the start. - Subscribe to onPlayerStop: send Stop and clear the sent-URL state so the next Play re-sends the track (renderers may drop the URI on Stop). - Ignore seek-to-timestamp while the store is STOPPED. - Do not map a renderer-side STOPPED to PAUSED when the app itself stopped. Observed on upmpdcli 1.9.17 (MPD 0.24) and a HEOS NR1609. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): ignore stale DLNA position polls after a seek or stop The position poller ran every 500 ms with no in-flight guard and the SOAP client has no timeout. Renderers such as upmpdcli block their control port for several seconds while seeking an HTTP stream, so polls piled up and answered late, out of order; an answer issued before a seek or stop then overwrote the app position with the pre-seek value (observed as the slider jumping back after a seek, and showing the old position after Stop). - Skip a poll tick while one is still in flight. - Discard any poll answer to a request issued before the latest app command (seek, stop, play, pause, track load); the play-URL flow now records the play time so a stale STOPPED is not mirrored back as a pause. - In the renderer, ignore device position updates while the app is STOPPED. Observed on upmpdcli 1.9.17 over a slow Wi-Fi link. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * feat(player): add max sample rate to transcoding settings Jellyfin transcodes at the source sample rate. For DSD sources (decoded by ffmpeg at 352.8 kHz) a FLAC transcode is therefore 352.8 kHz, which most renderers refuse; a HEOS receiver capped at 192 kHz stops immediately. Jellyfin's universal endpoint accepts maxAudioSampleRate, so expose it. - TranscodingConfig gains an optional maxSampleRate (Hz). - Transcoding settings get a "Max sample rate" field next to bitrate and format; the format placeholder now mentions flac. - The Jellyfin adapter appends maxAudioSampleRate to the universal URL. - Subsonic has no equivalent parameter and ignores the field. Verified on a Marantz NR1609: the same universal FLAC URL is rejected at 352.8 kHz and plays with maxAudioSampleRate=192000. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): do not let a renderer that ignores SetVolume overwrite the app volume Every device volume report was propagated to the app. A Marantz NR1609 (HEOS) playing a transcoded stream reports volume 0 and ignores SetVolume, so each poll and every track change dragged the app slider back to 0 and pushed 0 to the device. - Record the app-set volume and give the device 5 s to reflect it before its reports count. - Never pass on a zero that contradicts a non-zero app-set volume; a non-zero contradiction is treated as the user turning the device knob. - After six polls that still contradict the app-set value, stop treating the device's volume reports as truth (logged once); trust is restored as soon as a report agrees with the app again, and reset on connect. Direct FLAC on the same receiver reports and accepts volume normally, so the guard must be per-stream, not per-device. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(ui): add the missing setting.transcodeNote string The transcoding settings rows all use t('setting.transcodeNote') for their tooltip, but no locale ever defined the key, so the raw key text was shown. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): use stream.{format} URLs for renderer transcodes on Jellyfin Jellyfin transcodes were requested through the extension-less /Audio/{id}/universal route. UPnP/DLNA renderers commonly pick a decoder from the URL's file extension: a Yamaha HTR-6067 refuses the universal MP3 stream and plays the byte-identical /Audio/{id}/stream.mp3 stream. For renderer playback only (the DLNA engine passes forRenderer), the Jellyfin adapter now builds /Audio/{id}/stream.{format}?static=false with audioBitRate and, when the source sample rate exceeds the configured maximum, audioSampleRate (that route takes an exact rate, not a maximum). A source whose container already matches the requested format is sent untouched via Download, preserving the universal route's behaviour. Local MPV and web playback keep using universal. getSongUrl now forwards the song's container and sample rate so the adapter can make both decisions. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): clamp the transcode sample-rate cap to 48 kHz for lossy formats Passing the configured maximum sample rate through unchanged asked Jellyfin for e.g. 192 kHz MP3 from a DSD source; libmp3lame, libopus and aac cannot encode above 48 kHz, so ffmpeg fails and the stream never starts (observed as "Unable to load file or stream" from mpv with transcoding enabled). Clamp the cap to 48 kHz for aac, mp3, ogg, opus and vorbis on both the universal and the stream.{format} routes; lossless formats keep the configured value. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): seek transcoded DLNA streams by re-sending with a start offset Jellyfin's transcode routes answer with a chunked body, no Content-Length and Accept-Ranges: none, so a renderer cannot range into them. A UPnP Seek on such a stream is accepted by a HEOS receiver (Marantz NR1609) and then the transport sits in TRANSITIONING until it is given a new URI; the slider snaps back and nothing plays. The same request on a direct file works, which is why it only shows with transcoding on. Seeks on these streams are now expressed the way Jellyfin's own web client does it: the current track is re-sent with `startTimeTicks` at the requested position and the main process adds that offset to every position it polls, so the app keeps showing track time. The pending handoff / resume seek that the play flow already carried is sent the same way, which also removes the post-Play Seek (and its mute trick) on these streams. Streams the server cannot offset, other servers, and speed-changed playback keep the plain Seek. The timestamp reset that a track change makes in the same store update as the song swap is no longer forwarded as a Seek on these streams (it restarted the old stream on the receiver just before the new URI arrived), and the main process drops any Seek that still reaches it for a chunked stream. Verified on the NR1609: a re-sent stream with a 60 s offset starts within 4 s and reports position from 0; without the offset the receiver hangs in TRANSITIONING after Seek. The offset only takes effect with a distinct play session: Jellyfin keys a running transcode on media path, user agent, device id and play session id, and Feishin sent an empty id, so the offset request was served from the job already running, from its start. Transcode URLs now carry a play session id derived from item, format, sample-rate cap and offset (a running job is also found by session id alone, so the item must be part of it), which also means a changed cap no longer replays the old transcode. The send flow additionally checks, right before the URI goes out, that the song it resolved is still the current one, so a rapid double skip no longer delivers the earlier track after the later one. (A forward skip legitimately triggers two sends, from the song-change subscription and from MEDIA_NEXT; the existing 500 ms same-URL check collapses that pair, so the guard must not be a plain "newer send started" test, which made both sends stand down and nothing reach the renderer.) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): send the next track when the renderer does not advance on its own The poller reports a track end in two ways: gapless (the renderer switched to the queued next URI by itself) and not gapless (it sat at the end of the track, or dropped to STOPPED). The engine ignored the flag and treated every end as gapless: it marked the send as already done and only queued the following track, so a renderer that accepts SetNextAVTransportURI but never acts on it (Yamaha HTR-6067) was left at the end of the old track while the app walked the queue, one "stuck at end" every 1.5 s, through the rest of the album. The flag left set also swallowed the next manual skip. The handler now honours the flag: when the renderer did not advance, the new current track is sent and the queue is re-armed from there. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): announce a transcoded DLNA stream by its own container The DIDL-Lite protocolInfo sent with a track took its MIME type from the source's content type or suffix before looking at the URL, so a FLAC file transcoded to MP3 for a renderer was announced as audio/flac. A renderer that picks its decoder from the announcement, or filters by it, refuses or mis-decodes the stream. The URL's own extension (stream.mp3) now takes precedence; direct-play URLs have none and are unaffected. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): time out DLNA SOAP calls and treat NO_MEDIA_PRESENT as stopped The SOAP client had no timeout. Since the poller issues one request at a time, a renderer that never answers a position query parked polling for good: the slider froze, seeks looked ignored and track ends were never noticed. A Yamaha HTR-6067 stalls like this and also takes up to 7 s to answer SetAVTransportURI, so polls now give up after 4 s and commands after 15 s; a timed-out poll simply yields to the next tick. The same receiver reports NO_MEDIA_PRESENT rather than STOPPED once it has dropped or finished a stream; the poller only knew STOPPED, so the app sat on a silent device believing it was playing. The state is now treated as a stop. The play-URL handler's catch, which swallowed every failure silently, logs it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * fix(player): keep a queued next URI clear of a Play in flight A Yamaha HTR-6067 given SetNextAVTransportURI within about 300 ms of Play switches to the queued URI instead of the one it was just told to play (reproduced by SOAP: 50 ms after Play jumps, 300 ms after does not). The engine re-arms the queued next one second after issuing a load, and on that receiver the load itself takes about that long, so the re-arm landed on top of Play: a seek (re-sent as a new stream) or a track change played the following track instead. Next-URI changes (set and clear) now wait until no load or Play is in flight (a load runs from SetAVTransportURI until Play has returned) and the last Play is at least a second old; and Play waits for any next-URI call still being answered, since this receiver takes up to a second to answer SetNextAVTransportURI while loading. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01UxDiPkoRCtgk6rMMNjPfdT * Fix issue with client-side disconnection * Initial review pass * Lint fix * Implement requests and unify * Fix playback logic * Design parity improvements * Fix popover issue and implement feedback * Fix playback skipping since recent modifications * Implement requests --------- Co-authored-by: Paul Barker <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: Manuel <[email protected]> Co-authored-by: speedy-axolotl <[email protected]> Co-authored-by: Ray Tran <[email protected]> |