Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,4 @@ MigrationBackup/

.vscode
.DS_Store
/obs-studio-build
/build-libobs.cmd
/Resources/FFmpeg/ffmpeg.exe
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Verify C# code is formatted per .editorconfig
if command -v dotnet >/dev/null 2>&1; then
echo "Running dotnet format check..."
dotnet format --no-restore --verify-no-changes Segra.sln --exclude libobs-sharp || {
dotnet format --no-restore --verify-no-changes Segra.sln || {
echo "dotnet format found issues. Run 'dotnet format' to fix." >&2
exit 1
}
Expand Down
2 changes: 1 addition & 1 deletion Backend/App/MessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Segra.Backend.Core.Models;
using Segra.Backend.Media;
using Segra.Backend.Utils;
using Segra.Backend.Obs;
using Segra.Backend.Recorder;
using Segra.Backend.Games;

namespace Segra.Backend.App
Expand Down
2 changes: 1 addition & 1 deletion Backend/App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Photino.NET.Server;
using Segra.Backend.Api;
using Segra.Backend.Core.Models;
using Segra.Backend.Obs;
using Segra.Backend.Recorder;
using Segra.Backend.Services;
using Segra.Backend.Shared;
using Segra.Backend.Utils;
Expand Down
22 changes: 22 additions & 0 deletions Backend/Core/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ internal class Settings
private bool _forceMonoInputSources = false;
private bool _enableDisplayRecording = true;
private Display? _selectedDisplay = null;
private DisplayCaptureMethod _displayCaptureMethod = DisplayCaptureMethod.Auto;
private bool _recordWindowedApplications = false;
private bool _enableAi = true;
private bool _autoGenerateHighlights = true;
Expand Down Expand Up @@ -334,6 +335,19 @@ public Display? SelectedDisplay
}
}

[JsonPropertyName("displayCaptureMethod")]
public DisplayCaptureMethod DisplayCaptureMethod
{
get => _displayCaptureMethod;
set
{
if (_displayCaptureMethod != value)
{
_displayCaptureMethod = value;
}
}
}

[JsonPropertyName("recordWindowedApplications")]
public bool RecordWindowedApplications
{
Expand Down Expand Up @@ -1390,6 +1404,14 @@ public enum RecordingMode
Hybrid
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum DisplayCaptureMethod
{
Auto,
DXGI,
WGC
}

public class Game
{
[JsonPropertyName("name")]
Expand Down
51 changes: 34 additions & 17 deletions Backend/Games/Pubg/PubgIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ private void TimerTick()
foreach (var directory in newDirs)
{
Log.Information($"New PUBG replay: {directory}");
var processedVictims = new HashSet<string>();
Thread.Sleep(500);

var infoPath = Path.Combine(directory, "PUBG.replayinfo");
Expand All @@ -97,8 +96,8 @@ private void TimerTick()
continue;
}

ProcessDownedPlayers(directory, matchInfo, processedVictims);
ProcessKills(directory, matchInfo, processedVictims);
ProcessDownedPlayers(directory, matchInfo);
ProcessKills(directory, matchInfo);
ProcessPlayerDowned(directory, matchInfo);
ProcessPlayerDeath(directory, matchInfo);
}
Expand All @@ -109,7 +108,7 @@ private void TimerTick()
}
}

private void ProcessDownedPlayers(string folder, PubgMatchInfo matchInfo, HashSet<string> trackedVictims)
private void ProcessDownedPlayers(string folder, PubgMatchInfo matchInfo)
{
var downFiles = Directory.GetFiles(Path.Combine(folder, "events"), "DBNO*");
foreach (var filePath in downFiles)
Expand All @@ -128,20 +127,24 @@ private void ProcessDownedPlayers(string folder, PubgMatchInfo matchInfo, HashSe
!string.Equals(cleanVictim, cleanRecordName, StringComparison.OrdinalIgnoreCase))
{
var downTime = MatchTimestampToLocal(matchInfo.Timestamp, eventTime);
trackedVictims.Add(eventData.VictimName);
var bookmarkTime = downTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero;

// Skip events that occurred before recording started
if (bookmarkTime < TimeSpan.Zero)
continue;

var bookmark = new Bookmark
{
Type = BookmarkType.Kill,
Time = downTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero
Time = bookmarkTime
};
Settings.Instance.State.Recording?.Bookmarks.Add(bookmark);
}
}
}
}

private void ProcessKills(string folder, PubgMatchInfo matchInfo, HashSet<string> trackedVictims)
private void ProcessKills(string folder, PubgMatchInfo matchInfo)
{
var killFiles = Directory.GetFiles(Path.Combine(folder, "events"), "kill*");
foreach (var filePath in killFiles)
Expand All @@ -159,19 +162,21 @@ private void ProcessKills(string folder, PubgMatchInfo matchInfo, HashSet<string
if (string.Equals(cleanKiller, cleanRecordName, StringComparison.OrdinalIgnoreCase) &&
!string.Equals(cleanVictim, cleanRecordName, StringComparison.OrdinalIgnoreCase))
{
// Check if we already got credit for downing this victim
bool iDownedThem = !trackedVictims.Add(eventData.VictimName);

// Create bookmark if:
// - IsDBNO=false (instant kill or post-revive kill), OR
// - IsDBNO=true AND I didn't down them (finishing someone else's down)
if (!eventData.IsDBNO || !iDownedThem)
// Only bookmark instant kills (IsDBNO=false)
// Downs are already bookmarked in ProcessDownedPlayers
if (!eventData.IsDBNO)
{
var killTime = MatchTimestampToLocal(matchInfo.Timestamp, eventTime);
var bookmarkTime = killTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero;

// Skip events that occurred before recording started
if (bookmarkTime < TimeSpan.Zero)
continue;

var bookmark = new Bookmark
{
Type = BookmarkType.Kill,
Time = killTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero
Time = bookmarkTime
};
Settings.Instance.State.Recording?.Bookmarks.Add(bookmark);
}
Expand All @@ -197,10 +202,16 @@ private void ProcessPlayerDowned(string folder, PubgMatchInfo matchInfo)
if (string.Equals(cleanVictim, cleanRecordName, StringComparison.OrdinalIgnoreCase))
{
var downTime = MatchTimestampToLocal(matchInfo.Timestamp, eventTime);
var bookmarkTime = downTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero;

// Skip events that occurred before recording started
if (bookmarkTime < TimeSpan.Zero)
continue;

var bookmark = new Bookmark
{
Type = BookmarkType.Death,
Time = downTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero
Time = bookmarkTime
};
Settings.Instance.State.Recording?.Bookmarks.Add(bookmark);
}
Expand Down Expand Up @@ -229,10 +240,16 @@ private void ProcessPlayerDeath(string folder, PubgMatchInfo matchInfo)
if (!eventData.IsDBNO)
{
var deathTime = MatchTimestampToLocal(matchInfo.Timestamp, eventTime);
var bookmarkTime = deathTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero;

// Skip events that occurred before recording started
if (bookmarkTime < TimeSpan.Zero)
continue;

var bookmark = new Bookmark
{
Type = BookmarkType.Death,
Time = deathTime - Settings.Instance.State.Recording?.StartTime ?? TimeSpan.Zero
Time = bookmarkTime
};
Settings.Instance.State.Recording?.Bookmarks.Add(bookmark);
}
Expand Down
Loading