Skip to content

Commit e1a54ad

Browse files
committed
Merge classic-ui-modern-fixes into cursor/add-camera-placement-preview-tab-7452
Resolved conflict in SettingsPage.xaml by including both: - WebCam tab (from this branch) - Trim and About tabs (from classic-ui-modern-fixes)
2 parents 83fdc95 + 58c2061 commit e1a54ad

9 files changed

Lines changed: 186 additions & 50 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
namespace Captura
2+
{
3+
public enum GpuVendor
4+
{
5+
Unknown,
6+
AMD,
7+
NVIDIA,
8+
Intel,
9+
Other
10+
}
11+
12+
public interface IHardwareInfoService
13+
{
14+
/// <summary>
15+
/// Gets the primary GPU vendor
16+
/// </summary>
17+
GpuVendor GpuVendor { get; }
18+
19+
/// <summary>
20+
/// Gets the GPU name/description
21+
/// </summary>
22+
string GpuName { get; }
23+
24+
/// <summary>
25+
/// Checks if AMD hardware encoding is available
26+
/// </summary>
27+
bool HasAmdEncoder { get; }
28+
29+
/// <summary>
30+
/// Checks if NVIDIA hardware encoding is available
31+
/// </summary>
32+
bool HasNvidiaEncoder { get; }
33+
34+
/// <summary>
35+
/// Checks if Intel QuickSync encoding is available
36+
/// </summary>
37+
bool HasIntelQuickSync { get; }
38+
}
39+
}

src/Captura.FFmpeg/Video/FFmpegWriterProvider.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,45 @@ public class FFmpegWriterProvider : IVideoWriterProvider
1212
public string Name => "FFmpeg";
1313

1414
readonly FFmpegSettings _settings;
15+
readonly IHardwareInfoService _hardwareInfo;
1516

16-
public FFmpegWriterProvider(FFmpegSettings Settings)
17+
public FFmpegWriterProvider(FFmpegSettings Settings, IHardwareInfoService HardwareInfo)
1718
{
1819
_settings = Settings;
20+
_hardwareInfo = HardwareInfo;
1921
}
2022

