TASK 4 ship step 7: one-click go live + private-only enforcement (req 8) — the Go Live dialog is locked to Private (GoLiveViewModel.Visibility is a get-only string, no dropdown; settings' dead Default Visibility dropdown + Visibilities/DefaultStreamVisibility removed); YouTubeStreamService.CreateBroadcast always sends privacyStatus='private' and gained an injectable HttpClient? http = null seam; BeginGoLive fires CreateBroadcastAsync which stashes _currentBroadcastId for TASK 5's bind/transition (failure → StreamStatus.Error via AppLog, never a crash) alongside the frame pump, and StopStream clears it; the REC sign shows a dark-red PRIVATE badge next to REC whenever the live stream is private (IsLivePrivate) — the broadcast-insert integration test asserts the request body carries privacyStatus private (RecordingHandler seam) + a no-session guard test — 173 tests passing, 0 warnings
This commit is contained in:
+31
-11
@@ -55,7 +55,8 @@ public class MainViewModel : ViewModelBase
|
||||
private StreamHealth _currentHealth = new();
|
||||
private string _streamTitle = string.Empty;
|
||||
private string _streamDescription = string.Empty;
|
||||
private string _streamVisibility = "Public";
|
||||
private string _streamVisibility = "Private";
|
||||
private string? _currentBroadcastId;
|
||||
private string _windowTitle = "ytLlive";
|
||||
private string _topBarBackground = "#16213e";
|
||||
private string _previewGlowBrush = "Transparent";
|
||||
@@ -71,7 +72,6 @@ public class MainViewModel : ViewModelBase
|
||||
private string _overlayTitle = string.Empty;
|
||||
private string _defaultStreamTitle = string.Empty;
|
||||
private string _defaultStreamDescription = string.Empty;
|
||||
private string _defaultStreamVisibility = "Public";
|
||||
private string _bugReportText = string.Empty;
|
||||
private string _bugReportEmail = string.Empty;
|
||||
private string _featureRequestText = string.Empty;
|
||||
@@ -134,7 +134,6 @@ public class MainViewModel : ViewModelBase
|
||||
public ObservableCollection<Scene> Scenes { get; } = new();
|
||||
public ObservableCollection<ChatMessage> ChatMessages { get; } = new();
|
||||
public ObservableCollection<DisplayInfo> Displays { get; } = new();
|
||||
public string[] Visibilities { get; } = { "Public", "Unlisted", "Private" };
|
||||
|
||||
public Scene? ActiveScene
|
||||
{
|
||||
@@ -764,12 +763,6 @@ public class MainViewModel : ViewModelBase
|
||||
set => SetProperty(ref _defaultStreamDescription, value);
|
||||
}
|
||||
|
||||
public string DefaultStreamVisibility
|
||||
{
|
||||
get => _defaultStreamVisibility;
|
||||
set => SetProperty(ref _defaultStreamVisibility, value);
|
||||
}
|
||||
|
||||
// ─── Resolution quality dropdown (bottom bar) ───
|
||||
// Tiers offered to the creator before going live. First = default. The
|
||||
// dropdown is disabled while live because YouTube stream resolution is
|
||||
@@ -1954,23 +1947,49 @@ public class MainViewModel : ViewModelBase
|
||||
{
|
||||
StreamTitle = DefaultStreamTitle,
|
||||
StreamDescription = DefaultStreamDescription,
|
||||
Visibility = DefaultStreamVisibility,
|
||||
};
|
||||
var window = new ytLive.GoLiveWindow(dialog) { Owner = System.Windows.Application.Current.MainWindow };
|
||||
if (window.ShowDialog() == true)
|
||||
{
|
||||
StreamTitle = dialog.StreamTitle;
|
||||
StreamDescription = dialog.StreamDescription;
|
||||
StreamVisibility = dialog.Visibility;
|
||||
StreamVisibility = dialog.Visibility; // always "Private" (ship step 7)
|
||||
WindowTitle = string.IsNullOrWhiteSpace(dialog.StreamTitle)
|
||||
? "ytLlive"
|
||||
: $"{dialog.StreamTitle} — ytLlive";
|
||||
StreamStatus = StreamStatus.Streaming;
|
||||
ResetHealth(StreamStatus.Streaming);
|
||||
_ = CreateBroadcastAsync();
|
||||
_ = _framePump.StartAsync(); // never throws; failures log + surface via Failed
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Creates the YouTube broadcast (always private — enforced in the
|
||||
/// stream service) and remembers its ID for TASK 5's bind/transition. A
|
||||
/// failure surfaces as an error health state, never a crash.</summary>
|
||||
private async Task CreateBroadcastAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
_currentBroadcastId = await _youtubeStream.CreateBroadcast(
|
||||
StreamTitle, StreamDescription, DateTime.UtcNow);
|
||||
if (_currentBroadcastId == null)
|
||||
{
|
||||
AppLog.Write("Broadcast creation failed; check the OAuth session");
|
||||
StreamStatus = StreamStatus.Error;
|
||||
}
|
||||
else
|
||||
{
|
||||
AppLog.Write($"Broadcast created: {_currentBroadcastId}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppLog.Write($"Broadcast creation failed: {ex.Message}");
|
||||
StreamStatus = StreamStatus.Error;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopStream()
|
||||
{
|
||||
StreamStatus = StreamStatus.Offline;
|
||||
@@ -1979,6 +1998,7 @@ public class MainViewModel : ViewModelBase
|
||||
// Audio capture is always-on (preview monitoring); only the frame pump
|
||||
// and the session stop here.
|
||||
_ = _framePump.StopAsync();
|
||||
_currentBroadcastId = null;
|
||||
// Graceful end completes the session = signs out (the DPAPI token is
|
||||
// cleared so the next Start Stream requires a fresh sign-in). A crash
|
||||
// never runs this, so the token survives and the creator stays signed in.
|
||||
|
||||
Reference in New Issue
Block a user