diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f6e2084a..05947caa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### Added +* [Podcasts/OBS/PostIt] Replace the MediaMTX relay with direct encrypted SRT ingestion managed by [FFmpeg.NET](https://github.com/cmxl/FFmpeg.NET). Reserve bounded UDP listeners on activation, display a secret SRT URL with an empty OBS stream-key field, start on received media, preserve revocation/expiry/quotas and authenticated replay, and invalidate in-memory activations after restart. Remove relay configuration and its authentication endpoint; update deployment, privacy and real-media regressions. Use separate request connections to the shared SQLite test database for reliable concurrent podcast requests. + * [Podcasts/OBS/PostIt] Add opt-in MediaMTX RTMPS ingestion for programmed emissions, activated explicitly from PostIt with one-time scoped, expiring and revocable keys. Start on publisher connection, remux H.264/AAC into the existing authenticated segments and MP4 replay workflow, bound concurrency/duration/buffering, enforce consumption and effective disk quotas, account storage with deletion refunds, and report owner-only ingest errors. Add relay configuration, installation instructions and real synthetic RTMP/RTMPS-to-replay regressions, including active revocation. * [Yavsc/PostIt/Privacy] Close and pseudonymize withdrawn accounts, cancel PayPal subscriptions before confirming withdrawal, erase managed personal files, avatars and podcasts, and reject old sessions across hosts. Purge eligible technical payment residues one year after effective withdrawal automatically and through a confirmed administrator-only PostIt action; preserve accounting records separately. Clarify the privacy policy, recipients, third-party integrations, withdrawal failures and deployment responsibilities. Make the unique email constraint mutable to support pseudonymization without deleting accounting identities. diff --git a/Directory.Packages.props b/Directory.Packages.props index 12028b161..8e1341f23 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,6 +5,7 @@ + diff --git a/INSTALL.md b/INSTALL.md index 4987ef501..37feac4db 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -290,17 +290,14 @@ or PayPal account eligibility. ### OBS Studio for planned emissions -Deploy MediaMTX **v1.21.3** beside the **single Yavsc.Api media instance** and -FFmpeg on that API host. The generated configuration in -[`contrib/mediamtx-podcasts.yml`](contrib/mediamtx-podcasts.yml) enables only the -OBS publishing paths, RTMPS for publishers and private RTMP/control listeners. -Adjust its `authHTTPAddress` to the API's internal HTTP listener; this listener -must accept the local authentication callback without redirecting it to HTTPS. -Alternatively, use an internal HTTPS URL with a valid certificate. -Install the RTMPS TLS certificate and key at the configured paths. Keep the -control API and internal RTMP ports on loopback (or an isolated authenticated network), -never on the public Internet. Do not enable anonymous HLS/RTMP reads on the relay. -MediaMTX must not record independent copies: Yavsc owns storage and retention. +OBS publishes **encrypted SRT directly to Yavsc.Api**, using +[FFmpeg.NET](https://github.com/cmxl/FFmpeg.NET) (`xFFmpeg.NET`) to manage FFmpeg +listeners. No MediaMTX, external media server, authentication callback or RTMPS +certificate is required. Install **FFmpeg with libsrt, H.264/AAC and MPEG-TS +support** on the **single Yavsc.Api media host** (`ffmpeg -h protocol=srt`). +OBS supports SRT in its Custom streaming service; see its +[SRT streaming guide](https://obsproject.com/kb/srt-protocol-streaming-guide). +This replaces the previous RTMP/RTMPS transport, not the authenticated playback API. Apply the `PodcastObsIngestion` migration on the shared database. Configure `Podcast:Obs` on **Yavsc.Api only**, for example: @@ -310,10 +307,10 @@ Apply the `PodcastObsIngestion` migration on the shared database. Configure "Podcast": { "Obs": { "Enabled": true, - "ServerUrl": "rtmps://obs.example.org:1936", - "RelayApiUrl": "http://127.0.0.1:9997/", - "RelayReadUrl": "rtmp://127.0.0.1:1935/", - "RelayUser": "yavsc", + "ServerUrl": "srt://obs.example.org", + "ListenAddress": "0.0.0.0", + "FirstPort": 10000, + "PortCount": 16, "ActivationMinutes": 30, "MaxDurationMinutes": 120, "MaxConcurrentBroadcasts": 2 @@ -322,63 +319,75 @@ Apply the `PodcastObsIngestion` migration on the shared database. Configure } ``` -Set `Podcast__Obs__RelayPassword` through the deployment's secret mechanism to -a random password of at least 32 characters. It authenticates Yavsc's private -reader/control client, not OBS users. Keep process arguments and credentials -accessible only to the service administrator. The public RTMPS URL must have -no `/live` suffix: the stream key includes the full `obs/` path. -Plain RTMP for the public OBS URL requires the explicit `AllowUnencryptedRtmp: true` option and should -only be used for local testing or inside a VPN. Limit publisher network bitrate -at the relay/network level as well as configuring OBS; application quotas are -checked on completed media segments, not on every incoming RTMP packet. +`ServerUrl` contains the public SRT host only, with no port, path, secret or query. +`ListenAddress` is a literal local IP address (IPv4 or IPv6); configure a matching +public address family. Open/forward **UDP 10000-10015** in this example. +An ordinary HTTP reverse proxy does not carry SRT. NAT forwarding must preserve +the advertised port numbers. +One FFmpeg process and UDP port are reserved per armed emission, even before OBS +connects. Armed and running emissions share `MaxConcurrentBroadcasts`; an exhausted +pool returns HTTP 503. The port range is bounded (at most 128 ports) and must be +large enough for the concurrency limit. Listener startup failure is reported, +not treated as successful activation. +Keep process arguments and credentials accessible only to the service administrator. +Limit ingress bitrate at the network level and in OBS: application quotas are checked +on completed media segments, not on every incoming packet. In PostIt: 1. Prepare an emission and select it. 2. Choose **Activer OBS / renouveler la cle**. 3. In OBS, select **Parametres > Stream > Service : Personnalise**, then copy - the displayed server and stream key. Use **H.264 video**, **AAC audio**, + the complete displayed **secret SRT URL as Server**, leaving **Stream Key empty**. + The URL includes caller mode, a random passphrase and enforced AES-256 encryption. + Use **H.264 video**, **AAC audio**, a **2-second keyframe interval** and a bitrate producing segments below 8 MiB. 4. Start streaming in OBS before the activation expires. The actual emission - starts when the publisher connects, even if the scheduled date is later. + starts when the first complete media segment arrives, even if the scheduled date is later. No camera capture in PostIt is required; PostIt may be closed afterwards. 5. Stop OBS or choose **Revoquer OBS et arreter le diffuseur** in PostIt. Committed segments remain available and the normal MP4 worker prepares replay. -Keys are scoped to one emission, stored only as SHA-256 hashes, displayed once, -rotated on each activation and erased after completion. PostIt never persists -them; navigation/logout clears the displayed key but does not revoke a running +Passphrases are scoped to one emission, displayed once and rotated on activation. +Only a SHA-256 hash and lifecycle metadata are stored in the database; FFmpeg needs +the actual passphrase in memory/process arguments for SRT encryption. It is never +included in status responses or persisted in PostIt. Navigation/logout clears +the displayed secret URL but does not revoke a running external emission. Revocation is available at the consumption limit. After disconnect, restart or timeout, the emission ends rather than silently resuming under a new publisher: prepare a new emission for another broadcast. +An API restart invalidates all old activations; an unstarted emission must be +activated again because its passphrase is not recoverable from the database. +An invalid handshake can end an armed listener; no podcast is created without +media, and the owner can activate again. Rate-limit connection attempts at deployment. -The worker polls the authenticated relay once a second and starts bounded FFmpeg -remuxing tasks. It rejects ended, deleted, revoked or withdrawn accounts and caps +The worker manages bounded FFmpeg.NET listener/remuxing tasks. It rejects ended, +deleted, revoked or withdrawn accounts and caps concurrent captures and duration (the lower of planned duration and configured -maximum). MediaMTX also receives a session expiry from authentication, so the -publisher is disconnected at that maximum lifetime even if the API stops. +maximum). Revocation cancels the corresponding FFmpeg process and frees its port. +Activation expiry stops unused listeners. The passphrase is required before SRT +media can be received; a stream name alone is not an authentication mechanism. Committed segments are charged as transferred and stored MiB under the same consumption rule; their storage receipts are refunded on podcast deletion. OBS storage counts towards the user's effective disk quota and the existing podcast media limits. Pending capture files are monitored and bounded; enforcement can overshoot by one polling interval of incoming data. Processing errors are -reported in the owner-only OBS status endpoint, without exposing keys or FFmpeg -diagnostics. Monitor scan/cleanup failures and do not restore old activation keys -from backups. A prolonged relay/API outage requires operational intervention. +reported in the owner-only OBS status endpoint, without exposing secret URLs or +FFmpeg diagnostics. Monitor process/cleanup failures and drain active captures +before maintenance. An API outage ends ingestion and requires reactivation. -The normal API listens/authenticates playback; OBS stream credentials never grant -listener access. If the relay is separately hosted, include it in the deployment's -privacy/provider information. +The normal HTTP API authenticates playback; OBS stream credentials never grant +viewer or account access. -For the real media regression, set `YAVSC_TEST_MEDIAMTX` to the installed MediaMTX -v1.21.3 executable and run: +For the real media regressions, install FFmpeg with libsrt and run: ```bash dotnet test --project src/test/Yavsc.Api.Tests/Yavsc.Api.Tests.csproj --filter-class '*PodcastObsTests' ``` -The test launches loopback-only listeners, generates synthetic H.264/AAC media -with FFmpeg, verifies RTMP/RTMPS authentication, revocation during streaming, +The tests launch loopback-only listeners, generate synthetic H.264/AAC media +with FFmpeg, verify encrypted SRT through FFmpeg.NET, wrong-passphrase rejection, +revocation during streaming, AAC audio, HLS segments, MP4 replay and refund, then stops its own processes and removes its temporary files. @@ -613,6 +622,6 @@ You'll need to send e-mail ... using smtp and the provider of your choice, see t ### Google -I'll have to make with it, a least a moment, it needs a *service account*, and some setup, -in the `appsettings.*.json` file, and +I'll have to make with it, a least a moment, it needs a *service account*, and some setup, +in the `appsettings.*.json` file, and the execution environment variable GOOGLE_APPLICATION_CREDENTIALS to a value pointing the json description file for the Google Service account. diff --git a/contrib/mediamtx-podcasts.yml b/contrib/mediamtx-podcasts.yml deleted file mode 100644 index cc7aa2740..000000000 --- a/contrib/mediamtx-podcasts.yml +++ /dev/null @@ -1,26 +0,0 @@ -# MediaMTX v1.21.3. Run beside the single Yavsc.Api media host. -# Replace the auth URL port and TLS certificate paths for the deployment. -logLevel: warn -authMethod: http -authHTTPAddress: http://127.0.0.1:5103/api/v1/podcasts/relay/auth -authHTTPExclude: [] -api: true -apiAddress: 127.0.0.1:9997 -rtsp: false -rtmp: true -rtmpEncryption: optional -rtmpAddress: 127.0.0.1:1935 -rtmpsAddress: :1936 -rtmpServerKey: /etc/yavsc/obs/server.key -rtmpServerCert: /etc/yavsc/obs/server.crt -hls: false -webrtc: false -srt: false -playback: false -pathDefaults: - source: publisher - overridePublisher: false - maxReaders: 1 - record: false -paths: - "~^obs/[0-9a-f]{32}$": diff --git a/src/PostIt/PostIt.Tests/PodcastScheduleTests.cs b/src/PostIt/PostIt.Tests/PodcastScheduleTests.cs index 9a55ff3fc..274aee991 100644 --- a/src/PostIt/PostIt.Tests/PodcastScheduleTests.cs +++ b/src/PostIt/PostIt.Tests/PodcastScheduleTests.cs @@ -27,14 +27,16 @@ public sealed class PodcastScheduleTests var activation = vm.ActivateObsCommand.ExecuteAsync(null); vm.SelectedPodcast = api.Plan with { Id = Guid.NewGuid() }; vm.SelectedPodcast = api.Plan; - api.PendingActivation.SetResult(new("rtmps://obs.example:1936", "secret", DateTimeOffset.UtcNow.AddMinutes(30))); + api.PendingActivation.SetResult(new("srt://obs.example:10000?passphrase=secret", "", DateTimeOffset.UtcNow.AddMinutes(30))); await activation; + Assert.Empty(vm.ObsServerUrl); Assert.Empty(vm.ObsStreamKey); api.PendingActivation = new(TaskCreationOptions.RunContinuationsAsynchronously); activation = vm.ActivateObsCommand.ExecuteAsync(null); await vm.DeactivateAsync(); - api.PendingActivation.SetResult(new("rtmps://obs.example:1936", "secret", DateTimeOffset.UtcNow.AddMinutes(30))); + api.PendingActivation.SetResult(new("srt://obs.example:10000?passphrase=secret", "", DateTimeOffset.UtcNow.AddMinutes(30))); await activation; + Assert.Empty(vm.ObsServerUrl); Assert.Empty(vm.ObsStreamKey); } finally { File.Delete(path); File.Delete(path + ".settings"); } @@ -56,17 +58,19 @@ public sealed class PodcastScheduleTests vm.SelectedPodcast = api.Plan; Assert.True(vm.ActivateObsCommand.CanExecute(null)); await vm.ActivateObsCommand.ExecuteAsync(null); - Assert.Equal("rtmps://obs.example:1936", vm.ObsServerUrl); - Assert.Equal("obs/stream-secret", vm.ObsStreamKey); + Assert.Equal("srt://obs.example:10000?passphrase=stream-secret", vm.ObsServerUrl); + Assert.Empty(vm.ObsStreamKey); Assert.False(vm.IsBroadcasting); api.Settings.Save(); Assert.DoesNotContain("stream-secret", await File.ReadAllTextAsync(path + ".settings")); vm.SelectedPodcast = api.Plan with { Id = Guid.NewGuid(), OwnerId = "other" }; + Assert.Empty(vm.ObsServerUrl); Assert.Empty(vm.ObsStreamKey); Assert.False(vm.ActivateObsCommand.CanExecute(null)); vm.SelectedPodcast = api.Plan; await vm.ActivateObsCommand.ExecuteAsync(null); await vm.DeactivateAsync(); + Assert.Empty(vm.ObsServerUrl); Assert.Empty(vm.ObsStreamKey); Assert.True(api.ObsEnabled); await vm.ActivateAsync(); @@ -74,6 +78,7 @@ public sealed class PodcastScheduleTests await vm.ActivateObsCommand.ExecuteAsync(null); await vm.DeactivateObsCommand.ExecuteAsync(null); Assert.False(api.ObsEnabled); + Assert.Empty(vm.ObsServerUrl); Assert.Empty(vm.ObsStreamKey); Assert.EndsWith("/obs", api.RevokedPath); await vm.DeactivateAsync(); @@ -156,7 +161,7 @@ public sealed class PodcastScheduleTests { ObsEnabled = true; response = PendingActivation is null - ? new PodcastObsCredentials("rtmps://obs.example:1936", "obs/stream-secret", DateTimeOffset.UtcNow.AddMinutes(30)) + ? new PodcastObsCredentials("srt://obs.example:10000?passphrase=stream-secret", "", DateTimeOffset.UtcNow.AddMinutes(30)) : await PendingActivation.Task; } else response = new PodcastObsStatus(ObsEnabled, DateTimeOffset.UtcNow.AddMinutes(30), null); diff --git a/src/PostIt/PostIt/ViewModels/PodcastsPageViewModel.cs b/src/PostIt/PostIt/ViewModels/PodcastsPageViewModel.cs index 26307ed10..2382b7e1e 100644 --- a/src/PostIt/PostIt/ViewModels/PodcastsPageViewModel.cs +++ b/src/PostIt/PostIt/ViewModels/PodcastsPageViewModel.cs @@ -307,7 +307,7 @@ public partial class PodcastsPageViewModel : ViewModelBase if (SelectedPodcast is { FlowId: not null } selected && selected.OwnerId == _ownerId) { var obs = await _client.ObsStatusAsync(selected.Id); - ObsStatus = obs.Error ?? (obs.Enabled ? "Entree OBS activee. Le direct commence a la connexion du diffuseur." : "Entree OBS desactivee."); + ObsStatus = obs.Error ?? (obs.Enabled ? "Entree SRT activee. Le direct commence a la reception des premiers medias." : "Entree OBS desactivee."); if (!obs.Enabled) ClearObsCredentials(clearStatus: false); } Status = "Directs et replays reserves aux utilisateurs connectes."; @@ -410,7 +410,7 @@ public partial class PodcastsPageViewModel : ViewModelBase _obsPodcastId = podcast.Id; ObsServerUrl = credentials.ServerUrl; ObsStreamKey = credentials.StreamKey; - ObsStatus = $"Connectez OBS avant {credentials.ExpiresAt.ToLocalTime():g}. Cette cle remplace toute cle precedente."; + ObsStatus = $"Copiez l'URL SRT secrete dans OBS avant {credentials.ExpiresAt.ToLocalTime():g}, avec la cle de stream vide. Cette URL remplace la precedente."; } catch (Exception ex) { Status = $"Activation OBS impossible : {ex.Message}"; } diff --git a/src/PostIt/PostIt/Views/Video/PodcastsPage.axaml b/src/PostIt/PostIt/Views/Video/PodcastsPage.axaml index c75ea3e74..5a6a66b70 100644 --- a/src/PostIt/PostIt/Views/Video/PodcastsPage.axaml +++ b/src/PostIt/PostIt/Views/Video/PodcastsPage.axaml @@ -99,16 +99,14 @@