100 Commits

Author SHA1 Message Date
fe9dd9aba6 ♻️ refactor(pmowebrenderer): factoriser handlers et supprimer duplications
- Remplacer les Arc+Box::pin manuels par la macro action_handler!(captures(...))
- Supprimer helpers locaux dupliqués dans renderer.rs (add_var, add_action)
- Extraire handlers génériques pour GET requests
- Factoriser extraction metadata dans set_uri_handler /set_next_uriHandler  
- Simplifier build_renderingcontrol en retirant pipeline inutile
- Mettre à jour edition Rust de 2021 vers 2024 dans tous les Cargo.toml
- Corriger pattern matching inutile `ref` sur déréférencement dans pmoaudio et pmoflac
2026-04-05 14:09:46 +02:00
546e8a782f 🗑️ Remove unused imports, macros and dead code
- Drop `Path`/``State``` from unused Axum imports in config.rs and registry
- Mark `_position_sec` field as `#[allow(dead_code)]`` in PositionUpdateRequest and PlayerStateReport
- Remove unused macro rules (`add_action_arg!`, `add_action!``, `` add_var!)``
- Delete unused PlayerReport struct and related handler code
2026-04-05 11:37:36 +02:00
340c69cb2b ⬆️ ureq v2→v3, add continuous stream detection
- Updateurequest dependency from v2 to latest major (v3.14)
- Add ureq as optional dependency in pmoaudio-ext
- Introduce is_continuous flag to UriSource and PlayerState for proper StreamType handling (Finite vs Continuous)
- Implement detect_continuous_stream() with URL pattern matching and HTTP HEAD header inspection (ICY, chunked encoding)
- Update send_track_boundary() to accept StreamType parameter
2026-04-04 18:00:47 +02:00
8924552696 Add StreamType for multi-client support and improved UPnP control
- Introduce `Streamtype` enum (Continuous vs Finite) to distinguish radio streams from finite tracks
- Enrich `TrackBoundary` sync marker with stream type for proper pause behavior per mode (silence vs backpressure)
- Update all sources and sinks to pass `StreamType` when creating track boundaries
  - Radio Paradise, HTTP source → Continuous (infinite)
- Improve UPnP control architecture: pause sends silence for radio, blocks pipeline via backpressure for tracks
- Prepare groundwork for multi-client DSP architecture with shared source and per-DSP pipelines
2026-04-04 14:37:32 +02:00
718c0d2aed 🔧 refactor(base_url): centraliser gestion des URLs absolues via middleware
- Ajout d'un BaseUrl layer dans pmoserver pour gérer les URLs absolues (LAN/WAN)
- Renommage de `covers_absolute_url_for` → ` covers_relative_route`, stocker les routes relatives
- Mise à jour des appels UPnP vers `covers_absolute_url_for_upnp` (fallback PMO_SERVER_URL)
- Correction des tâches de fond pour stocker les routes, pas l'URL complète
- Suppression du feature gate `simd` inutilisé dans pmoaudio/src/lib.rs
2026-04-04 10:14:51 +02:00
ff699d220f 🔧 Add #[allow(dead_code)] to unused items
- Suppress dead code warnings for utility functions, enums and traits not yet used in production
- Reorganize imports to follow module conventions (e.g., `DeviceIdentity` moved earlier in openhome_renderer.rs)
- Improve formatting of ClientMessage variants for readability
These changes prepare codebase groundwork without altering runtime behavior.
2026-04-04 01:03:51 +02:00
1164a11410 feat(cache): centralize absolute URL generation with PMO_SERVER_URL
Replace hardcoded relative URLs and manual base_url concatenation with a unified absolute URL API via pmocache::covers_absolute_url_for() and CacheTrait::absolute_url_for().

- Add pmocache as a required dependency to pmoparadise
- Introduce absolute_url_for() and covers_absolute_url_for() helpers using PMO_SERVER_URL env var (default: http://localhost:8080)
- Update all callers to use absolute URLs for covers and audio in streaming, playlists, Qobuz, Radio France, UPnP, and server startup
- Remove redundant route_for() usage in URL construction
- Add pmocache to Cargo.lock
2026-03-24 12:03:07 +01:00
0f0a8d1c91 deps: update esbuild to 0.27.4, rollup to 4.60.0, vite to 7.3.1
deps: update esbuild to 0.27.4, rollup to 4.60.0, vite to 7.3.1

- bump esbuild and all platform-specific binaries from 0.25.10 to 0.27.4
- bump rollup and all platform-specific binaries from 4.52.3 to 4.60.0
- bump vite from 7.1.7 to 7.3.1 (esbuild peer dep updated to ^0.27.0)
- bump dompurify from 3.2.7 to 3.3.3

web: improve cover image retry logic
- increase maxRetries default from 3 to 5
- reduce initial retryDelay from 1000ms to 500ms
- implement exponential backoff: delay = retryDelay * 2^(retryCount - 1)
- add detailed logging for retries and final failure

rust: minor cleanup
- remove unused imports (watch, Url, AudioSegment, SyncMarker)
- add tracing debug logs for cache file requests
- handle missing files gracefully with warning + client retry hint
- add #[allow(async_fn_in_trait)] where needed
2026-03-24 10:49:47 +01:00
d1be71ff47 Fix stream header invalidation and source task cleanup
Invalidate the cached OGG header immediately when restarting the FLAC encoder to prevent clients from receiving stale data.

Also improve the player source cleanup by draining the chunk receiver and adding a timeout when waiting for the emit task to finish, preventing potential hangs when the downstream pipeline is saturated.
2026-03-02 20:02:35 +01:00
2b0def806a Ajout de la gestion de la position en temps réel et amélioration de la gestion de la durée
Ajout de l'événement Position pour envoyer la position courante ~1/s pendant la lecture.

Modification de la gestion de la durée dans le registry pour ne pas écraser une durée déjà connue par la source (priorité à la source pour les flux radio).

Mise à jour du handler position_update pour utiliser update_duration au lieu de update_position, et suppression de la gestion de position_sec qui est maintenant gérée par PlayerEvent::Position.

Le serveur gère maintenant la position via les événements Position émis par PlayerSource, et la durée est uniquement utilisée comme fallback pour les sources sans durée connue.
2026-03-01 23:55:51 +01:00
f57754b5f8 Implémentation du PlayerSource pour le contrôle AVTransport UPnP
Ajout de PlayerSource avec contrôle complet AVTransport (Play/Pause/Stop/Seek/LoadUri) dans le pipeline audio

- Introduit PlayerSource comme nœud source audio avec gestion complète du cycle de vie UPnP
- Implémente les commandes LoadUri, LoadNextUri, Play, Pause, Stop, Seek
- Gestion des transitions gapless avec TrackBoundary pour un bitstream propre
- Révision du pipeline audio pour utiliser PlayerSource au lieu de la logique de contrôle existante
- Mise à jour des handlers UPnP pour utiliser PlayerHandle au lieu du canal de contrôle
- Suppression des anciennes commandes PipelineControl et logique de gestion de source
- Ajout de gestion d'événements PlayerEvent pour mise à jour de l'état UPnP
- Migration vers StreamingOggFlacSink pour la diffusion audio
2026-03-01 23:40:42 +01:00
e33484b802 Refactor OGG-FLAC streaming to support multi-client broadcast
Migrate from single-client direct OGG-FLAC sink to multi-client broadcast streaming sink.

- Replace DirectOggFlacHandle with OggFlacStreamHandle for multi-client support
- Update sink implementation to use StreamingOggFlacSink with proper backpressure
- Change connection model from 'connect()' to 'subscribe()'
- Adjust stream handling to support independent client streams
- Update stream endpoint to always respond with 200 chunked instead of range requests
- Add tracing for stream lifecycle events
- Reduce OGG channel capacity to strict backpressure (1)
- Add Drop implementation for stream cleanup
- Improve logging and error handling for concurrent access

This change enables multiple simultaneous clients to connect to the same audio stream without interfering with each other, while maintaining proper TCP backpressure and stream lifecycle management.
2026-03-01 22:46:17 +01:00
de74c7b431 Migrate instance ID storage from localStorage to sessionStorage
Switch instance ID storage from localStorage to sessionStorage in useWebRenderer composable to ensure better session management and prevent data persistence across browser sessions.

Also update the DirectOggFlacSink implementation to improve backpressure handling, streamline the OGG chaining logic, and add proper Safari range header support for the stream endpoint.
2026-03-01 17:30:05 +01:00
f9056f92e0 Implémentation du OGG chaining pour les flux audio
Cette modification introduit le support du OGG chaining dans le flux audio, permettant une transition transparente entre les pistes sans interruption. Cela inclut la gestion des encodeurs successifs dans le même canal Bytes, l'annulation des encodeurs précédents lors des transitions, et le maintien d'une connexion persistante avec backpressure TCP. Les modifications affectent les composants de sink et de pipeline audio, ainsi que les endpoints d'écoute.
2026-02-28 12:15:17 +01:00
6fe2f6be95 Refactor audio pipeline for multi-client streaming and improved error handling
Refactor the audio pipeline to support multi-client streaming with new OggFlacStreamHandle and StreamingOggFlacSink.

- Replace DirectOggFlacSink with StreamingOggFlacSink in pipeline
- Update documentation and comments to reflect multi-client support
- Add detailed warning logs for buffer underruns and client disconnections
- Remove TimerBufferNode from pipeline as it's no longer needed
- Update connect() calls to subscribe() for new streaming behavior

This change enables multiple clients to subscribe to the same audio stream, with each subscription getting a live feed from the current point in time.
2026-02-26 20:42:07 +01:00
306e691c61 Refactor WebRenderer to use server-side streaming with OGG-FLAC sink
This commit refactors the WebRenderer to use a server-side streaming architecture with OGG-FLAC sink instead of the previous WebSocket-based approach. The changes include:

- Replaced WebSocket communication with HTTP streaming using DirectOggFlacSink
- Implemented a new pipeline architecture with dedicated handlers for UPnP commands
- Added new modules for registration, registry, and streaming
- Updated the renderer to work with a pipeline control system
- Removed old WebSocket session management
- Added support for HTTP streaming with gapless playback
- Updated dependencies and features for the new architecture

The WebRenderer now acts as a MediaRenderer UPnP device that serves audio streams via HTTP endpoints, with commands relayed to the audio pipeline through a new control system.
2026-02-26 20:05:42 +01:00
a4301140d8 Migration vers une forme unifiée des cargos 2025-12-30 16:49:29 +01:00
ca36a102e5 Amélioration des pmoplaylist 2025-12-17 08:47:07 +01:00
0a03f72467 Changement du mécanisme d'attention sur les channels Radio Paradise. 2025-12-06 12:48:21 +01:00
9e8491710c debug du lecteur web 2025-12-06 12:48:21 +01:00
3d1673157b debug media server suite 2025-12-06 12:48:21 +01:00
e21fa5948e debug lectueur générique 2025-12-06 12:48:21 +01:00
aeddcc9c64 update la webapp 2025-12-06 12:48:21 +01:00
3957e17f64 encore des debug... 2025-12-06 12:48:21 +01:00
792ac5cb95 metadonnée technique dans le cache audio 2025-12-06 12:48:21 +01:00
a51d7c551e Prblen enxt chanson en flac 2025-12-06 12:48:21 +01:00
e00d0ce4d8 je ne saus plus c'est vieux ;-) 2025-12-06 12:48:21 +01:00
f7f2364da6 Incorpore les métadata dans les header flac 2025-12-06 12:48:21 +01:00
75e4ad28b7 fin du debuggage des sink 2025-11-21 09:25:06 +01:00
7fd8d50b8b factorisation de code 2025-11-20 21:27:22 +01:00
12389dd7c1 debut de refactoring des stream sinks 2025-11-20 09:19:29 +01:00
ac93d09212 new bug stop music à la transition de pieste 2025-11-20 07:10:42 +01:00
a0f723e2d2 Corrige le marquage de des epoch 2025-11-19 15:36:26 +01:00
1ef9a8a932 Sépare les trac en amont de l'encodeur flac 2025-11-19 13:21:15 +01:00
77e5eb047e Suite des débugages, mais jusque là ça marche vachement mieux. 2025-11-19 08:49:04 +01:00
cd47266fc8 Gestion des morts prématurées. 2025-11-18 21:25:37 +01:00
9be6835ddc Ou encore un peu de factorisation dans les nœuds. 2025-11-17 22:21:56 +01:00
9bc0c2544d Round 3 2025-11-17 21:30:26 +01:00
cbe197da9c Second round 2025-11-17 03:02:10 +01:00
765070c4b0 Nouveau broadcast stratégie 2025-11-17 02:51:56 +01:00
66416dafa8 Fin de la correction de l'implémentation par ChatGPT. 2025-11-16 21:34:16 +01:00
c81a4651d6 Simplification de la gestion des channels. 2025-11-16 08:34:20 +01:00
97a383c079 Tentative de gestion d'un historique 2025-11-16 08:02:50 +01:00
58c4383023 Ajout d'un nœud de cache des images dans les trackboundary 2025-11-15 15:27:23 +01:00
d9ad056933 Fabriquans un object Channel dans RadioRaradise 2025-11-15 14:59:41 +01:00
4e27255305 Nouvelle tentative de broadcast avec considération d'un temps d'expiration. 2025-11-15 13:53:35 +01:00
1c2d30cbe9 debuggage des stream 2025-11-15 12:21:30 +01:00
Claude
fd5cead8d4 Fix OGG-FLAC streaming: Add CRC-8 validation to eliminate false frame sync detection
## Problem
ffplay was reporting decoding errors ("invalid sync code", "header crc mismatch",
"invalid residual") while VLC played the stream correctly. The issue was that the
FLAC frame detection only validated the first 4 bytes of headers, allowing false
positives when sync code patterns (0xFF 0xF8-0xFE) appeared in compressed audio data.

## Solution
Implemented complete FLAC frame header validation with CRC-8 checksum verification
as per FLAC specification:

1. **Added CRC-8 calculation** (`calculate_flac_crc8`):
   - Uses polynomial x^8 + x^2 + x^1 + x^0 (0x07)
   - Lookup table generated at compile time

2. **Implemented UTF-8 decoding** (`decode_utf8_number`):
   - Handles 1-7 byte frame/sample numbers per FLAC spec

3. **Added complete header length detection** (`get_frame_header_length`):
   - Parses variable-length UTF-8 coded frame numbers
   - Handles optional 8/16-bit block size extensions
   - Handles optional 8/16-bit sample rate extensions

4. **Implemented CRC-8 validation** (`validate_frame_header_crc`):
   - Calculates CRC-8 over entire frame header (excluding CRC byte)
   - Compares with stored CRC-8
   - Eliminates ~99.9% of false positives

5. **Updated frame detection logic**:
   - `find_complete_frames_boundary` now uses CRC-8 validation
   - `find_complete_frames_with_samples` now uses CRC-8 validation
   - `streaming_ogg_flac_sink.rs` updated to use CRC validation

## Impact
- Strict adherence to FLAC specification
- Eliminates false sync code detection in compressed data
- Should resolve all ffplay decoding errors while maintaining VLC compatibility

## Technical Details
- CRC-8 probability of false positive: 1/256
- Combined with existing validation: quasi-impossible false positives
- No performance impact (CRC table is compile-time generated)

Refs: xiph.org/flac/format.html, RFC 9639
2025-11-13 11:35:39 +00:00
Claude
9a7e4d9f00 Fix OGG-FLAC streaming: Send one FLAC frame per OGG page per spec
The OGG-FLAC specification requires that each audio data packet contains
one complete FLAC frame. The previous implementation was bundling multiple
FLAC frames into a single OGG page, which caused decode errors in strict
decoders like ffplay/ffmpeg (though VLC was tolerant enough to play it).

Changes:
- Modified broadcast_ogg_flac_stream() to process FLAC frames one at a time
- Each FLAC frame is now wrapped in its own OGG page (per spec)
- Granule position is updated per frame (cumulative sample count)
- Added garbage data detection and skipping

This fixes decode errors while maintaining compatibility with all players.

Ref: https://xiph.org/flac/ogg_mapping.html
"Each audio data packet contains one complete FLAC frame"
2025-11-13 10:41:41 +00:00
Claude
46dee1de7b Refactor: Extract FLAC frame detection to shared module
Both StreamingFlacSink and StreamingOggFlacSink had duplicate FLAC frame
detection logic. The OGG-FLAC sink had the improved validation, but the
regular FLAC sink was still using the old unvalidated detection.

Changes:
- Created new module: pmoaudio-ext/src/sinks/flac_frame_utils.rs
  * parse_flac_block_size() - comprehensive frame header validation
  * find_complete_frames_boundary() - for regular FLAC streaming
  * find_complete_frames_with_samples() - for OGG-FLAC with granule tracking
  * Includes unit tests for validation

- Updated streaming_ogg_flac_sink.rs:
  * Removed duplicate functions
  * Now uses shared flac_frame_utils module

- Updated streaming_flac_sink.rs:
  * Removed old unvalidated find_complete_frames_boundary()
  * Now uses shared flac_frame_utils with improved validation
  * Benefits from same false positive prevention as OGG-FLAC

- Updated mod.rs to include flac_frame_utils module

Result: Both FLAC and OGG-FLAC streams now use the same comprehensive
frame header validation to prevent false positive sync code detection.
2025-11-13 10:23:36 +00:00