2123
public IEnumerator<IVideoWriterItem> GetEnumerator()
2224
{
25+
// Always show CPU-based encoders
2326
yield return new X264VideoCodec();
2427
yield return new XvidVideoCodec();
2528

26-
// AMD AMF
27-
yield return AmfVideoCodec_Simple.CreateH264();
28-
yield return AmfVideoCodec_Simple.CreateHevc();
29-
yield return AmfVideoCodec.CreateH264();
30-
yield return AmfVideoCodec.CreateHevc();
31-
yield return AmfVideoCodec_VBR.CreateH264();
32-
yield return AmfVideoCodec_VBR.CreateHevc();
29+
// AMD AMF - only show if AMD GPU detected
30+
if (_hardwareInfo.HasAmdEncoder)
31+
{
32+
yield return AmfVideoCodec_Simple.CreateH264();
33+
yield return AmfVideoCodec_Simple.CreateHevc();
34+
yield return AmfVideoCodec.CreateH264();
35+
yield return AmfVideoCodec.CreateHevc();
36+
yield return AmfVideoCodec_VBR.CreateH264();
37+
yield return AmfVideoCodec_VBR.CreateHevc();
38+
}
3339

34-
// Intel QuickSync
35-
yield return new QsvHevcVideoCodec();
40+
// Intel QuickSync - only show if Intel GPU detected
41+
if (_hardwareInfo.HasIntelQuickSync)
42+
{
43+
yield return new QsvHevcVideoCodec();
44+
}
3645

37-
// NVIDIA NVENC
38-
yield return NvencVideoCodec.CreateH264();
39-
yield return NvencVideoCodec.CreateHevc();
46+
// NVIDIA NVENC - only show if NVIDIA GPU detected
47+
if (_hardwareInfo.HasNvidiaEncoder)
48+
{
49+
yield return NvencVideoCodec.CreateH264();
50+
yield return NvencVideoCodec.CreateHevc();
51+
}
4052

41-
// Custom
53+
// Custom - always show user's custom codecs
4254
foreach (var item in _settings.CustomCodecs)
4355
{
4456
yield return new CustomFFmpegVideoCodec(item);
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using System;
2+
using System.Linq;
3+
using SharpDX.DXGI;
4+
5+
namespace Captura.Windows
6+
{
7+
public class HardwareInfoService : IHardwareInfoService
8+
{
9+
public GpuVendor GpuVendor { get; }
10+
public string GpuName { get; }
11+
public bool HasAmdEncoder { get; }
12+
public bool HasNvidiaEncoder { get; }
13+
public bool HasIntelQuickSync { get; }
14+
15+
public HardwareInfoService()
16+
{
17+
try
18+
{
19+
using var factory = new Factory1();
20+
var adapter = factory.Adapters1.FirstOrDefault();
21+
22+
if (adapter != null)
23+
{
24+
GpuName = adapter.Description.Description ?? "Unknown GPU";
25+
GpuVendor = DetectVendor(adapter);
26+
27+
// Set encoder availability based on vendor
28+
HasAmdEncoder = GpuVendor == Captura.GpuVendor.AMD;
29+
HasNvidiaEncoder = GpuVendor == Captura.GpuVendor.NVIDIA;
30+
HasIntelQuickSync = GpuVendor == Captura.GpuVendor.Intel;
31+
}
32+
else
33+
{
34+
GpuName = "No GPU detected";
35+
GpuVendor = Captura.GpuVendor.Unknown;
36+
HasAmdEncoder = false;
37+
HasNvidiaEncoder = false;
38+
HasIntelQuickSync = false;
39+
}
40+
}
41+
catch (Exception)
42+
{
43+
// If detection fails, default to unknown and allow all encoders
44+
// (better to show too many options than too few)
45+
GpuName = "Detection failed";
46+
GpuVendor = Captura.GpuVendor.Unknown;
47+
HasAmdEncoder = true; // Allow all when detection fails
48+
HasNvidiaEncoder = true;
49+
HasIntelQuickSync = true;
50+
}
51+
}
52+
53+
private static GpuVendor DetectVendor(Adapter1 adapter)
54+
{
55+
var vendorId = adapter.Description.VendorId;
56+
57+
// Common GPU vendor IDs
58+
// AMD: 0x1002
59+
// NVIDIA: 0x10DE
60+
// Intel: 0x8086
61+
62+
return vendorId switch
63+
{
64+
0x1002 => Captura.GpuVendor.AMD,
65+
0x10DE => Captura.GpuVendor.NVIDIA,
66+
0x8086 => Captura.GpuVendor.Intel,
67+
_ => DetermineVendorFromName(adapter.Description.Description)
68+
};
69+
}
70+
71+
private static GpuVendor DetermineVendorFromName(string gpuName)
72+
{
73+
if (string.IsNullOrEmpty(gpuName))
74+
return Captura.GpuVendor.Unknown;
75+
76+
var lowerName = gpuName.ToLowerInvariant();
77+
78+
if (lowerName.Contains("amd") || lowerName.Contains("radeon") || lowerName.Contains("ati"))
79+
return Captura.GpuVendor.AMD;
80+
81+
if (lowerName.Contains("nvidia") || lowerName.Contains("geforce") || lowerName.Contains("quadro") || lowerName.Contains("tesla"))
82+
return Captura.GpuVendor.NVIDIA;
83+
84+
if (lowerName.Contains("intel") || lowerName.Contains("hd graphics") || lowerName.Contains("uhd graphics") || lowerName.Contains("iris"))
85+
return Captura.GpuVendor.Intel;
86+
87+
return Captura.GpuVendor.Unknown;
88+
}
89+
}
90+
}

src/Captura.Windows/WindowsModule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public static class WindowsModule
1212
{
1313
public static void Load(IBinder Binder)
1414
{
15+
// Register hardware detection service first, as it's used by encoder providers
16+
Binder.Bind<IHardwareInfoService, HardwareInfoService>();
17+
1518
if (Windows8OrAbove)
1619
{
1720
try

src/Captura/Pages/AboutPage.xaml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -118,26 +118,6 @@
118118
</DockPanel>
119119
</Button>
120120

121-
<Label Margin="0,15,0,5">
122-
<TextBlock Text="{Binding Tools, Source={StaticResource Loc}, Mode=OneWay}"/>
123-
</Label>
124-
125-
<WrapPanel Margin="3">
126-
<!-- Image Editor button removed - internal editor was removed, external editor is available via toggle in main UI -->
127-
<!-- Crop and Imgur upload buttons removed - features no longer working/supported -->
128-
129-
<Button ToolTip="{Binding Trim, Source={StaticResource Loc}, Mode=OneWay}"
130-
Padding="5"
131-
Margin="0,0,10,10"
132-
Click="OpenAudioVideoTrimmer">
133-
<Path Data="{Binding Icons.Trim, Source={StaticResource ServiceLocator}}"
134-
Width="15"
135-
Height="15"
136-
Stretch="Uniform"
137-
HorizontalAlignment="Center"
138-
VerticalAlignment="Center"/>
139-
</Button>
140-
</WrapPanel>
141121
</StackPanel>
142122
</ScrollViewer>
143123
</Grid>

src/Captura/Pages/AboutPage.xaml.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,5 @@ void ViewCrashLogs(object Sender, RoutedEventArgs E)
1414
{
1515
NavigationService?.Navigate(new CrashLogsPage());
1616
}
17-
18-
// OpenImageEditor, OpenImageCropper, and UploadToImgur methods removed - features no longer supported
19-
20-
void OpenAudioVideoTrimmer(object Sender, RoutedEventArgs E)
21-
{
22-
new TrimmerWindow().ShowAndFocus();
23-
}
2417
}
2518
}

src/Captura/Pages/MainPage.xaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,6 @@
109109

110110
<Frame Source="RecentPage.xaml"/>
111111
</TabItem>
112-
<TabItem>
113-
<TabItem.Header>
114-
<Path Data="{Binding Icons.Help, Source={StaticResource ServiceLocator}}"
115-
Style="{StaticResource TabIcon}"
116-
ToolTip="{Binding About, Source={StaticResource Loc}, Mode=OneWay}"/>
117-
</TabItem.Header>
118-
119-
<Frame Source="AboutPage.xaml"/>
120-
</TabItem>
121112
</TabControl>
122113
</DockPanel>
123114
</Page>

src/Captura/Pages/SettingsPage.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@
5656
<TabItem Header="{Binding WebCam, Source={StaticResource Loc}, Mode=OneWay}">
5757
<Frame Name="WebcamTabFrame"/>
5858
</TabItem>
59+
<TabItem Header="{Binding Trim, Source={StaticResource Loc}, Mode=OneWay}">
60+
<Frame Source="TrimmerPage.xaml"/>
61+
</TabItem>
62+
<TabItem Header="{Binding About, Source={StaticResource Loc}, Mode=OneWay}">
63+
<Frame Source="AboutPage.xaml"/>
64+
</TabItem>
5965
</TabControl>
6066
</Grid>
6167
</Page>

src/Captura/Windows/RegionSelector.xaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@
1818
Name="This"
1919
ShowInTaskbar="False">
2020
<Window.InputBindings>
21+
<KeyBinding Key="Left"
22+
Command="{Binding RegionSelectorViewModel.MoveLeftCommand, Source={StaticResource ServiceLocator}}"/>
23+
<KeyBinding Key="Right"
24+
Command="{Binding RegionSelectorViewModel.MoveRightCommand, Source={StaticResource ServiceLocator}}"/>
25+
<KeyBinding Key="Up"
26+
Command="{Binding RegionSelectorViewModel.MoveUpCommand, Source={StaticResource ServiceLocator}}"/>
27+
<KeyBinding Key="Down"
28+
Command="{Binding RegionSelectorViewModel.MoveDownCommand, Source={StaticResource ServiceLocator}}"/>
29+
30+
<KeyBinding Key="Left"
31+
Modifiers="Shift"
32+
Command="{Binding RegionSelectorViewModel.DecreaseWidthCommand, Source={StaticResource ServiceLocator}}"/>
33+
<KeyBinding Key="Right"
34+
Modifiers="Shift"
35+
Command="{Binding RegionSelectorViewModel.IncreaseWidthCommand, Source={StaticResource ServiceLocator}}"/>
36+
<KeyBinding Key="Up"
37+
Modifiers="Shift"
38+
Command="{Binding RegionSelectorViewModel.DecreaseHeightCommand, Source={StaticResource ServiceLocator}}"/>
39+
<KeyBinding Key="Down"
40+
Modifiers="Shift"
41+
Command="{Binding RegionSelectorViewModel.IncreaseHeightCommand, Source={StaticResource ServiceLocator}}"/>
42+
2143
<KeyBinding Key="Escape"
2244
Command="{Binding RegionSelectorViewModel.ExitDrawingModeCommand, Source={StaticResource ServiceLocator}}"/>
2345
</Window.InputBindings>

0 commit comments

Comments
 (0)