feat(cast): add Google Cast support and :output command#40
Conversation
|
This should use the latest version of SharpCaster. |
| public PlaybackState PlaybackState => _state; | ||
| public Song Song => _song; | ||
|
|
||
| public async void Play() { |
There was a problem hiding this comment.
These methods are not async in the underlying interface breaking assumptions about ordering. Functions where we call Stop() then Play() may execute in the wrong order.
mrazza
left a comment
There was a problem hiding this comment.
XML doc comments are required on all public classes and public methods.
Senior Code Review Feedback 🔍This is a phenomenal feature addition! Implementing Google Cast support with output switching is a major milestone for SMoC. The architecture (e.g., using I see that you successfully addressed the previous comments regarding upgrading to SharpCaster v3.0.0 and adding XML comments to all public classes/interfaces. Here are a few technical and robustness concerns that we should address before merging: 1. Wildcard Port Binding in HttpListener (Permissions & Privilege Issues)In _listener.Prefixes.Add($"http://*:{port}/");
2. Streaming Proxy Single-Use Stream Handling (Multi-Request/Probe Support)In await _currentStream.CopyToAsync(response.OutputStream, token);
3. Command CleanupIn _commandService.UnregisterCommand("output");This is great! It prevents memory leaks. Please look into resolving 1 and 2. Excellent job on the unit tests as well! |
… seek Resolves feedback (1) and (2) from PR #40 review: - Binds HttpListener specifically to the local IP address instead of using the wildcard prefix '*' to prevent permission issues. - Resets/seeks stream position to the beginning on each proxy request to allow multi-request/probing connections from Google Cast devices.
Summary of Changes
Implemented Google Cast support for Smoc, enabling users to cast music to Cast-enabled devices.
Core Features
CastDiscoveryServiceto discover Chromecast devices on the local network using mDNS viaChromecastLocator.CastAudioServiceandCastPlaybackServiceto control playback on remote devices.IChromecastClientandChromecastClientWrapperto allow for robust unit testing of Cast services via mocking.StreamingProxyServiceto bridge Smoc's internal audio streams to Chromecast using a local HTTP listener.:outputcommand to switch between local and remote playback.:output [tab]).Technical Details
Sharpcaster.Models.Media.MediaStatusupdates and map them to Smoc's internalPlaybackState.StandardPlaybackQueueServiceto support dynamic audio service switching without losing queue state.CommandServicewith a plugin-based completion architecture.Test Coverage
Added unit tests for all major new components:
StreamingProxyServiceTest: Verifies the local HTTP streaming proxy functionality.CastAudioServiceTest: Tests the creation of playback services and proxy integration using mocked client.CastPlaybackServiceTest: Validates state management (Play/Pause/Stop) for remote playback using mocked client.CommandServiceTest: Added coverage for the new tab-completion logic.CommandLineTest: Verified UI-level tab-completion handling.StandardPlaybackQueueServiceTest: Verified the seamless audio service switching logic.Resolves #39