mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Send frames to streaming client from replay recorder
This commit is contained in:
parent
93db75bd41
commit
175fd512b0
@ -7,7 +7,10 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
|
||||
namespace osu.Game.Online.Spectator
|
||||
{
|
||||
@ -22,6 +25,9 @@ namespace osu.Game.Online.Spectator
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> beatmap { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -111,5 +117,12 @@ namespace osu.Game.Online.Spectator
|
||||
public Task EndPlaying(int beatmapId) => connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), beatmapId);
|
||||
|
||||
private Task WatchUser(string userId) => connection.SendAsync(nameof(ISpectatorServer.StartWatchingUser), userId);
|
||||
|
||||
public void HandleFrame(ReplayFrame frame)
|
||||
{
|
||||
if (frame is IConvertibleReplayFrame convertible)
|
||||
// TODO: don't send a bundle for each individual frame
|
||||
SendFrames(new FrameDataBundle(new[] { convertible.ToLegacy(beatmap.Value.Beatmap) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,8 +250,11 @@ namespace osu.Game
|
||||
|
||||
FileStore.Cleanup();
|
||||
|
||||
// add api components to hierarchy.
|
||||
if (API is APIAccess apiAccess)
|
||||
AddInternal(apiAccess);
|
||||
AddInternal(spectatorStreaming);
|
||||
|
||||
AddInternal(RulesetConfigCache);
|
||||
|
||||
MenuCursorContainer = new MenuCursorContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
@ -4,10 +4,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Online.Spectator;
|
||||
using osu.Game.Replays;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osuTK;
|
||||
@ -60,6 +62,9 @@ namespace osu.Game.Rulesets.UI
|
||||
recordFrame(true);
|
||||
}
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private SpectatorStreamingClient spectatorStreaming { get; set; }
|
||||
|
||||
private void recordFrame(bool important)
|
||||
{
|
||||
var last = target.Frames.LastOrDefault();
|
||||
@ -72,7 +77,11 @@ namespace osu.Game.Rulesets.UI
|
||||
var frame = HandleFrame(position, pressedActions, last);
|
||||
|
||||
if (frame != null)
|
||||
{
|
||||
target.Frames.Add(frame);
|
||||
|
||||
spectatorStreaming?.HandleFrame(frame);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ReplayFrame HandleFrame(Vector2 mousePosition, List<T> actions, ReplayFrame previousFrame);
|
||||
|
Loading…
Reference in New Issue
Block a user